Esempio n. 1
0
    // Token: 0x06001088 RID: 4232 RVA: 0x000663F8 File Offset: 0x000645F8
    private void InitializeQuickItem(GameObject quickItemObject, LoadoutSlotType slot, InventoryItem inventoryItem)
    {
        int       slotIndex = this.GetSlotIndex(slot);
        QuickItem component = quickItemObject.GetComponent <QuickItem>();

        if (component)
        {
            component.gameObject.SetActive(true);
            for (int i = 0; i < component.gameObject.transform.childCount; i++)
            {
                component.gameObject.transform.GetChild(i).gameObject.SetActive(false);
            }
            component.gameObject.name  = inventoryItem.Item.Name;
            component.transform.parent = GameState.Current.Player.WeaponAttachPoint;
            if (component.rigidbody)
            {
                component.rigidbody.isKinematic = true;
            }
            ItemConfigurationUtil.CopyProperties <UberStrikeItemQuickView>(component.Configuration, inventoryItem.Item.View);
            ItemConfigurationUtil.CopyCustomProperties(inventoryItem.Item.View, component.Configuration);
            if (component.Configuration.RechargeTime <= 0)
            {
                int index = slotIndex;
                QuickItemBehaviour behaviour = component.Behaviour;
                behaviour.OnActivated = (Action)Delegate.Combine(behaviour.OnActivated, new Action(delegate()
                {
                    this.UseConsumableItem(inventoryItem);
                    this.Restriction.DecreaseUse(index);
                    this.NextCooldownFinishTime = Time.time + 0.5f;
                }));
                this.Restriction.InitializeSlot(slotIndex, component, inventoryItem.AmountRemaining);
            }
            else
            {
                component.Behaviour.CurrentAmount = component.Configuration.AmountRemaining;
            }
            component.Behaviour.FocusKey = this.GetFocusKey(slot);
            IGrenadeProjectile grenadeProjectile = component as IGrenadeProjectile;
            if (grenadeProjectile != null)
            {
                grenadeProjectile.OnProjectileEmitted += delegate(IGrenadeProjectile p)
                {
                    Singleton <ProjectileManager> .Instance.AddProjectile(p, Singleton <WeaponController> .Instance.NextProjectileId());

                    GameState.Current.Actions.EmitQuickItem(p.Position, p.Velocity, inventoryItem.Item.View.ID, GameState.Current.PlayerData.Player.PlayerId, p.ID);
                };
            }
            if (this._quickItems[slotIndex])
            {
                UnityEngine.Object.Destroy(this._quickItems[slotIndex].gameObject);
            }
            this._quickItems[slotIndex] = component;
        }
        else
        {
            Debug.LogError("Failed to initialize QuickItem");
        }
        GameData.Instance.OnQuickItemsChanged.Fire();
    }
    // Token: 0x060010D0 RID: 4304 RVA: 0x000672C8 File Offset: 0x000654C8
    public GameObject Create(Vector3 position, Quaternion rotation)
    {
        if (UnityItemConfiguration.Instance.IsPrefabAvailable(this.View.PrefabName))
        {
            string prefabPath = UnityItemConfiguration.Instance.GetPrefabPath(this.View.PrefabName);
            Debug.Log(string.Concat(new object[]
            {
                "Create Item:",
                this.View.ID,
                ", ",
                this.View.Name,
                ", ",
                prefabPath
            }));
            UnityEngine.Object @object = Resources.Load <GameObject>(prefabPath);
            this.Prefab = (GameObject)@object;
        }
        else
        {
            Debug.Log(string.Concat(new object[]
            {
                "Create DEFAULT Item:",
                this.View.ID,
                ", ",
                this.View.Name,
                ", ",
                this.View.PrefabName
            }));
            this.Prefab = UnityItemConfiguration.Instance.GetDefaultItem(this.View.ItemClass);
        }
        if (this.View.ItemType == UberstrikeItemType.QuickUse)
        {
            QuickItem component = this.Prefab.GetComponent <QuickItem>();
            if (component != null && component.Sfx)
            {
                Singleton <QuickItemSfxController> .Instance.RegisterQuickItemEffect(component.Logic, component.Sfx);
            }
        }
        GameObject gameObject = null;

        if (this.Prefab != null)
        {
            if (this.View.ItemClass == UberstrikeItemClass.GearHolo)
            {
                HoloGearItem component2 = this.Prefab.GetComponent <HoloGearItem>();
                if (component2 && component2.Configuration.Avatar)
                {
                    gameObject = (UnityEngine.Object.Instantiate(component2.Configuration.Avatar.gameObject) as GameObject);
                }
            }
            else
            {
                gameObject = (UnityEngine.Object.Instantiate(this.Prefab, position, rotation) as GameObject);
            }
            if (gameObject && this.View.ItemType == UberstrikeItemType.Weapon)
            {
                WeaponItem component3 = gameObject.GetComponent <WeaponItem>();
                if (component3)
                {
                    ItemConfigurationUtil.CopyCustomProperties(this.View, component3.Configuration);
                    if (this.View.ItemProperties.ContainsKey(ItemPropertyType.CritDamageBonus))
                    {
                        component3.Configuration.CriticalStrikeBonus = this.View.ItemProperties[ItemPropertyType.CritDamageBonus];
                    }
                    else
                    {
                        component3.Configuration.CriticalStrikeBonus = 0;
                    }
                }
            }
        }
        else
        {
            Debug.LogError("Trying to create item prefab, but it was null. Item Name:" + this.View.Name);
        }
        this.IsLoaded = true;
        return(gameObject);
    }