-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMod.cs
More file actions
51 lines (42 loc) · 1.98 KB
/
Mod.cs
File metadata and controls
51 lines (42 loc) · 1.98 KB
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
global using Mod = StylishDebug.Mod;
namespace StylishDebug;
public sealed class Mod : Verse.Mod
{
public static Mod Instance { get; private set; }
public Mod(ModContentPack content) : base(content)
{
Instance = this;
}
[DebugAction("General", "Spawn style category things.", allowedGameStates = AllowedGameStates.PlayingOnMap)]
public static void SpawnStyleCategoryThings()
{
var list = new List<DebugMenuOption>();
foreach(var styleCategory in DefDatabase<StyleCategoryDef>.AllDefsListForReading)
{
var styleCategoryName = styleCategory.defName;
list.Add(new(styleCategoryName, DebugMenuOptionMode.Action, () =>
{
Find.Targeter.BeginTargeting(new TargetingParameters() { canTargetLocations = true }, target =>
{
var cell = target.Cell;
var map = Find.CurrentMap;
for (var i = 0; i < styleCategory.thingDefStyles.Count; i++)
{
var thingStyle = styleCategory.thingDefStyles[i];
var thingDef = thingStyle.thingDef;
if (thingDef is null) Log.Error($"Thing definition is null at element {i} in {styleCategoryName}.");
var styleDef = thingStyle.styleDef;
if (styleDef is null) Log.Error($"Style definition is null at element {i} in {styleCategoryName}.");
if (thingDef is null)
continue;
var thing = GenSpawn.Spawn(thingDef, cell, map);
Log.Message($"Spawning thing '{thingDef.defName}' as '{thing.LabelCap}' with style '{styleDef?.defName}'.");
if(styleDef is not null)
thing.SetStyleDef(styleDef);
}
});
}));
}
Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
}
}