public void RefreshVisibleClothing() { bool flag = !LocalPlayer.Inventory.IsSlotEmpty(Item.EquipmentSlot.FullBody); this._wornClothingItemsFinal.Clear(); for (int i = 0; i < this._wornClothingItems.Count; i++) { if (flag) { ClothingItem clothingItem = ClothingItemDatabase.ClothingItemById(this._wornClothingItems[i]); if (clothingItem._displayType == ClothingItem.DisplayTypes.Hat) { this._wornClothingItemsFinal.Add(this._wornClothingItems[i]); } } else { this._wornClothingItemsFinal.Add(this._wornClothingItems[i]); } } if (flag) { this._wornClothingItemsFinal.Add(-1); } this._playerVariation.SetVariation(LocalPlayer.Stats.PlayerVariation, LocalPlayer.Stats.PlayerVariationHair, this._wornClothingItemsFinal); this._playerVariation.UpdateSkinVariation(LocalPlayer.Stats.IsBloody, LocalPlayer.Stats.IsMuddy, LocalPlayer.Stats.IsRed, LocalPlayer.Stats.IsCold); this.ToggleClothingInventoryViews(); this.MpSync(); }
private void OnDeserialized() { this.CheckInit(); if (this._availableClothingOutfits.Count > this._availableClothingOutfitCount) { this._availableClothingOutfits.RemoveRange(this._availableClothingOutfitCount, this._availableClothingOutfits.Count - this._availableClothingOutfitCount); } if (this._wornClothingItems.Count > this._wornClothingItemsCount) { this._wornClothingItems.RemoveRange(this._wornClothingItemsCount, this._wornClothingItems.Count - this._wornClothingItemsCount); } if (this._availableClothingOutfits.Count == 0 && this._wornClothingItems.Count == 0) { if (!BoltNetwork.isRunning) { this.AddClothingOutfit(new List <int> { 4, 24 }, true); } else { this.AddClothingOutfit(ClothingItemDatabase.GetRandomOutfit(LocalPlayer.Stats.PlayerVariation == 0), true); } } this.RefreshVisibleClothing(); }
private void Update() { if (TheForest.Utils.Input.GetButtonAfterDelay("Take", 0.5f, false)) { this.RefreshBoltState(); List <int> list = (from id in this._presetOutfitItemIds where id > 0 select id).ToList <int>(); List <int> ids = (list != null && list.Count != 0) ? list : ClothingItemDatabase.GetRandomOutfit(LocalPlayer.Stats.PlayerVariation == 0); if (LocalPlayer.Clothing.AddClothingOutfit(ids, true)) { Scene.HudGui.ToggleGotClothingOutfitHud(); LocalPlayer.Clothing.RefreshVisibleClothing(); LocalPlayer.Stats.CheckArmsStart(); if (BoltNetwork.isRunning && !base.entity.isOwner && !this._clientOnlyTake) { this.SendBoltTaken(); } else { this.DoDestroy(); } } else { Scene.HudGui.ToggleFullClothingOutfitCapacityHud(); } } }
private bool IsUnique(List <int> availableClothingOutfit) { foreach (int id in availableClothingOutfit) { ClothingItem clothingItem = ClothingItemDatabase.ClothingItemById(id); if (clothingItem != null) { if ((float)clothingItem._baseRollChance <= 0f) { return(true); } } } return(false); }
public static bool CombineClothingItemWithOutfit(List <int> outfitItemIds, ClothingItem addingCloth) { for (int i = outfitItemIds.Count - 1; i >= 0; i--) { ClothingItem clothingItem = ClothingItemDatabase.ClothingItemById(outfitItemIds[i]); if (clothingItem == null) { Debug.LogError("Null worn cloth id =" + outfitItemIds[i]); } else if (!addingCloth.CompatibleWith(clothingItem._slotType) && (addingCloth._slotType != ClothingItem.SlotTypes.Exclusive || (clothingItem._slotType != ClothingItem.SlotTypes.Bottom && clothingItem._slotType != ClothingItem.SlotTypes.Top))) { return(false); } } outfitItemIds.Add(addingCloth._id); return(true); }
public static List <int> GetRandomOutfit(bool allowBeanie) { List <int> list = new List <int>(); Dictionary <ClothingItem, int> ponderatedClothingByTypeChance = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.TShirt, (ClothingItem.DisplayTypes) 0); Dictionary <ClothingItem, int> ponderatedClothingByTypeChance2 = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.Pants, ClothingItem.DisplayTypes.FullBody); Dictionary <ClothingItem, int> ponderatedClothingByTypeChance3 = ClothingItemDatabase.GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes.TopPartial_Hands | ClothingItem.DisplayTypes.TopPartial_Arms | ClothingItem.DisplayTypes.TopFull_Hands | ClothingItem.DisplayTypes.TopFull_Arms, (ClothingItem.DisplayTypes) 0); int max = ponderatedClothingByTypeChance.Sum((KeyValuePair <ClothingItem, int> s) => s.Value); int max2 = ponderatedClothingByTypeChance2.Sum((KeyValuePair <ClothingItem, int> s) => s.Value); int max3 = (int)((float)ponderatedClothingByTypeChance3.Sum((KeyValuePair <ClothingItem, int> s) => s.Value) * 1.5f); int tshirtRand = UnityEngine.Random.Range(0, max); int pantsRand = UnityEngine.Random.Range(0, max2); int topRand = UnityEngine.Random.Range(0, max3); KeyValuePair <ClothingItem, int> keyValuePair = ponderatedClothingByTypeChance.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c) { tshirtRand -= c.Value; return(tshirtRand > 0); }).FirstOrDefault <KeyValuePair <ClothingItem, int> >(); KeyValuePair <ClothingItem, int> keyValuePair2 = ponderatedClothingByTypeChance2.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c) { pantsRand -= c.Value; return(pantsRand > 0); }).FirstOrDefault <KeyValuePair <ClothingItem, int> >(); KeyValuePair <ClothingItem, int> keyValuePair3 = ponderatedClothingByTypeChance3.SkipWhile(delegate(KeyValuePair <ClothingItem, int> c) { topRand -= c.Value; return(topRand > 0); }).FirstOrDefault <KeyValuePair <ClothingItem, int> >(); ClothingItem key = keyValuePair.Key; ClothingItem key2 = keyValuePair2.Key; ClothingItem key3 = keyValuePair3.Key; if (key3 != null && (key3._id != 9 || (AccountInfo.StoryCompleted && LocalPlayer.Clothing.AmountOf(9) == 0))) { if (key3._displayType != ClothingItem.DisplayTypes.FullBody) { allowBeanie = false; } list.Add(key3._id); } if (key3 == null || key3._displayType != ClothingItem.DisplayTypes.FullBody) { if (key != null) { ClothingItemDatabase.CombineClothingItemWithOutfit(list, key); } if (key2 != null) { ClothingItemDatabase.CombineClothingItemWithOutfit(list, key2); } } if (allowBeanie) { IEnumerable <ClothingItem> source = ClothingItemDatabase.ItemsByType(ClothingItem.DisplayTypes.Hat); int num = ponderatedClothingByTypeChance.Count <KeyValuePair <ClothingItem, int> >(); int hatRand = UnityEngine.Random.Range(0, num * 3); if (hatRand < num) { ClothingItem clothingItem = source.Where((ClothingItem ci, int i) => i == hatRand).FirstOrDefault <ClothingItem>(); if (clothingItem != null) { ClothingItemDatabase.CombineClothingItemWithOutfit(list, clothingItem); } } } return(list); }
private static Dictionary <ClothingItem, int> GetPonderatedClothingByTypeChance(ClothingItem.DisplayTypes typeMask, ClothingItem.DisplayTypes ignoreMask = (ClothingItem.DisplayTypes) 0) { return((from ci in ClothingItemDatabase.ItemsByType(typeMask) where ci._displayType != ignoreMask select ci).ToDictionary((ClothingItem c) => c, (ClothingItem c) => Mathf.Max(c._baseRollChance - LocalPlayer.Clothing.AmountOf(c._id) * c._ownedRollChanceReduction, 0))); }