Add rulesets

This commit is contained in:
Noah Pilarski 2022-11-25 18:51:49 -05:00
parent 76bcf40f1e
commit 7cae3805ff
5 changed files with 177 additions and 0 deletions

View File

@ -0,0 +1,18 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class PlayerImpactRulesetBuilder
{
public static PlayerImpactRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.PlayerImpactRulesetInfo info)
{
var volume = VolumeBuilder.Make<PlayerImpactRuleset>(planetGO, sector, info);
volume.minImpactSpeed = info.minImpactSpeed;
volume.maxImpactSpeed = info.maxImpactSpeed;
return volume;
}
}
}

View File

@ -0,0 +1,21 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class ProbeRulesetBuilder
{
public static ProbeRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ProbeRulesetInfo info)
{
var volume = VolumeBuilder.Make<ProbeRuleset>(planetGO, sector, info);
volume._overrideProbeSpeed = info.overrideProbeSpeed;
volume._probeSpeedOverride = info.probeSpeed;
volume._overrideLanternRange = info.overrideLanternRange;
volume._lanternRange = info.lanternRange;
volume._ignoreAnchor = info.ignoreAnchor;
return volume;
}
}
}

View File

@ -0,0 +1,19 @@
using NewHorizons.External.Modules;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class ThrustRulesetBuilder
{
public static ThrustRuleset Make(GameObject planetGO, Sector sector, VolumesModule.RulesetModule.ThrustRulesetInfo info)
{
var volume = VolumeBuilder.Make<ThrustRuleset>(planetGO, sector, info);
volume._thrustLimit = info.thrustLimit;
volume._nerfJetpackBooster = info.nerfJetpackBooster;
volume._nerfDuration = info.nerfDuration;
return volume;
}
}
}

View File

@ -140,6 +140,37 @@ namespace NewHorizons.Builder.Volumes
}
}
}
if (config.Volumes.rulesets != null)
{
if (config.Volumes.rulesets.antiTravelMusicRulesets != null)
{
foreach (var antiTravelMusicRuleset in config.Volumes.rulesets.antiTravelMusicRulesets)
{
VolumeBuilder.Make<AntiTravelMusicRuleset>(go, sector, antiTravelMusicRuleset);
}
}
if (config.Volumes.rulesets.playerImpactRulesets != null)
{
foreach (var playerImpactRuleset in config.Volumes.rulesets.playerImpactRulesets)
{
PlayerImpactRulesetBuilder.Make(go, sector, playerImpactRuleset);
}
}
if (config.Volumes.rulesets.probeRulesets != null)
{
foreach (var probeRuleset in config.Volumes.rulesets.probeRulesets)
{
ProbeRulesetBuilder.Make(go, sector, probeRuleset);
}
}
if (config.Volumes.rulesets.thrustRulesets != null)
{
foreach (var thrustRuleset in config.Volumes.rulesets.thrustRulesets)
{
ThrustRulesetBuilder.Make(go, sector, thrustRuleset);
}
}
}
}
}
}

View File

@ -75,6 +75,11 @@ namespace NewHorizons.External.Modules
/// </summary>
public VolumeInfo[] reverbVolumes;
/// <summary>
/// Add ruleset volumes to this planet.
/// </summary>
public RulesetModule rulesets;
/// <summary>
/// Add visor effect volumes to this planet.
/// </summary>
@ -483,6 +488,89 @@ namespace NewHorizons.External.Modules
public float streakRate = 1f;
}
}
[JsonObject]
public class RulesetModule
{
/// <summary>
/// Add anti travel music rulesets to this planet.
/// </summary>
public VolumeInfo[] antiTravelMusicRulesets;
/// <summary>
/// Add player impact rulesets to this planet.
/// </summary>
public PlayerImpactRulesetInfo[] playerImpactRulesets;
/// <summary>
/// Add probe rulesets to this planet.
/// </summary>
public ProbeRulesetInfo[] probeRulesets;
/// <summary>
/// Add thrust rulesets to this planet.
/// </summary>
public ThrustRulesetInfo[] thrustRulesets;
[JsonObject]
public class PlayerImpactRulesetInfo : VolumeInfo
{
/// <summary>
/// Minimum player impact speed. Player will take the minimum amount of damage if they impact something at this speed.
/// </summary>
[DefaultValue(20f)] public float minImpactSpeed = 20f;
/// <summary>
/// Maximum player impact speed. Players will die if they impact something at this speed.
/// </summary>
[DefaultValue(40f)] public float maxImpactSpeed = 40f;
}
[JsonObject]
public class ProbeRulesetInfo : VolumeInfo
{
/// <summary>
/// Should this ruleset override the probe's speed?
/// </summary>
public bool overrideProbeSpeed;
/// <summary>
/// The speed of the probe while in this ruleset volume.
/// </summary>
public float probeSpeed;
/// <summary>
/// Should this ruleset override the range of probe's light?
/// </summary>
public bool overrideLanternRange;
/// <summary>
/// The range of probe's light while in this ruleset volume.
/// </summary>
public float lanternRange;
/// <summary>
/// Stop the probe from attaching to anything while in this ruleset volume.
/// </summary>
public bool ignoreAnchor;
}
[JsonObject]
public class ThrustRulesetInfo : VolumeInfo
{
/// <summary>
/// Limit how fast you can fly with your jetpack while in this ruleset volume.
/// </summary>
[DefaultValue(float.PositiveInfinity)] public float thrustLimit = float.PositiveInfinity;
/// <summary>
/// Nerf the jetpack booster.
/// </summary>
public bool nerfJetpackBooster;
/// <summary>
/// How long the jetpack booster will be nerfed.
/// </summary>
[DefaultValue(0.5f)] public float nerfDuration = 0.5f;
}
}
}
[JsonConverter(typeof(StringEnumConverter))]