Beispiel #1
0
        private static void OnUnload(bool isTerminating)
        {
            AddonsManager.Instance.UnloadAddons();

            FireStationsManager.Instance.CleanUp(isTerminating);
            //PlayerManager.Instance.CleanUp(isTerminating);
            PlayerFireEquipmentController.Instance.CleanUp(isTerminating);
            FireCalloutsManager.Instance.CleanUp(isTerminating);

            HospitalsManager.Instance.CleanUp(isTerminating);
            EMSCalloutsManager.Instance.CleanUp(isTerminating);

            FirefightersBackupUnit[] firefightersUnits = BackupUnit.GetAllBackupUnitsOfType <FirefightersBackupUnit>();
            if (firefightersUnits != null)
            {
                foreach (FirefightersBackupUnit u in firefightersUnits)
                {
                    u.Delete();
                }
            }

            ParamedicsBackupUnit[] paramedicsUnits = BackupUnit.GetAllBackupUnitsOfType <ParamedicsBackupUnit>();
            if (paramedicsUnits != null)
            {
                foreach (ParamedicsBackupUnit u in paramedicsUnits)
                {
                    u.Delete();
                }
            }
        }
 protected AIBackupUnitDriveToPositionTask(BackupUnit unit, Vector3 position, bool sirenOn, float speed, float acceptedDistance, VehicleDrivingFlags flags) : base(unit)
 {
     this.position         = position;
     this.sirenOn          = sirenOn;
     this.speed            = speed;
     this.acceptedDistance = acceptedDistance;
     this.flags            = flags;
 }
        protected AIBackupUnitExtinguishFireInAreaTask(BackupUnit unit, Vector3 position, float range) : base(unit)
        {
            FirefightersUnit = unit as FirefightersBackupUnit;
            if (FirefightersUnit == null)
            {
                throw new System.ArgumentException($"The Unit instance isn't a FirefightersBackupUnit instance. The {nameof(AIBackupUnitExtinguishFireInAreaTask)} requires a FirefightersBackupUnit instance.", nameof(unit));
            }

            this.position = position;
            this.range    = range;
        }
        public static void SendFirefightersUnit(Vector3 position, FirefighterBackupTask task)
        {
            RotatedVector3 spawn = Util.GetSpawnLocationAroundPlayer(true);

            FirefightersBackupUnit[] currentUnits = BackupUnit.GetAllBackupUnitsOfType <FirefightersBackupUnit>();

            FirefightersBackupUnit unit = (currentUnits == null || currentUnits.Length == 0) ?
                                          null :
                                          currentUnits.Where(u => !u.IsDismissedOrDeleted && !u.IsResponding).OrderBy(u => Vector3.DistanceSquared(u.Vehicle.Position, position)).FirstOrDefault();

            if (unit == null)
            {
                unit = new FirefightersBackupUnit(spawn.Position, spawn.Heading);
            }
            else
            {
                unit.AI.AbortAllTasks();
            }

            unit.AI.DriveToPosition(position, true, 15f, 20.0f, VehicleDrivingFlags.Emergency);
            unit.IsResponding = true;
            switch (task)
            {
            case FirefighterBackupTask.ExtinguishFireInArea:
                unit.AI.ExtinguishFireInArea(position, 125.0f, false);
                break;
            }

            AIBackupUnitTask unitTask = unit.AI.DriveToPosition(FireStationsManager.Instance.Buildings.OrderBy(s => Vector3.DistanceSquared(s.Entrance, spawn.Position)).First().Entrance, false, 8f, 50.0f, VehicleDrivingFlags.Normal, false);

            unitTask.Started += (t) =>
            {
                unit.IsResponding = false;
            };
            unitTask.Finished += (t, aborted) =>
            {
                if (!aborted)
                {
                    if (Vector3.DistanceSquared(Game.LocalPlayer.Character.Position, unit.Vehicle) > 70.0f * 70.0f)
                    {
                        unit.Delete();
                    }
                    else
                    {
                        unit.Dismiss();
                    }
                }
            };
        }
 protected AIBackupUnitChillAroundTask(BackupUnit unit) : base(unit)
 {
 }
Beispiel #6
0
 public AIBackupUnitController(BackupUnit unit)
 {
     Unit       = unit;
     tasksQueue = new Queue <AIBackupUnitTask>();
 }
Beispiel #7
0
 protected AIBackupUnitTask(BackupUnit unit)
 {
     Unit = unit;
 }
Beispiel #8
0
 protected AIBackupUnitDriveToParkingLocationAndParkTask(BackupUnit unit, RotatedVector3 parkingLocation) : base(unit)
 {
     targetParkingLocation = parkingLocation;
 }