Toast Engine
Loading...
Searching...
No Matches
asset_proxy.hpp
Go to the documentation of this file.
1
7
8#pragma once
9
10#include <glm/glm.hpp>
11#include <string>
13#include <toast/uid.hpp>
14
15struct lua_State;
16
17namespace luabridge {
18class LuaRef;
19}
20
21namespace assets {
22class DataValue;
23}
24
25namespace scripting {
26
27class AssetProxy {
28public:
29 AssetProxy() = default;
30 explicit AssetProxy(toast::UID uid);
31 explicit AssetProxy(assets::HandleBase handle);
32
33 [[nodiscard]]
34 auto path() const -> std::string;
35 [[nodiscard]]
36 auto uid() const -> toast::UID;
37 [[nodiscard]]
38 auto hasValue() const -> bool;
39 [[nodiscard]]
40 auto type() const -> std::string;
41 [[nodiscard]]
42 auto toString() const -> std::string;
43 [[nodiscard]]
44 auto checkType(std::string_view field_type) const -> std::string;
45
46 [[nodiscard]]
47 auto get(const std::string& name, lua_State* l) const -> luabridge::LuaRef;
48
50 [[nodiscard]]
51 auto handle() const noexcept -> const assets::HandleBase& {
52 return m_handle;
53 }
54
55private:
56 assets::HandleBase m_handle;
57};
58
59// Called AFTER the normal luabridge method fails
60auto assetProxyIndex(AssetProxy& proxy, const luabridge::LuaRef& key, lua_State* l) -> luabridge::LuaRef;
61
62// Data assets are read-only from Lua, trying to modify them will just panic, if someone complains about this
63// im killing them (hi dario)
64auto assetProxyNewindex(AssetProxy& proxy, const luabridge::LuaRef& key, const luabridge::LuaRef& value, lua_State* l)
65 -> luabridge::LuaRef;
66
67auto dataValueToLuaRef(lua_State* l, const assets::DataValue& value) -> luabridge::LuaRef;
68
69}
Typed value for TOML files.
Definition data_value.hpp:50
Base class for type-erased asset handles.
Definition core_types.hpp:72
auto handle() const noexcept -> const assets::HandleBase &
Curve assets: the value at t, a number for a 1D curve, a vec2 for a 2D one and a vec3 for a 3D one.
Definition asset_proxy.hpp:51
Base types for the asset system.
Definition uid.hpp:20
Unique identifier for everything that exists in our engine.