Skip to content

Commit 9e4dd6b

Browse files
committed
Avoid compatibility issues with other mods and restrict storage size
1 parent f9613ad commit 9e4dd6b

12 files changed

+47
-18
lines changed

etc/SteamDescription_de-DE.txt

-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ Ein neues Spiel start mit einer Basis, einer Bel
1818
[h1]Schlussbemerkungen[/h1]
1919
Ich hoffe diese Mod hilft neuen Spielern, indem es den Spielstart weniger �berfordernd und bestrafend macht. Erfahrenere Spieler, welche sich nicht mit der Errichtung der Basisinfrastruktur hetzen und einen gem�tlicheren Spielstart haben wollen, k�nnten diese Mod ebenfalls m�gen.
2020

21-
Der [b]Mini-Pod[/b] erh�lt standardm��ig ebenfalls die oben beschriebenen Verbesserungen, dies kann aber in den Modeinstellungen deaktiviert werden (siehe oben). �ndere dazu die Einstellung auf [b]extendMiniPod: false[/b].
22-
2321
Du hast Verbesserungsvorschl�ge oder m�chtest den Quelltext dieser Mod sehen? Wirf einen Blick aufs [url=https://github.com/sungaila/SurvivalNotRequired]GitHub Repository[/url]!

etc/SteamDescription_en-US.txt

-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,4 @@ Open the file [b]%USERPROFILE%\Documents\Klei\OxygenNotIncluded\mods\Steam\28402
1818
[h1]Concluding remarks[/h1]
1919
I hope this mod helps new players by making the beginning less overwhelming and punishing. More experienced players, who don't want to rush basic colony infrastructure and wish for a more relaxed game start, might enjoy this mod as well.
2020

21-
The [b]Mini-Pod[/b] is enhanced by default but you can disable it by changing the mod settings (see above). Just change the setting to [b]extendMiniPod: false[/b].
22-
2321
You have ideas to improve this mod or wish to see its source code? Take a look at [url=https://github.com/sungaila/SurvivalNotRequired]the GitHub repository[/url]!

src/ComponentExtensions.cs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using UnityEngine;
2+
3+
namespace SurvivalNotRequired
4+
{
5+
internal static class ComponentExtensions
6+
{
7+
internal static T AddComponentAndTag<T>(this GameObject go, Tag tag) where T : Component
8+
{
9+
var result = go.AddComponent<T>();
10+
result.AddTag(tag);
11+
return result;
12+
}
13+
}
14+
}

src/ModSettings.cs

+3
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@ internal class ModSettings
2020

2121
[YamlMember(Alias = "extendMiniPod")]
2222
public bool? ExtendMiniPod { get; set; }
23+
24+
[YamlMember(Alias = "capacityInKg")]
25+
public float? CapacityInKg { get; set; }
2326
}
2427
}

src/MyUserMod.cs

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public override void OnLoad(Harmony harmony)
3535

3636
if (settings.ExtendMiniPod.HasValue)
3737
TelepadStatesInstancePatch.ExtendMiniPod = settings.ExtendMiniPod.Value;
38+
39+
if (settings.CapacityInKg.HasValue)
40+
TelepadStatesInstancePatch.CapacityInKg = settings.CapacityInKg.Value;
3841
}
3942
catch (Exception ex)
4043
{

src/Patches/HeadquartersConfigPatch.cs

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using HarmonyLib;
2+
using System.Collections.Generic;
23
using UnityEngine;
34

45
namespace SurvivalNotRequired.Patches
@@ -10,6 +11,11 @@ namespace SurvivalNotRequired.Patches
1011
[HarmonyPatch(typeof(HeadquartersConfig))]
1112
public static class HeadquartersConfigPatch
1213
{
14+
internal static readonly Tag StorageTag = TagManager.Create("6DB61B5E-2CC7-4354-BFAE-A0577DD7D65B");
15+
internal static readonly Tag ConduitDispenserTag = TagManager.Create("32EAE057-3F2E-44F0-833A-D9A212CD5F21");
16+
internal static readonly Tag ElementConverterTag = TagManager.Create("051FC465-2947-453C-BE2E-FEAFDF51B5EA");
17+
internal static readonly Tag GeneratorTag = TagManager.Create("B217C2D3-AAA6-4D7C-B079-C8EC0332BCAC");
18+
1319
/// <summary>
1420
/// Postfix for <see cref="HeadquartersConfig.CreateBuildingDef"/>.
1521
/// </summary>
@@ -50,10 +56,11 @@ public static void ConfigureBuildingTemplatePostfix(GameObject go)
5056

5157
internal static void ModifyBuildingTemplate(ref GameObject go)
5258
{
53-
Storage defaultStorage = BuildingTemplates.CreateDefaultStorage(go);
54-
defaultStorage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
59+
Storage storage = go.AddComponentAndTag<Storage>(StorageTag);
60+
storage.capacityKg = TelepadStatesInstancePatch.CapacityInKg;
61+
storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
5562

56-
ConduitDispenser conduitDispenser = go.AddOrGet<ConduitDispenser>();
63+
ConduitDispenser conduitDispenser = go.AddComponentAndTag<ConduitDispenser>(ConduitDispenserTag);
5764
conduitDispenser.alwaysDispense = true;
5865
conduitDispenser.conduitType = ConduitType.Gas;
5966
conduitDispenser.elementFilter = new SimHashes[1]
@@ -62,14 +69,14 @@ internal static void ModifyBuildingTemplate(ref GameObject go)
6269
};
6370

6471
// this converter is used indirectly but won't be converting anything
65-
ElementConverter elementConverter = go.AddOrGet<ElementConverter>();
72+
ElementConverter elementConverter = go.AddComponentAndTag<ElementConverter>(ElementConverterTag);
6673
elementConverter.OutputMultiplier = 1f;
6774
elementConverter.outputElements = new ElementConverter.OutputElement[]
6875
{
6976
new ElementConverter.OutputElement(TelepadStatesInstancePatch.OxygenOutputInKgPerSecond, SimHashes.Oxygen, TelepadStatesInstancePatch.OxygenMinTemperatureInKelvin, false, true)
7077
};
7178

72-
Generator generator = go.AddOrGet<Generator>();
79+
Generator generator = go.AddComponentAndTag<Generator>(GeneratorTag);
7380
generator.powerDistributionOrder = 10;
7481
}
7582
}

