public PedData(int handle, int hash, Vector3 rotation, Vector3 position, PedTask task, List <Weapon> weapons) { this.Handle = handle; this.Hash = hash; this.Rotation = rotation; this.Position = position; this.Task = task; this.Weapons = weapons; }
public PedData(int handle, int hash, Vector3 rotation, Vector3 position, PedTask task, List <Weapon> weapons) { Handle = handle; Hash = hash; Rotation = rotation; Position = position; Task = task; Weapons = weapons; }
private PedData UpdatePedData(Ped ped, PedData data) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type PlayerGroupManager.\u003C\u003Ec__DisplayClass18_0 cDisplayClass180 = new PlayerGroupManager.\u003C\u003Ec__DisplayClass18_0(); // ISSUE: reference to a compiler-generated field cDisplayClass180.ped = ped; // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field PedTask pedTask = this._pedTasks.ContainsKey(cDisplayClass180.ped) ? this._pedTasks[cDisplayClass180.ped] : ~PedTask.StandStill; // ISSUE: method pointer IEnumerable <WeaponHash> source = (IEnumerable <WeaponHash>)Enumerable.Where <WeaponHash>((IEnumerable <M0>)Enum.GetValues(typeof(WeaponHash)), (Func <M0, bool>) new Func <WeaponHash, bool>((object)cDisplayClass180, __methodptr(\u003CUpdatePedData\u003Eb__0))); // ISSUE: reference to a compiler-generated field cDisplayClass180.componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); // ISSUE: reference to a compiler-generated method List <Weapon> list = source.ToList <WeaponHash>().ConvertAll <Weapon>(new Converter <WeaponHash, Weapon>(cDisplayClass180.\u003CUpdatePedData\u003Eb__1)).ToList <Weapon>(); bool flag = data == null; if (flag) { if (flag) { // ISSUE: reference to a compiler-generated field int handle = ((Entity)cDisplayClass180.ped).get_Handle(); // ISSUE: reference to a compiler-generated field Model model = ((Entity)cDisplayClass180.ped).get_Model(); int hash = ((Model) ref model).get_Hash(); // ISSUE: reference to a compiler-generated field Vector3 rotation = ((Entity)cDisplayClass180.ped).get_Rotation(); // ISSUE: reference to a compiler-generated field Vector3 position = ((Entity)cDisplayClass180.ped).get_Position(); int num = (int)pedTask; List <Weapon> weapons = list; data = new PedData(handle, hash, rotation, position, (PedTask)num, weapons); } } else { // ISSUE: reference to a compiler-generated field data.Position = ((Entity)cDisplayClass180.ped).get_Position(); // ISSUE: reference to a compiler-generated field data.Rotation = ((Entity)cDisplayClass180.ped).get_Rotation(); data.Task = pedTask; data.Weapons = list; } return(data); }
private PedData UpdatePedData(Ped ped, PedData data) { PedTask task = _pedTasks.ContainsKey(ped) ? _pedTasks[ped] : ((PedTask)(-1)); IEnumerable <WeaponHash> hashes = from hash in (WeaponHash[])Enum.GetValues(typeof(WeaponHash)) where ped.Weapons.HasWeapon(hash) select hash; WeaponComponent[] componentHashes = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); List <Weapon> weapons = hashes.ToList().ConvertAll(delegate(WeaponHash hash) { GTA.Weapon weapon = ped.Weapons[hash]; WeaponComponent[] components = (from h in componentHashes where weapon.IsComponentActive(h) select h).ToArray(); return(new Weapon(weapon.Ammo, weapon.Hash, components)); }).ToList(); switch (data == null) { case true: { int handle = ped.Handle; Model model = ped.Model; data = new PedData(handle, model.Hash, ped.Rotation, ped.Position, task, weapons); break; } case false: data.Position = ped.Position; data.Rotation = ped.Rotation; data.Task = task; data.Weapons = weapons; break; } return(data); }
/// <summary> /// Check if this ped is doing a certain task /// </summary> public bool IsDoingTask(PedTask task) { return(MtaClient.IsPedDoingTask(element, task.ToString().ToUpper())); }
public PlayerGroupManager() { Instance = this; _pedMenu = new UIMenu("Guard", "SELECT AN OPTION"); MenuConrtoller.MenuPool.Add(_pedMenu); _pedMenu.OnMenuClose += delegate { _selectedPed = null; }; UIMenuListItem tasksItem = new UIMenuListItem("Tasks", Enum.GetNames(typeof(PedTask)).Cast <object>().ToList(), 0, "Give peds a specific task to perform."); tasksItem.Activated += delegate { if (!(_selectedPed == null)) { PedTask index = (PedTask)tasksItem.Index; SetTask(_selectedPed, index); } }; UIMenuItem applyAllItem = new UIMenuItem("Apply To Nearby", "Apply the selected task to nearby peds within 50 meters."); applyAllItem.Activated += delegate { PedTask task2 = (PedTask)tasksItem.Index; List <Ped> list2 = (from ped in (IEnumerable <Ped>)PlayerPed.CurrentPedGroup where ped.Position.VDist(PlayerPosition) < 50f select ped).ToList(); list2.ForEach(delegate(Ped ped) { SetTask(ped, task2); }); }; UIMenuItem giveWeaponItem = new UIMenuItem("Give Weapon", "Give this ped your current weapon."); giveWeaponItem.Activated += delegate { if (!(_selectedPed == null)) { TradeWeapons(PlayerPed, _selectedPed); } }; UIMenuItem takeWeaponItem = new UIMenuItem("Take Weapon", "Take the ped's current weapon."); takeWeaponItem.Activated += delegate { if (!(_selectedPed == null)) { TradeWeapons(_selectedPed, PlayerPed); } }; UIMenuListItem globalTasks = new UIMenuListItem("Guard Tasks", Enum.GetNames(typeof(PedTask)).Cast <object>().ToList(), 0, "Give all gurads a specific task to perform."); globalTasks.Activated += delegate { PedTask task = (PedTask)globalTasks.Index; List <Ped> list = ((IEnumerable <Ped>)PlayerPed.CurrentPedGroup).ToList(); list.ForEach(delegate(Ped ped) { SetTask(ped, task); }); }; _pedMenu.AddItem(tasksItem); _pedMenu.AddItem(applyAllItem); _pedMenu.AddItem(giveWeaponItem); _pedMenu.AddItem(takeWeaponItem); ModController.Instance.MainMenu.AddItem(globalTasks); this.Tick += (EventHandler)OnTick; this.Aborted += (EventHandler)OnAborted; }
private unsafe void SetTask(Ped ped, PedTask task) { if (task != (PedTask)(-1) && !ped.IsPlayer) { if (!_pedTasks.ContainsKey(ped)) { _pedTasks.Add(ped, task); } else { _pedTasks[ped] = task; } ped.Task.ClearAll(); switch (task) { case PedTask.Chill: Function.Call(GTA.Native.Hash.TASK_WANDER_IN_AREA, (InputArgument[])new InputArgument[6] { ped.Handle, ped.Position.X, ped.Position.Y, ped.Position.Z, 100f, -1 }); break; case PedTask.Combat: ped.Task.FightAgainstHatedTargets(100f); break; case PedTask.Guard: ped.Task.GuardCurrentPosition(); break; case PedTask.StandStill: ped.Task.StandStill(-1); break; case PedTask.Leave: { ped.LeaveGroup(); Blip currentBlip = ped.CurrentBlip; if (currentBlip.Handle != 0) { currentBlip.Remove(); } ped.MarkAsNoLongerNeeded(); EntityEventWrapper.Dispose(ped); break; } case PedTask.VehicleFollow: { Vehicle vehicle = World.GetClosestVehicle(ped.Position, 100f); if (vehicle == null) { UI.Notify("There's no vehicle near this ped.", true); return; } Function.Call(GTA.Native.Hash._TASK_VEHICLE_FOLLOW, (InputArgument[])new InputArgument[6] { ped.Handle, vehicle.Handle, PlayerPed.Handle, 1074528293, 262144, 15 }); break; } } ped.BlockPermanentEvents = task == PedTask.Follow; } }
private void SetTask(Ped ped, PedTask task) { if (task == ~PedTask.StandStill || ped.get_IsPlayer()) { return; } if (!this._pedTasks.ContainsKey(ped)) { this._pedTasks.Add(ped, task); } else { this._pedTasks[ped] = task; } ped.get_Task().ClearAll(); switch (task) { case PedTask.StandStill: ped.get_Task().StandStill(-1); break; case PedTask.Guard: ped.get_Task().GuardCurrentPosition(); break; case PedTask.VehicleFollow: Vehicle closestVehicle = World.GetClosestVehicle(((Entity)ped).get_Position(), 100f); if (Entity.op_Equality((Entity)closestVehicle, (Entity)null)) { UI.Notify("There's no vehicle near this ped.", true); return; } Function.Call((Hash) - 264486839058504778L, new InputArgument[6] { InputArgument.op_Implicit(((Entity)ped).get_Handle()), InputArgument.op_Implicit(((Entity)closestVehicle).get_Handle()), InputArgument.op_Implicit(((Entity)this.PlayerPed).get_Handle()), InputArgument.op_Implicit(1074528293), InputArgument.op_Implicit(262144), InputArgument.op_Implicit(15) }); break; case PedTask.Combat: ped.get_Task().FightAgainstHatedTargets(100f); break; case PedTask.Chill: Function.Call((Hash)2846071673660833803L, new InputArgument[6] { InputArgument.op_Implicit(((Entity)ped).get_Handle()), InputArgument.op_Implicit((float)((Entity)ped).get_Position().X), InputArgument.op_Implicit((float)((Entity)ped).get_Position().Y), InputArgument.op_Implicit((float)((Entity)ped).get_Position().Z), InputArgument.op_Implicit(100f), InputArgument.op_Implicit(-1) }); break; case PedTask.Leave: ped.LeaveGroup(); ((Entity)ped).get_CurrentBlip()?.Remove(); ((Entity)ped).MarkAsNoLongerNeeded(); EntityEventWrapper.Dispose((Entity)ped); break; } ped.set_BlockPermanentEvents(task == PedTask.Follow); }
/// <summary> /// Returns true if the specified task is active for this ped. /// </summary> public static bool IsTaskActive(this Ped ped, PedTask task) => NativeWrappers.GetIsTaskActive(ped, (int)task);