protected override void UpdateInternal() { if (drivingTask == null && (enterVehicleTasks == null || enterVehicleTasks.All(t => t.IsFinished))) { Unit.Vehicle.IsSirenOn = sirenOn; drivingTask = Unit.Driver.AI.DriveTo(position, speed, acceptedDistance, flags); } else if (drivingTask != null && drivingTask.IsFinished) { IsFinished = true; } }
internal void Update() { if (IsEnabled && Owner.Ped && !Owner.Ped.IsDead) { if (currentTask != null) { if (currentTask.IsFinished) { currentTask = null; return; } currentTask.Update(); } behaviour?.Update(); } }
protected override void UpdateInternal() { if (drivingTask == null && (enterVehicleTasks == null || enterVehicleTasks.All(t => t.IsFinished))) { Unit.Vehicle.IsSirenOn = false; Vector3 parkPos = targetParkingLocation.Position; Vector3 position; NativeFunction.Natives.GetClosestVehicleNode(parkPos.X, parkPos.Y, parkPos.Z, out position, 1, 3.0f, 0.0f); drivingTask = Unit.Driver.AI.DriveTo(position, 13.5f, 22.5f, VehicleDrivingFlags.YieldToCrossingPedestrians | VehicleDrivingFlags.DriveAroundObjects | VehicleDrivingFlags.DriveAroundPeds | VehicleDrivingFlags.DriveAroundVehicles | VehicleDrivingFlags.AllowWrongWay); } else if (parkTask == null && (drivingTask != null && drivingTask.IsFinished)) { Vector3 parkPos = targetParkingLocation.Position; float parkHeading = targetParkingLocation.Heading; NativeFunction.Natives.TaskVehiclePark(Unit.Driver.Ped, Unit.Vehicle, parkPos.X, parkPos.Y, parkPos.Z, parkHeading, 1, 20f, false); parkTask = Task.GetTask(Unit.Driver.Ped, "TASK_VEHICLE_PARK"); } else if (parkTask != null && !parkTask.IsActive) { IsFinished = true; } }
protected AITask GiveTask <TTask>(params object[] args) where TTask : AITask { currentTask = (AITask)Activator.CreateInstance(typeof(TTask), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, args, null); Log($"GiveTask ({typeof(TTask).Name})"); return(currentTask); }
public bool IsPerformingTask(AITask task) { return(currentTask != null && task != null && currentTask == task && !currentTask.IsFinished); }