void UpdateSpells(double dt) { var toRemove = new List <LinearSpell>(); ActiveSpells.ForEach(s => { Vec2 before = (Vec2)s.Position.Clone(); Match.CurrentState.ApplyPhysicsUpdate(s.ID, (float)dt); Vec2 pass = (s.Position - before) / PhysicsEngine.PHYSICS_PASSES; s.Position = before; for (int i = 0; i < PhysicsEngine.PHYSICS_PASSES; ++i) { // Check for entities collisions var rect = s.CreateCollisionRectangle(); var enemyTeam = TeamsHelper.Opposite(s.Team); // Check to hit players bool remove = CheckForSpellPlayerCollisions(s, rect, enemyTeam); // Check to hit structures if (!remove) { remove = CheckForSpellStructuresCollisions(s, rect, enemyTeam == Teams.Left ? Match.LeftStructures : Match.RightStructures); } // Check to remove spells if (!remove && // don't check if we know it already has to be removed Match.CurrentState.SpellShouldDisappear(s)) { remove = true; } // The spell has to be removed if (remove) { toRemove.Add(s); break; } s.Position += pass; } }); toRemove.ForEach(s => { ActiveSpells.Remove(s); RemarkableEvents.Add(Utilities.MakePair <ServerCommand, Action <NetBuffer> >( ServerCommand.SpellDisappear, (msg) => { ulong id = s.ID; msg.Write(id); })); }); }
void AddRemarkableEvent(ServerCommand command, Action <NetBuffer> action) { RemarkableEvents.Add(Utilities.MakePair(command, action)); }