src/Patches/TelepadStatesInstancePatch.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public static class TelepadStatesInstancePatch
1515
public static float WattageRating { get; internal set; } = 400f;
1616
public static float SelfHeatKilowattsWhenActive { get; internal set; } = 1f; // that's 1,000 DTU/s
1717
public static bool ExtendMiniPod { get; internal set; } = true;
18+
public static float CapacityInKg { get; internal set; } = 10f;
1819

1920
public static void Postfix(Telepad.States __instance)
2021
{
@@ -23,7 +24,8 @@ static void doAdditionalStuffHandler(Telepad.StatesInstance smi, float dt)
2324
smi.master.TryGetComponent<Operational>(out var operational);
2425

2526
// generate power
26-
if (smi.master.TryGetComponent<Generator>(out var generator))
27+
var generator = smi.master.GetComponents<Generator>().FirstOrDefault(c => c.HasTag(HeadquartersConfigPatch.GeneratorTag));
28+
if (generator != null)
2729
{
2830
generator.EnergySim200ms(dt);
2931
KSelectable component = smi.master.GetComponent<KSelectable>();
@@ -32,12 +34,13 @@ static void doAdditionalStuffHandler(Telepad.StatesInstance smi, float dt)
3234
}
3335

3436
// dispense oxygen
35-
if (smi.master.TryGetComponent<Storage>(out var storage) &&
36-
smi.master.TryGetComponent<ElementConverter>(out var elementConverter) &&
37-
operational?.IsOperational == true)
37+
var storage = smi.master.GetComponents<Storage>().FirstOrDefault(c => c.HasTag(HeadquartersConfigPatch.StorageTag));
38+
var elementConverter = smi.master.GetComponents<ElementConverter>().FirstOrDefault(c => c.HasTag(HeadquartersConfigPatch.ElementConverterTag));
39+
if (storage != null && elementConverter != null && operational?.IsOperational == true)
3840
{
3941
var outputElement = elementConverter.outputElements.Single(o => o.elementHash == SimHashes.Oxygen);
4042
float outputMass = outputElement.massGenerationRate * elementConverter.OutputMultiplier * dt;
43+
outputMass = Mathf.Max(Mathf.Min(outputMass, storage.RemainingCapacity()), 0);
4144
Game.Instance.accumulators.Accumulate(outputElement.accumulator, outputMass);
4245

4346
var component = smi.master.GetComponent<PrimaryElement>();
File renamed without changes.

src/SurvivalNotRequired.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFramework>net471</TargetFramework>
55
<AssemblyOriginatorKeyFile>SurvivalNotRequired.snk</AssemblyOriginatorKeyFile>
66
<Configurations>Debug;Release;ReleaseSigned;ReleaseSigned</Configurations>
7-
<Version>1.1.1</Version>
7+
<Version>1.1.2</Version>
88
</PropertyGroup>
99

1010
<!-- C# compiler -->
@@ -74,6 +74,6 @@
7474
</Reference>
7575
</ItemGroup>
7676

77-
<Import Project="PDFtoImage.PropertiesSigning.targets" />
78-
<Import Project="PDFtoImage.CodeSigning.targets" />
77+
<Import Project="SurvivalNotRequired.PropertiesSigning.targets" />
78+
<Import Project="SurvivalNotRequired.CodeSigning.targets" />
7979
</Project>

src/mod_info.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
supportedContent: ALL
22
minimumSupportedBuild: 514967
3-
version: 1.1.1
3+
version: 1.1.2
44
APIVersion: 2

src/settings.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ wattageRating: 400.0
1111
selfHeatKilowattsWhenActive: 1.0
1212

1313
# whether the Mini-Pod should be extended just like the Printing Pod
14-
extendMiniPod: true
14+
extendMiniPod: true
15+
16+
# the storage capacity (for oxygen) of the Printing Pod
17+
capacityInKg: 10.0

0 commit comments

Comments
 (0)