private static void HandleModifyExistingBeauty(GameSession session, PacketReader packet) { byte unk = packet.ReadByte(); bool useVoucher = packet.ReadBool(); long beautyItemUid = packet.ReadLong(); EquipColor equipColor = packet.Read <EquipColor>(); Item beautyItem = session.Player.Inventory.GetEquippedItem(beautyItemUid); if (beautyItem.ItemSlot is ItemSlot.CP) // This should only work with the mirror shop { HatData hatData = packet.Read <HatData>(); beautyItem.HatData = hatData; session.FieldManager.BroadcastPacket(ItemExtraDataPacket.Update(session.Player.FieldPlayer, beautyItem)); return; } BeautyShop beautyShop = DatabaseManager.BeautyShops.FindById(session.Player.ShopId); if (beautyShop is null) { return; } if (!HandleShopPay(session, beautyShop, useVoucher)) { return; } beautyItem.Color = equipColor; ModifyBeauty(session, packet, beautyItem); }
private static void HandleModifyExistingBeauty(GameSession session, PacketReader packet) { byte unk = packet.ReadByte(); bool useVoucher = packet.ReadBool(); long beautyItemUid = packet.ReadLong(); EquipColor equipColor = packet.Read <EquipColor>(); Item beautyItem = session.Player.GetEquippedItem(beautyItemUid); if (beautyItem.ItemSlot == ItemSlot.CP) { HatData hatData = packet.Read <HatData>(); beautyItem.HatData = hatData; session.FieldManager.BroadcastPacket(ItemExtraDataPacket.Update(session.FieldPlayer, beautyItem)); return; } BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(session.Player.ShopId); if (!HandleShopPay(session, beautyShop, useVoucher)) { return; } beautyItem.Color = equipColor; ModifyBeauty(session, packet, beautyItem); }
void Start() { Content.cellSize = new Vector2(UIManager.sizeDelta.x, Content.cellSize.y); GalleryPanel.galleryAR += Instan; OnSearchHat += SearchHat; m_informationPanel = FindObjectOfType <InformationPanel>(); hatData = FindObjectOfType <HatData>(); EventTrigger trigger = m_ScrollRect.gameObject.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.Drag; entry.callback.AddListener((data) => { OnDragDelegate((PointerEventData)data); }); trigger.triggers.Add(entry); m_ListContentHatPanel = new List <GameObject>(); m_ListElementOffsetX = Screen.width; backButton.onClick.AddListener(() => { AppController.OnBackAR(); StartCoroutine(ResetValues()); }); m_HatData = new List <HatDataD>(); HatDataD d1 = new HatDataD(); d1.hatId = "welfleet"; d1.hatName = "Benjamin Paul"; d1.hatBrand = "Fedora"; d1.hatPhoto = hatPhoto; d1.hatColorList = new List <string>(); d1.hatSizeList = new List <string> { "s", "m", "l" }; d1.hatColor = "black"; HatDataD d2 = new HatDataD(); d2.hatId = "county line"; d2.hatName = "County Line"; d2.hatBrand = "Fedora"; d2.hatPhoto = hatPhoto2; d2.hatColorList = new List <string> { "black", "gray" }; d2.hatSizeList = new List <string> { "m", "l" }; d2.hatColor = "black"; m_HatData.Add(d1); m_HatData.Add(d2); // LoadContentGG += GG; }
public static CustomHats.HatExtension getHatExtension(this HatData hat) { CustomHats.HatExtension ret = null; if (CustomHats.TestExt != null && CustomHats.TestExt.condition.Equals(hat.name)) { return(CustomHats.TestExt); } CustomHats.CustomHatRegistry.TryGetValue(hat.name, out ret); return(ret); }
// Make a copy of item public Item(Item other) { Id = other.Id; Name = other.Name; Level = other.Level; Gender = other.Gender; InventoryTab = other.InventoryTab; ItemSlot = other.ItemSlot; GemSlot = other.GemSlot; Rarity = other.Rarity; StackLimit = other.StackLimit; EnableBreak = other.EnableBreak; IsTwoHand = other.IsTwoHand; IsDress = other.IsDress; IsTemplate = other.IsTemplate; IsCustomScore = other.IsCustomScore; PlayCount = other.PlayCount; FileName = other.FileName; Function = other.Function; Uid = other.Uid; Slot = other.Slot; Amount = other.Amount; CreationTime = other.CreationTime; ExpiryTime = other.ExpiryTime; TimesAttributesChanged = other.TimesAttributesChanged; IsLocked = other.IsLocked; UnlockTime = other.UnlockTime; RemainingGlamorForges = other.RemainingGlamorForges; GachaDismantleId = other.GachaDismantleId; Enchants = other.Enchants; EnchantExp = other.EnchantExp; RepackageCount = other.RepackageCount; Charges = other.Charges; TransferFlag = other.TransferFlag; RemainingTrades = other.RemainingTrades; PairedCharacterId = other.PairedCharacterId; PairedCharacterName = other.PairedCharacterName; PetSkinBadgeId = other.PetSkinBadgeId; RecommendJobs = other.RecommendJobs; OwnerCharacterId = other.OwnerCharacterId; OwnerCharacterName = other.OwnerCharacterName; InventoryId = other.InventoryId; BankInventoryId = other.BankInventoryId; BlackMarketCategory = other.BlackMarketCategory; Category = other.Category; HomeId = other.HomeId; Color = other.Color; HairData = other.HairData; HatData = other.HatData; Score = new(); Stats = new(other.Stats); UGC = other.UGC; }
public static float createHatPackage(List <System.Tuple <HatData, HatExtension> > hats, string packageName, float YStart, HatsTab __instance) { float offset = YStart; if (textTemplate != null) { TMPro.TMP_Text title = UnityEngine.Object.Instantiate <TMPro.TMP_Text>(textTemplate, __instance.scroller.Inner); title.transform.parent = __instance.scroller.Inner; title.transform.localPosition = new Vector3(headerX, YStart, inventoryZ); title.alignment = TMPro.TextAlignmentOptions.Center; title.fontSize *= 1.25f; title.fontWeight = TMPro.FontWeight.Thin; title.enableAutoSizing = false; title.autoSizeTextContainer = true; title.text = ModTranslation.getString(packageName); offset -= headerSize * __instance.YOffset; hatsTabCustomTexts.Add(title); } var numHats = hats.Count; for (int i = 0; i < hats.Count; i++) { HatData hat = hats[i].Item1; HatExtension ext = hats[i].Item2; float xpos = __instance.XRange.Lerp((i % __instance.NumPerRow) / (__instance.NumPerRow - 1f)); float ypos = offset - (i / __instance.NumPerRow) * __instance.YOffset; ColorChip colorChip = UnityEngine.Object.Instantiate <ColorChip>(__instance.ColorTabPrefab, __instance.scroller.Inner); int color = __instance.HasLocalPlayer() ? PlayerControl.LocalPlayer.Data.DefaultOutfit.ColorId : SaveManager.BodyColor; colorChip.transform.localPosition = new Vector3(xpos, ypos, inventoryZ); if (ActiveInputManager.currentControlType == ActiveInputManager.InputType.Keyboard) { colorChip.Button.OnMouseOver.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(hat))); colorChip.Button.OnMouseOut.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(DestroyableSingleton <HatManager> .Instance.GetHatById(SaveManager.LastHat)))); colorChip.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() => __instance.ClickEquip())); } else { colorChip.Button.OnClick.AddListener((UnityEngine.Events.UnityAction)(() => __instance.SelectHat(hat))); } colorChip.Inner.SetHat(hat, color); colorChip.Inner.transform.localPosition = hat.ChipOffset; colorChip.Tag = hat; colorChip.Button.ClickMask = __instance.scroller.Hitbox; __instance.ColorChips.Add(colorChip); } return(offset - ((numHats - 1) / __instance.NumPerRow) * __instance.YOffset - headerSize); }
private void DoHatEditorConnections(Node editor, TreeItem entry) { activeHat = hats[entry]; DoEditorConnections(editor, activeHat); var intEdit = editor.GetNode <SpinBox>("Texture/SubImageEditor/Values/SubRectWidth/SpinBox"); intEdit.Value = 20; intEdit.Editable = false; intEdit = editor.GetNode <SpinBox>("Texture/SubImageEditor/Values/SubRectHeight/SpinBox"); intEdit.Value = 80; intEdit.Editable = false; }
private static HatBehaviour CreateHat(HatData hat, int id) { System.Console.WriteLine($"Creating Hat {hat.name}"); var sprite = ProxyOfUs.CreateSprite($"ProxyOfUs.Resources.Hats.hat_{hat.name}.png", true); var newHat = ScriptableObject.CreateInstance <HatBehaviour>(); newHat.MainImage = sprite; newHat.ProductId = hat.name; newHat.Order = 99 + id; newHat.InFront = true; newHat.NoBounce = !hat.bounce; newHat.ChipOffset = hat.offset; return(newHat); }
private static void HandleDyeItem(GameSession session, PacketReader packet) { BeautyMetadata beautyShop = BeautyMetadataStorage.GetShopById(506); byte itemCount = packet.ReadByte(); short[] quantity = new short[itemCount]; bool[] useVoucher = new bool[itemCount]; byte[] unk1 = new byte[itemCount]; long[] unk2 = new long[itemCount]; int[] unk3 = new int[itemCount]; long[] itemUid = new long[itemCount]; int[] itemId = new int[itemCount]; EquipColor[] equipColor = new EquipColor[itemCount]; HatData[] hatData = new HatData[itemCount]; for (int i = 0; i < itemCount; i++) { quantity[i] = packet.ReadShort(); // should always be one useVoucher[i] = packet.ReadBool(); unk1[i] = packet.ReadByte(); // just 0 unk2[i] = packet.ReadLong(); // just 0 unk3[i] = packet.ReadInt(); // also 0 itemUid[i] = packet.ReadLong(); itemId[i] = packet.ReadInt(); equipColor[i] = packet.Read <EquipColor>(); Item item = session.Player.GetEquippedItem(itemUid[i]); if (item == null) { return; } if (!HandleShopPay(session, beautyShop, useVoucher[i])) { return; } if (item.ItemSlot == ItemSlot.CP) { hatData[i] = packet.Read <HatData>(); item.HatData = hatData[i]; } item.Color = equipColor[i]; Console.WriteLine(item.Color); session.FieldManager.BroadcastPacket(ItemExtraDataPacket.Update(session.FieldPlayer, item)); } }
// Make a copy of item public Item(Item other) { Id = other.Id; InventoryTab = other.InventoryTab; ItemSlot = other.ItemSlot; GemSlot = other.GemSlot; Rarity = other.Rarity; StackLimit = other.StackLimit; EnableBreak = other.EnableBreak; IsTwoHand = other.IsTwoHand; IsDress = other.IsDress; IsTemplate = other.IsTemplate; IsCustomScore = other.IsCustomScore; PlayCount = other.PlayCount; FileName = other.FileName; Content = other.Content; Function = other.Function; AdBalloon = other.AdBalloon; Uid = other.Uid; Slot = other.Slot; Amount = other.Amount; CreationTime = other.CreationTime; ExpiryTime = other.ExpiryTime; TimesAttributesChanged = other.TimesAttributesChanged; IsLocked = other.IsLocked; UnlockTime = other.UnlockTime; RemainingGlamorForges = other.RemainingGlamorForges; GachaDismantleId = other.GachaDismantleId; Enchants = other.Enchants; EnchantExp = other.EnchantExp; CanRepackage = other.CanRepackage; Charges = other.Charges; TransferFlag = other.TransferFlag; RemainingTrades = other.RemainingTrades; PairedCharacterId = other.PairedCharacterId; PairedCharacterName = other.PairedCharacterName; PetSkinBadgeId = other.PetSkinBadgeId; Owner = other.Owner; Color = other.Color; HairData = other.HairData; HatData = other.HatData; Score = new MusicScore(); Stats = new ItemStats(other.Stats); }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>() }; // TODO: Clean up this chunk // I copy/pasted it from the unofficial update decompiled string str = ""; string[] array = new string[] { "spring", "summer", "fall", "winter" }.Except(crop.Seasons).ToArray <string>(); for (int i = 0; i < array.Length; i++) { string season = array[i]; str += string.Format("/z {0}", season); } string strtrimstart = str.TrimStart(new char[] { '/' }); if (crop.SeedPurchaseRequirements != null && crop.SeedPurchaseRequirements.Count > 0) { for (int index = 0; index < crop.SeedPurchaseRequirements.Count; index++) { if (SeasonLimiter.IsMatch(crop.SeedPurchaseRequirements[index])) { crop.SeedPurchaseRequirements[index] = strtrimstart; Log.warn(string.Format(" Faulty season requirements for {0}!\n", crop.SeedName) + string.Format(" Fixed season requirements: {0}", crop.SeedPurchaseRequirements[index])); } } if (!crop.SeedPurchaseRequirements.Contains(str.TrimStart(new char[] { '/' }))) { Log.trace(string.Format(" Adding season requirements for {0}:\n", crop.SeedName) + string.Format(" New season requirements: {0}", strtrimstart)); crop.seed.PurchaseRequirements.Add(strtrimstart); } } else { Log.trace(string.Format(" Adding season requirements for {0}:\n", crop.SeedName) + string.Format(" New season requirements: {0}", strtrimstart)); crop.seed.PurchaseRequirements.Add(strtrimstart); } objects.Add(crop.seed); } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice }; objects.Add(tree.sapling); } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); } } // load objects DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); } } }
private static HatData CreateHatData(CustomHat ch, bool fromDisk = false, bool testOnly = false) { if (hatShader == null && DestroyableSingleton <HatManager> .InstanceExists) { hatShader = new Material(Shader.Find("Unlit/PlayerShader")); } HatData hat = new HatData(); hat.hatViewData.viewData = new HatViewData(); hat.hatViewData.viewData.MainImage = CreateHatSprite(ch.resource, fromDisk); if (ch.backresource != null) { hat.hatViewData.viewData.BackImage = CreateHatSprite(ch.backresource, fromDisk); ch.behind = true; // Required to view backresource } if (ch.climbresource != null) { hat.hatViewData.viewData.ClimbImage = CreateHatSprite(ch.climbresource, fromDisk); } hat.name = ch.name + "\nby " + ch.author; hat.displayOrder = 99; hat.ProductId = "hat_" + ch.name.Replace(' ', '_'); hat.InFront = !ch.behind; hat.NoBounce = !ch.bounce; hat.ChipOffset = new Vector2(0f, 0.2f); hat.Free = true; hat.NotInStore = true; if (ch.adaptive && hatShader != null) { hat.hatViewData.viewData.AltShader = hatShader; } HatExtension extend = new HatExtension(); extend.author = ch.author != null ? ch.author : "Unknown"; extend.package = ch.package != null ? ch.package : "Misc."; extend.condition = ch.condition != null ? ch.condition : "none"; if (ch.flipresource != null) { extend.FlipImage = CreateHatSprite(ch.flipresource, fromDisk); } if (ch.backflipresource != null) { extend.BackFlipImage = CreateHatSprite(ch.backflipresource, fromDisk); } if (testOnly) { TestExt = extend; TestExt.condition = hat.name; } else { CustomHatRegistry.Add(hat.name, extend); } return(hat); }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } // Duplicate check if (dupObjects.ContainsKey(obj.Name)) { Log.error($"Duplicate object: {obj.Name} just added by {contentPack.Manifest.Name}, already added by {dupObjects[obj.Name].Manifest.Name}!"); } else { dupObjects[obj.Name] = contentPack; } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>(), NameLocalization = crop.SeedNameLocalization, DescriptionLocalization = crop.SeedDescriptionLocalization }; // TODO: Clean up this chunk // I copy/pasted it from the unofficial update decompiled string str = ""; string[] array = new[] { "spring", "summer", "fall", "winter" } .Except(crop.Seasons) .ToArray(); foreach (var season in array) { str += $"/z {season}"; } string strtrimstart = str.TrimStart(new char[] { '/' }); if (crop.SeedPurchaseRequirements != null && crop.SeedPurchaseRequirements.Count > 0) { for (int index = 0; index < crop.SeedPurchaseRequirements.Count; index++) { if (SeasonLimiter.IsMatch(crop.SeedPurchaseRequirements[index])) { crop.SeedPurchaseRequirements[index] = strtrimstart; Log.warn($" Faulty season requirements for {crop.SeedName}!\n Fixed season requirements: {crop.SeedPurchaseRequirements[index]}"); } } if (!crop.SeedPurchaseRequirements.Contains(str.TrimStart('/'))) { Log.trace($" Adding season requirements for {crop.SeedName}:\n New season requirements: {strtrimstart}"); crop.seed.PurchaseRequirements.Add(strtrimstart); } } else { Log.trace($" Adding season requirements for {crop.SeedName}:\n New season requirements: {strtrimstart}"); crop.seed.PurchaseRequirements.Add(strtrimstart); } objects.Add(crop.seed); // Duplicate check if (dupCrops.ContainsKey(crop.Name)) { Log.error($"Duplicate crop: {crop.Name} just added by {contentPack.Manifest.Name}, already added by {dupCrops[crop.Name].Manifest.Name}!"); } else { dupCrops[crop.Name] = contentPack; } } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice, NameLocalization = tree.SaplingNameLocalization, DescriptionLocalization = tree.SaplingDescriptionLocalization }; objects.Add(tree.sapling); // Duplicate check if (dupFruitTrees.ContainsKey(tree.Name)) { Log.error($"Duplicate fruit tree: {tree.Name} just added by {contentPack.Manifest.Name}, already added by {dupFruitTrees[tree.Name].Manifest.Name}!"); } else { dupFruitTrees[tree.Name] = contentPack; } } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); // Duplicate check if (dupBigCraftables.ContainsKey(craftable.Name)) { Log.error($"Duplicate big craftable: {craftable.Name} just added by {contentPack.Manifest.Name}, already added by {dupBigCraftables[craftable.Name].Manifest.Name}!"); } else { dupBigCraftables[craftable.Name] = contentPack; } } } // load hats DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); // Duplicate check if (dupHats.ContainsKey(hat.Name)) { Log.error($"Duplicate hat: {hat.Name} just added by {contentPack.Manifest.Name}, already added by {dupHats[hat.Name].Manifest.Name}!"); } else { dupBigCraftables[hat.Name] = contentPack; } } } // Load weapons // load objects DirectoryInfo weaponsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Weapons")); if (weaponsDir.Exists) { foreach (DirectoryInfo dir in weaponsDir.EnumerateDirectories()) { string relativePath = $"Weapons/{dir.Name}"; // load data WeaponData weapon = contentPack.ReadJsonFile <WeaponData>($"{relativePath}/weapon.json"); if (weapon == null) { continue; } // save object weapon.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/weapon.png"); weapons.Add(weapon); // Duplicate check if (dupWeapons.ContainsKey(weapon.Name)) { Log.error($"Duplicate weapon: {weapon.Name} just added by {contentPack.Manifest.Name}, already added by {dupWeapons[weapon.Name].Manifest.Name}!"); } else { dupBigCraftables[weapon.Name] = contentPack; } } } }
private void loadData(IContentPack contentPack) { Log.info($"\t{contentPack.Manifest.Name} {contentPack.Manifest.Version} by {contentPack.Manifest.Author} - {contentPack.Manifest.Description}"); // load objects DirectoryInfo objectsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Objects")); if (objectsDir.Exists) { foreach (DirectoryInfo dir in objectsDir.EnumerateDirectories()) { string relativePath = $"Objects/{dir.Name}"; // load data ObjectData obj = contentPack.ReadJsonFile <ObjectData>($"{relativePath}/object.json"); if (obj == null) { continue; } // save object obj.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/object.png"); if (obj.IsColored) { obj.textureColor = contentPack.LoadAsset <Texture2D>($"{relativePath}/color.png"); } this.objects.Add(obj); // save ring if (obj.Category == ObjectData.Category_.Ring) { this.myRings.Add(obj); } } } // load crops DirectoryInfo cropsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Crops")); if (cropsDir.Exists) { foreach (DirectoryInfo dir in cropsDir.EnumerateDirectories()) { string relativePath = $"Crops/{dir.Name}"; // load data CropData crop = contentPack.ReadJsonFile <CropData>($"{relativePath}/crop.json"); if (crop == null) { continue; } // save crop crop.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/crop.png"); crops.Add(crop); // save seeds crop.seed = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/seeds.png"), Name = crop.SeedName, Description = crop.SeedDescription, Category = ObjectData.Category_.Seeds, Price = crop.SeedPurchasePrice, CanPurchase = true, PurchaseFrom = crop.SeedPurchaseFrom, PurchasePrice = crop.SeedPurchasePrice, PurchaseRequirements = crop.SeedPurchaseRequirements ?? new List <string>() }; string[] excludeSeasons = new[] { "spring", "summer", "fall", "winter" }.Except(crop.Seasons).ToArray(); crop.seed.PurchaseRequirements.Add($"z {string.Join(" ", excludeSeasons)}"); objects.Add(crop.seed); } } // load fruit trees DirectoryInfo fruitTreesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FruitTrees")); if (fruitTreesDir.Exists) { foreach (DirectoryInfo dir in fruitTreesDir.EnumerateDirectories()) { string relativePath = $"FruitTrees/{dir.Name}"; // load data FruitTreeData tree = contentPack.ReadJsonFile <FruitTreeData>($"{relativePath}/tree.json"); if (tree == null) { continue; } // save fruit tree tree.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/tree.png"); fruitTrees.Add(tree); // save seed tree.sapling = new ObjectData { texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/sapling.png"), Name = tree.SaplingName, Description = tree.SaplingDescription, Category = ObjectData.Category_.Seeds, Price = tree.SaplingPurchasePrice, CanPurchase = true, PurchaseRequirements = tree.SaplingPurchaseRequirements, PurchaseFrom = tree.SaplingPurchaseFrom, PurchasePrice = tree.SaplingPurchasePrice }; objects.Add(tree.sapling); } } // load big craftables DirectoryInfo bigCraftablesDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "BigCraftables")); if (bigCraftablesDir.Exists) { foreach (DirectoryInfo dir in bigCraftablesDir.EnumerateDirectories()) { string relativePath = $"BigCraftables/{dir.Name}"; // load data BigCraftableData craftable = contentPack.ReadJsonFile <BigCraftableData>($"{relativePath}/big-craftable.json"); if (craftable == null) { continue; } // save craftable craftable.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/big-craftable.png"); bigCraftables.Add(craftable); } } // load objects DirectoryInfo hatsDir = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hats")); if (hatsDir.Exists) { foreach (DirectoryInfo dir in hatsDir.EnumerateDirectories()) { string relativePath = $"Hats/{dir.Name}"; // load data HatData hat = contentPack.ReadJsonFile <HatData>($"{relativePath}/hat.json"); if (hat == null) { continue; } // save object hat.texture = contentPack.LoadAsset <Texture2D>($"{relativePath}/hat.png"); hats.Add(hat); } } }