Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
node_proxy.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
11
#include <any>
12
#include <glm/vec3.hpp>
13
#include <string>
14
#include <
toast/world/box.hpp
>
15
#include <vector>
16
17
struct
lua_State;
18
19
namespace
luabridge {
20
class
LuaRef;
21
}
22
23
namespace
toast {
24
struct
FieldInfo
;
25
class
Node
;
26
}
27
28
namespace
scripting {
29
30
struct
TypeMarker
;
31
32
class
Vec3FieldProxy :
public
glm::vec3 {
33
public
:
34
Vec3FieldProxy(
toast::Box<toast::Node>
node,
const
toast::FieldInfo
* field,
const
glm::vec3& value)
noexcept
;
35
36
[[nodiscard]]
37
auto
getX()
const
-> float;
38
[[nodiscard]]
39
auto
getY()
const
-> float;
40
[[nodiscard]]
41
auto
getZ()
const
-> float;
42
void
setX(
float
value);
43
void
setY(
float
value);
44
void
setZ(
float
value);
45
46
private
:
47
[[nodiscard]]
48
auto
current()
const
-> glm::vec3;
49
void
commit(
const
glm::vec3& value);
50
51
toast::Box<toast::Node>
m_node;
52
const
toast::FieldInfo
* m_field =
nullptr
;
53
};
54
55
class
NodeProxy {
56
public
:
57
NodeProxy() =
default
;
58
explicit
NodeProxy(
toast::Box<toast::Node>
box)
noexcept
;
59
60
[[nodiscard]]
61
auto
box()
noexcept
->
toast::Box<toast::Node>
& {
62
return
m_box;
63
}
64
65
[[nodiscard]]
66
auto
box()
const
noexcept
->
const
toast::Box<toast::Node>
& {
67
return
m_box;
68
}
69
70
[[nodiscard]]
71
auto
exists()
const
noexcept
-> bool;
72
73
auto
find(
const
std::string& query, lua_State* l) -> luabridge::LuaRef;
74
auto
search(
const
std::string& query) -> std::vector<NodeProxy>;
75
auto
parent(lua_State* l) -> luabridge::LuaRef;
76
auto
root(lua_State* l) -> luabridge::LuaRef;
77
auto
searchType(
const
std::string& type, lua_State* l) -> std::vector<NodeProxy>;
78
auto
searchType(
const
TypeMarker
& type, lua_State* l) -> std::vector<NodeProxy>;
79
auto
getChildren(lua_State* l) -> std::vector<NodeProxy>;
80
auto
getChildren(
const
std::string& type, lua_State* l) -> std::vector<NodeProxy>;
81
auto
getChildren(
const
TypeMarker
& type, lua_State* l) -> std::vector<NodeProxy>;
82
auto
create(
const
std::string& type, lua_State* l) -> luabridge::LuaRef;
83
void
addDependsOn(
const
NodeProxy& other);
84
void
interactsWith(
const
NodeProxy& other);
85
86
[[nodiscard]]
87
auto
name()
const
-> std::string;
88
[[nodiscard]]
89
auto
uid()
const
-> uint64_t;
90
93
auto
call
(
const
std::string& fn_name, lua_State* l) -> luabridge::LuaRef;
94
96
[[nodiscard]]
97
auto
hasField
(std::string_view key)
const
noexcept
-> bool;
98
99
private
:
100
toast::Box<toast::Node>
m_box;
101
};
102
103
// Called AFTER the normal LuaBridge method/property lookup fails
104
auto
nodeProxyIndex(
NodeProxy
& proxy,
const
luabridge::LuaRef& key, lua_State* l) -> luabridge::LuaRef;
105
auto
nodeProxyNewindex(
NodeProxy
& proxy,
const
luabridge::LuaRef& key,
const
luabridge::LuaRef& value, lua_State* l)
106
-> luabridge::LuaRef;
107
108
auto
nodeProxyDispatchMethod(
NodeProxy
& np, std::string_view name, lua_State* l,
int
args_base,
int
n_args) -> int;
109
110
auto
anyValueToLuaRef(lua_State* l,
const
std::any& value) -> luabridge::LuaRef;
111
113
auto
luaRefValueToAny(lua_State* l,
const
luabridge::LuaRef& v) -> std::any;
114
115
}
box.hpp
pseudo shared pointer for Nodes
scripting::NodeProxy
Definition
node_proxy.hpp:55
scripting::NodeProxy::call
auto call(const std::string &fn_name, lua_State *l) -> luabridge::LuaRef
Definition
node_proxy.cpp:1192
scripting::NodeProxy::hasField
auto hasField(std::string_view key) const noexcept -> bool
Definition
node_proxy.cpp:1184
toast::Box
Intrusive reference-counted handle to a Node.
Definition
box.hpp:35
toast::Node
Definition
node.hpp:81
scripting::TypeMarker
Lua-side placeholder declaring a typed Node or Asset reference.
Definition
lua_types.hpp:22
toast::FieldInfo
Runtime descriptor for one reflected field.
Definition
reflect.hpp:79
engine
src
toast
scripting
node_proxy.hpp
Generated by
1.17.0