Merge branch 'dev' into eye-of-the-universe

This commit is contained in:
Noah Pilarski 2022-10-10 20:34:26 -04:00
commit 6cf04ec904
12 changed files with 218 additions and 63 deletions

View File

@ -28,15 +28,15 @@ namespace NewHorizons.Builder.Atmosphere
var innerRadius = config.Base.surfaceSize;
GameObject volumesGO = new GameObject("Volumes");
var volumesGO = new GameObject("Volumes");
volumesGO.SetActive(false);
volumesGO.transform.parent = planetGO.transform;
GameObject rulesetGO = new GameObject("Ruleset");
var rulesetGO = new GameObject("Ruleset");
rulesetGO.SetActive(false);
rulesetGO.transform.parent = volumesGO.transform;
SphereShape SS = rulesetGO.AddComponent<SphereShape>();
var SS = rulesetGO.AddComponent<SphereShape>();
SS.SetCollisionMode(Shape.CollisionMode.Volume);
SS.SetLayer(Shape.Layer.Sector);
SS.layerMask = -1;
@ -45,7 +45,7 @@ namespace NewHorizons.Builder.Atmosphere
rulesetGO.AddComponent<OWTriggerVolume>();
PlanetoidRuleset PR = rulesetGO.AddComponent<PlanetoidRuleset>();
var PR = rulesetGO.AddComponent<PlanetoidRuleset>();
PR._altitudeFloor = innerRadius;
PR._altitudeCeiling = sphereOfInfluence;
PR._shuttleLandingRadius = sphereOfInfluence;
@ -54,7 +54,7 @@ namespace NewHorizons.Builder.Atmosphere
rulesetGO.AddComponent<AntiTravelMusicRuleset>();
EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>();
var ER = rulesetGO.AddComponent<EffectRuleset>();
ER._type = EffectRuleset.BubbleType.Underwater;
ER._material = _gdMaterial;
@ -66,32 +66,6 @@ namespace NewHorizons.Builder.Atmosphere
}
ER._cloudMaterial = cloudMaterial;
if (config.Base.zeroGravityRadius != 0)
{
var zeroGObject = new GameObject("ZeroGVolume");
zeroGObject.transform.parent = volumesGO.transform;
zeroGObject.transform.localPosition = Vector3.zero;
zeroGObject.transform.localScale = Vector3.one * config.Base.zeroGravityRadius;
zeroGObject.layer = LayerMask.NameToLayer("BasicEffectVolume");
var sphereCollider = zeroGObject.AddComponent<SphereCollider>();
sphereCollider.radius = 1;
sphereCollider.isTrigger = true;
var owCollider = zeroGObject.AddComponent<OWCollider>();
owCollider._parentBody = owrb;
owCollider._collider = sphereCollider;
var triggerVolume = zeroGObject.AddComponent<OWTriggerVolume>();
triggerVolume._owCollider = owCollider;
var zeroGVolume = zeroGObject.AddComponent<ZeroGVolume>();
zeroGVolume._attachedBody = owrb;
zeroGVolume._triggerVolume = triggerVolume;
zeroGVolume._inheritable = true;
zeroGVolume._priority = 1;
}
volumesGO.transform.position = planetGO.transform.position;
rulesetGO.SetActive(true);
volumesGO.SetActive(true);

View File

@ -50,7 +50,7 @@ namespace NewHorizons.Builder.General
gravityVolume._upperSurfaceRadius = config.Base.surfaceSize;
gravityVolume._lowerSurfaceRadius = 0;
gravityVolume._layer = 3;
gravityVolume._priority = 0;
gravityVolume._priority = config.Base.gravityVolumePriority;
gravityVolume._alignmentPriority = 0;
gravityVolume._surfaceAcceleration = config.Base.surfaceGravity;
gravityVolume._inheritable = false;

View File

