Fix meteors + document

This commit is contained in:
Nick 2022-05-02 02:09:36 -04:00
parent 2e7028be66
commit 54f341d16e
6 changed files with 80 additions and 13 deletions

View File

@ -49,9 +49,9 @@ namespace NewHorizons.Builder.Props
TornadoBuilder.Make(go, sector, tornadoInfo, config.Atmosphere?.Cloud != null);
}
}
if (config.Props.Volcanos != null)
if (config.Props.Volcanoes != null)
{
foreach (var volcanoInfo in config.Props.Volcanos)
foreach (var volcanoInfo in config.Props.Volcanoes)
{
VolcanoBuilder.Make(go, sector, volcanoInfo);
}

View File

@ -17,6 +17,7 @@ namespace NewHorizons.Builder.Props
var launcherGO = prefab.InstantiateInactive();
launcherGO.transform.parent = sector.transform;
launcherGO.transform.localPosition = info.position == null ? Vector3.zero : (Vector3) info.position;
launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), ((Vector3)info.position).normalized).normalized;
launcherGO.name = "MeteorLauncher";
var meteorLauncher = launcherGO.GetComponent<MeteorLauncher>();
@ -24,30 +25,49 @@ namespace NewHorizons.Builder.Props
meteorLauncher._detectableFluid = null;
meteorLauncher._detectableField = null;
meteorLauncher._launchDirection = info.position == null ? Vector3.up : ((Vector3)info.position).normalized;
meteorLauncher._launchDirection = Vector3.up;
var meteorPrefab = GameObject.Instantiate(meteorLauncher._meteorPrefab);
FixMeteor(meteorPrefab, info);
meteorLauncher._dynamicProbability = 0f;
meteorLauncher._meteorPrefab = meteorPrefab;
meteorLauncher._minLaunchSpeed = info.minLaunchSpeed;
meteorLauncher._maxLaunchSpeed = info.maxLaunchSpeed;
meteorLauncher._minInterval = info.minInterval;
meteorLauncher._maxInterval = info.maxInterval;
launcherGO.SetActive(true);
// Kill the prefab when its done with it
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => meteorPrefab.SetActive(false));
// Have to null check else it breaks on reload configs
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady && meteorLauncher._meteorPool != null, () => {
foreach (var meteor in meteorLauncher._meteorPool)
{
FixMeteor(meteor, info);
}
});
}
private static void FixMeteor(GameObject meteor, PropModule.VolcanoInfo info)
private static void FixMeteor(MeteorController meteor, PropModule.VolcanoInfo info)
{
var mat = meteor.GetComponentInChildren<MeshRenderer>().material;
mat.SetColor("_Color", info.stoneTint == null ? defaultStoneTint : info.stoneTint.ToColor());
mat.SetColor("_EmissionColor", info.lavaTint == null ? defaultLavaTint : info.lavaTint.ToColor());
var detectors = meteor.transform.Find("ConstantDetectors");
var detectors = meteor.transform.Find("ConstantDetectors").gameObject;
GameObject.Destroy(detectors.GetComponent<ConstantForceDetector>());
GameObject.Destroy(detectors.GetComponent<ConstantFluidDetector>());
detectors.gameObject.AddComponent<DynamicForceDetector>();
var forceDetector = detectors.gameObject.AddComponent<DynamicForceDetector>();
detectors.gameObject.AddComponent<DynamicFluidDetector>();
detectors.layer = LayerMask.NameToLayer("BasicDetector");
var sphere = detectors.AddComponent<SphereCollider>();
sphere.radius = 1;
var sphere2 = detectors.AddComponent<SphereShape>();
sphere2._collisionMode = Shape.CollisionMode.Detector;
sphere2.radius = 1;
forceDetector._collider = sphere;
forceDetector._shape = sphere2;
}
}
}

View File

@ -14,7 +14,7 @@ namespace NewHorizons.External
public RaftInfo[] Rafts;
public GeyserInfo[] Geysers;
public TornadoInfo[] Tornados;
public VolcanoInfo[] Volcanos;
public VolcanoInfo[] Volcanoes;
public DialogueInfo[] Dialogue;
public RevealInfo[] Reveal;
public EntryLocationInfo[] EntryLocation;
@ -67,6 +67,10 @@ namespace NewHorizons.External
public MVector3 position = null;
public MColor stoneTint = null;
public MColor lavaTint = null;
public float minLaunchSpeed = 50f;
public float maxLaunchSpeed = 150f;
public float minInterval = 5f;
public float maxInterval = 20f;
}
public class DialogueInfo

View File

@ -135,6 +135,7 @@ namespace NewHorizons
SearchUtilities.ClearCache();
ImageUtilities.ClearCache();
AudioUtilities.ClearCache();
IsSystemReady = false;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)

View File

@ -3,7 +3,7 @@
"author": "xen, Bwc9876, & Book",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "0.10.3",
"version": "0.11.0",
"owmlVersion": "2.1.0",
"dependencies": [ "PacificEngine.OW_CommonResources" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "Vesper.OuterWildsMMO", "Vesper.AutoResume" ],

View File

@ -760,6 +760,48 @@
}
}
}
},
"volcanoes": {
"type": "array",
"description": "A set of meteor-spewing volcanoes",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"position": {
"$ref": "#/$defs/vector3",
"description": "The position of this volcano."
},
"stoneTint": {
"$ref": "#/$defs/color",
"description": "The colour of the meteor's stone."
},
"lavaTint": {
"$ref": "#/$defs/color",
"description": "The colour of the meteor's lava."
},
"minLaunchSpeed": {
"type": "number",
"description": "Minimum random speed at which meteors are launched.",
"default": 50
},
"maxLaunchSpeed": {
"type": "number",
"description": "Maximum random speed at which meteors are launched.",
"default": 150
},
"minInterval": {
"type": "number",
"description": "Minimum time between meteor launches.",
"default": 5
},
"maxInterval": {
"type": "number",
"description": "Maximum time between meteor launches."
"default": 20
}
}
}
}
}
},