Skip to content

Commit

Permalink
Merge pull request #459 from CWolfs/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
CWolfs authored Oct 27, 2021
2 parents 7e940ab + 2124e72 commit 6a07976
Show file tree
Hide file tree
Showing 29 changed files with 259 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{
"label": "copy (assets)",
"type": "shell",
"command": "copy-assets.sh"
"command": "./copy-assets.sh"
}
]
}
4 changes: 3 additions & 1 deletion config/Contracts/My_FP_Contract_ID_Example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"AdditionalLances": {
"Enable": true,
"EnemyLanceCount": 2,
"AllyLanceCount": 1
"EnemyLances": ["Damaged_Assault_Battle_Lance", "lancedef_vehicle_d10_dynamic_convoy"],
"AllyLanceCount": 1,
"AllyLances": ["Generic_Light_Battle_Lance"]
},
"ExtendedLances": {
"Enable": true,
Expand Down
9 changes: 1 addition & 8 deletions contractTypeBuilds/Blackout/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
},
"Team": "Player1",
"Guid": "76b654a6-4f2c-4a6f-86e6-d4cf868335fe", // Must be this Guid and the contract .json must have this specific. It's hardcoded in BT for PlayerLance.
"SpawnPoints": 4,
"SpawnPointGuids": [
"ec9d2280-ca9a-4d90-8a20-963d8a4c0a39",
"5df48a48-1840-49b0-84e9-126847053afa",
Expand Down Expand Up @@ -53,7 +52,6 @@
},
"Team": "Target",
"Guid": "c13c63a1-95ba-460a-af07-4096cfc6ff06",
"SpawnPoints": 4,
"SpawnPointGuids": [
"2407c766-aa2e-440b-8118-a70b1a4679ed",
"625aa0ff-2c5b-48a4-becb-621c1bbaccd3",
Expand Down Expand Up @@ -101,7 +99,6 @@
"Team": "NeutralToAll",
"Guid": "223fd528-c333-4367-883c-a817acf24360",
"Tags": ["turrets_1b"],
"SpawnPoints": 4,
"SpawnPointGuids": [
"6826832c-83d5-4287-b349-33008dc1fac5",
"0329e03f-9d9c-4a5d-99df-ccdb6afe2bb5",
Expand Down Expand Up @@ -135,7 +132,6 @@
"Team": "NeutralToAll",
"Guid": "98fc619a-28f5-4a29-ae7f-5f42576cd0bc",
"Tags": ["turrets_3x"],
"SpawnPoints": 3,
"SpawnPointGuids": [
"38538181-1208-4cd1-bad9-7469f2cb9478",
"6552d0c2-b705-49b8-a4f8-5205e537db05",
Expand Down Expand Up @@ -287,7 +283,6 @@
},
"Team": "Target",
"Guid": "b60da416-495c-474d-8b58-1678966835df", // Must match the spawner guids in the contract .json
"SpawnPoints": 4,
"SpawnPointGuids": [
"9405bf60-db6c-4ae9-95b0-3c26a6e9fd88",
"8f1a8422-917c-47c4-ada9-01eaa94499ee",
Expand Down Expand Up @@ -448,7 +443,6 @@
},
"Team": "Target",
"Guid": "f5714221-5fc6-41e5-a369-c8aa2b6d1bcf", // Must match the spawner guids in the contract .json
"SpawnPoints": 4,
"SpawnPointGuids": [
"ec9b2fd0-15a0-488c-8190-64cea5cce242",
"993b100b-dc76-44c2-85ac-e50beb0dc9ed",
Expand Down Expand Up @@ -567,7 +561,6 @@
},
"Team": "Target",
"Guid": "f426f0dc-969d-477d-81a9-d02f9e1eff79", // Must match the spawner guids in the contract .json
"SpawnPoints": 4,
"SpawnPointGuids": [
"6cd3107e-0f9d-4809-ab8c-fb30faf4cd80",
"14c58a13-96a6-4f91-a1e5-47b5d02b81d1",
Expand Down Expand Up @@ -803,7 +796,7 @@
]
},
{
"Name": "Trigger_Emable_Chunk_Post_1c",
"Name": "Trigger_Enable_Chunk_Post_1c",
"TriggerOn": "OnObjectiveUpdated",
"Description": "Complete the destroy lance objective",
"Conditionals": [
Expand Down
2 changes: 1 addition & 1 deletion contractTypeBuilds/Blackout/mountainhold_lunar.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"Path": "Chunks[?(@.Name == 'Chunk_Alpha_Base_Turrets')].Children[?(@.Name == 'Spawner_Alpha_Turrets')]",
"Action": "ObjectMerge",
"Value": {
"Name": "Spawner_Alpha_Turredts",
"Name": "Spawner_Alpha_Turrets",
"Position": {
"Type": "World",
"Value": { "x": -700, "y": 0, "z": 160 }
Expand Down
2 changes: 0 additions & 2 deletions contractTypeBuilds/DuoDuel/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"Team": "Player1",
"Guid": "76b654a6-4f2c-4a6f-86e6-d4cf868335fe", // Must be this Guid and the contract .json must have this specific. It's hardcoded in BT for PlayerLance.
"SpawnPoints": 2,
"SpawnPointGuids": [
"ec9d2280-ca9a-4d90-8a20-963d8a4c0a39",
"5df48a48-1840-49b0-84e9-126847053afa"
Expand Down Expand Up @@ -52,7 +51,6 @@
},
"Team": "Target",
"Guid": "f426f0dc-969d-477d-81a9-d02f9e1eff79", // Must match the spawner guids in the contract .json
"SpawnPoints": 2,
"SpawnPointGuids": [
"6cd3107e-0f9d-4809-ab8c-fb30faf4cd80",
"14c58a13-96a6-4f91-a1e5-47b5d02b81d1"
Expand Down
2 changes: 0 additions & 2 deletions contractTypeBuilds/SoloDuel/common.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"Team": "Player1",
"Guid": "76b654a6-4f2c-4a6f-86e6-d4cf868335fe", // Must be this Guid and the contract .json must have this specific. It's hardcoded in BT for PlayerLance.
"SpawnPoints": 1,
"SpawnPointGuids": ["ec9d2280-ca9a-4d90-8a20-963d8a4c0a39"], // Must match the unit spawn guids in the contract .json
"SpawnType": "Instant" // Leopard, DropPod, Instant
}
Expand Down Expand Up @@ -49,7 +48,6 @@
},
"Team": "Target",
"Guid": "f426f0dc-969d-477d-81a9-d02f9e1eff79", // Must match the spawner guids in the contract .json
"SpawnPoints": 1,
"SpawnPointGuids": ["6cd3107e-0f9d-4809-ab8c-fb30faf4cd80"], // Must match the unit spawn guids in the contract .json
"SpawnType": "Instant", // Leopard, DropPod, Instant
"AI": [
Expand Down
18 changes: 5 additions & 13 deletions overrides/contracts/duoduel/DuoDuel_FestiveCouple.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,11 @@
"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
}
]
"name": "Chunk_DisablePilotDeath",
"encounterChunk": {
"EncounterObjectGuid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea"
},
"enableChunkFromContract": true
}
],
"objectiveList": [
Expand Down
18 changes: 5 additions & 13 deletions overrides/contracts/duoduel/DuoDuel_YearlyTussle.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,11 @@
"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
}
]
"name": "Chunk_DisablePilotDeath",
"encounterChunk": {
"EncounterObjectGuid": "953a5930-06d0-4a2d-9840-e9a70c2a63ea"
},
"enableChunkFromContract": true
}
],
"cameraFocusHelperList": [
Expand Down
2 changes: 2 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"MatchAllyLanceCountToEnemy": false,
"DropWeightInfluence": {
"Enable": false,
"EnemySpawnInfluenceMax": 0.9,
"AllySpawnInfluenceMax": 0.9,
"EnemySpawnInfluencePerHalfSkullAbove": 0.1,
"AllySpawnInfluencePerHalfSkullAbove": -0.1,
"EnemySpawnInfluencePerHalfSkullBelow": -0.1,
Expand Down
14 changes: 12 additions & 2 deletions src/Core/ContractTypeBuilders/NodeBuilders/DialogueBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using MissionControl.Trigger;
using MissionControl.Rules;
using MissionControl.EncounterFactories;
using MissionControl.Messages;

using Newtonsoft.Json.Linq;

Expand Down Expand Up @@ -42,9 +43,18 @@ public override void Build() {
private void BuildSimpleDialogue() {
DialogueFactory.CreateDialogLogic(this.parent, this.name, this.guid, this.showOnlyOnce);

MessageCenterMessageType messageType;
if (this.trigger != null) {
MessageCenterMessageType triggerMessageType = (MessageCenterMessageType)Enum.Parse(typeof(MessageCenterMessageType), this.trigger);
DialogTrigger dialogueTrigger = new DialogTrigger(triggerMessageType, this.guid);
if (!Enum.TryParse(this.trigger, out messageType)) {
MessageTypes customMessageType;
if (!Enum.TryParse(this.trigger, out customMessageType)) {
Main.Logger.LogError("[DialogueBuilder] Invalid 'Trigger' provided.");
} else {
messageType = (MessageCenterMessageType)customMessageType;
}
}

DialogTrigger dialogueTrigger = new DialogTrigger(messageType, this.guid);
dialogueTrigger.Run();
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Data/Deserialisation/MLanceOverride.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public MLanceOverride(MLanceOverrideData lanceOverrideData) {
}

public MLanceOverride(LanceDef lanceDef) {
this.LanceKey = lanceDef.Description.Id;
this.lanceDefId = lanceDef.Description.Id;
this.lanceTagSet = lanceDef.LanceTags;

Expand All @@ -48,6 +49,7 @@ public MLanceOverride(LanceDef lanceDef) {
}

public MLanceOverride(LanceOverride lanceOverride) {
this.LanceKey = lanceOverride.lanceDefId;
this.lanceDefId = lanceOverride.lanceDefId;
this.lanceTagSet = new TagSet(lanceOverride.lanceTagSet);
this.lanceExcludedTagSet = new TagSet(lanceOverride.lanceExcludedTagSet);
Expand All @@ -59,6 +61,7 @@ public MLanceOverride(LanceOverride lanceOverride) {
public MLanceOverride(string lanceDefId, TagSet lanceTagSet, TagSet lanceExcludedTagSet, TagSet spawnEffectTags,
int lanceDifficultyAdjustment, List<UnitSpawnPointOverride> unitSpawnOverrides) {

this.LanceKey = lanceDefId;
this.lanceDefId = lanceDefId;
this.lanceTagSet = lanceTagSet;
this.lanceExcludedTagSet = lanceExcludedTagSet;
Expand Down
10 changes: 2 additions & 8 deletions src/Core/Data/SceneManipulationLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,8 @@ public Vector3 GetRandomPositionWithinBounds(Vector3 target, float maxDistance)
}

public Vector3 GetRandomPositionWithinBounds() {
MissionControl EncounterManager = MissionControl.Instance;
GameObject chunkBoundaryRect = MissionControl.Instance.EncounterLayerGameObject.transform.Find("Chunk_EncounterBoundary")?.gameObject;
if (chunkBoundaryRect == null) {
chunkBoundaryRect = MissionControl.Instance.EncounterLayerGameObject.transform.Find("Gen_EncounterBoundary").gameObject;
}
GameObject boundary = chunkBoundaryRect.transform.Find("EncounterBoundaryRect").gameObject;
EncounterBoundaryChunkGameLogic chunkBoundary = chunkBoundaryRect.GetComponent<EncounterBoundaryChunkGameLogic>();
EncounterBoundaryRectGameLogic boundaryLogic = boundary.GetComponent<EncounterBoundaryRectGameLogic>();
EncounterBoundaryChunkGameLogic chunkBoundary = MissionControl.Instance.EncounterLayerGameObject.GetComponentInChildren<EncounterBoundaryChunkGameLogic>();
EncounterBoundaryRectGameLogic boundaryLogic = chunkBoundary.GetComponentInChildren<EncounterBoundaryRectGameLogic>();
Rect boundaryRec = chunkBoundary.GetEncounterBoundaryRectBounds();

Vector3 randomRecPosition = boundaryRec.GetRandomPosition();
Expand Down
62 changes: 39 additions & 23 deletions src/Core/DataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,30 @@ private void LoadSettingsOverrides() {

private void LoadCustomContractTypeBuilds() {
foreach (string directory in Directory.GetDirectories($"{ModDirectory}/contractTypeBuilds/")) {
string contractTypeBuildCommonSource = File.ReadAllText($"{directory}/common.jsonc");
JObject contractTypeCommonBuild = JsonConvert.DeserializeObject<JObject>(contractTypeBuildCommonSource, serialiserSettings);
string contractTypeName = (string)contractTypeCommonBuild["Key"];
Main.LogDebug($"[DataManager.LoadCustomContractTypeBuilds] Loading contract type build '{contractTypeName}'");

Dictionary<string, JObject> contractTypeMapBuilds = new Dictionary<string, JObject>();
AvailableCustomContractTypeBuilds.Add(contractTypeCommonBuild["Key"].ToString(), contractTypeMapBuilds);

foreach (string file in Directory.GetFiles(directory, "*.json*", SearchOption.AllDirectories)) {
string contractTypeBuildMapSource = File.ReadAllText(file);
JObject contractTypeMapBuild = JsonConvert.DeserializeObject<JObject>(contractTypeBuildMapSource, serialiserSettings);
string fileName = Path.GetFileNameWithoutExtension(file.Substring(file.LastIndexOf("/")));

if (fileName == "common" || contractTypeMapBuild.ContainsKey("EncounterLayerId")) {
string encounterLayerId = (fileName == "common") ? fileName : (string)contractTypeMapBuild["EncounterLayerId"];
Main.LogDebug($"[DataManager.LoadCustomContractTypeBuilds] Loaded contract type map build '{contractTypeName}/{fileName}' with encounterLayerId '{encounterLayerId}'");
contractTypeMapBuilds.Add(encounterLayerId, contractTypeMapBuild);
} else {
Main.Logger.LogError($"[DataManager.LoadCustomContractTypeBuilds] Unable to load contract type map build file '{fileName}' for contract type '{contractTypeName}' because no 'EncounterLayerId' exists");
if (File.Exists($"{directory}/common.jsonc")) {
string contractTypeBuildCommonSource = File.ReadAllText($"{directory}/common.jsonc");
JObject contractTypeCommonBuild = JsonConvert.DeserializeObject<JObject>(contractTypeBuildCommonSource, serialiserSettings);
string contractTypeName = (string)contractTypeCommonBuild["Key"];
Main.LogDebug($"[DataManager.LoadCustomContractTypeBuilds] Loading contract type build '{contractTypeName}'");

Dictionary<string, JObject> contractTypeMapBuilds = new Dictionary<string, JObject>();
AvailableCustomContractTypeBuilds.Add(contractTypeCommonBuild["Key"].ToString(), contractTypeMapBuilds);

foreach (string file in Directory.GetFiles(directory, "*.json*", SearchOption.AllDirectories)) {
string contractTypeBuildMapSource = File.ReadAllText(file);
JObject contractTypeMapBuild = JsonConvert.DeserializeObject<JObject>(contractTypeBuildMapSource, serialiserSettings);
string fileName = Path.GetFileNameWithoutExtension(file.Substring(file.LastIndexOf("/")));

if (fileName == "common" || contractTypeMapBuild.ContainsKey("EncounterLayerId")) {
string encounterLayerId = (fileName == "common") ? fileName : (string)contractTypeMapBuild["EncounterLayerId"];
Main.LogDebug($"[DataManager.LoadCustomContractTypeBuilds] Loaded contract type map build '{contractTypeName}/{fileName}' with encounterLayerId '{encounterLayerId}'");
contractTypeMapBuilds.Add(encounterLayerId, contractTypeMapBuild);
} else {
Main.Logger.LogError($"[DataManager.LoadCustomContractTypeBuilds] Unable to load contract type map build file '{fileName}' for contract type '{contractTypeName}' because no 'EncounterLayerId' exists");
}
}
} else {
Main.Logger.LogWarning($"[DataManager.LoadCustomContractTypeBuilds] Directory exists for contract type but no common.jsonc exists. Probably bad data or WIP contract type build - {directory}");
}
}
}
Expand Down Expand Up @@ -227,7 +231,7 @@ private void LoadLanceOverrides() {
}
*/
} else {
Main.Logger.LogError($"[DataManager] Json format is wrong. Read the documentation on the lance override format.");
Main.Logger.LogError($"[DataManager] Json format is wrong for file '{file}'. Read the documentation on the lance override format.");
}
}
}
Expand Down Expand Up @@ -255,18 +259,30 @@ public MLanceOverride GetLanceOverride(string key) {

if (LanceOverrides.ContainsKey(key)) {
Main.Logger.Log($"[GetLanceOverride] Found a lance override for '{key}'");
return LanceOverrides[key];
return LanceOverrides[key].Copy();
}

LanceDef lanceDef = null;
lanceDefs.TryGet(key, out lanceDef);
if (lanceDef != null) {
MLanceOverride lanceOverride = new MLanceOverride(lanceDef);
LanceOverrides.Add(lanceOverride.lanceDefId, lanceOverride);
Main.Logger.Log($"[GetLanceOverride] Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty - 0' and no 'spawnEffectTags'");
return lanceOverride;
Main.Logger.Log($"[GetLanceOverride] Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty' of '0' and no 'spawnEffectTags'");
return lanceOverride.Copy();
} else {
Main.Logger.Log($"[GetLanceOverride] No loaded LanceDef was found for '{key}'. Attempting to load the LanceDef.");
lanceDef = BattleTechResourceLoader.LoadDefFromId<LanceDef>(key, BattleTechResourceType.LanceDef);
DataManager.Instance.RequestResourcesAndProcess(BattleTechResourceType.LanceDef, key);

if (lanceDef != null) {
MLanceOverride lanceOverride = new MLanceOverride(lanceDef);
LanceOverrides.Add(lanceOverride.lanceDefId, lanceOverride);
Main.Logger.Log($"[GetLanceOverride] Load succeeded. Found a lance def for '{key}', creating and caching a lance override for it. Using defaults of 'adjustedDifficulty' of '0' and no 'spawnEffectTags'");
return lanceOverride.Copy();
}
}

Main.Logger.LogError($"[GetLanceOverride] No MC Lance or LanceDef found with key '{key}'. This is a case sensitive search.'");
return null;
}

Expand Down
11 changes: 8 additions & 3 deletions src/Core/EncounterDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,22 @@ public void SetMountOnPosition(GameObject target, string mountTargetPath) {
Main.LogDebug($"[EncounterDataManager.SetMountOnPositions] Target '{mountTargetPath}' found with '{go.name}'");
}

Vector3 pos = go.transform.position;
Collider col = go.GetComponentInChildren<Collider>();
GameObject copyGo = GameObject.Instantiate(go);
copyGo.transform.position = go.transform.position;
Vector3 pos = copyGo.transform.position;
Collider col = copyGo.GetComponentInChildren<Collider>();
Vector4 colliderPos = col.transform.position;

RaycastHit[] hits = Physics.RaycastAll(new Vector3(pos.x, pos.y + 500f, pos.z), go.transform.TransformDirection(Vector3.down), 1000f);
RaycastHit[] hits = Physics.RaycastAll(new Vector3(colliderPos.x, colliderPos.y + 500f, colliderPos.z), go.transform.TransformDirection(Vector3.down), 1000f);
foreach (RaycastHit hit1 in hits) {
if (hit1.collider.gameObject.name == col.gameObject.name) {
pos.y = hit1.point.y;
break;
}
}

target.transform.position = pos;
GameObject.Destroy(copyGo);
}

public void GenerateEncounterLayerBuildingData() {
Expand Down
Loading

0 comments on commit 6a07976

Please sign in to comment.