载入中...
搜索中...
未找到
LocationProfileBindings.cpp
浏览该文件的文档.
23 pose.addVar("x", &LocationPose::x); pose.addVar("y", &LocationPose::y); pose.addVar("z", &LocationPose::z);
24 pose.addVar("qx", &LocationPose::qx); pose.addVar("qy", &LocationPose::qy); pose.addVar("qz", &LocationPose::qz);
30 bookmark.addFunc("setCamera", [](LocationBookmark* b, const LocationPose* p) { if (b && p) b->camera = *p; });
31 bookmark.addFunc("setPlayer", [](LocationBookmark* b, const LocationPose* p) { if (b && p) b->player = *p; });
35 profile.addFunc("hasSavedLocation", [](const LocationProfile* p) { return p && p->hasSavedLocation(); });
36 profile.addFunc("getBookmarkCount", [](const LocationProfile* p) { return p ? p->getBookmarkCount() : 0; });
39 auto r=p?p->serializeJson():Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
40 return eve::script::projectResult(vm,std::move(r),[](const std::string& v){return eve::Value(v);});
42 profile.addFunc("restoreJson", [vm=table.getHandle()](LocationProfile* p,const std::string& json) {
43 auto r=p?p->restoreJson(json):Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
46 profile.addFunc("saveLocation", [vm=table.getHandle()](LocationProfile* p, const LocationPose* camera) {
48 : Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"location profile and camera required")));
50 profile.addFunc("saveLocationWithPlayer", [vm=table.getHandle()](LocationProfile* p, const LocationPose* camera,
53 : Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile, camera and player required")));
56 auto r=p?p->loadLocation():Result<LocationSnapshot>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
57 return eve::script::projectResult(vm,std::move(r),[](const LocationSnapshot& s){return snapshotValue(s);});
59 profile.addFunc("addBookmark", [vm=table.getHandle()](LocationProfile* p, const LocationBookmark* b) {
60 auto r=p&&b?p->addBookmark(*b):Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile and bookmark required"));
64 auto r=p?p->loadBookmark(i):Result<LocationSnapshot>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
65 return eve::script::projectResult(vm,std::move(r),[](const LocationSnapshot& s){return snapshotValue(s);});
67 profile.addFunc("removeBookmark", [vm=table.getHandle()](LocationProfile* p,int i,int selected) {
68 auto r=p?p->removeBookmark(i,selected):Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
72 auto r=p?p->getBookmarkName(i):Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
73 return eve::script::projectResult(vm,std::move(r),[](const std::string& v){return eve::Value(v);});
75 profile.addFunc("getBookmarkController", [vm=table.getHandle()](const LocationProfile* p,int i) {
76 auto r=p?p->getBookmarkController(i):Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
77 return eve::script::projectResult(vm,std::move(r),[](const std::string& v){return eve::Value(v);});
80 auto r=p?p->getBookmarkScene(i):Result<std::string>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
81 return eve::script::projectResult(vm,std::move(r),[](const std::string& v){return eve::Value(v);});
83 profile.addFunc("overrideBookmark", [vm=table.getHandle()](LocationProfile* p,int i,const LocationBookmark* b) {
85 :Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile and bookmark required"));
89 auto r=p?p->previousBookmark(i):Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
93 auto r=p?p->nextBookmark(i):Result<int>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,"profile required"));
The single Squirrel projection for common Result, Status and Value.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Caller-owned Pcg location and bookmark state. Mutable operations validate complete candidate data bef...
Definition LocationProfile.h:40
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
Definition AvatarInstance.h:33
void exposeLocationProfileBindings(ssq::Table &table)
Register Pcg location profile value types and operations.
Definition LocationProfileBindings.cpp:21
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:470
@ InvalidArgument
One named Pcg location bookmark with optional player transform metadata.
Definition LocationProfile.h:22
Provider-neutral position and quaternion stored by Pcg's location profile.
Definition LocationProfile.h:16