mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Add hazard volumes
This commit is contained in:
parent
0921b23f8f
commit
2f7eb0c695
40
NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs
Normal file
40
NewHorizons/Builder/Volumes/HazardVolumeBuilder.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using NewHorizons.External.Modules;
|
||||||
|
using OWML.Common;
|
||||||
|
using OWML.Utils;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Builder.Volumes
|
||||||
|
{
|
||||||
|
public static class HazardVolumeBuilder
|
||||||
|
{
|
||||||
|
public static HazardVolume Make(GameObject planetGO, Sector sector, OWRigidbody owrb, VolumesModule.HazardVolumeInfo info, IModBehaviour mod)
|
||||||
|
{
|
||||||
|
var go = new GameObject("HazardVolume");
|
||||||
|
go.SetActive(false);
|
||||||
|
|
||||||
|
go.transform.parent = sector?.transform ?? planetGO.transform;
|
||||||
|
go.transform.position = planetGO.transform.TransformPoint(info.position != null ? (Vector3)info.position : Vector3.zero);
|
||||||
|
go.layer = LayerMask.NameToLayer("BasicEffectVolume");
|
||||||
|
|
||||||
|
var shape = go.AddComponent<SphereShape>();
|
||||||
|
shape.radius = info.radius;
|
||||||
|
|
||||||
|
var owTriggerVolume = go.AddComponent<OWTriggerVolume>();
|
||||||
|
owTriggerVolume._shape = shape;
|
||||||
|
|
||||||
|
var hazardVolume = go.AddComponent<SimpleHazardVolume>();
|
||||||
|
hazardVolume._attachedBody = owrb;
|
||||||
|
hazardVolume._type = EnumUtils.Parse<HazardVolume.HazardType>(info.type.ToString(), HazardVolume.HazardType.GENERAL);
|
||||||
|
hazardVolume._damagePerSecond = info.damagePerSecond;
|
||||||
|
hazardVolume._firstContactDamageType = EnumUtils.Parse<InstantDamageType>(info.firstContactDamage.ToString(), InstantDamageType.Impact);
|
||||||
|
hazardVolume._firstContactDamage = info.firstContactDamage;
|
||||||
|
|
||||||
|
go.SetActive(true);
|
||||||
|
|
||||||
|
return hazardVolume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Volumes
|
|||||||
{
|
{
|
||||||
public static class VolumesBuildManager
|
public static class VolumesBuildManager
|
||||||
{
|
{
|
||||||
public static void Make(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod)
|
public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, PlanetConfig config, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
if (config.Volumes.revealVolumes != null)
|
if (config.Volumes.revealVolumes != null)
|
||||||
{
|
{
|
||||||
@ -42,6 +42,13 @@ namespace NewHorizons.Builder.Volumes
|
|||||||
NotificationVolumeBuilder.Make(go, sector, notificationVolume, mod);
|
NotificationVolumeBuilder.Make(go, sector, notificationVolume, mod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (config.Volumes.hazardVolumes != null)
|
||||||
|
{
|
||||||
|
foreach (var hazardVolume in config.Volumes.hazardVolumes)
|
||||||
|
{
|
||||||
|
HazardVolumeBuilder.Make(go, sector, planetBody, hazardVolume, mod);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
60
NewHorizons/External/Modules/VolumesModule.cs
vendored
60
NewHorizons/External/Modules/VolumesModule.cs
vendored
@ -19,6 +19,11 @@ namespace NewHorizons.External.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public AudioVolumeInfo[] audioVolumes;
|
public AudioVolumeInfo[] audioVolumes;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add hazard volumes to this planet
|
||||||
|
/// </summary>
|
||||||
|
public HazardVolumeInfo[] hazardVolumes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add notification volumes to this planet
|
/// Add notification volumes to this planet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -158,6 +163,61 @@ namespace NewHorizons.External.Modules
|
|||||||
[EnumMember(Value = @"player")] Player = 2,
|
[EnumMember(Value = @"player")] Player = 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[JsonObject]
|
||||||
|
public class HazardVolumeInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The location of this hazard volume. Optional (will default to 0,0,0).
|
||||||
|
/// </summary>
|
||||||
|
public MVector3 position;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The radius of this hazard volume.
|
||||||
|
/// </summary>
|
||||||
|
public float radius;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of hazard for this volume.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("general")] public HazardType type = HazardType.GENERAL;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of damage you will take per second while inside this volume.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(10f)] public float damagePerSecond = 10f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The type of damage you will take when you first touch this volume.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue("impact")] public InstantDamageType _firstContactDamageType = InstantDamageType.Impact;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of damage you will take when you first touch this volume.
|
||||||
|
/// </summary>
|
||||||
|
public float firstContactDamage;
|
||||||
|
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum HazardType
|
||||||
|
{
|
||||||
|
[EnumMember(Value = @"none")] NONE = 0,
|
||||||
|
[EnumMember(Value = @"general")] GENERAL = 1,
|
||||||
|
[EnumMember(Value = @"darkMatter")] DARKMATTER = 2,
|
||||||
|
[EnumMember(Value = @"heat")] HEAT = 4,
|
||||||
|
[EnumMember(Value = @"fire")] FIRE = 8,
|
||||||
|
[EnumMember(Value = @"sandfall")] SANDFALL = 16,
|
||||||
|
[EnumMember(Value = @"electricity")] ELECTRICITY = 32,
|
||||||
|
[EnumMember(Value = @"rapids")] RAPIDS = 64
|
||||||
|
}
|
||||||
|
|
||||||
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public enum InstantDamageType
|
||||||
|
{
|
||||||
|
[EnumMember(Value = @"impact")] Impact,
|
||||||
|
[EnumMember(Value = @"puncture")] Puncture,
|
||||||
|
[EnumMember(Value = @"electrical")] Electrical
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
|||||||
@ -611,7 +611,7 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
if (body.Config.Volumes != null)
|
if (body.Config.Volumes != null)
|
||||||
{
|
{
|
||||||
VolumesBuildManager.Make(go, sector, body.Config, body.Mod);
|
VolumesBuildManager.Make(go, sector, rb, body.Config, body.Mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (body.Config.Funnel != null)
|
if (body.Config.Funnel != null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user