Skip to content

Commit

Permalink
1.8.5 (#494)
Browse files Browse the repository at this point in the history
## Improvements
- `Water` module now has `buoyancy` and `density` values.
- Add `remoteTriggerPrereqCondition` to only show a remote dialogue
trigger once a condition has been met.

## Bug fixes
- Heightmap error logging will properly deal with empty strings now.
- Stop RemoteDialogueTrigger from softlocking you if you disable its
CharacterDialogueTree.
  • Loading branch information
xen-42 committed Jan 19, 2023
2 parents a2b47d3 + 086ca65 commit d1d9935
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 13 deletions.
12 changes: 6 additions & 6 deletions NewHorizons/Builder/Body/HeightMapBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ public static GameObject Make(GameObject planetGO, Sector sector, HeightMapModul
Texture2D heightMap, textureMap, emissionMap;
try
{
if (module.heightMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.heightMap)))
if (!string.IsNullOrEmpty(module.heightMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.heightMap)))
{
Logger.LogError($"Bad path for {planetGO.name} heightMap: {module.heightMap} couldn't be found.");
module.heightMap = null;
}
if (module.textureMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.textureMap)))
if (!string.IsNullOrEmpty(module.textureMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.textureMap)))
{
Logger.LogError($"Bad path for {planetGO.name} textureMap: {module.textureMap} couldn't be found.");
module.textureMap = null;
}
if (module.emissionMap != null && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.emissionMap)))
if (!string.IsNullOrEmpty(module.emissionMap) && !File.Exists(Path.Combine(mod.ModHelper.Manifest.ModFolderPath, module.emissionMap)))
{
Logger.LogError($"Bad path for {planetGO.name} emissionMap: {module.emissionMap} couldn't be found.");
module.emissionMap = null;
}

if (module.heightMap == null)
if (string.IsNullOrEmpty(module.heightMap))
{
heightMap = Texture2D.whiteTexture;
}
Expand All @@ -52,7 +52,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, HeightMapModul
heightMap = ImageUtilities.GetTexture(mod, module.heightMap);
}

if (module.textureMap == null)
if (string.IsNullOrEmpty(module.textureMap))
{
textureMap = Texture2D.whiteTexture;
}
Expand All @@ -61,7 +61,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, HeightMapModul
textureMap = ImageUtilities.GetTexture(mod, module.textureMap);
}

if (module.emissionMap == null)
if (string.IsNullOrEmpty(module.emissionMap))
{
emissionMap = Texture2D.blackTexture;
}
Expand Down
2 changes: 2 additions & 0 deletions NewHorizons/Builder/Body/WaterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, Wate
fluidVolume._attachedBody = rb;
fluidVolume._triggerVolume = buoyancyTriggerVolume;
fluidVolume._radius = waterSize;
fluidVolume._buoyancyDensity = module.buoyancy;
fluidVolume._density = module.density;
fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume");

