// Returns the strongest barrier at that location private ExplosionBarrier GetBarrierAtLocation(Point point) { ExplosionBarrier strongestBarrier = ExplosionBarrier.None; entityGrid.QueryUniqueIdsAt(point.X, point.Y, barrierQueryList); foreach (int uniqueId in barrierQueryList) { Entity there = EntityManager.TryGetEntityByUniqueId(uniqueId); if (there != null) { ExplosionImpact explosionImpact = (ExplosionImpact)EntityManager.GetComponent(there, ComponentTypeIds.ExplosionImpact); if (explosionImpact != null) { strongestBarrier = (ExplosionBarrier)Math.Max((int)explosionImpact.Barrier, (int)strongestBarrier); } } } return(strongestBarrier); }
private void ApplyImpacts(int x, int y, Explosion explosion) { entityGrid.QueryUniqueIdsAt(x, y, uniqueIdWorker); foreach (int uniqueId in uniqueIdWorker) { Entity entityHere = EntityManager.GetEntityByUniqueId(uniqueId); ExplosionImpact impact = (ExplosionImpact)EntityManager.GetComponent(entityHere, ComponentTypeIds.ExplosionImpact); //if ((impact != null) && impact.ShouldSendMessage) if (impact != null) { // We differentiate between being in the path of an explosion vs being hit by the initial blast (since the explosion // lasts for a while). For most objects it may not matter - but consider that destroying a soft block may reveal a powerup. // Powerups are destroyed by explosions, but we only want to destroy existing powerups. Instead of marking powerups specially, // we can just have them react to the "initial explosion". That way, powerups that we reveal haven't been created yet. if (!explosion.MadeInitialBlast) { EntityManager.SendMessage(entityHere, Messages.HitByInitialExplosion, null); } EntityManager.SendMessage(entityHere, Messages.InExplosion, null); } } explosion.MadeInitialBlast = true; }