| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design) |
| 5 | * Copyright (c) 2017-2021, The LegacyClonk Team and contributors |
| 6 | * |
| 7 | * Distributed under the terms of the ISC license; see accompanying file |
| 8 | * "COPYING" for details. |
| 9 | * |
| 10 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 11 | * See accompanying file "TRADEMARK" for details. |
| 12 | * |
| 13 | * To redistribute this file separately, substitute the full license texts |
| 14 | * for the above references. |
| 15 | */ |
| 16 | |
| 17 | /* Pixel Sprite system for tiny bits of moving material */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "C4ForwardDeclarations.h" |
| 22 | #include <C4Material.h> |
| 23 | #include "Fixed.h" |
| 24 | |
| 25 | class C4PXS |
| 26 | { |
| 27 | C4PXS() : Mat(MNone), x(Fix0), y(Fix0), xdir(Fix0), ydir(Fix0) {} |
| 28 | |
| 29 | friend class C4PXSSystem; |
| 30 | |
| 31 | protected: |
| 32 | int32_t Mat; |
| 33 | C4Fixed x, y, xdir, ydir; |
| 34 | |
| 35 | protected: |
| 36 | void Execute(); |
| 37 | void Deactivate(); |
| 38 | }; |
| 39 | |
| 40 | const size_t PXSChunkSize = 500, PXSMaxChunk = 20; |
| 41 | |
| 42 | class C4PXSSystem |
| 43 | { |
| 44 | public: |
| 45 | C4PXSSystem(); |
| 46 | ~C4PXSSystem(); |
| 47 | |
| 48 | public: |
| 49 | int32_t Count; |
| 50 | |
| 51 | protected: |
| 52 | C4PXS *Chunk[PXSMaxChunk]; |
| 53 | size_t iChunkPXS[PXSMaxChunk]; |
| 54 | |
| 55 | public: |
| 56 | void Delete(C4PXS *pPXS); |
| 57 | void Default(); |
| 58 | void Clear(); |
| 59 | void Execute(); |
| 60 | void Draw(C4FacetEx &cgo); |
| 61 | void Synchronize(); |
| 62 | void SyncClearance(); |
| 63 | void Cast(int32_t mat, int32_t num, int32_t tx, int32_t ty, int32_t level); |
| 64 | bool Create(int32_t mat, C4Fixed ix, C4Fixed iy, C4Fixed ixdir = Fix0, C4Fixed iydir = Fix0); |
| 65 | bool Load(C4Group &hGroup); |
| 66 | bool Save(C4Group &hGroup); |
| 67 | |
| 68 | protected: |
| 69 | C4PXS *New(); |
| 70 | }; |
| 71 | |