var fogGO = GameObject.Instantiate(_oceanFog, waterGO.transform);
Expand Down
4 changes: 3 additions & 1 deletion NewHorizons/Builder/Props/DialogueBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planet
priority = 1,
dialogue = dialogue,
prereqConditionType = RemoteDialogueTrigger.MultiConditionType.AND,
prereqConditions = new string[]{ },
// Base game never uses more than one condition anyone so we'll keep it simple
prereqConditions = string.IsNullOrEmpty(info.remoteTriggerPrereqCondition) ? new string[]{ } : new string[] { info.remoteTriggerPrereqCondition },
// Just set your enter conditions in XML instead of complicating it with this
onTriggerEnterConditions = new string[]{ }
}
};
Expand Down
11 changes: 7 additions & 4 deletions NewHorizons/Builder/Props/ScatterBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ private static void MakeScatter(GameObject go, PropModule.ScatterInfo[] scatterI
{
try
{
// TODO copy what heightmap builder does eventually
heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.heightMap);
// defer remove texture to next frame
Delay.FireOnNextUpdate(() => Object.Destroy(heightMapTexture));
if (!string.IsNullOrEmpty(heightMap.heightMap))
{
// TODO copy what heightmap builder does eventually
heightMapTexture = ImageUtilities.GetTexture(mod, heightMap.heightMap);
// defer remove texture to next frame
Delay.FireOnNextUpdate(() => Object.Destroy(heightMapTexture));
}
}
catch (Exception) { }
if (heightMapTexture == null)
Expand Down
5 changes: 5 additions & 0 deletions NewHorizons/External/Modules/PropModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,11 @@ public class DialogueInfo
/// </summary>
public float remoteTriggerRadius;

/// <summary>
/// If setting up a remote trigger volume, this conditions must be met for it to trigger. Note: This is a dialogue condition, not a persistent condition.
/// </summary>
public string remoteTriggerPrereqCondition;

/// <summary>
/// Relative path to the xml file defining the dialogue.
/// </summary>
Expand Down
13 changes: 12 additions & 1 deletion NewHorizons/External/Modules/VariableSize/WaterModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NewHorizons.Utility;
using NewHorizons.Utility;
using Newtonsoft.Json;
using System.ComponentModel;

namespace NewHorizons.External.Modules.VariableSize
{
Expand All @@ -11,6 +12,16 @@ public class WaterModule : VariableSizeModule
/// </summary>
public float size;

/// <summary>
/// Density of the water sphere. The higher the density, the harder it is to go through this fluid.
/// </summary>
[DefaultValue(1.2f)] public float density = 1.2f;

/// <summary>
/// Buoyancy density of the water sphere
/// </summary>
[DefaultValue(1f)] public float buoyancy = 1f;

/// <summary>
/// Tint of the water
/// </summary>
Expand Down
44 changes: 44 additions & 0 deletions NewHorizons/Patches/RemoteDialogueTriggerPatches.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using HarmonyLib;
using NewHorizons.Utility;
using System;

namespace NewHorizons.Patches
{
/// <summary>
/// Should fix a bug where disabled a CharacterDialogueTree makes its related RemoteDialogueTriggers softlock your game
/// </summary>
[HarmonyPatch]
public static class RemoteDialogueTriggerPatches
{
private static bool _wasLastDialogueInactive = false;

[HarmonyPostfix]
[HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnTriggerEnter))]
public static void RemoteDialogueTrigger_OnTriggerEnter(RemoteDialogueTrigger __instance)
{
if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue?.gameObject != null)
{
_wasLastDialogueInactive = __instance._activeRemoteDialogue.gameObject.activeInHierarchy;
if (!_wasLastDialogueInactive)
{
__instance._activeRemoteDialogue.gameObject.SetActive(true);
}
}
}

[HarmonyPrefix]
[HarmonyPatch(typeof(RemoteDialogueTrigger), nameof(RemoteDialogueTrigger.OnEndConversation))]
public static void RemoteDialogueTrigger_OnEndConversation(RemoteDialogueTrigger __instance)
{
if (__instance._inRemoteDialogue && __instance._activeRemoteDialogue != null)
{
if (_wasLastDialogueInactive)
{
__instance._activeRemoteDialogue.gameObject.SetActive(false);
}
}

_wasLastDialogueInactive = false;
}
}
}
16 changes: 16 additions & 0 deletions NewHorizons/Schemas/body_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,10 @@
"description": "The radius of the remote trigger volume.",
"format": "float"
},
"remoteTriggerPrereqCondition": {
"type": "string",
"description": "If setting up a remote trigger volume, this conditions must be met for it to trigger. Note: This is a dialogue condition, not a persistent condition."
},
"xmlFile": {
"type": "string",
"description": "Relative path to the xml file defining the dialogue."
Expand Down Expand Up @@ -2573,6 +2577,18 @@
"description": "Size of the water sphere",
"format": "float"
},
"density": {
"type": "number",
"description": "Density of the water sphere. The higher the density, the harder it is to go through this fluid.",
"format": "float",
"default": 1.2
},
"buoyancy": {
"type": "number",
"description": "Buoyancy density of the water sphere",
"format": "float",
"default": 1.0
},
"tint": {
"description": "Tint of the water",
"$ref": "#/definitions/MColor"
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.8.3",
"version": "1.8.5",
"owmlVersion": "2.9.0",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_Randomizer" ],
Expand Down

0 comments on commit d1d9935

Please sign in to comment.