-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPlanetPainter.cs
84 lines (75 loc) · 3.3 KB
/
PlanetPainter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using static Bulldozer.Log;
using static PlatformSystem;
namespace Bulldozer
{
public static class PlanetPainter
{
public static bool PaintPlanet(PlatformSystem platformSystem, ReformIndexInfoProvider reformInfoProvider)
{
var maxReformCount = platformSystem.maxReformCount;
var actionBuild = GameMain.mainPlayer?.controller.actionBuild;
if (actionBuild == null)
{
return true;
}
// reform brush type of 7 is foundation with no decoration
// brush type 2 is decorated, but not painted
// 1 seems to be paint mode
var brushType = 1;
switch (PluginConfig.foundationDecorationMode.Value)
{
case FoundationDecorationMode.Tool:
brushType = actionBuild.reformTool.brushType;
break;
case FoundationDecorationMode.Paint:
brushType = 1;
break;
case FoundationDecorationMode.Decorate:
brushType = 2;
break;
case FoundationDecorationMode.Clear:
brushType = 7;
break;
default:
Warn($"unexpected brush type requested {PluginConfig.foundationDecorationMode.Value}");
break;
}
var consumedFoundation = 0;
var foundationUsedUp = false;
var outOfFoundationMessageShown = false;
for (var index = 0; index < maxReformCount; ++index)
{
if (PluginConfig.IsLatConstrained())
{
var forIndex = reformInfoProvider.GetForIndex(index);
if (PluginConfig.LatitudeOutOfBounds(forIndex.Lat))
continue;
}
var foundationNeeded = platformSystem.IsTerrainReformed(platformSystem.GetReformType(index)) ? 0 : 1;
if (foundationNeeded > 0 && PluginConfig.foundationConsumption.Value != OperationMode.FullCheat)
{
consumedFoundation += foundationNeeded;
var (_, successful) = StorageSystemManager.RemoveItems(REFORM_ID, foundationNeeded);
if (!successful)
{
if (PluginConfig.foundationConsumption.Value == OperationMode.Honest)
{
LogAndPopupMessage("Out of foundation, halting.");
foundationUsedUp = true;
break;
}
if (!outOfFoundationMessageShown)
{
outOfFoundationMessageShown = true;
LogAndPopupMessage("All foundation used, continuing");
}
}
}
platformSystem.SetReformType(index, brushType);
platformSystem.SetReformColor(index, actionBuild.reformTool.brushColor);
}
GameMain.mainPlayer.mecha.AddConsumptionStat(REFORM_ID, consumedFoundation, GameMain.mainPlayer.nearestFactory);
return foundationUsedUp;
}
}
}