Beispiel #1
0
        public void Repair(Actor repairer, int direction, Action onComplete)
        {
            // Repair self
            var initialDamage = health.DamageState;

            self.World.AddFrameEndTask(w =>
            {
                if (health.IsDead)
                {
                    health.Resurrect(self, repairer);
                    killedUnits = false;
                    KillUnitsOnBridge();
                }
                else
                {
                    health.InflictDamage(self, repairer, -health.MaxHP, null, true);
                }
                if (direction < 0 ? neighbours[0] == null && neighbours[1] == null : Hut != null || neighbours[direction] == null)
                {
                    onComplete();                     // Done if single or reached other hut
                }
            });

            // Repair adjacent spans onto next hut or end
            if (direction >= 0 && Hut == null && neighbours[direction] != null)
            {
                var delay = initialDamage == DamageState.Undamaged || NeighbourIsDeadShore(neighbours[direction]) ?
                            0 : info.RepairPropagationDelay;

                self.World.AddFrameEndTask(w => w.Add(new DelayedAction(delay, () =>
                                                                        neighbours[direction].Repair(repairer, direction, onComplete))));
            }
        }
 void IBridgeSegment.Repair(Actor repairer)
 {
     health.InflictDamage(self, repairer, new Damage(-health.MaxHP), true);
 }