mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Repair volume builder and wire-up
This commit is contained in:
parent
fd6ea03f5b
commit
4212027aca
52
NewHorizons/Builder/Volumes/RepairVolumeBuilder.cs
Normal file
52
NewHorizons/Builder/Volumes/RepairVolumeBuilder.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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)
|
||||||
|
|||||||
49
NewHorizons/External/Modules/Volumes/VolumeInfos/RepairVolumeInfo.cs
vendored
Normal file
49
NewHorizons/External/Modules/Volumes/VolumeInfos/RepairVolumeInfo.cs
vendored
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user