OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PXS.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2013-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Pixel Sprite system for tiny bits of moving material */
19 
20 #ifndef INC_C4PXS
21 #define INC_C4PXS
22 
23 #include "landscape/C4Material.h"
24 
25 class C4PXS
26 {
27  C4PXS(): Mat(MNone), x(Fix0), y(Fix0), xdir(Fix0), ydir(Fix0) {}
28  friend class C4PXSSystem;
29 protected:
30  int32_t Mat;
32 protected:
33  void Execute();
34  void Deactivate();
35 };
36 
37 const size_t PXSChunkSize=500,PXSMaxChunk=20;
38 
40 {
41 public:
42  C4PXSSystem();
43  ~C4PXSSystem();
44 public:
45  int32_t Count;
46 protected:
49 public:
50  void Delete(C4PXS *pPXS);
51  void Default();
52  void Clear();
53  void Execute();
54  void Draw(C4TargetFacet &cgo);
55  void Synchronize();
56  void SyncClearance();
57  void Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level);
58  bool Create(int32_t mat, C4Real ix, C4Real iy, C4Real ixdir=Fix0, C4Real iydir=Fix0);
59  bool Load(C4Group &hGroup);
60  bool Save(C4Group &hGroup);
61  int32_t GetCount() const { return Count; } // count all PXS
62  int32_t GetCount(int32_t mat) const; // count PXS of given material
63  int32_t GetCount(int32_t mat, int32_t x, int32_t y, int32_t wdt, int32_t hgt) const; // count PXS of given material in given area. mat==-1 for all materials.
64 protected:
65  C4PXS *New();
66 };
67 
68 extern C4PXSSystem PXS;
69 #endif
C4PXS * New()
Definition: C4PXS.cpp:179
void Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level)
Definition: C4PXS.cpp:356
C4PXSSystem PXS
Definition: C4PXS.cpp:525
void Default()
Definition: C4PXS.cpp:159
C4PXS * Chunk[PXSMaxChunk]
Definition: C4PXS.h:47
Definition: C4PXS.h:25
void Synchronize()
Definition: C4PXS.cpp:457
bool Create(int32_t mat, C4Real ix, C4Real iy, C4Real ixdir=Fix0, C4Real iydir=Fix0)
Definition: C4PXS.cpp:205
C4Real y
Definition: C4PXS.h:31
bool Save(C4Group &hGroup)
Definition: C4PXS.cpp:372
Definition: C4Real.h:58
C4Real ydir
Definition: C4PXS.h:31
C4PXSSystem()
Definition: C4PXS.cpp:149
void Deactivate()
Definition: C4PXS.cpp:136
const int32_t MNone
Definition: C4Constants.h:178
void Clear()
Definition: C4PXS.cpp:169
bool Load(C4Group &hGroup)
Definition: C4PXS.cpp:414
void SyncClearance()
Definition: C4PXS.cpp:462
void Draw(C4TargetFacet &cgo)
Definition: C4PXS.cpp:240
const size_t PXSMaxChunk
Definition: C4PXS.h:37
int32_t Mat
Definition: C4PXS.h:30
const size_t PXSChunkSize
Definition: C4PXS.h:37
~C4PXSSystem()
Definition: C4PXS.cpp:154
C4Real xdir
Definition: C4PXS.h:31
int32_t GetCount() const
Definition: C4PXS.h:61
C4Real x
Definition: C4PXS.h:31
void Execute()
Definition: C4PXS.cpp:216
void Execute()
Definition: C4PXS.cpp:33
size_t iChunkPXS[PXSMaxChunk]
Definition: C4PXS.h:48
const C4Real Fix0
Definition: C4Real.h:312
int32_t Count
Definition: C4PXS.h:45
void Delete(C4PXS *pPXS)
Definition: C4PXS.cpp:485