Skip to content

Commit

Permalink
Add respawn here option (#486)
Browse files Browse the repository at this point in the history
Resolves #485
  • Loading branch information
MegaPiggy committed Jan 14, 2023
2 parents e292e5e + dc0816b commit 88b7236
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions NewHorizons/External/Configs/StarSystemConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,15 @@ public class StarSystemConfig
public SkyboxModule Skybox;

/// <summary>
/// Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star
/// system.
/// Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star system.
/// </summary>
public bool startHere;

/// <summary>
/// Set to `true` if you want the player to stay in this star system if they die in it.
/// </summary>
public bool respawnHere;

[Obsolete("travelAudioClip is deprecated, please use travelAudio instead")]
public string travelAudioClip;

Expand Down Expand Up @@ -238,7 +242,7 @@ public void Merge(StarSystemConfig otherConfig)

// False by default so if one is true go true
mapRestricted = mapRestricted || otherConfig.mapRestricted;
mapRestricted = mapRestricted || otherConfig.mapRestricted;
respawnHere = respawnHere || otherConfig.respawnHere;
startHere = startHere || otherConfig.startHere;

Vessel = Vessel == null ? otherConfig.Vessel : Vessel;
Expand Down
5 changes: 2 additions & 3 deletions NewHorizons/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -819,18 +819,17 @@ void OnDeath(DeathType _)
// We reset the solar system on death
if (!IsChangingStarSystem)
{
if (SystemDict[_currentStarSystem].Config.respawnHere) return;

// If the override is a valid system then we go there
if (SystemDict.ContainsKey(_defaultSystemOverride))
{
_currentStarSystem = _defaultSystemOverride;
IsWarpingFromShip = true; // always do this else sometimes the spawn gets messed up
}
else
{
_currentStarSystem = _defaultStarSystem;
}

IsWarpingFromShip = false;
}
}
#endregion Change star system
Expand Down
6 changes: 5 additions & 1 deletion NewHorizons/Schemas/star_system_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
},
"startHere": {
"type": "boolean",
"description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star\nsystem."
"description": "Set to `true` if you want to spawn here after dying, not Timber Hearth. You can still warp back to the main star system."
},
"respawnHere": {
"type": "boolean",
"description": "Set to `true` if you want the player to stay in this star system if they die in it."
},
"travelAudio": {
"type": "string",
Expand Down

0 comments on commit 88b7236

Please sign in to comment.