OpenClonk
C4SolidMask.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk 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 /* Solid areas of objects, put into the landscape */
18 
19 #ifndef INC_C4SolidMask
20 #define INC_C4SolidMask
21 
22 #include "object/C4ObjectList.h"
23 #include "object/C4Shape.h"
24 
26 {
27 protected:
28  bool MaskPut; // if set, the mask is currently put into landscape
29  int MaskPutRotation; // rotation in which the mask was put (and resides in the buffers)
30  int MatBuffPitch; // pitch (and width) of mat buffer
31 
32  // last position mask was removed from
33  // A rounded position is used for y, even though that causes movement to be less smooth, because gravity will counter sub-pixel movement and cause all non-attached objects to fall through the mask eventually
35  int32_t MaskRemovalY;
36 
37  class C4Object **ppAttachingObjects; // objects to be moved with mask motion
39 
40  C4TargetRect MaskPutRect; // absolute bounding screen rect at which the mask is put - tx and ty are offsets within pSolidMask (for rects outside the landscape)
41 
42  BYTE *pSolidMaskMatBuff; // material replaced by this solidmask. MCVehic if no solid mask data at this position OR another solidmask was already present during put (independent of MaskMaterial)
43 
44  BYTE MaskMaterial; // Either MCVehicle or MCHalfVehicle
45 
47 
48  // provides density within put SolidMask of an object
50  {
51  private:
52  C4SolidMask &rSolidMaskData;
53 
54  public:
55  DensityProvider(C4SolidMask &rSolidMaskData)
56  : rSolidMaskData(rSolidMaskData) {}
57 
58  int32_t GetDensity(int32_t x, int32_t y) const override;
59  };
60  // Remove the solidmask temporarily
61  void RemoveTemporary(C4Rect where);
62  void PutTemporary(C4Rect where);
63  // Reput and update Matbuf after landscape change underneath
64  void Repair(C4Rect where);
65 
66  friend class C4Landscape;
67  friend class DensityProvider;
68 
69 public:
70  // Linked list of all solidmasks
71  static C4SolidMask * First;
72  static C4SolidMask * Last;
75 
76  void Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRestoreAttachment); // put mask to landscape
77  void Remove(bool fBackupAttachment); // remove mask from landscape
78  void Draw(C4TargetFacet &cgo); // draw the solidmask (dbg display)
79 
80  bool IsPut() { return MaskPut; }
82  ~C4SolidMask(); // dtor
83 
84  static bool CheckConsistency();
85  static void RemoveSolidMasks();
86  static void PutSolidMasks();
87 
88  static CSurface8 *LoadMaskFromFile(class C4Group &hGroup, const char *szFilename);
89 
90  void SetHalfVehicle(bool set);
91 };
92 
93 #endif
uint8_t BYTE
Definition: C4Real.h:59
Definition: C4Rect.h:28
int32_t GetDensity(int32_t x, int32_t y) const override
DensityProvider(C4SolidMask &rSolidMaskData)
Definition: C4SolidMask.h:55
int MaskPutRotation
Definition: C4SolidMask.h:29
bool IsPut()
Definition: C4SolidMask.h:80
static C4SolidMask * Last
Definition: C4SolidMask.h:72
class C4Object ** ppAttachingObjects
Definition: C4SolidMask.h:37
void Draw(C4TargetFacet &cgo)
bool MaskPut
Definition: C4SolidMask.h:28
C4Real MaskRemovalX
Definition: C4SolidMask.h:34
static void RemoveSolidMasks()
void PutTemporary(C4Rect where)
int iAttachingObjectsCapacity
Definition: C4SolidMask.h:38
BYTE * pSolidMaskMatBuff
Definition: C4SolidMask.h:42
C4TargetRect MaskPutRect
Definition: C4SolidMask.h:40
C4SolidMask * Prev
Definition: C4SolidMask.h:73
C4SolidMask(C4Object *pForObject)
int MatBuffPitch
Definition: C4SolidMask.h:30
void Put(bool fCauseInstability, C4TargetRect *pClipRect, bool fRestoreAttachment)
Definition: C4SolidMask.cpp:32
static void PutSolidMasks()
void Repair(C4Rect where)
static CSurface8 * LoadMaskFromFile(class C4Group &hGroup, const char *szFilename)
void Remove(bool fBackupAttachment)
static bool CheckConsistency()
void RemoveTemporary(C4Rect where)
static C4SolidMask * First
Definition: C4SolidMask.h:71
C4Object * pForObject
Definition: C4SolidMask.h:46
int iAttachingObjectsCount
Definition: C4SolidMask.h:38
void SetHalfVehicle(bool set)
int32_t MaskRemovalY
Definition: C4SolidMask.h:35
BYTE MaskMaterial
Definition: C4SolidMask.h:44
C4SolidMask * Next
Definition: C4SolidMask.h:74