internal static void Configure(GameObject prefab) { ModMillableComponent modMillable = ComponentUtils.GetComponent <ModMillableComponent>(prefab); if (modMillable is null) { return; } Millable millable = ComponentUtils.GetOrCreateComponent <Millable>(modMillable); millable.m_CanRestoreFromWornOut = modMillable.CanRestoreFromWornOut; millable.m_RecoveryDurationMinutes = modMillable.RecoveryDurationMinutes; millable.m_RepairDurationMinutes = modMillable.RepairDurationMinutes; millable.m_Skill = EnumUtils.TranslateEnumValue <SkillType, ModComponentAPI.SkillType>(modMillable.skill); if (modMillable.RepairRequiredGear.Length != modMillable.RepairRequiredGearUnits.Length) { throw new ArgumentException("RepairRequiredGear and RepairRequiredGearUnits do not have the same length on gear item '" + modMillable.name + "'."); } millable.m_RepairRequiredGear = ModUtils.GetItems <GearItem>(modMillable.RepairRequiredGear, modMillable.name); millable.m_RepairRequiredGearUnits = modMillable.RepairRequiredGearUnits; if (modMillable.RestoreRequiredGear.Length != modMillable.RestoreRequiredGearUnits.Length) { throw new ArgumentException("RestoreRequiredGear and RestoreRequiredGearUnits do not have the same length on gear item '" + modMillable.name + "'."); } millable.m_RestoreRequiredGear = ModUtils.GetItems <GearItem>(modMillable.RestoreRequiredGear, modMillable.name); millable.m_RestoreRequiredGearUnits = modMillable.RestoreRequiredGearUnits; }
internal static void Configure(GameObject prefab) { ModHarvestableComponent modHarvestableComponent = ComponentUtils.GetComponent <ModHarvestableComponent>(prefab); if (modHarvestableComponent is null) { return; } Harvest harvest = ComponentUtils.GetOrCreateComponent <Harvest>(modHarvestableComponent); harvest.m_Audio = modHarvestableComponent.Audio; harvest.m_DurationMinutes = modHarvestableComponent.Minutes; if (modHarvestableComponent.YieldNames.Length != modHarvestableComponent.YieldCounts.Length) { throw new ArgumentException("YieldNames and YieldCounts do not have the same length on gear item '" + modHarvestableComponent.name + "'."); } harvest.m_YieldGear = ModUtils.GetItems <GearItem>(modHarvestableComponent.YieldNames, modHarvestableComponent.name); harvest.m_YieldGearUnits = modHarvestableComponent.YieldCounts; harvest.m_AppliedSkillType = SkillType.None; harvest.m_RequiredTools = ModUtils.GetItems <ToolsItem>(modHarvestableComponent.RequiredToolNames, modHarvestableComponent.name); harvest.m_GunpowderYield = 0f; }
internal static void Configure(GameObject prefab) { ModRepairableComponent modRepairableComponent = ComponentUtils.GetComponent <ModRepairableComponent>(prefab); if (modRepairableComponent is null) { return; } Repairable repairable = ComponentUtils.GetOrCreateComponent <Repairable>(modRepairableComponent); repairable.m_RepairAudio = modRepairableComponent.Audio; repairable.m_DurationMinutes = modRepairableComponent.Minutes; repairable.m_ConditionIncrease = modRepairableComponent.Condition; if (modRepairableComponent.MaterialNames.Length != modRepairableComponent.MaterialCounts.Length) { throw new ArgumentException("MaterialNames and MaterialCounts do not have the same length on gear item '" + modRepairableComponent.name + "'."); } repairable.m_RequiredGear = ModUtils.GetItems <GearItem>(modRepairableComponent.MaterialNames, modRepairableComponent.name); repairable.m_RequiredGearUnits = modRepairableComponent.MaterialCounts; repairable.m_RepairToolChoices = ModUtils.GetItems <ToolsItem>(modRepairableComponent.RequiredTools, modRepairableComponent.name); repairable.m_RequiresToolToRepair = repairable.m_RepairToolChoices.Length > 0; }
internal static void Prefix(GearItem __instance) { if (__instance.m_CookingPotItem) { ComponentUtils.GetOrCreateComponent <OverrideCookingState>(__instance); ComponentUtils.GetOrCreateComponent <CookingPotWaterSaveData>(__instance); } }
internal static void Postfix(GearItem __instance) { float waterRequired = __instance?.m_Cookable?.m_PotableWaterRequiredLiters ?? 0; if (waterRequired > 0) { ComponentUtils.GetOrCreateComponent <CookingModifier>(__instance); } }
internal static void Configure(GameObject prefab) { ModScentComponent modScentComponent = ComponentUtils.GetComponent <ModScentComponent>(prefab); if (modScentComponent is null) { return; } Scent scent = ComponentUtils.GetOrCreateComponent <Scent>(modScentComponent); scent.m_ScentCategory = EnumUtils.TranslateEnumValue <ScentRangeCategory, ScentCategory>(modScentComponent.scentCategory); }
public static void Configure(GameObject prefab) { ModAccelerantComponent modAccelerantComponent = ComponentUtils.GetComponent <ModAccelerantComponent>(prefab); if (modAccelerantComponent is null) { return; } FireStarterItem fireStarterItem = ComponentUtils.GetOrCreateComponent <FireStarterItem>(modAccelerantComponent); fireStarterItem.m_IsAccelerant = true; fireStarterItem.m_FireStartDurationModifier = modAccelerantComponent.DurationOffset; fireStarterItem.m_FireStartSkillModifier = modAccelerantComponent.SuccessModifier; fireStarterItem.m_ConsumeOnUse = modAccelerantComponent.DestroyedOnUse; }
internal static void Configure(GameObject prefab) { ModEvolveComponent modEvolveComponent = ComponentUtils.GetComponent <ModEvolveComponent>(prefab); if (modEvolveComponent is null) { return; } EvolveItem evolveItem = ComponentUtils.GetOrCreateComponent <EvolveItem>(modEvolveComponent); evolveItem.m_ForceNoAutoEvolve = false; evolveItem.m_GearItemToBecome = GetTargetItem(modEvolveComponent.TargetItemName, modEvolveComponent.name); evolveItem.m_RequireIndoors = modEvolveComponent.IndoorsOnly; evolveItem.m_StartEvolvePercent = 0; evolveItem.m_TimeToEvolveGameDays = Mathf.Clamp(modEvolveComponent.EvolveHours / 24f, 0.01f, 1000); }
public static void Execute() { Panel_Cooking panel_Cooking = InterfaceManager.m_Panel_Cooking; GearItem cookedItem = panel_Cooking.GetSelectedFood(); CookingPotItem cookingPotItem = panel_Cooking.m_CookingPotInteractedWith; GearItem result = cookedItem.Drop(1, false, true); CookingModifier cookingModifier = ComponentUtils.GetOrCreateComponent <CookingModifier>(result); cookingModifier.additionalMinutes = result.m_Cookable.m_PotableWaterRequiredLiters * panel_Cooking.m_MinutesToMeltSnowPerLiter; cookingModifier.Apply(); GameAudioManager.Play3DSound(result.m_Cookable.m_PutInPotAudio, cookingPotItem.gameObject); cookingPotItem.StartCooking(result); panel_Cooking.ExitCookingInterface(); }
internal static void Postfix(GearItem __instance) { if (NameUtils.NormalizeName(__instance?.name) == "GEAR_Crampons") { __instance.m_Millable = ComponentUtils.GetOrCreateComponent <Millable>(__instance.gameObject); __instance.m_Millable.m_CanRestoreFromWornOut = true; __instance.m_Millable.m_RecoveryDurationMinutes = 210; __instance.m_Millable.m_RepairDurationMinutes = 30; __instance.m_Millable.m_RepairRequiredGear = new GearItem[] { GetGearItemPrefab(SCRAP_METAL_NAME) }; __instance.m_Millable.m_RepairRequiredGearUnits = new int[] { 1 }; __instance.m_Millable.m_RestoreRequiredGear = new GearItem[] { GetGearItemPrefab(SCRAP_METAL_NAME) }; __instance.m_Millable.m_RestoreRequiredGearUnits = new int[] { 4 }; __instance.m_Millable.m_Skill = SkillType.None; } if (NameUtils.NormalizeName(__instance?.name) == "GEAR_Flaregun") { __instance.m_Millable = ComponentUtils.GetOrCreateComponent <Millable>(__instance.gameObject); __instance.m_Millable.m_CanRestoreFromWornOut = true; __instance.m_Millable.m_RecoveryDurationMinutes = 180; __instance.m_Millable.m_RepairDurationMinutes = 30; __instance.m_Millable.m_RepairRequiredGear = new GearItem[] { GetGearItemPrefab(SCRAP_METAL_NAME) }; __instance.m_Millable.m_RepairRequiredGearUnits = new int[] { 1 }; __instance.m_Millable.m_RestoreRequiredGear = new GearItem[] { GetGearItemPrefab(SCRAP_METAL_NAME) }; __instance.m_Millable.m_RestoreRequiredGearUnits = new int[] { 3 }; __instance.m_Millable.m_Skill = SkillType.None; } if (__instance.m_BeenInspected) { return; } if (Settings.instance.flareGunsStartRuined && NameUtils.NormalizeName(__instance.name) == "GEAR_FlareGun") { __instance.ForceWornOut(); } else if (Settings.instance.revolversStartRuined && NameUtils.NormalizeName(__instance.name) == "GEAR_Revolver") { __instance.ForceWornOut(); } else if (Settings.instance.riflesStartRuined && NameUtils.NormalizeName(__instance.name) == "GEAR_Rifle") { __instance.ForceWornOut(); } }
public static void Configure(GameObject prefab) { ModSharpenableComponent modSharpenableComponent = ComponentUtils.GetComponent <ModSharpenableComponent>(prefab); if (modSharpenableComponent is null) { return; } Sharpenable sharpenable = ComponentUtils.GetOrCreateComponent <Sharpenable>(modSharpenableComponent); sharpenable.m_ConditionIncreaseMax = modSharpenableComponent.ConditionMax; sharpenable.m_ConditionIncreaseMin = modSharpenableComponent.ConditionMin; sharpenable.m_DurationMinutesMax = modSharpenableComponent.MinutesMax; sharpenable.m_DurationMinutesMin = modSharpenableComponent.MinutesMin; sharpenable.m_SharpenToolChoices = ModUtils.GetItems <ToolsItem>(modSharpenableComponent.Tools, prefab.name + ": Tools"); sharpenable.m_RequiresToolToSharpen = sharpenable.m_SharpenToolChoices.Count() > 0; }
public static void Configure(GameObject prefab) { ModCarryingCapacityComponent capacityComponent = ComponentUtils.GetComponent <ModCarryingCapacityComponent>(prefab); if (capacityComponent is null) { return; } CarryingCapacityBuff capacityBuff = ComponentUtils.GetOrCreateComponent <CarryingCapacityBuff>(capacityComponent); capacityBuff.m_IsWorn = ComponentUtils.GetComponent <ModClothingComponent>(capacityComponent) != null || ComponentUtils.GetComponent <ClothingItem>(capacityComponent) != null; capacityBuff.m_CarryingCapacityBuffValues = new CarryingCapacityBuff.BuffValues() { m_MaxCarryCapacityKGBuff = capacityComponent.MaxCarryCapacityKGBuff }; }
public static void Configure(GameObject prefab) { ModTinderComponent modBurnableComponent = ComponentUtils.GetComponent <ModTinderComponent>(prefab); if (modBurnableComponent is null) { return; } FuelSourceItem fuelSourceItem = ComponentUtils.GetOrCreateComponent <FuelSourceItem>(modBurnableComponent); fuelSourceItem.m_BurnDurationHours = 0.02f; fuelSourceItem.m_FireAgeMinutesBeforeAdding = 0; fuelSourceItem.m_FireStartSkillModifier = modBurnableComponent.SuccessModifier; fuelSourceItem.m_HeatIncrease = 5; fuelSourceItem.m_HeatInnerRadius = 2.5f; fuelSourceItem.m_HeatOuterRadius = 6f; fuelSourceItem.m_FireStartDurationModifier = modBurnableComponent.DurationOffset; fuelSourceItem.m_IsWet = false; fuelSourceItem.m_IsTinder = true; fuelSourceItem.m_IsBurntInFireTracked = false; }
internal static void Postfix(CookingPotItem __instance) { //Implementation.Log("CookingPotItem -- UpdateBoilingWater"); if (__instance.AttachedFireIsBurning()) { return; } else if (__instance.m_LitersWaterBeingBoiled > 0) { if ((__instance.m_ParticlesWaterBoiling.activeInHierarchy || __instance.m_ParticlesWaterReady.activeInHierarchy) && WaterUtils.IsCooledDown(__instance)) { Utils.SetActive(__instance.m_ParticlesWaterReady, false); Utils.SetActive(__instance.m_ParticlesWaterBoiling, false); if (__instance.GetCookingState() == CookingPotItem.CookingState.Ready) { ComponentUtils.GetOrCreateComponent <OverrideCookingState>(__instance).ForceReady = true; WaterUtils.SetElapsedCookingTimeForWater(__instance, WaterUtils.GetWaterAmount(__instance)); } } } }
private static void ConfigureGearItem(ModComponent modComponent) { GearItem gearItem = ComponentUtils.GetOrCreateComponent <GearItem>(modComponent); gearItem.m_Type = GetGearType(modComponent); gearItem.m_WeightKG = modComponent.WeightKG; gearItem.m_MaxHP = modComponent.MaxHP; gearItem.m_DailyHPDecay = GetDecayPerStep(modComponent.DaysToDecay, modComponent.MaxHP); gearItem.OverrideGearCondition(EnumUtils.TranslateEnumValue <GearStartCondition, InitialCondition>(modComponent.InitialCondition), false); // OverrideGearCondition wanted to know if the item had been picked up yet; since Awake hadn't been called yet, I put false gearItem.m_LocalizedDisplayName = NameUtils.CreateLocalizedString(modComponent.DisplayNameLocalizationId); gearItem.m_LocalizedDescription = NameUtils.CreateLocalizedString(modComponent.DescriptionLocalizatonId); gearItem.m_PickUpAudio = modComponent.PickUpAudio; gearItem.m_StowAudio = modComponent.StowAudio; gearItem.m_PutBackAudio = modComponent.PickUpAudio; gearItem.m_WornOutAudio = modComponent.WornOutAudio; gearItem.m_ConditionTableType = GetConditionTableType(modComponent); gearItem.m_ScentIntensity = ScentMapper.GetScentIntensity(modComponent); gearItem.Awake(); }
public static void InitializeComponents(ref GameObject prefab, ProxyObject dict) { if (ComponentUtils.GetModComponent(prefab) != null || dict is null) { return; } #region Mod Components if (JsonUtils.ContainsKey(dict, "ModBedComponent")) { ModBedComponent newComponent = ComponentUtils.GetOrCreateComponent <ModBedComponent>(prefab); InitializeBedComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModBodyHarvestComponent")) { ModBodyHarvestComponent newComponent = ComponentUtils.GetOrCreateComponent <ModBodyHarvestComponent>(prefab); InitializeBodyHarvestComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModCharcoalComponent")) { ModCharcoalComponent newComponent = ComponentUtils.GetOrCreateComponent <ModCharcoalComponent>(prefab); InitializeCharcoalComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModClothingComponent")) { ModClothingComponent newComponent = ComponentUtils.GetOrCreateComponent <ModClothingComponent>(prefab); InitializeClothingComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModCollectibleComponent")) { ModCollectibleComponent newComponent = ComponentUtils.GetOrCreateComponent <ModCollectibleComponent>(prefab); InitializeCollectibleComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModCookableComponent")) { ModCookableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModCookableComponent>(prefab); InitializeCookableComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModCookingPotComponent")) { ModCookingPotComponent newComponent = ComponentUtils.GetOrCreateComponent <ModCookingPotComponent>(prefab); InitializeCookingPotComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModExplosiveComponent")) { ModExplosiveComponent newComponent = ComponentUtils.GetOrCreateComponent <ModExplosiveComponent>(prefab); InitializeExplosiveComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModFirstAidComponent")) { ModFirstAidComponent newComponent = ComponentUtils.GetOrCreateComponent <ModFirstAidComponent>(prefab); InitializeFirstAidComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModFoodComponent")) { ModFoodComponent newComponent = ComponentUtils.GetOrCreateComponent <ModFoodComponent>(prefab); InitializeFoodComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModGenericComponent")) { ModGenericComponent newComponent = ComponentUtils.GetOrCreateComponent <ModGenericComponent>(prefab); InitializeGenericComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModGenericEquippableComponent")) { ModGenericEquippableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModGenericEquippableComponent>(prefab); InitializeGenericEquippableComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModLiquidComponent")) { ModLiquidComponent newComponent = ComponentUtils.GetOrCreateComponent <ModLiquidComponent>(prefab); InitializeLiquidComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModPowderComponent")) { ModPowderComponent newComponent = ComponentUtils.GetOrCreateComponent <ModPowderComponent>(prefab); InitializePowderComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModPurificationComponent")) { ModPurificationComponent newComponent = ComponentUtils.GetOrCreateComponent <ModPurificationComponent>(prefab); InitializePurificationComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModRandomItemComponent")) { ModRandomItemComponent newComponent = ComponentUtils.GetOrCreateComponent <ModRandomItemComponent>(prefab); InitializeRandomItemComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModRandomWeightedItemComponent")) { ModRandomWeightedItemComponent newComponent = ComponentUtils.GetOrCreateComponent <ModRandomWeightedItemComponent>(prefab); InitializeRandomWeightedItemComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModResearchComponent")) { ModResearchComponent newComponent = ComponentUtils.GetOrCreateComponent <ModResearchComponent>(prefab); InitializeResearchComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModRifleComponent")) { ModRifleComponent newComponent = ComponentUtils.GetOrCreateComponent <ModRifleComponent>(prefab); InitializeRifleComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModToolComponent")) { ModToolComponent newComponent = ComponentUtils.GetOrCreateComponent <ModToolComponent>(prefab); InitializeToolComponent(newComponent, dict); } #endregion #region Behaviour Components if (JsonUtils.ContainsKey(dict, "ModAccelerantComponent")) { ModAccelerantComponent newComponent = ComponentUtils.GetOrCreateComponent <ModAccelerantComponent>(prefab); InitializeAccelerantComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModBurnableComponent")) { ModBurnableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModBurnableComponent>(prefab); InitializeBurnableComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModFireStarterComponent")) { ModFireStarterComponent newComponent = ComponentUtils.GetOrCreateComponent <ModFireStarterComponent>(prefab); InitializeFireStarterComponent(newComponent, dict); } else if (JsonUtils.ContainsKey(dict, "ModTinderComponent")) { ModTinderComponent newComponent = ComponentUtils.GetOrCreateComponent <ModTinderComponent>(prefab); InitializeTinderComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModCarryingCapacityComponent")) { ModCarryingCapacityComponent newComponent = ComponentUtils.GetOrCreateComponent <ModCarryingCapacityComponent>(prefab); InitializeCarryingCapacityComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModEvolveComponent")) { ModEvolveComponent newComponent = ComponentUtils.GetOrCreateComponent <ModEvolveComponent>(prefab); InitializeEvolveComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModHarvestableComponent")) { ModHarvestableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModHarvestableComponent>(prefab); InitializeHarvestableComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModMillableComponent")) { ModMillableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModMillableComponent>(prefab); InitializeMillableComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModRepairableComponent")) { ModRepairableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModRepairableComponent>(prefab); InitializeRepairableComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModScentComponent")) { ModScentComponent newComponent = ComponentUtils.GetOrCreateComponent <ModScentComponent>(prefab); InitializeScentComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModSharpenableComponent")) { ModSharpenableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModSharpenableComponent>(prefab); InitializeSharpenableComponent(newComponent, dict); } if (JsonUtils.ContainsKey(dict, "ModStackableComponent")) { ModStackableComponent newComponent = ComponentUtils.GetOrCreateComponent <ModStackableComponent>(prefab); InitializeStackableComponent(newComponent, dict); } #endregion #region Modifications if (JsonUtils.ContainsKey(dict, "ChangeLayer")) { ChangeLayer newComponent = ComponentUtils.GetOrCreateComponent <ChangeLayer>(prefab); InitializeChangeLayer(newComponent, dict); } #endregion }
internal static void Postfix(CookingPotItem __instance) { Water.AdjustWaterToWaterSupply(); ComponentUtils.GetOrCreateComponent <OverrideCookingState>(__instance).ForceReady = false; }
internal static void Postfix(CookingPotItem __instance) { //Implementation.Log("CookingPotItem -- StartMeltingSnow"); ComponentUtils.GetOrCreateComponent <OverrideCookingState>(__instance).ForceReady = false; }