mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Allow making multiple spawns and choosing which with fact or persistent condition
This commit is contained in:
parent
3c05f0bf12
commit
3f92573c4c
@ -42,15 +42,21 @@ namespace NewHorizons.Builder.General
|
||||
spawnGO.SetActive(false);
|
||||
spawnGO.layer = Layer.PlayerSafetyCollider;
|
||||
|
||||
ShipSpawn = spawnGO.AddComponent<SpawnPoint>();
|
||||
ShipSpawn._isShipSpawn = true;
|
||||
ShipSpawn._attachedBody = owRigidBody;
|
||||
ShipSpawn._spawnLocation = SpawnLocation.None;
|
||||
var shipSpawn = spawnGO.AddComponent<SpawnPoint>();
|
||||
shipSpawn._isShipSpawn = true;
|
||||
shipSpawn._attachedBody = owRigidBody;
|
||||
shipSpawn._spawnLocation = SpawnLocation.None;
|
||||
|
||||
// #601 we need to actually set the right trigger volumes here
|
||||
ShipSpawn._triggerVolumes = new OWTriggerVolume[0];
|
||||
shipSpawn._triggerVolumes = new OWTriggerVolume[0];
|
||||
|
||||
ShipSpawnOffset = module.shipSpawn.offset ?? (module.shipSpawn.alignRadial.GetValueOrDefault() ? Vector3.up * 4 : Vector3.zero);
|
||||
var shipSpawnOffset = module.shipSpawn.offset ?? (module.shipSpawn.alignRadial.GetValueOrDefault() ? Vector3.up * 4 : Vector3.zero);
|
||||
|
||||
if (ShipSpawn == null || module.shipSpawn.IsDefault())
|
||||
{
|
||||
ShipSpawn = shipSpawn;
|
||||
ShipSpawnOffset = shipSpawnOffset;
|
||||
}
|
||||
|
||||
spawnGO.SetActive(true);
|
||||
}
|
||||
|
||||
41
NewHorizons/External/Modules/SpawnModule.cs
vendored
41
NewHorizons/External/Modules/SpawnModule.cs
vendored
@ -1,4 +1,5 @@
|
||||
using NewHorizons.External.SerializableData;
|
||||
using NewHorizons.Handlers;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
|
||||
@ -30,6 +31,40 @@ namespace NewHorizons.External.Modules
|
||||
/// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).
|
||||
/// </summary>
|
||||
public MVector3 offset;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this planet's spawn point is the one the player/ship will initially spawn at, if multiple spawn points exist.
|
||||
/// Do not use at the same time as makeDefaultIfFactRevealed or makeDefaultIfPersistentCondition
|
||||
/// </summary>
|
||||
public bool isDefault;
|
||||
|
||||
/// <summary>
|
||||
/// If the given ship log fact is revealed, this spawn point will be used
|
||||
/// Do not use at the same time as isDefault or makeDefaultIfPersistentCondition
|
||||
/// </summary>
|
||||
public string makeDefaultIfFactRevealed;
|
||||
|
||||
/// <summary>
|
||||
/// If the given persistent condition is true, this spawn point will be used
|
||||
/// Do not use at the same time as isDefault or makeDefaultIfFactRevealed
|
||||
/// </summary>
|
||||
public string makeDefaultIfPersistentCondition;
|
||||
|
||||
public bool IsDefault()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(makeDefaultIfFactRevealed) && ShipLogHandler.KnowsFact(makeDefaultIfFactRevealed))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(makeDefaultIfPersistentCondition) && PlayerData.GetPersistentCondition(makeDefaultIfPersistentCondition))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
@ -39,12 +74,6 @@ namespace NewHorizons.External.Modules
|
||||
/// If you spawn on a planet with no oxygen, you probably want to set this to true ;;)
|
||||
/// </summary>
|
||||
public bool startWithSuit;
|
||||
/// <summary>
|
||||
/// Whether this planet's spawn point is the one the player will initially spawn at, if multiple spawn points exist.
|
||||
/// </summary>
|
||||
public bool isDefault;
|
||||
|
||||
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
|
||||
@ -504,7 +504,7 @@ namespace NewHorizons.Handlers
|
||||
var spawnPoint = SpawnPointBuilder.Make(go, body.Config.Spawn, owRigidBody);
|
||||
var isVanillaSystem = body.Config.starSystem == "SolarSystem" || body.Config.starSystem == "EyeOfTheUniverse";
|
||||
var needsSpawnPoint = Main.SystemDict[body.Config.starSystem].SpawnPoint == null || isVanillaSystem;
|
||||
var isDefaultSpawn = body.Config.Spawn.playerSpawn?.isDefault ?? true; // Backwards compat
|
||||
var isDefaultSpawn = body.Config.Spawn.playerSpawn?.IsDefault() ?? true; // Backwards compat
|
||||
if (needsSpawnPoint || isDefaultSpawn)
|
||||
{
|
||||
Main.SystemDict[body.Config.starSystem].SpawnPoint = spawnPoint;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user