@ -21,18 +21,47 @@ namespace NewHorizons.Builder.Props
var dialogue = MakeConversationZone(go, sector, info, mod.ModHelper);
RemoteDialogueTrigger remoteTrigger = null;
if (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0) remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, dialogue);
if (info.remoteTriggerPosition != null || info.remoteTriggerRadius != 0)
{
remoteTrigger = MakeRemoteDialogueTrigger(go, sector, info, dialogue);
}
if (!string.IsNullOrEmpty(info.rename))
{
dialogue.name = info.rename;
if (remoteTrigger != null)
{
remoteTrigger.name = $"{info.rename}_{remoteTrigger.name}";
}
}
if (!string.IsNullOrEmpty(info.parentPath))
{
var parent = go.transform.Find(info.parentPath);
if (parent != null)
{
dialogue.transform.parent = parent;
if (remoteTrigger != null)
{
remoteTrigger.transform.parent = parent;
}
}
}
// Make the character look at the player
// Useful for dialogue replacement
if (!string.IsNullOrEmpty(info.pathToAnimController)) MakePlayerTrackingZone(go, dialogue, info);
// Overrides parent path for dialogue
if (!string.IsNullOrEmpty(info.pathToAnimController))
{
MakePlayerTrackingZone(go, dialogue, info);
}
return (dialogue, remoteTrigger);
}
private static RemoteDialogueTrigger MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue)
{
GameObject conversationTrigger = new GameObject("ConversationTrigger");
var conversationTrigger = new GameObject("ConversationTrigger");
conversationTrigger.SetActive(false);
var remoteDialogueTrigger = conversationTrigger.AddComponent<RemoteDialogueTrigger>();
@ -64,7 +93,7 @@ namespace NewHorizons.Builder.Props
private static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod)
{
GameObject conversationZone = new GameObject("ConversationZone");
var conversationZone = new GameObject("ConversationZone");
conversationZone.SetActive(false);
conversationZone.layer = LayerMask.NameToLayer("Interactible");
@ -88,10 +117,11 @@ namespace NewHorizons.Builder.Props
var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>();
var xml = File.ReadAllText(Path.Combine(mod.Manifest.ModFolderPath, info.xmlFile));
var text = new TextAsset(xml);
var text = new TextAsset(xml)
{
// Text assets need a name to be used with VoiceMod
text.name = Path.GetFileNameWithoutExtension(info.xmlFile);
name = Path.GetFileNameWithoutExtension(info.xmlFile)
};
dialogueTree.SetTextXml(text);
AddTranslation(xml);
@ -146,7 +176,7 @@ namespace NewHorizons.Builder.Props
if (info.lookAtRadius > 0)
{
GameObject playerTrackingZone = new GameObject("PlayerTrackingZone");
var playerTrackingZone = new GameObject("PlayerTrackingZone");
playerTrackingZone.SetActive(false);
playerTrackingZone.layer = LayerMask.NameToLayer("BasicEffectVolume");
@ -194,22 +224,22 @@ namespace NewHorizons.Builder.Props
private static void AddTranslation(string xml)
{
XmlDocument xmlDocument = new XmlDocument();
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xml);
XmlNode xmlNode = xmlDocument.SelectSingleNode("DialogueTree");
XmlNodeList xmlNodeList = xmlNode.SelectNodes("DialogueNode");
var xmlNode = xmlDocument.SelectSingleNode("DialogueTree");
var xmlNodeList = xmlNode.SelectNodes("DialogueNode");
string characterName = xmlNode.SelectSingleNode("NameField").InnerText;
TranslationHandler.AddDialogue(characterName);
foreach (object obj in xmlNodeList)
{
XmlNode xmlNode2 = (XmlNode)obj;
var xmlNode2 = (XmlNode)obj;
var name = xmlNode2.SelectSingleNode("Name").InnerText;
XmlNodeList xmlText = xmlNode2.SelectNodes("Dialogue/Page");
var xmlText = xmlNode2.SelectNodes("Dialogue/Page");
foreach (object page in xmlText)
{
XmlNode pageData = (XmlNode)page;
var pageData = (XmlNode)page;
var text = pageData.InnerText;
// The text is trimmed in DialogueText constructor (_listTextBlocks), so we also need to trim it for the key
TranslationHandler.AddDialogue(text, true, name);
@ -218,7 +248,7 @@ namespace NewHorizons.Builder.Props
xmlText = xmlNode2.SelectNodes("DialogueOptionsList/DialogueOption/Text");
foreach (object option in xmlText)
{
XmlNode optionData = (XmlNode)option;
var optionData = (XmlNode)option;
var text = optionData.InnerText;
// The text is trimmed in CharacterDialogueTree.LoadXml, so we also need to trim it for the key
TranslationHandler.AddDialogue(text, true, characterName, name);

View File

@ -170,8 +170,7 @@ namespace NewHorizons.Builder.Props
slideCollectionContainer.slideCollection = slideCollection;
// Idk why but it wants reveals to be comma delimited not a list
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
LinkShipLogFacts(info, slideCollectionContainer);
StreamingHandler.SetUpStreaming(slideReelObj, sector);
@ -284,8 +283,7 @@ namespace NewHorizons.Builder.Props
target.slideCollection = g.AddComponent<MindSlideCollection>();
target.slideCollection._slideCollectionContainer = slideCollectionContainer;
// Idk why but it wants reveals to be comma delimited not a list
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
LinkShipLogFacts(info, slideCollectionContainer);
g.SetActive(true);
@ -370,7 +368,8 @@ namespace NewHorizons.Builder.Props
var mindSlideCollection = standingTorch.AddComponent<MindSlideCollection>();
mindSlideCollection._slideCollectionContainer = slideCollectionContainer;
// Make sure that these slides play when the player wanders into the beam
LinkShipLogFacts(info, slideCollectionContainer);
mindSlideProjector.SetMindSlideCollection(mindSlideCollection);
standingTorch.SetActive(true);
@ -450,6 +449,14 @@ namespace NewHorizons.Builder.Props
Slide.WriteModules(modules, ref slide._modulesList, ref slide._modulesData, ref slide.lengths);
}
private static void LinkShipLogFacts(ProjectionInfo info, SlideCollectionContainer slideCollectionContainer)
{
// Idk why but it wants reveals to be comma delimited not a list
if (info.reveals != null) slideCollectionContainer._shipLogOnComplete = string.Join(",", info.reveals);
// Don't use null value, NRE in SlideCollectionContainer.Initialize
slideCollectionContainer._playWithShipLogFacts = info.playWithShipLogFacts ?? Array.Empty<string>();
}
}
public class VisionTorchTarget : MonoBehaviour

View File

@ -0,0 +1,17 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class PriorityVolumeBuilder
{
public static TVolume Make<TVolume>(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info) where TVolume : PriorityVolume
{
var volume = VolumeBuilder.Make<TVolume>(planetGO, sector, info);
volume.SetPriority(info.priority);
return volume;
}
}
}

View File

@ -78,6 +78,13 @@ namespace NewHorizons.Builder.Volumes
VolumeBuilder.Make<InsulatingVolume>(go, sector, insulatingVolume);
}
}
if (config.Volumes.zeroGravityVolumes != null)
{
foreach (var zeroGravityVolume in config.Volumes.zeroGravityVolumes)
{
ZeroGVolumeBuilder.Make(go, sector, zeroGravityVolume);
}
}
}
}
}

