Pioneer
LuaBodyComponent.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #pragma once
5 
6 #include "BodyComponent.h"
7 #include "LuaObject.h"
8 
9 // Type-specific Lua management implementation for body components.
10 //
11 // BodyComponents are not automatically compatible with LuaPush / LuaPull,
12 // and must either be managed with PushComponentToLua() or retrieved with
13 // GetComponent(typeName) from the Lua side.
14 //
15 // Note: there is currently no Lua event handling for when a C++ component is
16 // deleted - the LuaObject handle is just silently orphaned.
17 template <typename T>
19  static_assert(std::is_base_of_v<LuaWrappable, T>, "BodyComponents must inherit from LuaWrappable to be pushed to Lua!");
20 
22  pool(pool)
23  {}
25 
26  virtual void PushToLua(const Body *body) override
27  {
29  }
30 
31  virtual void DeregisterComponent(const Body *body) override
32  {
34  }
35 };
Definition: Body.h:57
static void DeregisterObject(LuaWrappable *object)
Definition: LuaObject.cpp:581
static void PushComponentToLua(LuaWrappable *o)
Definition: LuaObject.h:464
Definition: BodyComponent.h:54
Definition: LuaBodyComponent.h:18
virtual void DeregisterComponent(const Body *body) override
Definition: LuaBodyComponent.h:31
virtual void PushToLua(const Body *body) override
Definition: LuaBodyComponent.h:26
Pool< T > * pool
Definition: LuaBodyComponent.h:24
LuaInterface(Pool< T > *pool)
Definition: LuaBodyComponent.h:21
Definition: BodyComponent.h:100