mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add map marker display distance overrides and make a map marker module (#878)
## Minor features - Added a map marker module with display distance overrides (#847)
This commit is contained in:
commit
eebcdc1ccd
@ -36,7 +36,6 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
config.Base = new BaseModule()
|
config.Base = new BaseModule()
|
||||||
{
|
{
|
||||||
hasMapMarker = false,
|
|
||||||
surfaceGravity = 1,
|
surfaceGravity = 1,
|
||||||
surfaceSize = size,
|
surfaceSize = size,
|
||||||
gravityFallOff = GravityFallOff.InverseSquared
|
gravityFallOff = GravityFallOff.InverseSquared
|
||||||
@ -58,6 +57,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
enabled = false
|
enabled = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
config.MapMarker = new MapMarkerModule()
|
||||||
|
{
|
||||||
|
enabled = false
|
||||||
|
};
|
||||||
|
|
||||||
config.ProcGen = belt.procGen;
|
config.ProcGen = belt.procGen;
|
||||||
if (config.ProcGen == null)
|
if (config.ProcGen == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace NewHorizons.Builder.General
|
|||||||
var config = nhBody.Config;
|
var config = nhBody.Config;
|
||||||
|
|
||||||
astroObject.isVanilla = isVanilla;
|
astroObject.isVanilla = isVanilla;
|
||||||
astroObject.HideDisplayName = !config.Base.hasMapMarker;
|
astroObject.HideDisplayName = !config.MapMarker.enabled;
|
||||||
astroObject.invulnerableToSun = config.Base.invulnerableToSun;
|
astroObject.invulnerableToSun = config.Base.invulnerableToSun;
|
||||||
|
|
||||||
if (config.Orbit != null) astroObject.SetOrbitalParametersFromConfig(config.Orbit);
|
if (config.Orbit != null) astroObject.SetOrbitalParametersFromConfig(config.Orbit);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#region
|
#region
|
||||||
|
|
||||||
|
using NewHorizons.Components;
|
||||||
using NewHorizons.External.Configs;
|
using NewHorizons.External.Configs;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -12,7 +13,8 @@ namespace NewHorizons.Builder.General
|
|||||||
{
|
{
|
||||||
public static void Make(GameObject body, string name, PlanetConfig config)
|
public static void Make(GameObject body, string name, PlanetConfig config)
|
||||||
{
|
{
|
||||||
MapMarker mapMarker = body.AddComponent<MapMarker>();
|
var module = config.MapMarker;
|
||||||
|
NHMapMarker mapMarker = body.AddComponent<NHMapMarker>();
|
||||||
mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.name);
|
mapMarker._labelID = (UITextType)TranslationHandler.AddUI(config.name);
|
||||||
|
|
||||||
var markerType = MapMarker.MarkerType.Planet;
|
var markerType = MapMarker.MarkerType.Planet;
|
||||||
@ -37,6 +39,9 @@ namespace NewHorizons.Builder.General
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mapMarker._markerType = markerType;
|
mapMarker._markerType = markerType;
|
||||||
|
|
||||||
|
mapMarker.minDisplayDistanceOverride = module.minDisplayDistanceOverride;
|
||||||
|
mapMarker.maxDisplayDistanceOverride = module.maxDisplayDistanceOverride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
NewHorizons/Components/NHMapMarker.cs
Normal file
27
NewHorizons/Components/NHMapMarker.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace NewHorizons.Components
|
||||||
|
{
|
||||||
|
public class NHMapMarker : MapMarker
|
||||||
|
{
|
||||||
|
public float minDisplayDistanceOverride = -1;
|
||||||
|
public float maxDisplayDistanceOverride = -1;
|
||||||
|
|
||||||
|
public new void Awake()
|
||||||
|
{
|
||||||
|
base.Awake();
|
||||||
|
if (minDisplayDistanceOverride >= 0)
|
||||||
|
{
|
||||||
|
_minDisplayDistance = minDisplayDistanceOverride;
|
||||||
|
}
|
||||||
|
if (maxDisplayDistanceOverride >= 0)
|
||||||
|
{
|
||||||
|
_maxDisplayDistance = maxDisplayDistanceOverride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
NewHorizons/External/Configs/PlanetConfig.cs
vendored
8
NewHorizons/External/Configs/PlanetConfig.cs
vendored
@ -113,6 +113,11 @@ namespace NewHorizons.External.Configs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public LavaModule Lava;
|
public LavaModule Lava;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Map marker properties of this body
|
||||||
|
/// </summary>
|
||||||
|
public MapMarkerModule MapMarker;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Describes this Body's orbit (or lack there of)
|
/// Describes this Body's orbit (or lack there of)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -214,6 +219,7 @@ namespace NewHorizons.External.Configs
|
|||||||
if (Base == null) Base = new BaseModule();
|
if (Base == null) Base = new BaseModule();
|
||||||
if (Orbit == null) Orbit = new OrbitModule();
|
if (Orbit == null) Orbit = new OrbitModule();
|
||||||
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
|
if (ReferenceFrame == null) ReferenceFrame = new ReferenceFrameModule();
|
||||||
|
if (MapMarker == null) MapMarker = new MapMarkerModule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Validate()
|
public void Validate()
|
||||||
@ -307,6 +313,8 @@ namespace NewHorizons.External.Configs
|
|||||||
|
|
||||||
if (!Base.hasReferenceFrame) ReferenceFrame.enabled = false;
|
if (!Base.hasReferenceFrame) ReferenceFrame.enabled = false;
|
||||||
|
|
||||||
|
if (Base.hasMapMarker) MapMarker.enabled = true;
|
||||||
|
|
||||||
if (childrenToDestroy != null) removeChildren = childrenToDestroy;
|
if (childrenToDestroy != null) removeChildren = childrenToDestroy;
|
||||||
|
|
||||||
if (Base.cloakRadius != 0)
|
if (Base.cloakRadius != 0)
|
||||||
|
|||||||
8
NewHorizons/External/Modules/BaseModule.cs
vendored
8
NewHorizons/External/Modules/BaseModule.cs
vendored
@ -36,11 +36,6 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float groundSize;
|
public float groundSize;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If the body should have a marker on the map screen.
|
|
||||||
/// </summary>
|
|
||||||
public bool hasMapMarker;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Can this planet survive entering a star?
|
/// Can this planet survive entering a star?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -108,6 +103,9 @@ namespace NewHorizons.External.Modules
|
|||||||
[Obsolete("AmbientLight is deprecated, please use AmbientLightModule instead")]
|
[Obsolete("AmbientLight is deprecated, please use AmbientLightModule instead")]
|
||||||
public float ambientLight;
|
public float ambientLight;
|
||||||
|
|
||||||
|
[Obsolete("HasMapMarker is deprecated, please use MapMarkerModule instead")]
|
||||||
|
public bool hasMapMarker;
|
||||||
|
|
||||||
[Obsolete("HasReferenceFrame is deprecated, please use ReferenceModule instead")]
|
[Obsolete("HasReferenceFrame is deprecated, please use ReferenceModule instead")]
|
||||||
[DefaultValue(true)] public bool hasReferenceFrame = true;
|
[DefaultValue(true)] public bool hasReferenceFrame = true;
|
||||||
|
|
||||||
|
|||||||
25
NewHorizons/External/Modules/MapMarkerModule.cs
vendored
Normal file
25
NewHorizons/External/Modules/MapMarkerModule.cs
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using NewHorizons.External.SerializableData;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace NewHorizons.External.Modules
|
||||||
|
{
|
||||||
|
[JsonObject]
|
||||||
|
public class MapMarkerModule
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// If the body should have a marker on the map screen.
|
||||||
|
/// </summary>
|
||||||
|
public bool enabled;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Lowest distance away from the body that the marker can be shown. This is automatically set to 0 for all bodies except focal points where it is 5,000.
|
||||||
|
/// </summary>
|
||||||
|
public float minDisplayDistanceOverride = -1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Highest distance away from the body that the marker can be shown. For planets and focal points the automatic value is 50,000. Moons and planets in focal points are 5,000. Stars are 1E+10 (10,000,000,000).
|
||||||
|
/// </summary>
|
||||||
|
public float maxDisplayDistanceOverride = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -366,7 +366,7 @@ namespace NewHorizons.Handlers
|
|||||||
go.SetActive(false);
|
go.SetActive(false);
|
||||||
|
|
||||||
body.Config.Base.showMinimap = false;
|
body.Config.Base.showMinimap = false;
|
||||||
body.Config.Base.hasMapMarker = false;
|
body.Config.MapMarker.enabled = false;
|
||||||
|
|
||||||
const float sphereOfInfluence = 2000f;
|
const float sphereOfInfluence = 2000f;
|
||||||
|
|
||||||
@ -459,7 +459,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence, body.Config.ReferenceFrame);
|
RFVolumeBuilder.Make(go, owRigidBody, sphereOfInfluence, body.Config.ReferenceFrame);
|
||||||
|
|
||||||
if (body.Config.Base.hasMapMarker)
|
if (body.Config.MapMarker.enabled)
|
||||||
{
|
{
|
||||||
MarkerBuilder.Make(go, body.Config.name, body.Config);
|
MarkerBuilder.Make(go, body.Config.name, body.Config);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,10 @@
|
|||||||
"description": "Add lava to this planet",
|
"description": "Add lava to this planet",
|
||||||
"$ref": "#/definitions/LavaModule"
|
"$ref": "#/definitions/LavaModule"
|
||||||
},
|
},
|
||||||
|
"MapMarker": {
|
||||||
|
"description": "Map marker properties of this body",
|
||||||
|
"$ref": "#/definitions/MapMarkerModule"
|
||||||
|
},
|
||||||
"Orbit": {
|
"Orbit": {
|
||||||
"description": "Describes this Body's orbit (or lack there of)",
|
"description": "Describes this Body's orbit (or lack there of)",
|
||||||
"$ref": "#/definitions/OrbitModule"
|
"$ref": "#/definitions/OrbitModule"
|
||||||
@ -543,10 +547,6 @@
|
|||||||
"description": "Radius of a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as\n0.",
|
"description": "Radius of a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as\n0.",
|
||||||
"format": "float"
|
"format": "float"
|
||||||
},
|
},
|
||||||
"hasMapMarker": {
|
|
||||||
"type": "boolean",
|
|
||||||
"description": "If the body should have a marker on the map screen."
|
|
||||||
},
|
|
||||||
"invulnerableToSun": {
|
"invulnerableToSun": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Can this planet survive entering a star?"
|
"description": "Can this planet survive entering a star?"
|
||||||
@ -1022,6 +1022,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"MapMarkerModule": {
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false,
|
||||||
|
"properties": {
|
||||||
|
"enabled": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If the body should have a marker on the map screen."
|
||||||
|
},
|
||||||
|
"minDisplayDistanceOverride": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Lowest distance away from the body that the marker can be shown. This is automatically set to 0 for all bodies except focal points where it is 5,000.",
|
||||||
|
"format": "float"
|
||||||
|
},
|
||||||
|
"maxDisplayDistanceOverride": {
|
||||||
|
"type": "number",
|
||||||
|
"description": "Highest distance away from the body that the marker can be shown. For planets and focal points the automatic value is 50,000. Moons and planets in focal points are 5,000. Stars are 1E+10 (10,000,000,000).",
|
||||||
|
"format": "float"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"OrbitModule": {
|
"OrbitModule": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user