示例#1
0
            void WriteObject_InventoryItem(InventoryItemBase ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
            {
                if (((object)ob) == null)
                {
                    if (isNullable)
                    {
                        WriteNullTagLiteral(element, namesp);
                    }
                    return;
                }

                System.Type type = ob.GetType();
                if (type == typeof(InventoryItemBase))
                {
                }
                else
                {
                    throw CreateUnknownTypeException(ob);
                }

                if (writeWrappingElem)
                {
                    WriteStartElement(element, namesp, ob);
                }

                if (needType)
                {
                    WriteXsiType("InventoryItemBase", "");
                }

                WriteObject_UUID(ob.@ID, "ID", "", false, false, true);
                WriteElementString("InvType", "", [email protected](CultureInfo.InvariantCulture));
                WriteObject_UUID(ob.@Folder, "Folder", "", false, false, true);
                WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true);
                WriteElementString("Creator", "", ob.@CreatorId);
                WriteElementString("Name", "", ob.@Name);
                WriteElementString("Description", "", ob.@Description);
                WriteElementString("NextPermissions", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("CurrentPermissions", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("BasePermissions", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("EveryOnePermissions", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("GroupPermissions", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("AssetType", "", [email protected](CultureInfo.InvariantCulture));
                WriteObject_UUID(ob.@AssetID, "AssetID", "", false, false, true);
                WriteObject_UUID(ob.@GroupID, "GroupID", "", false, false, true);
                WriteElementString("GroupOwned", "", (ob.@GroupOwned ? "true" : "false"));
                WriteElementString("SalePrice", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("SaleType", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("Flags", "", [email protected](CultureInfo.InvariantCulture));
                WriteElementString("CreationDate", "", [email protected](CultureInfo.InvariantCulture));
                if (writeWrappingElem)
                {
                    WriteEndElement(ob);
                }
            }
示例#2
0
        private void InventoryOnItemUsed(InventoryItemBase item, ItemType type)
        {
            if (item == null || type == ItemType.Resource)
            {
                return;
            }
            int?eventArgument;

            if (System.Type.op_Equality(item.GetType(), typeof(FoodInventoryItem)))
            {
                FoodInventoryItem foodInventoryItem = (FoodInventoryItem)item;
                PlayerInventory.PlayerPed.get_Task().PlayAnimation(foodInventoryItem.AnimationDict, foodInventoryItem.AnimationName, 8f, foodInventoryItem.AnimationDuration, foodInventoryItem.AnimationFlags);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedFoodEvent foodUsed = PlayerInventory.FoodUsed;
                if (foodUsed != null)
                {
                    foodUsed(foodInventoryItem, foodInventoryItem.FoodType);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(WeaponInventoryItem)))
            {
                WeaponInventoryItem weapon = (WeaponInventoryItem)item;
                PlayerInventory.PlayerPed.get_Weapons().Give(weapon.Hash, weapon.Ammo, true, true);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedWeaponEvent weaponUsed = PlayerInventory.WeaponUsed;
                if (weaponUsed != null)
                {
                    weaponUsed(weapon);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(BuildableInventoryItem)) || System.Type.op_Equality(item.GetType(), typeof(WeaponStorageInventoryItem)))
            {
                if (PlayerInventory.PlayerPed.IsInVehicle())
                {
                    UI.Notify("You can't build while in a vehicle!");
                    return;
                }
                BuildableInventoryItem buildableInventoryItem = (BuildableInventoryItem)item;
                ItemPreview            itemPreview            = new ItemPreview();
                itemPreview.StartPreview(buildableInventoryItem.PropName, buildableInventoryItem.GroundOffset, buildableInventoryItem.IsDoor);
                while (!itemPreview.PreviewComplete)
                {
                    Script.Yield();
                }
                Prop result = itemPreview.GetResult();
                if (Entity.op_Equality((Entity)result, (Entity)null))
                {
                    return;
                }
                PlayerInventory.AddBlipToProp((IProp)buildableInventoryItem, buildableInventoryItem.Id, (Entity)result);
                // ISSUE: reference to a compiler-generated field
                PlayerInventory.OnUsedBuildableEvent buildableUsed = PlayerInventory.BuildableUsed;
                if (buildableUsed != null)
                {
                    buildableUsed(buildableInventoryItem, result);
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(UsableInventoryItem)))
            {
                foreach (UsableItemEvent itemEvent in ((UsableInventoryItem)item).ItemEvents)
                {
                    switch (itemEvent.Event)
                    {
                    case ItemEvent.GiveArmor:
                        eventArgument = itemEvent.EventArgument as int?;
                        int num1       = eventArgument ?? 0;
                        Ped playerPed1 = PlayerInventory.PlayerPed;
                        ((Entity)playerPed1).set_Health(((Entity)playerPed1).get_Health() + num1);
                        break;

                    case ItemEvent.GiveHealth:
                        eventArgument = itemEvent.EventArgument as int?;
                        int num2       = eventArgument ?? 0;
                        Ped playerPed2 = PlayerInventory.PlayerPed;
                        playerPed2.set_Armor(playerPed2.get_Armor() + num2);
                        break;
                    }
                }
            }
            else if (System.Type.op_Equality(item.GetType(), typeof(CraftableInventoryItem)) && !((CraftableInventoryItem)item).Validation.Invoke())
            {
                return;
            }
            this._inventory.AddItem(item, -1, type);
        }
 public bool VerifyFilter(InventoryItemBase item, System.Type type, FilterType filterType)
 {
     return VerifyFilterEqualNotEqual(item.GetType(), type, filterType);
 }
示例#4
0
        private void InventoryOnItemUsed(InventoryItemBase item, ItemType type)
        {
            if (item != null && type != 0)
            {
                if (item.GetType() == typeof(FoodInventoryItem))
                {
                    FoodInventoryItem foodItem = (FoodInventoryItem)item;
                    PlayerPed.Task.PlayAnimation(foodItem.AnimationDict, foodItem.AnimationName, 8f, foodItem.AnimationDuration, foodItem.AnimationFlags);
                    PlayerInventory.FoodUsed?.Invoke(foodItem, foodItem.FoodType);
                }
                else if (item.GetType() == typeof(WeaponInventoryItem))
                {
                    WeaponInventoryItem weaponItem = (WeaponInventoryItem)item;
                    PlayerPed.Weapons.Give(weaponItem.Hash, weaponItem.Ammo, true, true);
                    PlayerInventory.WeaponUsed?.Invoke(weaponItem);
                }
                else if (item.GetType() == typeof(BuildableInventoryItem) || item.GetType() == typeof(WeaponStorageInventoryItem))
                {
                    if (PlayerPed.IsInVehicle())
                    {
                        UI.Notify("You can't build while in a vehicle!");
                        return;
                    }
                    BuildableInventoryItem buildableItem = (BuildableInventoryItem)item;
                    ItemPreview            preview       = new ItemPreview();
                    preview.StartPreview(buildableItem.PropName, buildableItem.GroundOffset, buildableItem.IsDoor);
                    while (!preview.PreviewComplete)
                    {
                        Script.Yield();
                    }
                    Prop result = preview.GetResult();
                    if (result == null)
                    {
                        return;
                    }
                    AddBlipToProp(buildableItem, buildableItem.Id, result);
                    PlayerInventory.BuildableUsed?.Invoke(buildableItem, result);
                }
                else if (item.GetType() == typeof(UsableInventoryItem))
                {
                    UsableInventoryItem usableItem = (UsableInventoryItem)item;
                    UsableItemEvent[]   events     = usableItem.ItemEvents;
                    UsableItemEvent[]   array      = events;
                    foreach (UsableItemEvent @event in array)
                    {
                        switch (@event.Event)
                        {
                        case ItemEvent.GiveArmor:
                        {
                            int arg        = (@event.EventArgument as int?) ?? 0;
                            Ped playerPed2 = new Ped(PlayerPed.Handle);
                            playerPed2.Health = playerPed2.Health + arg;
                            break;
                        }

                        case ItemEvent.GiveHealth:
                        {
                            int arg2      = (@event.EventArgument as int?) ?? 0;
                            Ped playerPed = new Ped(PlayerPed.Handle);
                            playerPed.Armor = playerPed.Armor + arg2;
                            break;
                        }
                        }
                    }
                }
                else if (item.GetType() == typeof(CraftableInventoryItem))
                {
                    CraftableInventoryItem craftableItem = (CraftableInventoryItem)item;
                    if (!craftableItem.Validation())
                    {
                        return;
                    }
                }
                _inventory.AddItem(item, -1, type);
            }
        }
        public override void OnEnter()
        {
            result.stringValue = item.GetType().ToString();

            Finish();
        }