Emergency 20 Dokumentation  4.2.0
VehicleComponent-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Namespace ]
6 //[-------------------------------------------------------]
7 namespace em5
8 {
9 
10 
11  //[-------------------------------------------------------]
12  //[ Public methods ]
13  //[-------------------------------------------------------]
15  DamageComponent(prototype),
16  qsf::game::PrototypeContainer(*prototype),
17  mCutDuration(qsf::Time::fromSeconds(10.0f)), // TODO(oi) Hardcoded value. Taken from the CutRoadVehicleAction. Original Comment: TODO(mk) Hard coded value - Read timing from setting/specs file
18  mIsOnEmergencyOperations(false),
19  mLifeEnergy(1.0f),
20  mDamageLevel1MaterialActive(false),
21  mDamagePrefabActive(false),
22  mFireResistance(0.0f),
23  mDamageResistance(0.0f),
24  mInvincible(false),
25  mIsParkingEntity(true),
26  mCurrentPrefabState(VehiclePrefabState_Normal),
27  mIsSirenEnabled(true),
28  mIsSirenSFXSet(false),
29  mSpecialEntityId(qsf::getUninitialized<uint64>()),
30  mMainDoorType(DoorComponent::DOORTYPE_CODRIVER),
31  mSecondsPassedBetweenUpdates(0.0f),
32  VehicleDoorsArray(*this, mVehicleDoorsIds),
33  DamagedLevel1Particles(*this, mDamagedLevel1ParticleIds),
34  DamagedLevel2Particles(*this, mDamagedLevel2ParticleIds),
35  DestroyedParticles(*this, mDestroyedParticleIds)
36  {
37  // By default, vehicles can be repaired when their health is low
38  mInternalFlags.set(CAN_BE_REPAIRED, true);
39  }
40 
42  {
43  // Nothing to do in here
44  }
45 
47  {
48  return mSpecialEntityId;
49  }
50 
52  {
53  return mMainDoorType;
54  }
55 
56  inline const std::vector<uint64>& VehicleComponent::getVehicleDoors() const
57  {
58  return mVehicleDoorsIds;
59  }
60 
61  inline float VehicleComponent::getLifeEnergy() const
62  {
63  return mLifeEnergy;
64  }
65 
67  {
68  return mIsOnEmergencyOperations;
69  }
70 
72  {
73  mIsOnEmergencyOperations = enable;
74  }
75 
77  {
78  return mSignalSound;
79  }
80 
82  {
83  mSignalSound = signalSound;
84  mIsSirenSFXSet = false;
85  }
86 
88  {
89  return mIsSirenEnabled;
90  }
91 
92  inline bool VehicleComponent::isMovable() const
93  {
94  // The vehicle is movable when it is not in damage state level 2 or destroyed
95  return (!isDamagedLevel2() && !isDestroyed());
96  }
97 
98  inline bool VehicleComponent::getCanBeTowed() const
99  {
100  // Is a recovery by the crane vehicle necessary first?
101  if (getMustBeRecovered())
102  return false;
103 
104  // Is it burning?
105  if (isBurning())
106  return false;
107 
108  // The "CAN_BE_TOWED" flag is only an override for actually intact vehicles
109  return (isDamagedLevel2() || isDestroyed() || mInternalFlags.isSet(CAN_BE_TOWED)) && !mInternalFlags.isSet(CAN_REALLY_NOT_BE_TOWED);
110  }
111 
113  {
114  return mInternalFlags.isSet(CAN_BE_TOWED);
115  }
116 
118  {
119  return mInternalFlags.isSet(CAN_REALLY_NOT_BE_TOWED);
120  }
121 
123  {
124  return mInternalFlags.isSet(MUST_BE_RECOVERED);
125  }
126 
128  {
129  return mIsParkingEntity;
130  }
131 
132  inline void VehicleComponent::setIsParkingEntity(bool isParkingEntity)
133  {
134  mIsParkingEntity = isParkingEntity;
135  }
136 
137 
138  //[-------------------------------------------------------]
139  //[ Protected methods ]
140  //[-------------------------------------------------------]
142  {
143  return mInternalFlags;
144  }
145 
146 
147  //[-------------------------------------------------------]
148  //[ CAMP reflection system ]
149  //[-------------------------------------------------------]
150  inline std::size_t VehicleComponent::EntityIdArrayInterface::size() const
151  {
152  return getVariable().size();
153  }
154 
155  inline const uint64& VehicleComponent::EntityIdArrayInterface::get(std::size_t index) const
156  {
157  return getVariable()[index];
158  }
159 
160  inline void VehicleComponent::EntityIdArrayInterface::set(std::size_t index, const uint64& value)
161  {
162  getVariable()[index] = value;
163  }
164 
165  inline void VehicleComponent::EntityIdArrayInterface::insert(std::size_t before, const uint64& value)
166  {
167  getVariable().insert(getVariable().begin() + before, value);
168  }
169 
170  inline void VehicleComponent::EntityIdArrayInterface::remove(std::size_t index)
171  {
172  getVariable().erase(getVariable().begin() + index);
173  }
174 
175 
176 //[-------------------------------------------------------]
177 //[ Namespace ]
178 //[-------------------------------------------------------]
179 } // em5
Definition: ActionPriority.h:13
bool getIsParkingEntity() const
Definition: VehicleComponent-inl.h:127
void set(ENUM flag)
Set a single flag.
Definition: EnumBitmask.h:187
const qsf::AssetProxy & getSignalAudioAsset() const
Definition: VehicleComponent-inl.h:76
virtual ~VehicleComponent()
Destructor.
Definition: VehicleComponent-inl.h:41
virtual bool isDamagedLevel2() const
Definition: DamageComponent-inl.h:87
void setIsOnEmergencyOperations(bool enable)
Definition: VehicleComponent-inl.h:71
const std::vector< uint64 > & getVehicleDoors() const
Definition: VehicleComponent-inl.h:56
The vehicle can not be towed under any circumstances.
Definition: VehicleComponent.h:398
virtual bool isDestroyed() const
Definition: DamageComponent-inl.h:92
uint64_t uint64
Definition: PlatformTypes.h:184
bool isMovable() const
Return "true" if the vehicle is allowed to move.
Definition: VehicleComponent-inl.h:92
Has to be recovered by the crane vehicle before any other interaction.
Definition: VehicleComponent.h:401
DoorComponent::DoorType getMainDoorType() const
Get/set the mainly used door type, used for entering/leaving the vehicle.
Definition: VehicleComponent-inl.h:51
Definition: PickupPersonByParamedicAction.h:21
bool getCanBeTowed() const
Check if the vehicle can be picked up by the towcar.
Definition: VehicleComponent-inl.h:98
Asset proxy class.
Definition: AssetProxy.h:57
EMERGENCY 5 damage component class.
Definition: DamageComponent.h:49
Can be picked up by the tow car.
Definition: VehicleComponent.h:400
T getUninitialized()
Definition: GetUninitialized.h:38
DoorType
Definition: DoorComponent.h:63
InternalFlagSet & getInternalFlags()
Definition: VehicleComponent-inl.h:141
bool getCanReallyNotBeTowed() const
Check if the vehicle is set as totally untowable.
Definition: VehicleComponent-inl.h:117
EntityIdArray mVehicleDoorsIds
Definition: VehicleComponent.h:426
void setIsParkingEntity(bool isParkingEntity)
Definition: VehicleComponent-inl.h:132
Can be repaired by an engineer.
Definition: VehicleComponent.h:402
bool getIsOnEmergencyOperations() const
Definition: VehicleComponent-inl.h:66
float getLifeEnergy() const
Get vehicle life energy.
Definition: VehicleComponent-inl.h:61
void setSignalAudioAsset(const qsf::AssetProxy &signalSound)
Definition: VehicleComponent-inl.h:81
EMERGENCY 5 door component class.
Definition: DoorComponent.h:41
uint64 getSpecialEntity() const
Get/set special child entity ID.
Definition: VehicleComponent-inl.h:46
Prototype class.
Definition: Prototype.h:100
bool getCanBeTowedFlag() const
Check if the vehicle's "CAN_BE_TOWED" flag is set (this is only a part of the check whether the vehic...
Definition: VehicleComponent-inl.h:112
bool isSet(ENUM flag) const
Check whether a certain flag is set.
Definition: EnumBitmask.h:118
VehicleComponent(qsf::Prototype *prototype)
Default constructor.
Definition: VehicleComponent-inl.h:14
virtual bool isBurning() const
Definition: DamageComponent-inl.h:97
bool isSirenEnabled() const
Definition: VehicleComponent-inl.h:87
bool getMustBeRecovered() const
Check if the vehicle can and must be recovered by the crane vehicle.
Definition: VehicleComponent-inl.h:122