mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Condition trigger volume
This commit is contained in:
parent
ea5857497b
commit
b84d94a404
25
NewHorizons/Builder/Volumes/ConditionTriggerVolumeBuilder.cs
Normal file
25
NewHorizons/Builder/Volumes/ConditionTriggerVolumeBuilder.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using NewHorizons.Components.Volumes;
|
||||
using NewHorizons.External.Modules.Volumes.VolumeInfos;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Builder.Volumes
|
||||
{
|
||||
internal static class ConditionTriggerVolumeBuilder
|
||||
{
|
||||
public static ConditionTriggerVolume Make(GameObject planetGO, Sector sector, ConditionTriggerVolumeInfo info)
|
||||
{
|
||||
var volume = VolumeBuilder.Make<ConditionTriggerVolume>(planetGO, sector, info);
|
||||
|
||||
volume.Condition = info.condition;
|
||||
volume.Persistent = info.persistent;
|
||||
volume.Reversible = info.reversible;
|
||||
volume.Player = info.player;
|
||||
volume.Probe = info.probe;
|
||||
volume.Ship = info.ship;
|
||||
|
||||
volume.gameObject.SetActive(true);
|
||||
|
||||
return volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,6 +35,13 @@ namespace NewHorizons.Builder.Volumes
|
||||
AudioVolumeBuilder.Make(go, sector, audioVolume, mod);
|
||||
}
|
||||
}
|
||||
if (config.Volumes.conditionTriggerVolumes != null)
|
||||
{
|
||||
foreach (var conditionTriggerVolume in config.Volumes.conditionTriggerVolumes)
|
||||
{
|
||||
ConditionTriggerVolumeBuilder.Make(go, sector, conditionTriggerVolume);
|
||||
}
|
||||
}
|
||||
if (config.Volumes.dayNightAudioVolumes != null)
|
||||
{
|
||||
foreach (var dayNightAudioVolume in config.Volumes.dayNightAudioVolumes)
|
||||
|
||||
66
NewHorizons/Components/Volumes/ConditionTriggerVolume.cs
Normal file
66
NewHorizons/Components/Volumes/ConditionTriggerVolume.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Components.Volumes
|
||||
{
|
||||
public class ConditionTriggerVolume : BaseVolume
|
||||
{
|
||||
public string Condition { get; set; }
|
||||
public bool Persistent { get; set; }
|
||||
public bool Reversible { get; set; }
|
||||
public bool Player { get; set; } = true;
|
||||
public bool Probe { get; set; }
|
||||
public bool Ship { get; set; }
|
||||
|
||||
public override void OnTriggerVolumeEntry(GameObject hitObj)
|
||||
{
|
||||
if (TestHitObject(hitObj))
|
||||
{
|
||||
if (Persistent)
|
||||
{
|
||||
PlayerData.SetPersistentCondition(Condition, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogueConditionManager.SharedInstance.SetConditionState(Condition, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnTriggerVolumeExit(GameObject hitObj)
|
||||
{
|
||||
if (Reversible && TestHitObject(hitObj))
|
||||
{
|
||||
if (Persistent)
|
||||
{
|
||||
PlayerData.SetPersistentCondition(Condition, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
DialogueConditionManager.SharedInstance.SetConditionState(Condition, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TestHitObject(GameObject hitObj)
|
||||
{
|
||||
if (Player && hitObj.CompareTag("PlayerDetector"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Probe && hitObj.CompareTag("ProbeDetector"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (Ship && hitObj.CompareTag("ShipDetector"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
NewHorizons/External/Modules/Volumes/VolumeInfos/ConditionTriggerVolumeInfo.cs
vendored
Normal file
39
NewHorizons/External/Modules/Volumes/VolumeInfos/ConditionTriggerVolumeInfo.cs
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace NewHorizons.External.Modules.Volumes.VolumeInfos
|
||||
{
|
||||
[JsonObject]
|
||||
public class ConditionTriggerVolumeInfo : VolumeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the dialogue condition or persistent condition to set when entering the volume.
|
||||
/// </summary>
|
||||
public string condition;
|
||||
|
||||
/// <summary>
|
||||
/// If true, the condition will persist across all future loops until unset.
|
||||
/// </summary>
|
||||
public bool persistent;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to unset the condition when existing the volume.
|
||||
/// </summary>
|
||||
public bool reversible;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to set the condition when the player enters this volume. Defaults to true.
|
||||
/// </summary>
|
||||
[DefaultValue(true)] public bool player = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to set the condition when the scout probe enters this volume.
|
||||
/// </summary>
|
||||
public bool probe;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to set the condition when the ship enters this volume.
|
||||
/// </summary>
|
||||
public bool ship;
|
||||
}
|
||||
}
|
||||
@ -11,6 +11,11 @@ namespace NewHorizons.External.Modules.Volumes
|
||||
/// </summary>
|
||||
public AudioVolumeInfo[] audioVolumes;
|
||||
|
||||
/// <summary>
|
||||
/// Add condition trigger volumes to this planet. Sets a condition when the player, scout, or ship enters this volume.
|
||||
/// </summary>
|
||||
public ConditionTriggerVolumeInfo[] conditionTriggerVolumes;
|
||||
|
||||
/// <summary>
|
||||
/// Add day night audio volumes to this planet. These volumes play a different clip depending on the time of day.
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user