Example #1
0
 private void InstallMod(ref ItemModPair to, int slot, ItemModDataBlock datablock, CharacterStateFlags flags)
 {
     to.dataBlock = datablock;
     if (to.representation != null)
     {
         this.KillModRep(ref to.representation, false);
     }
     if (to.dataBlock.hasModRepresentation && to.dataBlock.AddModRepresentationComponent(base.gameObject, out to.representation))
     {
         to.bindState = BindState.None;
         to.representation.Initialize(this, slot, flags);
         if (to.representation != null)
         {
             if (this.worldModels)
             {
                 this._itemMods.BindAsProxy(slot, this);
             }
         }
         else
         {
             to.bindState      = BindState.Vacant;
             to.representation = null;
         }
     }
 }
Example #2
0
    public void AddMod(ItemModDataBlock mod)
    {
        this.RecalculateMods();
        int usedModSlots = this.usedModSlots;

        this._itemMods[usedModSlots] = mod;
        this.RecalculateMods();
        this.OnModAdded(mod);
        base.MarkDirty();
    }
Example #3
0
 public int FindMod(ItemModDataBlock mod)
 {
     if (mod != null)
     {
         for (int i = 0; i < 5; i++)
         {
             if (this._itemMods[i] == mod)
             {
                 return(i);
             }
         }
     }
     return(-1);
 }
Example #4
0
    protected void Mods(byte[] data)
    {
        this.ClearMods();
        uLink.BitStream stream = new uLink.BitStream(data, false);
        byte            num    = stream.ReadByte();

        if (num > 0)
        {
            CharacterStateFlags characterStateFlags = this.GetCharacterStateFlags();
            for (int i = 0; i < num; i++)
            {
                ItemModDataBlock byUniqueID = (ItemModDataBlock)DatablockDictionary.GetByUniqueID(stream.ReadInt32());
                this._itemMods.InstallMod(i, this, byUniqueID, characterStateFlags);
                this._modFlags |= byUniqueID.modFlag;
            }
        }
    }
Example #5
0
 public bool addWeaponMod(string name)
 {
     if (this.isWeapon)
     {
         ItemModDataBlock weaponmod = DatablockDictionary.GetByName(name) as ItemModDataBlock;
         if (weaponmod == null)
         {
             return(false);
         }
         this.heldItem.AddMod(weaponmod);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #6
0
        public void InstallMod(int slotNumber, ItemRepresentation owner, ItemModDataBlock datablock, CharacterStateFlags flags)
        {
            switch (slotNumber)
            {
            case 0:
            {
                owner.InstallMod(ref this.a, 0, datablock, flags);
                break;
            }

            case 1:
            {
                owner.InstallMod(ref this.b, 1, datablock, flags);
                break;
            }

            case 2:
            {
                owner.InstallMod(ref this.c, 2, datablock, flags);
                break;
            }

            case 3:
            {
                owner.InstallMod(ref this.d, 3, datablock, flags);
                break;
            }

            case 4:
            {
                owner.InstallMod(ref this.e, 4, datablock, flags);
                break;
            }

            default:
            {
                throw new IndexOutOfRangeException();
            }
            }
        }
 int IHeldItem.FindMod(ItemModDataBlock mod)
 {
     return(base.FindMod(mod));
 }
 void IHeldItem.AddMod(ItemModDataBlock mod)
 {
     base.AddMod(mod);
 }
Example #9
0
 protected virtual void OnModAdded(ItemModDataBlock mod)
 {
 }
Example #10
0
 private void EraseModDatablock(ref ItemModDataBlock block)
 {
     block = null;
 }
        public static Data.Entities.StoreItem GetStoreItem(Data.Entities.User user, Fougerite.PlayerItem item, int price = 1)
        {
            if (item.Name != "" && item.Quantity != -1 && item != null)
            {
                IInventoryItem itemdata   = item.RInventoryItem;
                string         category   = item.RInventoryItem.datablock.category.ToString();
                int            internalID = 1;
                if (StoreItems.Count > 0)
                {
                    Data.Entities.StoreItem lastItem = StoreItems.Last <Data.Entities.StoreItem>();

                    if (lastItem != null)
                    {
                        internalID = lastItem.InternalID + 1;
                    }
                }
                Data.Entities.StoreItem newItem = new Data.Entities.StoreItem
                {
                    InternalID    = internalID,
                    UserID        = user.ID,
                    Price         = price,
                    Date          = DateTime.Now.ToString(),
                    ItemName      = item.Name,
                    ItemCategory  = GetCategoryNumber(category),
                    ItemQuantity  = item.Quantity,
                    ItemCondition = itemdata.condition,
                    Item          = item,
                };
                if (user.Player != null)
                {
                    newItem.Player = user.Player;
                }
                else
                {
                    return(null);
                }
                if (item.isWeapon)
                {
                    newItem.ItemWeaponBullets = itemdata.uses;
                    ItemModDataBlock mod1 = item.getModSlot(0);
                    ItemModDataBlock mod2 = item.getModSlot(1);
                    ItemModDataBlock mod3 = item.getModSlot(2);
                    ItemModDataBlock mod4 = item.getModSlot(3);
                    ItemModDataBlock mod5 = item.getModSlot(4);
                    newItem.ItemWeaponSlots = item.getModSlotsCount;
                    if (mod1 != null)
                    {
                        newItem.ItemWeaponSlot1 = mod1.name;
                    }
                    if (mod2 != null)
                    {
                        newItem.ItemWeaponSlot2 = mod2.name;
                    }
                    if (mod3 != null)
                    {
                        newItem.ItemWeaponSlot3 = mod3.name;
                    }
                    if (mod4 != null)
                    {
                        newItem.ItemWeaponSlot4 = mod4.name;
                    }
                    if (mod5 != null)
                    {
                        newItem.ItemWeaponSlot5 = mod5.name;
                    }
                }

                return(newItem);
            }
            return(null);
        }