MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / checkProjectileCollision

Method checkProjectileCollision

game/state/shared/projectile.cpp:187–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187Collision Projectile::checkProjectileCollision(TileMap &map)
188{
189 if (!this->tileObject)
190 {
191 // It's possible the projectile reached the end of it's lifetime this frame
192 // so ignore stuff without a tile
193 return {};
194 }
195
196 sp<TileObject> ignoredObject;
197 StateRef<Organisation> firer;
198 if (ownerInvulnerableTicks > 0)
199 {
200 if (firerVehicle)
201 {
202 ignoredObject = firerVehicle->tileObject;
203 }
204 else if (firerUnit)
205 {
206 ignoredObject = firerUnit->tileObject;
207 }
208 }
209 if (firerVehicle)
210 {
211 firer = firerVehicle->owner;
212 }
213 else if (firerUnit)
214 {
215 firer = firerUnit->owner;
216 }
217#ifdef DEBUG_ALLOW_PROJECTILE_ON_PROJECTILE_FRIENDLY_FIRE
218 // Missiles should not shoot down non-missiles even when friendly firing
219 // otherwise they kill themselves immediately
220 if (type == Type::Beam)
221 {
222 firer = nullptr;
223 }
224#endif // DEBUG_ALLOW_PROJECTILE_ON_PROJECTILE_FRIENDLY_FIRE
225
226 Collision c = map.findCollision(this->previousPosition, this->position, {}, ignoredObject,
227 false, false, 0, false, firer);
228 if (!c)
229 return {};
230
231 c.projectile = shared_from_this();
232 return c;
233}
234
235Projectile::~Projectile()
236{

Callers 2

updateMethod · 0.80
updateProjectilesMethod · 0.80

Calls 1

findCollisionMethod · 0.80

Tested by

no test coverage detected