Skip to content

Commit

Permalink
Merge pull request #417 from CWolfs/develop
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
CWolfs authored Sep 1, 2020
2 parents 10243e9 + 38914d0 commit a48153f
Show file tree
Hide file tree
Showing 24 changed files with 347 additions and 54 deletions.
20 changes: 0 additions & 20 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,6 @@
"args": ["build", "D:/Modding/Battletech/MissionControl/src/MissionControl.csproj"],
"problemMatcher": "$msCompile"
},
/*
{
"label": "copy",
"type": "shell",
"command": "cp",
"args": [
"D:/Modding/Battletech/MissionControl/src/bin/Debug/net471/MissionControl.dll",
"'D:/Program Files (x86)/Steam/steamapps/common/BATTLETECH/Mods/MissionControl'"
]
},
{
"label": "copy (hbs)",
"type": "shell",
"command": "cp",
"args": [
"D:/Modding/Battletech/MissionControl/src/bin/Debug/net471/MissionControl.dll",
"'C:/Users/Rich/Documents/my games/BattleTech/mods/HBS/MissionControl'"
]
},
*/
{
"label": "copy (assets)",
"type": "shell",
Expand Down
4 changes: 2 additions & 2 deletions contractTypeBuilds/Blackout/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@
"Tags": ["turrets_1b"]
},
{
"Type": "SetLanceEvasionTicksByTag", // Prevent evasion helping them in a trap
"Amount": 0,
"Type": "ModifyLanceEvasionTicksByTag", // Reduce evasion to indicate a trap
"Amount": -3,
"Tags": ["Player 1"]
}
]
Expand Down
15 changes: 15 additions & 0 deletions contractTypeBuilds/DuoDuel/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@
"TargetGuid2": "f426f0dc-969d-477d-81a9-d02f9e1eff79" // Enemy spawner
}
]
},
{
"Name": "Chunk_DisablePilotDeath",
"Type": "Chunk",
"SubType": "Container",
"ControlledByContract": true,
"Guid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea",
"Children": [
{
"Name": "CombatState_DisablePilotDeath",
"Type": "CombatState",
"SubType": "DisablePilotDeath",
"DisableInjuries": false
}
]
}
]
}
15 changes: 15 additions & 0 deletions contractTypeBuilds/SoloDuel/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@
"TargetGuid2": "f426f0dc-969d-477d-81a9-d02f9e1eff79" // Enemy spawner
}
]
},
{
"Name": "Chunk_DisablePilotDeath",
"Type": "Chunk",
"SubType": "Container",
"ControlledByContract": true,
"Guid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea",
"Children": [
{
"Name": "CombatState_DisablePilotDeath",
"Type": "CombatState",
"SubType": "DisablePilotDeath",
"DisableInjuries": false
}
]
}
]
}
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Mission Control",
"Enabled": true,
"Version": "1.1.2",
"Version": "1.1.3",
"Description": "A HBS BattleTech mod that adds custom contract types and varies the encounter specifics such as encounter boundary size, spawn locations, lance numbers and objectives",
"Author": "CWolf",
"Contact": "[email protected]",
Expand Down
15 changes: 15 additions & 0 deletions overrides/contracts/duoduel/DuoDuel_FestiveCouple.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@
"isPrimary": true,
"forPlayer": "Player1",
"objectiveGuids": ["a0b9c5b2-c594-4c5a-be1d-028a51c51519"]
},
{
"Name": "Chunk_DisablePilotDeath",
"Type": "Chunk",
"SubType": "Container",
"ControlledByContract": true,
"Guid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea",
"Children": [
{
"Name": "CombatState_DisablePilotDeath",
"Type": "CombatState",
"SubType": "DisablePilotDeath",
"DisableInjuries": false
}
]
}
],
"objectiveList": [
Expand Down
15 changes: 15 additions & 0 deletions overrides/contracts/duoduel/DuoDuel_YearlyTussle.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,21 @@
"EncounterObjectGuid": "ed007c52-f4cb-4bfc-842a-a50454d8a82a"
},
"enableChunkFromContract": true
},
{
"Name": "Chunk_DisablePilotDeath",
"Type": "Chunk",
"SubType": "Container",
"ControlledByContract": true,
"Guid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea",
"Children": [
{
"Name": "CombatState_DisablePilotDeath",
"Type": "CombatState",
"SubType": "DisablePilotDeath",
"DisableInjuries": false
}
]
}
],
"cameraFocusHelperList": [
Expand Down
7 changes: 7 additions & 0 deletions overrides/contracts/soloduel/SoloDuel_AllEyesOn.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@
"EncounterObjectGuid": "ed007c52-f4cb-4bfc-842a-a50454d8a82a"
},
"enableChunkFromContract": true
},
{
"name": "Chunk_DisablePilotDeath",
"encounterChunk": {
"EncounterObjectGuid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea"
},
"enableChunkFromContract": true
}
],
"cameraFocusHelperList": [
Expand Down
7 changes: 7 additions & 0 deletions overrides/contracts/soloduel/SoloDuel_LifeLesson.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
"isPrimary": true,
"forPlayer": "Player1",
"objectiveGuids": ["a0b9c5b2-c594-4c5a-be1d-028a51c51519"]
},
{
"name": "Chunk_DisablePilotDeath",
"encounterChunk": {
"EncounterObjectGuid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea"
},
"enableChunkFromContract": true
}
],
"objectiveList": [
Expand Down
1 change: 1 addition & 0 deletions src/Core/ContractTypeBuilders/ContractTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ private void BuildNode(GameObject parent, JObject child) {
case "Dialogue": nodeBuilder = new DialogueBuilder(this, parent, child); break;
case "SwapPlacement": nodeBuilder = new PlacementBuilder(this, parent, child); break;
case "ContractEdit": nodeBuilder = new ContractEditBuilder(this, parent, child); break;
case "CombatState": nodeBuilder = new CombatStateBuilder(this, parent, child); break;
default: break;
}

Expand Down
41 changes: 41 additions & 0 deletions src/Core/ContractTypeBuilders/NodeBuilders/CombatStateBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using UnityEngine;

using Newtonsoft.Json.Linq;

using System;

using MissionControl.EncounterFactories;
using MissionControl.LogicComponents.CombatStates;

namespace MissionControl.ContractTypeBuilders {
public class CombatStateBuilder : NodeBuilder {
private ContractTypeBuilder contractTypeBuilder;
private JObject state;

private GameObject parent;
private string name;
private string subType;

public CombatStateBuilder(ContractTypeBuilder contractTypeBuilder, GameObject parent, JObject state) {
this.contractTypeBuilder = contractTypeBuilder;
this.state = state;

this.parent = parent;
this.name = state["Name"].ToString();
this.subType = state["SubType"].ToString();
}

public override void Build() {
switch (subType) {
case "DisablePilotDeath": BuildDisablePilotDeath(); break;
default: Main.LogDebug($"[CombatStateBuilder.{contractTypeBuilder.ContractTypeKey}] No support for sub-type '{subType}'. Check for spelling mistakes."); break;
}
}

private void BuildDisablePilotDeath() {
bool disableInjuries = state.ContainsKey("DisableInjuries") ? (bool)state["DisableInjuries"] : false;

DisablePilotDeathGameLogic disablePilotDeathGameLogic = CombatStateFactory.CreateDisablePilotDeath(this.parent, this.name, Guid.NewGuid().ToString(), disableInjuries);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ContractEditBuilder(ContractTypeBuilder contractTypeBuilder, GameObject p
public override void Build() {
switch (subType) {
case "SwapTeamFactions": BuildSwapFactions(); break;
default: Main.LogDebug($"[RegionBuilder.{contractTypeBuilder.ContractTypeKey}] No support for sub-type '{subType}'. Check for spelling mistakes."); break;
default: Main.LogDebug($"[ContractEditBuilder.{contractTypeBuilder.ContractTypeKey}] No support for sub-type '{subType}'. Check for spelling mistakes."); break;
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/Core/ContractTypeBuilders/NodeBuilders/SpawnBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class SpawnBuilder : NodeBuilder {
private JObject rotation;
private string team;
private string guid;
private int spawnPoints;
private List<string> spawnPointGuids;
private bool preciseSpawnPoints;
private JObject mountOnTargets;
Expand All @@ -43,7 +42,6 @@ public SpawnBuilder(ContractTypeBuilder contractTypeBuilder, GameObject parent,
this.subType = spawner["SubType"].ToString();
this.team = spawner["Team"].ToString();
this.guid = spawner["Guid"].ToString();
this.spawnPoints = (int)spawner["SpawnPoints"];
this.spawnPointGuids = spawner["SpawnPointGuids"].ToObject<List<string>>();
this.preciseSpawnPoints = spawner.ContainsKey("PreciseSpawnPoints") ? (bool)spawner["PreciseSpawnPoints"] : false;
this.mountOnTargets = spawner.ContainsKey("MountOn") ? (JObject)spawner["MountOn"] : null;
Expand All @@ -54,7 +52,7 @@ public SpawnBuilder(ContractTypeBuilder contractTypeBuilder, GameObject parent,
this.rotation = spawner.ContainsKey("Rotation") ? (JObject)spawner["Rotation"] : null;
this.aiOrdersArray = spawner.ContainsKey("AI") ? (JArray)spawner["AI"] : null;
this.alertLanceOnSpawn = spawner.ContainsKey("AlertLanceOnSpawn") ? (bool)spawner["AlertLanceOnSpawn"] : false;
this.defaultDetectionRange = spawner.ContainsKey("DefaultDetectionRange") ? (int)spawner["DefaultDetectionRange"] : 0;
this.defaultDetectionRange = spawner.ContainsKey("DefaultDetectionRange") ? (int)spawner["DefaultDetectionRange"] : 200;
this.tags = spawner.ContainsKey("Tags") ? spawner["Tags"].ToObject<List<string>>() : null;

if (this.aiOrdersArray != null) {
Expand Down
17 changes: 15 additions & 2 deletions src/Core/ContractTypeBuilders/ResultsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private void BuildResult(JObject result) {
case "CompleteObjective": BuildCompleteObjectiveResult(result); break;
case "SetTemporaryUnitPhaseInitiativeByTag": BuildSetTemporaryUnitPhaseInitiativeByTagResult(result); break;
case "SetLanceEvasionTicksByTag": BuildSetLanceEvasionTicksByTagResult(result); break;
case "ModifyLanceEvasionTicksByTag": BuildModifyLanceEvasionTicksByTagResult(result); break;
case "CameraFocus": BuildCameraFocusResult(result); break;
case "DestroyBuildingsAtLanceSpawns": BuildDestroyBuildingsAtLanceSpawnsResult(result); break;
case "Delay": BuildDelayResult(result); break;
Expand Down Expand Up @@ -234,7 +235,7 @@ private void BuildCompleteObjectiveResult(JObject resultObject) {
}

private void BuildSetTemporaryUnitPhaseInitiativeByTagResult(JObject resultObject) {
Main.LogDebug("[BuildSetTemporaryUnitPhaseInitiativeByTagResult] Building 'SetTemporaryUnitPhaseInitiativeByTagResult' result");
Main.LogDebug("[BuildSetTemporaryUnitPhaseInitiativeByTagResult] Building 'SetTemporaryUnitPhaseInitiativeByTag' result");
int initiative = (int)resultObject["Initiative"];
string[] tags = ((JArray)resultObject["Tags"]).ToObject<string[]>();

Expand All @@ -246,7 +247,7 @@ private void BuildSetTemporaryUnitPhaseInitiativeByTagResult(JObject resultObjec
}

private void BuildSetLanceEvasionTicksByTagResult(JObject resultObject) {
Main.LogDebug("[BuildSetLanceEvasionTicksByTagResult] Building 'SetLanceEvasionTicksByTagResult' result");
Main.LogDebug("[BuildSetLanceEvasionTicksByTagResult] Building 'SetLanceEvasionTicksByTag' result");
int amount = (int)resultObject["Amount"];
string[] tags = ((JArray)resultObject["Tags"]).ToObject<string[]>();

Expand All @@ -257,6 +258,18 @@ private void BuildSetLanceEvasionTicksByTagResult(JObject resultObject) {
results.Add(result);
}

private void BuildModifyLanceEvasionTicksByTagResult(JObject resultObject) {
Main.LogDebug("[BuildModifyLanceEvasionTicksByTagResult] Building 'ModifyLanceEvasionTicksByTag' result");
int amount = (int)resultObject["Amount"];
string[] tags = ((JArray)resultObject["Tags"]).ToObject<string[]>();

ModifyLanceEvasionTicksByTagResult result = ScriptableObject.CreateInstance<ModifyLanceEvasionTicksByTagResult>();
result.Amount = amount;
result.Tags = tags;

results.Add(result);
}

private void BuildCameraFocusResult(JObject resultObject) {
Main.LogDebug("[BuildCameraFocusResult] Building 'CameraFocus' result");
string guid = resultObject["EncounterGuid"].ToString();
Expand Down
1 change: 1 addition & 0 deletions src/Core/Data/MCTaggedObjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ public enum MCTaggedObjectType {
SwapPlacement = 100,
SwapTeamFaction = 101,
ActivateDialogue = 102,
DisablePilotDeath = 103,
};
}
25 changes: 25 additions & 0 deletions src/Core/EncounterFactories/CombatStateFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;

using MissionControl.LogicComponents.CombatStates;

namespace MissionControl.EncounterFactories {
public class CombatStateFactory {
private static GameObject CreateGameObject(GameObject parent, string name = null) {
GameObject go = new GameObject((name == null) ? "CombatState" : name);
go.transform.parent = parent.transform;
go.transform.localPosition = Vector3.zero;

return go;
}

public static DisablePilotDeathGameLogic CreateDisablePilotDeath(GameObject parent, string name, string guid, bool disableInjuries) {
GameObject disablePilotDeathGameObject = CreateGameObject(parent, name);

DisablePilotDeathGameLogic disablePilotDeathGameLogic = disablePilotDeathGameObject.AddComponent<DisablePilotDeathGameLogic>();
disablePilotDeathGameLogic.encounterObjectGuid = guid;
disablePilotDeathGameLogic.DisableInjuries = disableInjuries;

return disablePilotDeathGameLogic;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public override void Run(RunPayload payload) {
GameObject objectGo = objectGos[i];
string objectKey = objectKeys[i];
string orientationTargetKey = orientationTargetKeys[i];
Main.Logger.Log($"[SpawnObjectsAroundTarget] Attemping for '{objectGo.name}' with key '{objectKey}'");
Main.Logger.LogDebug($"[SpawnObjectsAroundTarget] Attempting for '{objectGo.name}' with key '{objectKey}'");
GameObject orientationTarget = orientationTargets[orientationTargetKey];
Main.Logger.Log($"[SpawnObjectsAroundTarget] Using orientation target key '{orientationTargetKey}' and Go name '{orientationTarget.transform.name}'");
Main.Logger.LogDebug($"[SpawnObjectsAroundTarget] Using orientation target key '{orientationTargetKey}' and Go name '{orientationTarget.transform.name}'");

SaveSpawnPosition(objectGo);

Expand Down
35 changes: 35 additions & 0 deletions src/Core/EncounterResults/ModifyLanceEvasionTicksByTagResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using BattleTech;
using BattleTech.Framework;

using HBS.Collections;

using Harmony;

using System;
using System.Collections.Generic;

namespace MissionControl.Result {
public class ModifyLanceEvasionTicksByTagResult : EncounterResult {
public string[] Tags { get; set; }
public int Amount { get; set; }

public override void Trigger(MessageCenterMessage inMessage, string triggeringName) {
Main.LogDebug($"[ModifyLanceEvasionTicksByTagResult] Modifying evasion by '{Amount}' on combatants with tags '{String.Concat(Tags)}'");
List<ICombatant> combatants = ObjectiveGameLogic.GetTaggedCombatants(UnityGameInstance.BattleTechGame.Combat, new TagSet(Tags));

Main.LogDebug($"[ModifyLanceEvasionTicksByTagResult] Found'{combatants.Count}' combatants");

foreach (ICombatant combatant in combatants) {
if (combatant is AbstractActor) {
AbstractActor actor = combatant as AbstractActor;

actor.EvasivePipsCurrent += Amount;
if (actor.EvasivePipsCurrent < 0) actor.EvasivePipsCurrent = 0;

AccessTools.Property(typeof(AbstractActor), "EvasivePipsTotal").SetValue(actor, actor.EvasivePipsCurrent, null);
UnityGameInstance.BattleTechGame.Combat.MessageCenter.PublishMessage(new EvasiveChangedMessage(actor.GUID, actor.EvasivePipsCurrent));
}
}
}
}
}
Loading

0 comments on commit a48153f

Please sign in to comment.