1#ifndef GAME_EDITOR_MAPITEMS_LAYER_SWITCH_H
2#define GAME_EDITOR_MAPITEMS_LAYER_SWITCH_H
3
4#include "layer_tiles.h"
5
6struct SSwitchTileStateChange
7{
8 bool m_Changed;
9 struct SData
10 {
11 int m_Number;
12 int m_Type;
13 int m_Flags;
14 int m_Delay;
15 int m_Index;
16 } m_Previous, m_Current;
17};
18
19class CLayerSwitch : public CLayerTiles
20{
21public:
22 CLayerSwitch(CEditorMap *pMap, int w, int h);
23 CLayerSwitch(const CLayerSwitch &Other);
24 ~CLayerSwitch() override;
25
26 CSwitchTile *m_pSwitchTile;
27 unsigned char m_SwitchNumber;
28 unsigned char m_SwitchDelay;
29
30 void Resize(int NewW, int NewH) override;
31 void Shift(EShiftDirection Direction) override;
32 [[nodiscard]] bool IsEmpty() const override;
33 void BrushDraw(CLayer *pBrush, vec2 WorldPos) override;
34 void BrushFlipX() override;
35 void BrushFlipY() override;
36 void BrushRotate(float Amount) override;
37 void FillSelection(bool Empty, CLayer *pBrush, CUIRect Rect) override;
38 int FindNextFreeNumber() const;
39 bool ContainsElementWithId(int Id) const;
40 void GetPos(int Number, int Offset, ivec2 &SwitchPos);
41
42 int m_GotoSwitchOffset;
43 ivec2 m_GotoSwitchLastPos;
44
45 EditorTileStateChangeHistory<SSwitchTileStateChange> m_History;
46 void ClearHistory() override
47 {
48 CLayerTiles::ClearHistory();
49 m_History.clear();
50 }
51
52 std::shared_ptr<CLayer> Duplicate() const override;
53 const char *TypeName() const override;
54
55private:
56 void RecordStateChange(int x, int y, SSwitchTileStateChange::SData Previous, SSwitchTileStateChange::SData Current);
57};
58
59#endif
60