Repair volume builder and wire-up

This commit is contained in:
Joshua Thome 2025-04-19 14:29:29 -05:00
parent fd6ea03f5b
commit 4212027aca
4 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,52 @@
using NewHorizons.Builder.Props;
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Volumes.VolumeInfos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
{
public static class RepairVolumeBuilder
{
public static NHRepairReceiver Make(GameObject planetGO, Sector sector, RepairVolumeInfo info)
{
// Repair receivers aren't technically volumes (no OWTriggerVolume) so we don't use the VolumeBuilder
var go = GeneralPropBuilder.MakeNew("RepairVolume", planetGO, sector, info);
if (info.shape != null)
{
ShapeBuilder.AddCollider(go, info.shape);
}
else
{
var shapeInfo = new ShapeInfo()
{
type = ShapeType.Sphere,
useShape = false,
hasCollision = true,
radius = info.radius,
};
ShapeBuilder.AddCollider(go, shapeInfo);
}
var repairReceiver = go.AddComponent<NHRepairReceiver>();
repairReceiver.displayName = info.name ?? info.rename ?? go.name;
repairReceiver.repairFraction = info.repairFraction;
repairReceiver.repairTime = info.repairTime;
repairReceiver.repairDistance = info.repairDistance;
repairReceiver.damagedCondition = info.damagedCondition;
repairReceiver.repairedCondition = info.repairedCondition;
repairReceiver.revealFact = info.revealFact;
go.SetActive(true);
return repairReceiver;
}
}
}

View File

@ -222,6 +222,13 @@ namespace NewHorizons.Builder.Volumes
VolumeBuilder.MakeAndEnable<ReferenceFrameBlockerVolume>(go, sector, referenceFrameBlockerVolume); VolumeBuilder.MakeAndEnable<ReferenceFrameBlockerVolume>(go, sector, referenceFrameBlockerVolume);
} }
} }
if (config.Volumes.repairVolumes != null)
{
foreach (var repairVolume in config.Volumes.repairVolumes)
{
RepairVolumeBuilder.Make(go, sector, repairVolume);
}
}
if (config.Volumes.speedTrapVolumes != null) if (config.Volumes.speedTrapVolumes != null)
{ {
foreach (var speedTrapVolume in config.Volumes.speedTrapVolumes) foreach (var speedTrapVolume in config.Volumes.speedTrapVolumes)

View File

@ -0,0 +1,49 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
{
[JsonObject]
public class RepairVolumeInfo : VolumeInfo
{
/// <summary>
/// The name displayed in the UI when the player is repairing this object. If not set, the name of the object will be used.
/// </summary>
public string name;
/// <summary>
/// How much of the object is initially repaired. 0 = not repaired, 1 = fully repaired.
/// </summary>
[DefaultValue(0f)] public float repairFraction = 0f;
/// <summary>
/// The time it takes to repair the object. Defaults to 3 seconds.
/// </summary>
[DefaultValue(3f)] public float repairTime = 3f;
/// <summary>
/// The distance from the object that the player can be to repair it. Defaults to 3 meters.
/// </summary>
[DefaultValue(3f)] public float repairDistance = 3f;
/// <summary>
/// A dialogue condition that will be set while the object is damaged. It will be unset when the object is repaired.
/// </summary>
public string damagedCondition;
/// <summary>
/// A dialogue condition that will be set when the object is repaired. It will be unset if the object is damaged again.
/// </summary>
public string repairedCondition;
/// <summary>
/// A ship log fact that will be revealed when the object is repaired.
/// </summary>
public string revealFact;
}
}

View File

@ -85,6 +85,11 @@ namespace NewHorizons.External.Modules.Volumes
/// </summary> /// </summary>
public VolumeInfo[] referenceFrameBlockerVolumes; public VolumeInfo[] referenceFrameBlockerVolumes;
/// <summary>
/// Add repair volumes to this planet.
/// </summary>
public RepairVolumeInfo[] repairVolumes;
/// <summary> /// <summary>
/// Add triggers that reveal parts of the ship log on this planet. /// Add triggers that reveal parts of the ship log on this planet.
/// </summary> /// </summary>