Skip to content

Commit 0901d9d

Browse files
committed
Add remove/restore slugs cheat
1 parent abfd817 commit 0901d9d

19 files changed

+102
-17
lines changed

SatisfactorySaveEditor/Cheats/ArmSlotsCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using SatisfactorySaveEditor.View;
33
using SatisfactorySaveEditor.ViewModel;
44
using SatisfactorySaveEditor.ViewModel.Property;
5+
6+
using SatisfactorySaveParser;
7+
58
using System.Windows;
69

710
namespace SatisfactorySaveEditor.Cheats
@@ -10,7 +13,7 @@ public class ArmSlotsCheat : ICheat
1013
{
1114
public string Name => "Set arm slot count...";
1215

13-
public bool Apply(SaveObjectModel rootItem)
16+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1417
{
1518
var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.UnlockSubsystem", false);
1619
if (gameState == null)

SatisfactorySaveEditor/Cheats/CouponChangerCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using SatisfactorySaveEditor.View;
33
using SatisfactorySaveEditor.ViewModel;
44
using SatisfactorySaveEditor.ViewModel.Property;
5+
6+
using SatisfactorySaveParser;
7+
58
using System;
69
using System.Windows;
710
using static System.Math;
@@ -22,7 +25,7 @@ private long pointsRequiredFromTicketCount(int tickets)
2225
return (long) (Pow(Ceiling(tickets / 3.0), 2) * 1000);
2326
}
2427

25-
public bool Apply(SaveObjectModel rootItem)
28+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
2629
{
2730
var sinkSubsystem = rootItem.FindChild("Persistent_Level:PersistentLevel.ResourceSinkSubsystem", false);
2831
if (sinkSubsystem == null)

SatisfactorySaveEditor/Cheats/CrateSummonCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class CrateSummonCheat : ICheat
1313
{
1414
public string Name => "Teleport crates to host player";
1515

16-
public bool Apply(SaveObjectModel rootItem)
16+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1717
{
1818
var cratesList = rootItem.FindChild("BP_Crate.BP_Crate_C", false);
1919
if (cratesList == null)

SatisfactorySaveEditor/Cheats/DeleteEnemiesCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ private static double Distance(Vector3 a, Vector3 b)
183183
return Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y) + (a.Z - b.Z) * (a.Z - b.Z));
184184
}
185185

186-
public bool Apply(SaveObjectModel rootItem)
186+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
187187
{
188188
var animalSpawners = rootItem.FindChild("BP_CreatureSpawner.BP_CreatureSpawner_C", false);
189189
if (animalSpawners == null)

SatisfactorySaveEditor/Cheats/EverythingBoxCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class EverythingBoxCheat : ICheat
1818
{
1919
public string Name => "Create crate with all items...";
2020

21-
public bool Apply(SaveObjectModel rootItem)
21+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
2222
{
2323

2424
var hostPlayerModel = rootItem.FindChild("Char_Player.Char_Player_C", false);

SatisfactorySaveEditor/Cheats/ICheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using SatisfactorySaveEditor.Model;
22

3+
using SatisfactorySaveParser;
4+
35
namespace SatisfactorySaveEditor.Cheats
46
{
57
public interface ICheat
@@ -10,7 +12,8 @@ public interface ICheat
1012
/// Activate the cheat
1113
/// </summary>
1214
/// <param name="rootItem">SaveObjectModel to apply the cheat on</param>
15+
/// <param name="saveGame"></param>
1316
/// <returns>true if succesfull and the SaveObjectModel was mutated, false on failure</returns>
14-
bool Apply(SaveObjectModel rootItem);
17+
bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame);
1518
}
1619
}

SatisfactorySaveEditor/Cheats/InventorySlotsCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using SatisfactorySaveEditor.View;
33
using SatisfactorySaveEditor.ViewModel;
44
using SatisfactorySaveEditor.ViewModel.Property;
5+
6+
using SatisfactorySaveParser;
7+
58
using System.Windows;
69

710
namespace SatisfactorySaveEditor.Cheats
@@ -10,7 +13,7 @@ public class InventorySlotsCheat : ICheat
1013
{
1114
public string Name => "Set inventory slot count...";
1215

13-
public bool Apply(SaveObjectModel rootItem)
16+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1417
{
1518
var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.UnlockSubsystem", false);
1619
if (gameState == null)

SatisfactorySaveEditor/Cheats/KillPlayersCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private int GetNextStorageID(int currentId, SaveObjectModel rootItem)
2020
return currentId;
2121
}
2222

23-
public bool Apply(SaveObjectModel rootItem)
23+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
2424
{
2525
var players = rootItem.FindChild("Char_Player.Char_Player_C", false);
2626
if (players == null)

SatisfactorySaveEditor/Cheats/MassDismantleCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private int MassDismantle(List<SaveObjectModel> objects, ArrayProperty inventory
181181
return count;
182182
}
183183

184-
public bool Apply(SaveObjectModel rootItem)
184+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
185185
{
186186
BuildPolygon();
187187
if (polygon.Length < 2)

SatisfactorySaveEditor/Cheats/NoCostCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using SatisfactorySaveEditor.Model;
22
using SatisfactorySaveEditor.ViewModel.Property;
3+
4+
using SatisfactorySaveParser;
5+
36
using System.Windows;
47

58
namespace SatisfactorySaveEditor.Cheats
@@ -8,7 +11,7 @@ public class NoCostCheat : ICheat
811
{
912
public string Name => "Toggle no build cost";
1013

11-
public bool Apply(SaveObjectModel rootItem)
14+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1215
{
1316
var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.BP_GameState_C_0", false);
1417
if (gameState == null)

SatisfactorySaveEditor/Cheats/NoPowerCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using SatisfactorySaveEditor.Model;
22
using SatisfactorySaveEditor.ViewModel.Property;
3+
4+
using SatisfactorySaveParser;
5+
36
using System.Windows;
47

58
namespace SatisfactorySaveEditor.Cheats
@@ -8,7 +11,7 @@ public class NoPowerCheat : ICheat
811
{
912
public string Name => "Toggle no power cost";
1013

11-
public bool Apply(SaveObjectModel rootItem)
14+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1215
{
1316
var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.BP_GameState_C_0", false);
1417
if (gameState == null)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using SatisfactorySaveEditor.Model;
8+
9+
using SatisfactorySaveParser;
10+
using SatisfactorySaveParser.Structures;
11+
12+
namespace SatisfactorySaveEditor.Cheats
13+
{
14+
public class RemoveSlugsCheat : ICheat
15+
{
16+
public string Name => "Remove slugs";
17+
18+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
19+
{
20+
var slugTypes = new[] {
21+
"/Game/FactoryGame/Resource/Environment/Crystal/BP_Crystal.BP_Crystal_C",
22+
"/Game/FactoryGame/Resource/Environment/Crystal/BP_Crystal_mk2.BP_Crystal_mk2_C",
23+
"/Game/FactoryGame/Resource/Environment/Crystal/BP_Crystal_mk3.BP_Crystal_mk3_C"
24+
};
25+
26+
var slugs = saveGame.Entries.Where(x => slugTypes.Contains(x.TypePath));
27+
28+
saveGame.CollectedObjects.RemoveAll(x => x.PathName.Contains("PersistentLevel.BP_Crystal"));
29+
saveGame.CollectedObjects.AddRange(slugs.Select(s => new ObjectReference
30+
{
31+
LevelName = s.RootObject,
32+
PathName = s.InstanceName
33+
}));
34+
35+
return true;
36+
}
37+
}
38+
}

SatisfactorySaveEditor/Cheats/ResearchUnlockCheat.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using SatisfactorySaveEditor.Model;
22
using SatisfactorySaveEditor.ViewModel.Property;
3+
4+
using SatisfactorySaveParser;
35
using SatisfactorySaveParser.Data;
46
using SatisfactorySaveParser.PropertyTypes;
57
using System.Linq;
@@ -11,7 +13,7 @@ public class ResearchUnlockCheat : ICheat
1113
{
1214
public string Name => "Unlock all research";
1315

14-
public bool Apply(SaveObjectModel rootItem)
16+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1517
{
1618
var tutorialManager = rootItem.FindChild("Persistent_Level:PersistentLevel.TutorialIntroManager", false);
1719
if (tutorialManager == null)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+

2+
using SatisfactorySaveEditor.Model;
3+
4+
using SatisfactorySaveParser;
5+
6+
namespace SatisfactorySaveEditor.Cheats
7+
{
8+
public class RestoreSlugsCheat : ICheat
9+
{
10+
public string Name => "Restore slugs";
11+
12+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
13+
{
14+
saveGame.CollectedObjects.RemoveAll(x => x.PathName.Contains("PersistentLevel.BP_Crystal"));
15+
return true;
16+
}
17+
}
18+
}

SatisfactorySaveEditor/Cheats/RevealMapCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using SatisfactorySaveEditor.View;
33
using SatisfactorySaveEditor.ViewModel;
44
using SatisfactorySaveEditor.ViewModel.Property;
5+
6+
using SatisfactorySaveParser;
7+
58
using System;
69
using System.Windows;
710

@@ -11,7 +14,7 @@ public class RevealMapCheat : ICheat
1114
{
1215
public string Name => "Uncover entire map";
1316

14-
public bool Apply(SaveObjectModel rootItem)
17+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1518
{
1619
var mapManager = rootItem.FindChild("Persistent_Level:PersistentLevel.MapManager", false);
1720
if (mapManager == null)

SatisfactorySaveEditor/Cheats/SpawnDoggoCheat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public SpawnDoggoCheat(DeleteEnemiesCheat deleter)
2626
deleteEnemiesCheat = deleter;
2727
}
2828

29-
public bool Apply(SaveObjectModel rootItem)
29+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
3030
{
3131
int doggocount = 1;
3232

SatisfactorySaveEditor/Cheats/UnlockMapCheat.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using SatisfactorySaveEditor.Model;
22
using SatisfactorySaveEditor.ViewModel.Property;
3+
4+
using SatisfactorySaveParser;
5+
36
using System.Windows;
47

58
namespace SatisfactorySaveEditor.Cheats
@@ -8,7 +11,7 @@ public class UnlockMapCheat : ICheat
811
{
912
public string Name => "Unlock map";
1013

11-
public bool Apply(SaveObjectModel rootItem)
14+
public bool Apply(SaveObjectModel rootItem, SatisfactorySave saveGame)
1215
{
1316
var gameState = rootItem.FindChild("Persistent_Level:PersistentLevel.UnlockSubsystem", false);
1417
if (gameState == null)

SatisfactorySaveEditor/SatisfactorySaveEditor.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@
127127
</Compile>
128128
<Compile Include="Cheats\NoPowerCheat.cs" />
129129
<Compile Include="Cheats\NoCostCheat.cs" />
130+
<Compile Include="Cheats\RemoveSlugsCheat.cs" />
130131
<Compile Include="Cheats\ResearchUnlockCheat.cs" />
132+
<Compile Include="Cheats\RestoreSlugsCheat.cs" />
131133
<Compile Include="Cheats\RevealMapCheat.cs" />
132134
<Compile Include="Cheats\SpawnDoggoCheat.cs" />
133135
<Compile Include="Cheats\UnlockMapCheat.cs" />

SatisfactorySaveEditor/ViewModel/MainViewModel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ public MainViewModel()
152152
CheatMenuItems.Add(new CrateSummonCheat());
153153
CheatMenuItems.Add(new NoCostCheat());
154154
CheatMenuItems.Add(new NoPowerCheat());
155-
155+
CheatMenuItems.Add(new RemoveSlugsCheat());
156+
CheatMenuItems.Add(new RestoreSlugsCheat());
156157

157158
TreeSelectCommand = new RelayCommand<SaveObjectModel>(SelectNode);
158159
JumpCommand = new RelayCommand<string>(Jump, CanJump);
@@ -248,7 +249,7 @@ private bool CanCheat(ICheat cheat)
248249
private void Cheat(ICheat cheat)
249250
{
250251
log.Info($"Applying cheat {cheat.Name}");
251-
if (cheat.Apply(rootItem))
252+
if (cheat.Apply(rootItem, saveGame))
252253
HasUnsavedChanges = true;
253254
}
254255

0 commit comments

Comments
 (0)