summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities/MobSpawnerEntity.h
blob: b173214a58b0c71c77897b514ceccb1a1d65e48d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

#pragma once

#include "BlockEntity.h"
#include "../Entities/Player.h"





namespace Json
{
	class Value;
}





// tolua_begin

class cMobSpawnerEntity :
	public cBlockEntity
{
	typedef cBlockEntity super;
public:

	// tolua_end
	
	cMobSpawnerEntity(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World);
	virtual ~cMobSpawnerEntity();

	bool LoadFromJson(const Json::Value & a_Value);
	virtual void SaveToJson(Json::Value & a_Value) override;

	virtual bool Tick(float a_Dt, cChunk & a_Chunk) override;

	// tolua_begin

	/** Returns the entity who will be spawn by this mob spawner. */
	const AString & GetEntityName(void) const { return m_EntityName; }

	// tolua_end

	static const char * GetClassStatic(void) { return "cMobSpawnerEntity"; }
	
	virtual void UsedBy(cPlayer * a_Player) override;
	virtual void SendTo(cClientHandle &) override {}

private:
	/** The entity to spawn. */
	AString m_EntityName;

	int m_SpawnDelay;
	int m_MinSpawnDelay;
	int m_MaxSpawnDelay;

	/** The mob spawner spawns only mobs when the count of nearby entities (without players) is lesser than this number. */
	short m_MaxNearbyEntities;

	/** The mob spawner spawns only mobs when a player is in the range of the mob spawner. */
	short m_ActivatingRange;

	/** The range coefficient for spawning entities around. */
	short m_SpawnRange;
} ;  // tolua_end