Example #1
0
        public IDisposable Reserve(Actor self, Actor forActor, Aircraft forAircraft)
        {
            if (reservedForAircraft != null && reservedForAircraft.MayYieldReservation)
            {
                reservedForAircraft.UnReserve();
            }

            reservedFor         = forActor;
            reservedForAircraft = forAircraft;

            return(new DisposableAction(() => { reservedFor = null; reservedForAircraft = null; }, () => WarGame.RunAfterTick(() =>
            {
                if (WarGame.IsCurrentWorld(self.World))
                {
                    throw new InvalidOperationException("Attempted to finalize  an undisposed DisposableAction.{0} ({1}) reserved {2} ({3}) "
                                                        .F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));
                }
            })));
        }