View File

@ -0,0 +1,17 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class ZeroGVolumeBuilder
{
public static ZeroGVolume Make(GameObject planetGO, Sector sector, VolumesModule.PriorityVolumeInfo info)
{
var volume = PriorityVolumeBuilder.Make<ZeroGVolume>(planetGO, sector, info);
volume._inheritable = true;
return volume;
}
}
}

View File

@ -416,6 +416,20 @@ namespace NewHorizons.External.Configs
}
}
if (Base.zeroGravityRadius != 0f)
{
Volumes ??= new VolumesModule();
Volumes.zeroGravityVolumes ??= new VolumesModule.PriorityVolumeInfo[0];
Volumes.zeroGravityVolumes = Volumes.zeroGravityVolumes.Append(new VolumesModule.PriorityVolumeInfo()
{
priority = 1,
rename = "ZeroGVolume",
radius = Base.zeroGravityRadius,
parentPath = "Volumes"
}).ToArray();
}
// So that old mods still have shock effects
if (ShockEffect == null && Star == null && name != "Sun" && name != "EyeOfTheUniverse" && FocalPoint == null)
{

View File

@ -82,9 +82,9 @@ namespace NewHorizons.External.Modules
public float surfaceSize;
/// <summary>
/// Radius of the zero gravity volume. This will make it so no gravity from any planet will affect you. Useful for satellites.
/// Optional. You can force this planet's gravity to be felt over other gravity/zero-gravity sources by increasing this number.
/// </summary>
public float zeroGravityRadius;
public int gravityVolumePriority;
#region Obsolete
@ -115,6 +115,9 @@ namespace NewHorizons.External.Modules
[Obsolete("SphereOfInfluence is deprecated, please use soiOverride instead")]
public float sphereOfInfluence;
[Obsolete("zeroGravityRadius is deprecated, please use Volumes->ZeroGravityVolumes instead")]
public float zeroGravityRadius;
#endregion Obsolete
}
}

View File

