private void UseWeaponsCrate(MapProp prop) { if (prop?.Weapons != null) { _weaponsMenu.OnMenuChange += delegate(UIMenu oldMenu, UIMenu newMenu, bool forward) { if (newMenu == _storageMenu) { TradeOffWeapons(prop, prop.Weapons, _storageMenu, true); } else if (newMenu == _myWeaponsMenu) { List <Weapon> playerWeapons = new List <Weapon>(); WeaponHash[] source = (WeaponHash[])Enum.GetValues(typeof(WeaponHash)); WeaponComponent[] weaponComponents = (WeaponComponent[])Enum.GetValues(typeof(WeaponComponent)); source.ToList().ForEach(delegate(WeaponHash hash) { if ((int)hash != -1569615261 && PlayerPed.Weapons.HasWeapon(hash)) { GTA.Weapon val = PlayerPed.Weapons[hash]; WeaponComponent[] components = (from c in weaponComponents where PlayerPed.Weapons[hash].IsComponentActive(c) select c).ToArray(); Weapon item = new Weapon(val.Ammo, hash, components); playerWeapons.Add(item); } }); TradeOffWeapons(prop, playerWeapons, _myWeaponsMenu, false); } }; _weaponsMenu.Visible = !_weaponsMenu.Visible; } }
private static void TradeOffWeapons(MapProp item, List <Weapon> weapons, UIMenu currentMenu, bool giveToPlayer) { UIMenuItem uiMenuItem1 = new UIMenuItem("Back"); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: method pointer uiMenuItem1.add_Activated(MapInteraction.\u003C\u003Ec.\u003C\u003E9__18_0 ?? (MapInteraction.\u003C\u003Ec.\u003C\u003E9__18_0 = new ItemActivatedEvent((object)MapInteraction.\u003C\u003Ec.\u003C\u003E9, __methodptr(\u003CTradeOffWeapons\u003Eb__18_0)))); currentMenu.Clear(); currentMenu.AddItem(uiMenuItem1); // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: reference to a compiler-generated field // ISSUE: method pointer Action notify = MapInteraction.\u003C\u003Ec.\u003C\u003E9__18_1 ?? (MapInteraction.\u003C\u003Ec.\u003C\u003E9__18_1 = new Action((object)MapInteraction.\u003C\u003Ec.\u003C\u003E9, __methodptr(\u003CTradeOffWeapons\u003Eb__18_1))); weapons.ForEach((Action <Weapon>)(weapon => { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type MapInteraction.\u003C\u003Ec__DisplayClass18_1 cDisplayClass181 = new MapInteraction.\u003C\u003Ec__DisplayClass18_1(); // ISSUE: reference to a compiler-generated field cDisplayClass181.CS\u0024\u003C\u003E8__locals1 = this; // ISSUE: reference to a compiler-generated field cDisplayClass181.weapon = weapon; // ISSUE: reference to a compiler-generated field UIMenuItem uiMenuItem2 = new UIMenuItem(string.Format("{0}", (object)cDisplayClass181.weapon.Hash)); currentMenu.AddItem(uiMenuItem2); // ISSUE: method pointer uiMenuItem2.add_Activated(new ItemActivatedEvent((object)cDisplayClass181, __methodptr(\u003CTradeOffWeapons\u003Eb__3))); })); currentMenu.RefreshIndex(); }
private void MapOnInteracted(MapProp mapProp, InventoryItemBase inventoryItem) { BuildableInventoryItem item = inventoryItem as BuildableInventoryItem; if (item != null) { switch (item.Id) { case "Tent": Sleep(mapProp.Position); break; case "Weapons Crate": UseWeaponsCrate(mapProp); break; case "Work Bench": CraftAmmo(); break; } if (item.IsDoor) { Prop prop = new Prop(mapProp.Handle); prop.SetStateOfDoor(!prop.GetDoorLockState(), DoorState.Closed); } } }
public override void PostLevelLoaded() { base.PostLevelLoaded(); if (Host.IsClient) { return; } foreach (Entity entity in Entity.All) { if (entity is Prop prop && entity.ClassInfo != null && (entity.ClassInfo.Name == "prop_physics" || entity.ClassInfo.Name == "ph_prop_physics")) { MapProp mapProp = new MapProp(); mapProp.ClassName = prop.ClassInfo.Name; mapProp.Model = prop.GetModel(); mapProp.Position = prop.Position; mapProp.Rotation = prop.Rotation; mapProp.Scale = prop.Scale; mapProp.Color = prop.RenderColor; MapProps.Add(mapProp); } } }
private void TryUseMapProp(MapProp mapProp) { bool pickup = mapProp.CanBePickedUp && EditMode; if (pickup || mapProp.Interactable) { if (pickup) { Game.DisableControlThisFrame(2, GTA.Control.Context); } if (mapProp.Interactable) { DisableAttackActions(); } GameExtended.DisableWeaponWheel(); UiExtended.DisplayHelpTextThisFrame(string.Format("{0}", pickup ? $"Press ~INPUT_CONTEXT~ to pickup the {mapProp.Id}.\n" : ((!EditMode) ? "You're not in edit mode.\n" : "")) + string.Format("{0}", mapProp.Interactable ? string.Format("Press ~INPUT_ATTACK~ to {0}.", mapProp.IsDoor ? "Lock/Unlock" : "interact") : ""), false); if (Game.IsDisabledControlJustPressed(2, GTA.Control.Attack) && mapProp.Interactable) { PlayerMap.Interacted?.Invoke(mapProp, PlayerInventory.Instance.ItemFromName(mapProp.Id)); } if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context) && mapProp.CanBePickedUp && PlayerInventory.Instance.PickupItem(PlayerInventory.Instance.ItemFromName(mapProp.Id), ItemType.Item)) { mapProp.Delete(); _map.Remove(mapProp); ZombieVehicleSpawner.Instance.SpawnBlocker.Remove(mapProp.Position); } } }
private void InventoryOnBuildableUsed(BuildableInventoryItem item, Prop newProp) { if (_map == null) { Deserialize(); } MapProp mapProp = new MapProp(item.Id, item.PropName, item.BlipSprite, item.BlipColor, item.GroundOffset, item.Interactable, item.IsDoor, item.CanBePickedUp, newProp.Rotation, newProp.Position, newProp.Handle, (item as WeaponStorageInventoryItem)?.WeaponsList); _map.Add(mapProp); ZombieVehicleSpawner.Instance.SpawnBlocker.Add(mapProp.Position); }
private void OnTick(object sender, EventArgs eventArgs) { if (_map != null && _map.Any() && !MenuConrtoller.MenuPool.IsAnyMenuOpen()) { MapProp closest = World.GetClosest <MapProp>(PlayerPosition, _map.ToArray()); if (closest != null && closest.CanBePickedUp) { float dist = closest.Position.VDist(PlayerPosition); if (!(dist > 3f)) { TryUseMapProp(closest); } } } }
private void UseWeaponsCrate(MapProp prop) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type MapInteraction.\u003C\u003Ec__DisplayClass17_0 cDisplayClass170 = new MapInteraction.\u003C\u003Ec__DisplayClass17_0(); // ISSUE: reference to a compiler-generated field cDisplayClass170.\u003C\u003E4__this = this; // ISSUE: reference to a compiler-generated field cDisplayClass170.prop = prop; // ISSUE: reference to a compiler-generated field if (cDisplayClass170.prop?.Weapons == null) { return; } // ISSUE: method pointer this._weaponsMenu.add_OnMenuChange(new MenuChangeEvent((object)cDisplayClass170, __methodptr(\u003CUseWeaponsCrate\u003Eb__0))); this._weaponsMenu.set_Visible(!this._weaponsMenu.get_Visible()); }
private static void TradeOffWeapons(MapProp item, List <Weapon> weapons, UIMenu currentMenu, bool giveToPlayer) { UIMenuItem back = new UIMenuItem("Back"); back.Activated += delegate(UIMenu sender, UIMenuItem selectedItem) { sender.GoBack(); }; currentMenu.Clear(); currentMenu.AddItem(back); Action notify = delegate { PlayerMap.Instance.NotifyListChanged(); }; weapons.ForEach(delegate(Weapon weapon) { UIMenuItem uIMenuItem = new UIMenuItem($"{(object)weapon.Hash}"); currentMenu.AddItem(uIMenuItem); uIMenuItem.Activated += delegate { currentMenu.RemoveItemAt(currentMenu.CurrentSelection); currentMenu.RefreshIndex(); if (giveToPlayer) { PlayerPed.Weapons.Give(weapon.Hash, 0, true, true); PlayerPed.Weapons[weapon.Hash].Ammo = weapon.Ammo; weapon.Components.ToList().ForEach(delegate(WeaponComponent component) { PlayerPed.Weapons[weapon.Hash].SetComponent(component, true); }); item.Weapons.Remove(weapon); notify(); } else { PlayerPed.Weapons.Remove(weapon.Hash); item.Weapons.Add(weapon); notify(); } }; }); currentMenu.RefreshIndex(); }
private void MapOnInteracted(MapProp mapProp, InventoryItemBase inventoryItem) { BuildableInventoryItem buildableInventoryItem = inventoryItem as BuildableInventoryItem; if (buildableInventoryItem == null) { return; } string id = buildableInventoryItem.Id; if (!(id == "Tent")) { if (!(id == "Weapons Crate")) { if (id == "Work Bench") { this.CraftAmmo(); } } else { this.UseWeaponsCrate(mapProp); } } else { this.Sleep(mapProp.Position); } if (!buildableInventoryItem.IsDoor) { return; } Prop prop = new Prop(mapProp.Handle); prop.SetStateOfDoor(!prop.GetDoorLockState(), DoorState.Closed); }