Skip to content

Commit

Permalink
Task Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiWorm0 committed Apr 11, 2021
1 parent 1fc0481 commit f3f4b3b
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 11 deletions.
74 changes: 70 additions & 4 deletions LevelImposter-BepInEx/Builders/TaskBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ class TaskBuilder : Builder
private PolusHandler polus;
private GameObject taskMgr;

private int nodeId = 0;
private int divertId = 0;
private readonly SystemTypes[] DIVERT_SYSTEMS = {
SystemTypes.Launchpad,
SystemTypes.MedBay,
SystemTypes.Comms,
SystemTypes.Office,
SystemTypes.Laboratory,
SystemTypes.Greenhouse,
SystemTypes.Admin,
SystemTypes.Cafeteria
};

public TaskBuilder(PolusHandler polus)
{
this.polus = polus;
Expand All @@ -34,6 +47,25 @@ public bool Build(MapAsset asset)
spriteRenderer.material = taskData.SpriteRenderer.material;
obj.layer = (int)Layer.ShortObjects;

// Target Room
SystemTypes target = 0;
if (asset.targetIds.Length > 0)
if (asset.targetIds[0] > 0)
target = ShipRoomBuilder.db[asset.targetIds[0]];

// Divert Power
if (asset.type == "task-divert2")
{
if (divertId >= DIVERT_SYSTEMS.Length)
{
LILogger.LogError("Hit Divert Power's Max System Limit");
return false;
}

target = DIVERT_SYSTEMS[divertId];
divertId++;
}

// Console
Console origConsole = taskData.GameObj.GetComponent<Console>();
Console console = obj.AddComponent<Console>();
Expand All @@ -45,7 +77,7 @@ public bool Build(MapAsset asset)
console.onlyFromBelow = true;
console.onlySameRoom = false;
console.usableDistance = 1;
console.Room = 0;
console.Room = target;
console.TaskTypes = origConsole.TaskTypes;
console.ValidTasks = origConsole.ValidTasks;
polus.Add(obj, asset);
Expand Down Expand Up @@ -100,6 +132,35 @@ public bool Build(MapAsset asset)
polus.shipStatus.MedScanner = medscan;
}

// Multipart Tasks
if (asset.type.StartsWith("task-waterwheel"))
{
int id = int.Parse(asset.type.Substring(15));
if (1 <= id && id <= 3)
console.ConsoleId = id - 1;
}
else if (asset.type.StartsWith("task-waterjug"))
{
int id = int.Parse(asset.type.Substring(13));
if (1 <= id && id <= 2)
{
console.ValidTasks = new UnhollowerBaseLib.Il2CppReferenceArray<TaskSet>(1);
console.ValidTasks[0] = new TaskSet();
console.ValidTasks[0].taskType = TaskTypes.ReplaceWaterJug;
console.ValidTasks[0].taskStep = new IntRange(id - 1, id - 1);
}
}
else if (asset.type == "task-node")
{
if (nodeId >= 6)
{
LILogger.LogError("Hit Weather Node's Max System Limit");
return false;
}

console.ConsoleId = nodeId;
}

// Task
if (!string.IsNullOrEmpty(taskData.BehaviorName))
{
Expand All @@ -112,17 +173,22 @@ public bool Build(MapAsset asset)
DivertPowerTask taskNode = task.Cast<DivertPowerTask>();
DivertPowerTask origNode = origTask.Cast<DivertPowerTask>();

taskNode.TargetSystem = origNode.TargetSystem;
taskNode.TargetSystem = target;
}
else if (asset.type.StartsWith("task-node"))
else if (asset.type == "task-node")
{
task = taskMgr.AddComponent<WeatherNodeTask>();

WeatherNodeTask taskNode = task.Cast<WeatherNodeTask>();
WeatherNodeTask origNode = origTask.Cast<WeatherNodeTask>();

taskNode.Stage2Prefab = origNode.Stage2Prefab;
taskNode.NodeId = origNode.NodeId;
taskNode.NodeId = nodeId;
nodeId++;
}
else if (asset.type.StartsWith("task-waterwheel"))
{
task = taskMgr.AddComponent<WaterWayTask>();
}
else
{
Expand Down
4 changes: 0 additions & 4 deletions LevelImposter-BepInEx/Builders/VentBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ public static void ConnectVents()
Vent vent = ventDb[targetData.Key];
long[] targets = targetData.Value;

LILogger.LogInfo(targetData.Key + ":" + targetData.Value[0]);
LILogger.LogInfo(targetData.Key + ":" + targetData.Value[1]);
LILogger.LogInfo(targetData.Key + ":" + targetData.Value[2]);

if (targets.Length < 3)
continue;
if (ventDb.ContainsKey(targets[0]))
Expand Down
22 changes: 19 additions & 3 deletions LevelImposter-BepInEx/Resources/AssetDB.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,30 @@
"GameObjName": "panel_fuel",
"BehaviorName": ""
},
"task-waterwheel": {
"task-waterwheel1": {
"Name": "Water Wheel",
"MapType": 2,
"SpriteRendererName": "panel_waterwheel",
"TaskType": 2,
"GameObjName": "panel_waterwheel",
"BehaviorName": "OpenWaterways"
},
"task-waterwheel2": {
"Name": "Water Wheel",
"MapType": 2,
"SpriteRendererName": "panel_waterwheel",
"TaskType": 2,
"GameObjName": "panel_waterwheel",
"BehaviorName": ""
},
"task-waterwheel3": {
"Name": "Water Wheel",
"MapType": 2,
"SpriteRendererName": "panel_waterwheel",
"TaskType": 2,
"GameObjName": "panel_waterwheel",
"BehaviorName": ""
},
"task-samples": {
"Name": "Inspect Samples",
"MapType": 2,
Expand All @@ -102,7 +118,7 @@
"SpriteRendererName": "panel_waterjug",
"TaskType": 2,
"GameObjName": "panel_waterjug",
"BehaviorName": "ReplaceWater"
"BehaviorName": ""
},
"task-node": {
"Name": "Weather Node",
Expand Down Expand Up @@ -262,7 +278,7 @@
"SpriteRendererName": "PlantConsole",
"TaskType": 2,
"GameObjName": "PlantConsole",
"BehaviorName": "WaterPlants"
"BehaviorName": ""
},
"task-crystal": {
"Name": "Assemble Artifact",
Expand Down

0 comments on commit f3f4b3b

Please sign in to comment.