@ -450,6 +450,16 @@ namespace NewHorizons.External.Modules
/// Relative path to the xml file defining the dialogue.
/// </summary>
public string xmlFile;
/// <summary>
/// Optionally rename the dialogue object. The remote trigger volume will be renamed to have this as a prefix.
/// </summary>
public string rename;
/// <summary>
/// Optionally set the parent object that the dialogue and remote trigger will be attached to
/// </summary>
public string parentPath;
}
[JsonObject]
@ -617,10 +627,18 @@ namespace NewHorizons.External.Modules
public MVector3 position;
/// <summary>
/// The ship log entries revealed after finishing this slide reel.
/// The ship log facts revealed after finishing this slide reel.
/// </summary>
public string[] reveals;
/// <summary>
/// The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows).
/// You should probably include facts from `reveals` here.
/// If you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only
/// rumor facts because an entry with revealed explore facts doesn't display rumor facts.
/// </summary>
public string[] playWithShipLogFacts;
/// <summary>
/// The rotation of this slideshow.
/// </summary>
@ -712,7 +730,7 @@ namespace NewHorizons.External.Modules
// SlideShipLogEntryModule
/// <summary>
/// Ship log entry revealed when viewing this slide
/// Ship log fact revealed when viewing this slide
/// </summary>
public string reveal;

View File

@ -55,6 +55,12 @@ namespace NewHorizons.External.Modules
/// </summary>
public VolumeInfo[] reverbVolumes;
/// <summary>
/// Add zero-gravity volumes to this planet.
/// Good for surrounding planets which are using a static position to stop the player being pulled away.
/// </summary>
public PriorityVolumeInfo[] zeroGravityVolumes;
[JsonObject]
public class VolumeInfo
{
@ -79,6 +85,17 @@ namespace NewHorizons.External.Modules
public string rename;
}
[JsonObject]
public class PriorityVolumeInfo : VolumeInfo
{
/// <summary>
/// The priority for this volume's effects to be applied.
/// Ex, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity.
/// </summary>
[DefaultValue(1)]
public int priority = 1;
}
[JsonObject]
public class RevealVolumeInfo : VolumeInfo
{

View File

@ -497,10 +497,10 @@
"description": "A scale height used for a number of things. Should be the approximate radius of the body.",
"format": "float"
},
"zeroGravityRadius": {
"type": "number",
"description": "Radius of the zero gravity volume. This will make it so no gravity from any planet will affect you. Useful for satellites.",
"format": "float"
"gravityVolumePriority": {
"type": "integer",
"description": "Optional. You can force this planet's gravity to be felt over other gravity/zero-gravity sources by increasing this number.",
"format": "int32"
}
}
},
@ -1105,6 +1105,14 @@
"xmlFile": {
"type": "string",
"description": "Relative path to the xml file defining the dialogue."
},
"rename": {
"type": "string",
"description": "Optionally rename the dialogue object. The remote trigger volume will be renamed to have this as a prefix."
},
"parentPath": {
"type": "string",
"description": "Optionally set the parent object that the dialogue and remote trigger will be attached to"
}
}
},
@ -1425,7 +1433,14 @@
},
"reveals": {
"type": "array",
"description": "The ship log entries revealed after finishing this slide reel.",
"description": "The ship log facts revealed after finishing this slide reel.",
"items": {
"type": "string"
}
},
"playWithShipLogFacts": {
"type": "array",
"description": "The ship log facts that make the reel play when they are displayed in the computer (by selecting entries or arrows).\nYou should probably include facts from `reveals` here.\nIf you only specify a rumor fact, then it would only play in its ship log entry if this has revealed only\nrumor facts because an entry with revealed explore facts doesn't display rumor facts.",
"items": {
"type": "string"
}
@ -1504,7 +1519,7 @@
},
"reveal": {
"type": "string",
"description": "Ship log entry revealed when viewing this slide"
"description": "Ship log fact revealed when viewing this slide"
},
"spotIntensityMod": {
"type": "number",
@ -2473,6 +2488,13 @@
"items": {
"$ref": "#/definitions/VolumeInfo"
}
},
"zeroGravityVolumes": {
"type": "array",
"description": "Add zero-gravity volumes to this planet. \nGood for surrounding planets which are using a static position to stop the player being pulled away.",
"items": {
"$ref": "#/definitions/PriorityVolumeInfo"
}
}
}
},
@ -2794,6 +2816,35 @@
"observe",
"snapshot"
]
},
"PriorityVolumeInfo": {
"type": "object",
"additionalProperties": false,
"properties": {
"position": {
"description": "The location of this volume. Optional (will default to 0,0,0).",
"$ref": "#/definitions/MVector3"
},
"radius": {
"type": "number",
"description": "The radius of this volume.",
"format": "float"
},
"parentPath": {
"type": "string",
"description": "The relative path from the planet to the parent of this object. Optional (will default to the root sector)."
},
"rename": {
"type": "string",
"description": "An optional rename of this volume."
},
"priority": {
"type": "integer",
"description": "The priority for this volume's effects to be applied. \nEx, a player in a gravity volume with priority 0, and zero-gravity volume with priority 1, will feel zero gravity.",
"format": "int32",
"default": 1
}
}
}
},
"$docs": {