Cuberite
A lightweight, fast and extensible game server for Minecraft
LuaChunkStay.h
Go to the documentation of this file.
1 
2 // LuaChunkStay.h
3 
4 // Declares the cLuaChunkStay class representing a cChunkStay binding for plugins, used by cWorld:ChunkStay() Lua API
5 
6 
7 
8 
9 
10 #pragma once
11 
12 #include "LuaState.h"
13 #include "../ChunkStay.h"
14 
15 
16 
17 
18 
19 // fwd:
20 class cChunkMap;
21 
22 
23 
24 
25 
27  public cChunkStay
28 {
29  using Super = cChunkStay;
30 
31 public:
32  cLuaChunkStay();
33 
34  virtual ~cLuaChunkStay() override { }
35 
39  bool AddChunks(const cLuaState::cStackTable & a_ChunkCoords);
40 
42  void Enable(cChunkMap & a_ChunkMap, cLuaState::cCallbackPtr a_OnChunkAvailable, cLuaState::cCallbackPtr a_OnAllChunksAvailable);
43 
44 protected:
47 
50 
51 
52  // cChunkStay overrides:
53  virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override;
54  virtual bool OnAllChunksAvailable(void) override;
55  virtual void OnDisabled(void) override;
56 
62  void AddChunkCoord(cLuaState & a_LuaState, int a_Index);
63 } ;
64 
65 
66 
67 
68 
virtual ~cLuaChunkStay() override
Definition: LuaChunkStay.h:34
cLuaState::cCallbackPtr m_OnChunkAvailable
The Lua function to call in OnChunkAvailable.
Definition: LuaChunkStay.h:46
cLuaState::cCallbackPtr m_OnAllChunksAvailable
The Lua function to call in OnAllChunksAvailable.
Definition: LuaChunkStay.h:49
bool AddChunks(const cLuaState::cStackTable &a_ChunkCoords)
Adds chunks in the specified Lua table.
void AddChunkCoord(cLuaState &a_LuaState, int a_Index)
Adds a single chunk coord from the table at the top of the Lua stack.
virtual void OnChunkAvailable(int a_ChunkX, int a_ChunkZ) override
Called when a specific chunk become available.
virtual bool OnAllChunksAvailable(void) override
Called once all of the contained chunks are available.
void Enable(cChunkMap &a_ChunkMap, cLuaState::cCallbackPtr a_OnChunkAvailable, cLuaState::cCallbackPtr a_OnAllChunksAvailable)
Enables the ChunkStay for the specified chunkmap, with the specified Lua callbacks.
virtual void OnDisabled(void) override
Called by the ChunkMap when the ChunkStay is disabled.
Encapsulates a Lua state and provides some syntactic sugar for common operations.
Definition: LuaState.h:56
std::unique_ptr< cCallback > cCallbackPtr
Definition: LuaState.h:326
Represents a table on the Lua stack.
Definition: LuaState.h:516
Makes chunks stay loaded until this object is cleared or destroyed Works by setting internal flags in...
Definition: ChunkStay.h:36
cChunkStay(void)
Definition: ChunkStay.cpp:14