//public static void Orig_DelayedRefresh(SplitScreenManager self, DictionaryExt<int, SplitPlayer> localUIs) // { // for (int i = 0; i < localUIs.Count; i++) // { // SplitPlayer splitPlayer = localUIs.Values[i]; // float foV = 0f; // Vector3 default_OFFSET = CharacterCamera.DEFAULT_OFFSET; // Vector2 zero = Vector2.zero; // Vector2 zero2 = Vector2.zero; // Rect splitRect = new Rect(0f, 0f, 0f, 0f); // RawImage rawImage = self.RenderInImage ? GameDisplayInUI.Instance.Screens[i] : null; // if (localUIs.Count == 1) // { // splitRect.position = Vector2.zero; // splitRect.size = Vector2.one; // foV = OptionManager.Instance.GetFoVSolo(i); // if (self.RenderInImage) // { // rawImage.rectTransform.localScale = Vector3.one; // GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(false); // } // GameDisplayInUI.Instance.SetMultiDisplayActive(false); // } // else if (localUIs.Count == 2) // { // if (self.CurrentSplitType == SplitScreenManager.SplitType.Horizontal) // { // if (self.RenderInImage) // { // splitRect.position = ((i == 0) ? new Vector2(0.5f, 0.5f) : Vector2.zero); // splitRect.size = new Vector2(1f, 0.5f); // } // else // { // splitRect.position = new Vector2(0f, 0.5f * (float)((i == 0) ? 1 : -1)); // splitRect.size = Vector2.one; // } // foV = OptionManager.Instance.GetFoVSplit(i); // default_OFFSET.z = -5f; // default_OFFSET.y = 0.6f; // zero2.y = -0.5f; // zero.y = (float)((i % 2 == 1) ? 1 : -1) * 0.5f; // GameDisplayInUI.Instance.SetMultiDisplayActive(false); // if (self.RenderInImage) // { // rawImage.rectTransform.localScale = new Vector3(1f, 0.5f, 1f); // } // } // else if (self.CurrentSplitType == SplitScreenManager.SplitType.Vertical) // { // if (self.RenderInImage) // { // splitRect.position = ((i == 0) ? Vector2.zero : new Vector2(0.5f, 0f)); // splitRect.size = new Vector2(0.5f, 1f); // } // else // { // splitRect.position = new Vector2(0.5f * (float)((i == 0) ? -1 : 1), 0f); // splitRect.size = Vector2.one; // } // foV = self.VSplitFoV; // default_OFFSET.z = -2.5f; // zero2.x = -0.5f; // zero.x = (float)((i % 2 == 1) ? 1 : -1) * 0.5f; // } // else if (self.CurrentSplitType == SplitScreenManager.SplitType.MultiDisplay) // { // splitRect.position = Vector2.zero; // splitRect.size = Vector2.one; // foV = OptionManager.Instance.GetFoVSolo(i); // if (self.RenderInImage) // { // rawImage.rectTransform.localScale = Vector3.one; // } // GameDisplayInUI.Instance.SetMultiDisplayActive(true); // } // if (self.RenderInImage) // { // GameDisplayInUI.Instance.Screens[1].gameObject.SetActive(true); // } // } // else // { // splitRect.size = new Vector2(0.5f, 0.5f); // Vector2 zero3 = Vector2.zero; // zero3.x = ((i == 0 || i == 2) ? 0f : 0.5f); // zero3.y = ((i < 2) ? 0.5f : 0f); // splitRect.position = zero3; // zero2.y = -0.5f; // zero.y = (float)((i % 2 == 1) ? 1 : -1) * 0.5f; // zero2.x = -0.5f; // zero.x = (float)((i % 2 == 1) ? 1 : -1) * 0.5f; // } // CameraSettings settings; // settings.FoV = foV; // settings.SplitRect = splitRect; // settings.Offset = default_OFFSET; // settings.CameraDepth = 2 * i; // settings.Image = rawImage; // splitPlayer.RefreshSplitScreen(zero, zero2, settings); // } //} public static void RefreshHorizontal(SplitScreenManager self) { if ((bool)CONFIG.GetValue(Settings.moveGlobalUiToPlayer1.ToString())) { var zero = Vector2.zero; var zero2 = Vector2.zero; if (self.LocalPlayers.Count == 2) { zero2.y = -0.5f; zero.y = -0.5f; } var vector = Vector2.Scale(zero2, MenuManager.Instance.ScreenSize); var anchoredPosition = Vector2.Scale(zero, vector); if (At.GetField(MenuManager.Instance, "m_masterLoading") is LoadingFade loadingFade) { if (loadingFade.GetComponentInChildren <RectTransform>() is RectTransform loadingRect) { loadingRect.sizeDelta = vector; loadingRect.anchoredPosition = anchoredPosition; } } if (At.GetField(MenuManager.Instance, "m_prologueScreen") is ProloguePanel prologuePanel) { var rectTransform = prologuePanel.RectTransform; rectTransform.sizeDelta = vector; rectTransform.anchoredPosition = anchoredPosition; } } }
public void Serialize(TrapEffectRecipe recipe, DeployableTrap trap) { var items = (Item[])At.GetField(recipe, "m_compatibleItems"); var tags = (TagSourceSelector[])At.GetField(recipe, "m_compatibleTags"); trap.GetCompatibleFilters(); var compatibleTags = ((List <Tag>[])At.GetField <DeployableTrap>("COMPATIBLE_TAGS"))[(int)trap.CurrentTrapType]; if (items != null) { foreach (var item in items) { switch (trap.CurrentTrapType) { case DeployableTrap.TrapType.PressurePlateTrap: if (!item.HasTag(TagSourceManager.PlateTrapComponent) && !HasAnyTag(item, compatibleTags)) { continue; } break; case DeployableTrap.TrapType.TripWireTrap: if (!item.HasTag(TagSourceManager.TripWireTrapComponent) && !HasAnyTag(item, compatibleTags)) { continue; } break; } this.CompatibleItemIDs.Add(item.Name); } } if (tags != null) { foreach (var tag in tags) { this.CompatibleItemTags.Add(tag.Tag.TagName); } } if (recipe.TrapEffectsPrefab) { this.StandardEffects = new List <DM_Effect>(); foreach (var effect in recipe.TrapEffectsPrefab.GetComponents <Effect>()) { this.StandardEffects.Add(DM_Effect.ParseEffect(effect)); } } if (recipe.HiddenTrapEffectsPrefab) { this.HiddenEffects = new List <DM_Effect>(); foreach (var effect in recipe.HiddenTrapEffectsPrefab.GetComponents <Effect>()) { this.HiddenEffects.Add(DM_Effect.ParseEffect(effect)); } } }
// ~~~~~~~~~ Core internal ~~~~~~~~~ internal static void OnSaveInstanceSave(SaveInstance __instance) { try { if (__instance.CharSave == null || string.IsNullOrEmpty(__instance.CharSave.CharacterUID)) { return; } var charUID = __instance.CharSave.CharacterUID; bool isHost = !PhotonNetwork.isNonMasterClientInRoom && !(bool)At.GetField(NetworkLevelLoader.Instance, "m_saveOnHostLost") && CharacterManager.Instance?.GetWorldHostCharacter()?.UID == charUID; // Save internal stuff for the host if (isHost) { SLCharacterSaveManager.SaveCharacters(); SLItemSpawnSaveManager.SaveItemSpawns(); } // Save custom extensions from other mods PlayerSaveExtension.SaveAllExtensions(CharacterManager.Instance.GetCharacter(charUID), isHost); } catch (Exception ex) { SL.LogWarning("Exception on SaveInstance.Save!"); SL.LogInnerException(ex); } }
public static void Prefix(Building __instance) { if (!StoreManager.Instance.IsDlcInstalled(OTWStoreAPI.DLCs.DLC2) || !BuildingHelperMod.Instance.settings.AutoFinishBuildings || PhotonNetwork.isNonMasterClientInRoom) { return; } int sanity = 5; while (sanity >= 0 && __instance.CurrentPhase.ConstructionType == Building.ConstructionPhase.Type.WIP) { int cur = (int)At.GetField(__instance, "m_currentBasicPhaseIndex"); if (cur < 0) { cur = 0; } else { cur++; } At.SetField(__instance, "m_currentBasicPhaseIndex", cur); sanity--; } if (sanity < 0) { SL.LogWarning("Did more than 6 loops trying to auto-finish building, something went wrong!"); } At.SetField(__instance, "m_remainingConstructionTime", 0f); }
public static DM_LootContainer ParseLootContainer(TreasureChest loot) { var lootHolder = new DM_LootContainer { Name = loot.Name?.Trim(), ItemID = loot.ItemID, UID = loot.UID }; if (lootHolder.Name == "Pocket") { lootHolder.Name = "Corpse"; } if (At.GetField(loot as SelfFilledItemContainer, "m_drops") is List <Dropable> droppers) { foreach (Dropable dropper in droppers) { var dropableHolder = DM_DropTable.ParseDropable(dropper, null, lootHolder.Name); lootHolder.DropTables.Add(dropableHolder.Name); } } string dir = Serializer.Folders.Scenes + "/" + SceneManager.Instance.GetCurrentRegion() + "/" + SceneManager.Instance.GetCurrentLocation(loot.transform.position); string saveName = lootHolder.Name + "_" + lootHolder.UID; Serializer.SaveToXml(dir + "/LootContainers", saveName, lootHolder); return(lootHolder); }
public override void Update() { // update position var character = CharacterManager.Instance.GetFirstLocalCharacter(); if (character) { m_positionInput.text = character.transform.position.ToString("F3"); } else { m_positionInput.text = "<color=grey><i>No character loaded...</i></color>"; } // update current sound track if (References.GLOBALAUDIOMANAGER) { var music = (GlobalAudioManager.Sounds)At.GetField <GlobalAudioManager>("s_currentMusic"); m_soundInput.text = music.ToString(); } else { m_soundInput.text = "<color=grey><i>GlobalAudioManager still loading...</i></color>"; } }
public static void GetStatusLocalization(StatusEffect effect, out string name, out string desc) { var namekey = (string)At.GetField(effect, "m_nameLocKey"); name = LocalizationManager.Instance.GetLoc(namekey); var desckey = (string)At.GetField(effect, "m_descriptionLocKey"); desc = LocalizationManager.Instance.GetLoc(desckey); }
public static void Postfix(OptionsPanel __instance) { var slider = (Slider)At.GetField(__instance, "m_sldFoVSplit"); if (slider) { slider.maxValue = 90f; } }
public override void SerializeEffect <T>(T effect) { var comp = effect as AddAllStatusEffectBuildUp; BuildUpValue = comp.BuildUpValue; NoDealer = comp.NoDealer; AffectController = comp.AffectController; BuildUpBonus = (float)At.GetField(comp, "m_buildUpBonus"); }
public static void Prefix(Deployable __instance) { var item = At.GetField(__instance as ItemExtension, "m_item") as Item; if (!item) { item = __instance.GetComponent <Item>(); } At.SetField(__instance as ItemExtension, "m_item", item); }
public override void SerializeStatus(StatusEffect status) { base.SerializeStatus(status); var comp = status as Disease; this.AutoHealTime = (int)At.GetField(comp, "m_autoHealTime"); this.CanDegenerate = (bool)At.GetField(comp, "m_canDegenerate"); this.DegenerateTime = (float)At.GetField(comp, "m_degenerateTime"); this.DiseaseType = (Diseases)At.GetField(comp, "m_diseasesType"); this.SleepHealTime = comp.StraightSleepHealTime; }
public static void Prefix(LocalizationManager __instance) { var localizationData = At.GetField(__instance, "m_localizationData") as LocalizationReference; foreach (LocalizationReference.Localization loc in localizationData.Languages) { if (loc.DefaultName == "English") { LocalizationHolder.SaveLocalization(loc); } } }
public override void SerializeStatusEffect(StatusEffect status, EffectPreset preset) { base.SerializeStatusEffect(status, preset); var disease = status as Disease; CanDegenerate = disease.CanHealByItself; StraightSleepHealTime = disease.StraightSleepHealTime; CanBeHealedBySleeping = disease.CanBeHealedBySleeping; AutoHealTime = (int)At.GetField(disease, "m_autoHealTime"); DegenerateTime = (float)At.GetField(disease, "m_degenerateTime"); DiseaseType = (Diseases)At.GetField(disease, "m_diseasesType"); }
public static void Postfix(MapDisplay __instance, CharacterUI _owner) { if ((bool)CONFIG.GetValue(Settings.moveGlobalUiToPlayer1.ToString())) { var rect = (RectTransform)At.GetField(_owner, "m_rectTransform"); __instance.RectTransform.anchoredPosition = rect.anchoredPosition; __instance.RectTransform.sizeDelta = rect.sizeDelta; } else { __instance.RectTransform.anchoredPosition = Vector2.zero; __instance.RectTransform.sizeDelta = Vector2.zero; } }
public void ApplyToCharacter(Character character) { // set faction character.ChangeFaction(Faction); // gear TryEquip(character, Weapon); TryEquip(character, Shield); // AI var ai = character.GetComponent <CharacterAI>(); foreach (var state in ai.AiStates) { if (state is AISCombat aisCombat) { aisCombat.CanDodge = CanDodge; aisCombat.CanBlock = CanBlock; } } // stats var stats = character.GetComponent <CharacterStats>(); var m_maxHealthStat = (Stat)At.GetField(stats, "m_maxHealthStat"); m_maxHealthStat.AddStack(new StatStack(StatSourceID, Health - 100), false); var m_impactResistance = (Stat)At.GetField(stats, "m_impactResistance"); m_impactResistance.AddStack(new StatStack(StatSourceID, ImpactResist), false); var m_damageProtection = (Stat[])At.GetField(stats, "m_damageProtection"); m_damageProtection[0].AddStack(new StatStack(StatSourceID, Protection), false); var m_damageResistance = (Stat[])At.GetField(stats, "m_damageResistance"); for (int i = 0; i < 6; i++) { m_damageResistance[i].AddStack(new StatStack(StatSourceID, Damage_Resists[i]), false); } var m_damageTypesModifier = (Stat[])At.GetField(stats, "m_damageTypesModifier"); for (int i = 0; i < 6; i++) { m_damageTypesModifier[i].AddStack(new StatStack(StatSourceID, Damage_Bonus[i]), false); } }
public override void SerializeItem(Item item, DM_Item holder) { base.SerializeItem(item, holder); var trap = item as DeployableTrap; var recipes = (TrapEffectRecipe[])At.GetField(trap, "m_trapRecipes"); foreach (var recipe in recipes) { var dmRecipe = new DM_TrapRecipe(); dmRecipe.Serialize(recipe, trap); TrapRecipeEffects.Add(dmRecipe); } }
public static DM_Gatherable ParseGatherable(Gatherable gatherable) { var gatherableHolder = new DM_Gatherable { Name = gatherable.Name?.Trim(), ItemID = gatherable.ItemID }; if (At.GetField(gatherable as SelfFilledItemContainer, "m_drops") is List <Dropable> droppers) { if (droppers == null || droppers.Count < 1) { //SL.LogWarning("droppers is null or list count is 0!"); } else { foreach (Dropable dropper in droppers) { var dropableHolder = DM_DropTable.ParseDropable(dropper); gatherableHolder.DropTables.Add(dropableHolder.Name); } } } if (gatherableHolder.Name == "Fish") { gatherableHolder.Name = "Fishing Spot (" + gatherableHolder.DropTables[0] + ")"; } if (gatherableHolder.Name.Contains("vein")) { gatherableHolder.Name.Replace("vein", "Vein"); if (gatherableHolder.Name.Contains("Iron") || gatherableHolder.Name == "Palladium") { foreach (var table in gatherableHolder.DropTables) { if (table.Contains("Tourmaline")) { gatherableHolder.Name += " (Tourmaline)"; break; } } } } return(gatherableHolder); }
internal static void OnEnvironmentSaveLoaded(DictionaryExt <string, CharacterSaveInstanceHolder> charSaves) { var host = CharacterManager.Instance.GetWorldHostCharacter(); if (!host || !host.IsPhotonPlayerLocal) { SL.WasLastSceneReset = false; return; } if (charSaves.TryGetValue(host.UID, out CharacterSaveInstanceHolder holder)) { if (At.GetField(holder.CurrentSaveInstance, "m_loadedScene") is EnvironmentSave loadedScene) { var areaHolder = AreaManager.Instance.GetAreaFromSceneName(loadedScene.AreaName); if (areaHolder == null) { SLCharacterSaveManager.SceneResetWanted = true; } else { var area = (AreaManager.AreaEnum)AreaManager.Instance.GetAreaFromSceneName(loadedScene.AreaName).ID; if (IsPermanent(area)) { SLCharacterSaveManager.SceneResetWanted = false; } else { float age = (float)(loadedScene.GameTime - EnvironmentConditions.GameTime); SLCharacterSaveManager.SceneResetWanted = AreaManager.Instance.IsAreaExpired(loadedScene.AreaName, age); } } } else { SLCharacterSaveManager.SceneResetWanted = true; } } else { SLCharacterSaveManager.SceneResetWanted = true; } SL.WasLastSceneReset = SLCharacterSaveManager.SceneResetWanted; SL.Log("Set SceneResetWanted: " + SLCharacterSaveManager.SceneResetWanted); }
public static void Postfix(Building __instance) { if (!StoreManager.Instance.IsDlcInstalled(OTWStoreAPI.DLCs.DLC2) || !BuildingHelperMod.Instance.settings.AutoFinishBuildings || PhotonNetwork.isNonMasterClientInRoom) { return; } At.SetField(__instance, "m_remainingConstructionTime", 0f); var pending = (int)At.GetField(__instance, "m_pendingUpgradePhaseIndex"); At.SetField(__instance, "m_currentUpgradePhaseIndex", pending); At.SetField(__instance, "m_pendingUpgradePhaseIndex", -1); __instance.UpdateConstruction(0f); }
public override void SerializeItem(Item item, DM_Item holder) { base.SerializeItem(item, holder); var bag = item as Bag; var template = holder as DM_Bag; template.Capacity = bag.BagCapacity; template.Restrict_Dodge = bag.RestrictDodge; template.InventoryProtection = bag.InventoryProtection; if (bag.GetComponentInChildren <Preserver>() is Preserver p && At.GetField(p, "m_preservedElements") is List <Preserver.PreservedElement> list && list.Count > 0) { template.Preserver_Amount = list[0].Preservation; template.Nullify_Perish = p.NullifyPerishing; } }
public override void SerializeItem(Item item, DM_Item holder) { base.SerializeItem(item, holder); var building = item as Building; var constructionPhases = At.GetField(building, "m_constructionPhases") as Building.ConstructionPhase[]; foreach (var phase in constructionPhases) { ConstructionPhases.Add(DM_ConstructionPhase.SerializePhase(phase)); } var upgradePhases = At.GetField(building, "m_upgradePhases") as Building.ConstructionPhase[]; foreach (var phase in upgradePhases) { UpgradePhases.Add(DM_ConstructionPhase.SerializePhase(phase)); } }
public static void Postfix(SelfFilledItemContainer __instance) { if (PhotonNetwork.isNonMasterClientInRoom) { return; } var drops = At.GetField(__instance, "m_drops") as List <Dropable>; foreach (var dropable in drops) { foreach (var dropAddition in SL_DropTableAddition.s_registeredDropTableSources) { if (dropAddition.IsTargeting(dropable.name)) { dropAddition.GenerateItems(__instance.transform); } } } }
public static DM_ConstructionPhase SerializePhase(Building.ConstructionPhase phase) { return(new DM_ConstructionPhase { PhaseType = phase.ConstructionType, HouseCountRequirement = phase.HouseCountRequirements, ConstructionTime = phase.GetConstructionTime(), ConstructionCosts = (BuildingResourceValues)At.GetField(phase, "m_constructionCosts"), UpkeepCosts = phase.UpkeepCosts, UpkeepProductions = phase.UpkeepProductions, CapacityBonus = phase.CapacityBonus, MultiplyProductionPerHouse = phase.MultiplyProductionPerHouse, HousingValue = phase.HousingValue, RareMaterial = phase.RareMaterial?.Name, BuildingRequirements = (from req in phase.BuildingRequirements select new DM_BuildingRequirement() { ReqBuildingName = req.ReqBuilding?.Name, ReqUpgradeIndex = req.UpgradeIndex }).ToList(), }); }
public override void SerializeStats(ItemStats stats, DM_ItemStats holder) { base.SerializeStats(stats, holder); try { var item = stats.GetComponent <Item>(); var eStats = stats as EquipmentStats; Cooldown_Reduction = eStats.CooldownReduction; Hunger_Affect = eStats.HungerModifier; Thirst_Affect = eStats.ThirstModifier; Fatigue_Affect = eStats.SleepModifier; Impact_Resistance = eStats.ImpactResistance; Damage_Protection = eStats.GetDamageProtection(DamageType.Types.Physical); Stamina_Use_Penalty = eStats.StaminaUsePenalty; Mana_Use_Modifier = (float)At.GetField(eStats, "m_manaUseModifier"); Mana_Regen = eStats.ManaRegenBonus; Movement_Penalty = eStats.MovementPenalty; Pouch_Bonus = eStats.PouchCapacityBonus; Heat_Protection = eStats.HeatProtection; Cold_Protection = eStats.ColdProtection; Corruption_Protection = eStats.CorruptionResistance; Damage_Bonus = At.GetField(eStats, "m_damageAttack") as float[]; Damage_Resistance = At.GetField(eStats, "m_damageResistance") as float[]; Impact_Bonus = eStats.ImpactModifier; BarrierProtection = eStats.BarrierProtection; GlobalStatusEffectResistance = (float)At.GetField(eStats, "m_baseStatusEffectResistance"); StaminaRegenModifier = eStats.StaminaRegenModifier; } catch (Exception e) { SL.Log("Exception getting stats of " + stats.name + "\r\n" + e.Message + "\r\n" + e.StackTrace); } }
public static void ParseAllRecipes() { var recipes = (Dictionary <int, EnchantmentRecipe>)At.GetField(RecipeManager.Instance, "m_enchantmentRecipes"); if (recipes == null) { SL.Log("null enchantment dict!"); return; } SL.Log("Parsing Enchantments..."); foreach (var recipe in recipes.Values) { if (recipe.RecipeID <= 0) { recipe.InitID(); } var enchantment = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(recipe.RecipeID); if (!enchantment) { SL.Log("null enchantment!"); continue; } var template = new DM_EnchantmentRecipe(); template.Serialize(recipe, enchantment); string dir = Serializer.Folders.Enchantments; string saveName = template.Name + " (" + template.RecipeID + ")"; ListManager.EnchantmentRecipes.Add(template.RecipeID.ToString(), template); Serializer.SaveToXml(dir, saveName, template); } }
public static void Prefix(LootableOnDeath __instance, bool _loadedDead) { if (_loadedDead || !__instance.enabled || PhotonNetwork.isNonMasterClientInRoom || !SL_DropTableAddition.s_registeredDropTableSources.Any()) { return; } var m_character = At.GetField(__instance, "m_character") as Character; if (!m_character) { return; } bool wasAlive = (bool)At.GetField(__instance, "m_wasAlive"); if (!m_character.Alive || (m_character.IsDead && wasAlive)) { var drops = (Dropable[])At.GetField(__instance, "m_lootDroppers"); if (drops == null || !drops.Any()) { return; } foreach (var dropable in drops) { foreach (var dropAddition in SL_DropTableAddition.s_registeredDropTableSources) { if (dropAddition.IsTargeting(dropable.name)) { dropAddition.GenerateItems(m_character.Inventory.Pouch.transform); } } } } }
public static DM_Merchant ParseMerchant(Merchant merchant) { var merchantHolder = new DM_Merchant { Name = merchant.ShopName?.Trim(), UID = merchant.HolderUID }; if (At.GetField(merchant, "m_dropableInventory") is Dropable dropper) { merchantHolder.DropTable = DM_DropTable.ParseDropable(dropper, merchant); } foreach (var priceMod in merchant.GetComponentsInChildren <PriceModifier>()) { if (priceMod.BuyMultiplierAdded != 0f || priceMod.SellMultiplierAdded != 0f) { //SL.Log("Merchant " + merchantHolder.Name + " has buy or sell mods! Buy: " + priceMod.BuyMultiplierAdded + ", Sell: " + priceMod.SellMultiplierAdded); merchantHolder.BuyModifiers.Add(priceMod.BuyMultiplierAdded); merchantHolder.SellModifiers.Add(priceMod.SellMultiplierAdded); } } string dir = Serializer.Folders.Merchants; string saveName = SceneManager.Instance.GetCurrentLocation(merchant.transform.position) + " - " + merchantHolder.Name + " (" + merchantHolder.UID + ")"; if (ListManager.Merchants.ContainsKey(saveName)) { return(null); } Serializer.SaveToXml(dir, saveName, merchantHolder); ListManager.Merchants.Add(saveName, merchantHolder); return(merchantHolder); }
public static DM_DropTable ParseDropable(Dropable dropable, Merchant merchant = null, string containerName = "") { if (!dropable) { return(null); } var dropTableHolder = new DM_DropTable { Name = dropable.name }; if (dropTableHolder.Name == "InventoryTable" && merchant) { dropTableHolder.Name = SceneManager.Instance.GetCurrentLocation(merchant.transform.position) + " - " + merchant.ShopName; } dropTableHolder.Name = dropTableHolder.Name.Trim(); if (At.GetField(dropable, "m_allGuaranteedDrops") is List <GuaranteedDrop> guaranteedDrops) { foreach (GuaranteedDrop gDropper in guaranteedDrops) { if (At.GetField(gDropper, "m_itemDrops") is List <BasicItemDrop> gItemDrops && gItemDrops.Count > 0) { foreach (BasicItemDrop gItemDrop in gItemDrops) { if (!gItemDrop.DroppedItem) { continue; } //var pos = dropable.transform.position; AddGuaranteedDrop(dropTableHolder, gItemDrop.DroppedItem.ItemID, gItemDrop.DroppedItem.Name, gItemDrop.MinDropCount, gItemDrop.MaxDropCount); } } } } if (At.GetField(dropable, "m_conditionalGuaranteedDrops") is List <ConditionalGuaranteedDrop> conditionalGuaranteed) { foreach (var guaConditional in conditionalGuaranteed) { if (!guaConditional.Dropper) { continue; } var drops = At.GetField(guaConditional.Dropper, "m_itemDrops") as List <BasicItemDrop>; foreach (var gItemDrop in drops) { if (!gItemDrop.DroppedItem) { continue; } //var pos = dropable.transform.position; AddGuaranteedDrop(dropTableHolder, gItemDrop.DroppedItem.ItemID, gItemDrop.DroppedItem.Name, gItemDrop.MinDropCount, gItemDrop.MaxDropCount); } } } if (At.GetField(dropable, "m_mainDropTables") is List <DropTable> dropTables) { foreach (DropTable table in dropTables) { if (ParseDropTable(dropTableHolder, containerName, dropable, table) is DropGeneratorHolder generatorHolder) { dropTableHolder.Random_Tables.Add(generatorHolder); } } } if (At.GetField(dropable, "m_conditionalDropTables") is List <ConditionalDropTable> conditionals) { foreach (var conTable in conditionals) { if (ParseDropTable(dropTableHolder, containerName, dropable, conTable.Dropper) is DropGeneratorHolder generatorHolder) { generatorHolder.DropConditionType = conTable.DropCondition.GetType().FullName; dropTableHolder.Random_Tables.Add(generatorHolder); } } } if (merchant == null) { string dir = Serializer.Folders.DropTables; if (!File.Exists(dir + "/" + dropTableHolder.Name + ".xml")) { ListManager.DropTables.Add(dropTableHolder.Name, dropTableHolder); Serializer.SaveToXml(dir, dropTableHolder.Name, dropTableHolder); } } return(dropTableHolder); }
public static DropGeneratorHolder ParseDropTable(DM_DropTable dropTableHolder, string containerName, Dropable dropper, DropTable table) { var generatorHolder = new DropGeneratorHolder { MinNumberOfDrops = table.MinNumberOfDrops, MaxNumberOfDrops = table.MaxNumberOfDrops, MaxDiceValue = (int)At.GetField(table, "m_maxDiceValue"), }; //if (generatorHolder.MaxDiceValue <= 0) //{ // SL.LogWarning("This random table's MaxDiceValue is 0, skipping..."); // return null; //} if (At.GetField(table, "m_dropAmount") is SimpleRandomChance dropAmount) { generatorHolder.ChanceReduction = dropAmount.ChanceReduction; generatorHolder.ChanceRegenQty = dropAmount.ChanceRegenQty; if (dropAmount.CanRegen) { generatorHolder.RegenTime = dropAmount.ChanceRegenDelay; } else { generatorHolder.RegenTime = -1; } } else { generatorHolder.RegenTime = -1; } if (At.GetField(table, "m_emptyDropChance") is int i && generatorHolder.MaxDiceValue > 0) { try { decimal emptyChance = (decimal)i / generatorHolder.MaxDiceValue; generatorHolder.EmptyDrop = (float)emptyChance * 100; } catch { generatorHolder.EmptyDrop = 0; } } if (At.GetField(table, "m_itemDrops") is List <ItemDropChance> itemDrops) { foreach (ItemDropChance drop in itemDrops) { if (!drop.DroppedItem) { continue; } float percentage; try { percentage = (float)((decimal)drop.DropChance / generatorHolder.MaxDiceValue) * 100f; } catch { percentage = 100f; } percentage = (float)Math.Round(percentage, 2); string name = drop.DroppedItem.Name; if (IsUnidentified(drop.DroppedItem.ItemID, out string identified)) { name += " (" + identified + ")"; } if (percentage >= 100) { AddGuaranteedDrop(dropTableHolder, drop.DroppedItem.ItemID, name, drop.MaxDropCount, drop.MinDropCount); } else { generatorHolder.Item_Drops.Add(new DropTableChanceEntry { Item_ID = drop.DroppedItem.ItemID, Item_Name = name, Min_Quantity = drop.MinDropCount, Max_Quantity = drop.MaxDropCount, Drop_Chance = percentage, Dice_Range = drop.MaxDiceRollValue - drop.MinDiceRollValue, ChanceReduction = drop.ChanceReduction, ChanceRegenDelay = drop.ChanceRegenDelay, ChanceRegenQty = drop.ChanceRegenQty }); } } } return(generatorHolder); }
public virtual void SerializeItem(Item item, DM_Item holder) { holder.gameObjectName = item.gameObject.name; holder.ItemID = item.ItemID; holder.Name = item.Name; holder.Description = item.Description; holder.LegacyItemID = item.LegacyItemID; holder.CastLocomotionEnabled = item.CastLocomotionEnabled; holder.CastModifier = item.CastModifier; holder.CastSheatheRequired = item.CastSheathRequired; holder.GroupItemInDisplay = item.GroupItemInDisplay; holder.HasPhysicsWhenWorld = item.HasPhysicsWhenWorld; holder.IsPickable = item.IsPickable; holder.IsUsable = item.IsUsable; holder.QtyRemovedOnUse = item.QtyRemovedOnUse; holder.MobileCastMovementMult = item.MobileCastMovementMult; holder.RepairedInRest = item.RepairedInRest; holder.BehaviorOnNoDurability = item.BehaviorOnNoDurability; holder.OverrideSellModifier = (float)At.GetField(item, "m_overrideSellModifier"); if (item.GetComponent <Perishable>() is Perishable perish) { float perishRate = perish.DepletionRate * 0.03333333f; float perishModifier = 1 / perishRate; var remainingTicks = item.MaxDurability * perishModifier; // each tick is 2 in-game minutes (~5 seconds irl) var minutes = remainingTicks * 2; TimeSpan t = TimeSpan.FromMinutes(minutes); holder.PerishTime = $"{t.Days} Days, {t.Hours} Hours, {t.Minutes} Minutes, {t.Seconds} Seconds"; } holder.CastType = (Character.SpellCastType)At.GetField(item, "m_activateEffectAnimType"); if (item.GetComponent <ItemStats>() is ItemStats stats) { holder.StatsHolder = DM_ItemStats.ParseItemStats(stats); } if (item.Tags != null) { foreach (Tag tag in item.Tags) { holder.Tags.Add(tag.TagName); ListManager.AddTagSource(tag, Serializer.SafeName(item.Name)); } } foreach (Transform child in item.transform) { var effectsChild = DM_EffectTransform.ParseTransform(child); if (effectsChild.ChildEffects.Count > 0 || effectsChild.Effects.Count > 0 || effectsChild.EffectConditions.Count > 0) { holder.EffectTransforms.Add(effectsChild); } } }