Ejemplo n.º 1
0
    public void SetPlayerLoadOuts()
    {
        JobOutfit standardOutfit = GameManager.Instance.StandardOutfit.GetComponent <JobOutfit>();
        JobOutfit jobOutfit      = GameManager.Instance.GetOccupationOutfit(playerScript.mind.jobType);

        //Create collection of all the new items to add to the gear slots
        Dictionary <EquipSlot, ClothOrPrefab> gear = new Dictionary <EquipSlot, ClothOrPrefab>();

        gear.Add(EquipSlot.uniform, standardOutfit.uniform);
        gear.Add(EquipSlot.feet, standardOutfit.shoes);
        gear.Add(EquipSlot.eyes, standardOutfit.glasses);
        gear.Add(EquipSlot.hands, standardOutfit.gloves);
        Backpack = standardOutfit.backpack;
        Ears     = standardOutfit.ears;
        gear.Add(EquipSlot.exosuit, standardOutfit.suit);
        gear.Add(EquipSlot.head, standardOutfit.head);
        gear.Add(EquipSlot.mask, standardOutfit.mask);
        gear.Add(EquipSlot.suitStorage, standardOutfit.suit_store);

        AddifPresent(gear, EquipSlot.exosuit, jobOutfit.suit);
        AddifPresent(gear, EquipSlot.head, jobOutfit.head);
        AddifPresent(gear, EquipSlot.uniform, jobOutfit.uniform);
        AddifPresent(gear, EquipSlot.feet, jobOutfit.shoes);
        AddifPresent(gear, EquipSlot.hands, jobOutfit.gloves);
        AddifPresent(gear, EquipSlot.eyes, jobOutfit.glasses);
        AddifPresent(gear, EquipSlot.mask, jobOutfit.mask);

        if (jobOutfit.backpack?.Backpack?.Sprites?.Equipped?.Texture != null || jobOutfit.backpack.Prefab != null)
        {
            Backpack = jobOutfit.backpack;
        }

        if (jobOutfit.ears?.Headset?.Sprites?.Equipped?.Texture != null || jobOutfit.ears.Prefab != null)
        {
            Ears = jobOutfit.ears;
        }

        foreach (KeyValuePair <EquipSlot, ClothOrPrefab> gearItem in gear)
        {
            if (gearItem.Value.Clothing != null)
            {
                if (gearItem.Value.Clothing.PrefabVariant != null)
                {
                    var            obj      = ClothFactory.CreateCloth(gearItem.Value.Clothing, TransformState.HiddenPos, transform.parent, PrefabOverride: gearItem.Value.Clothing.PrefabVariant);     //Where it is made
                    ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                    SetItem(gearItem.Key, itemAtts.gameObject, true);
                }
                else
                {
                    var            obj      = ClothFactory.CreateCloth(gearItem.Value.Clothing, TransformState.HiddenPos, transform.parent);
                    ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                    SetItem(gearItem.Key, itemAtts.gameObject, true);
                }
            }
            else if (gearItem.Value.Prefab != null)
            {
                var            obj      = PoolManager.PoolNetworkInstantiate(gearItem.Value.Prefab, TransformState.HiddenPos, transform.parent);
                ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                SetItem(gearItem.Key, itemAtts.gameObject, true);
            }
        }
        if (Backpack.Backpack != null)
        {
            if (Backpack.Backpack.PrefabVariant != null)
            {
                var            obj      = ClothFactory.CreateBackpackCloth(Backpack.Backpack, TransformState.HiddenPos, transform.parent, PrefabOverride: Backpack.Backpack.PrefabVariant); //Where it is made
                ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                SetItem(EquipSlot.back, itemAtts.gameObject, true);
            }
            else
            {
                var            obj      = ClothFactory.CreateBackpackCloth(Backpack.Backpack, TransformState.HiddenPos, transform.parent);
                ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                SetItem(EquipSlot.back, itemAtts.gameObject, true);
            }
        }
        else if (Backpack.Prefab)
        {
            var            obj      = PoolManager.PoolNetworkInstantiate(Backpack.Prefab, TransformState.HiddenPos, transform.parent);
            ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
            SetItem(EquipSlot.back, itemAtts.gameObject, true);
        }


        if (Ears.Headset != null)
        {
            if (Ears.Headset.PrefabVariant != null)
            {
                var            obj      = ClothFactory.CreateHeadsetCloth(Ears.Headset, TransformState.HiddenPos, transform.parent, PrefabOverride: Ears.Headset.PrefabVariant); //Where it is made
                ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                SetItem(EquipSlot.ear, itemAtts.gameObject, true);
            }
            else
            {
                var            obj      = ClothFactory.CreateHeadsetCloth(Ears.Headset, TransformState.HiddenPos, transform.parent);
                ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
                SetItem(EquipSlot.ear, itemAtts.gameObject, true);
            }
        }
        else if (Ears.Prefab)
        {
            var            obj      = PoolManager.PoolNetworkInstantiate(Backpack.Prefab, TransformState.HiddenPos, transform.parent);
            ItemAttributes itemAtts = obj.GetComponent <ItemAttributes>();
            SetItem(EquipSlot.ear, itemAtts.gameObject, true);
        }
        SpawnID(jobOutfit);
    }