quantum-space-buddies/QSB/TriggerSync/TriggerManager.cs

33 lines
758 B
C#
Raw Normal View History

2022-01-13 01:02:21 +00:00
using OWML.Common;
using QSB.Utility;
using QSB.WorldSync;
using System.Linq;
namespace QSB.TriggerSync
{
public class TriggerManager : WorldObjectManager
{
public override WorldObjectType WorldObjectType => WorldObjectType.Both;
private static TriggerLink[] _triggerLinks;
protected override void RebuildWorldObjects(OWScene scene)
{
_triggerLinks?.ForEach(x => x.Dispose());
_triggerLinks = QSBWorldSync.GetUnityObjects<OWTriggerVolume>()
.Select((x, i) => new TriggerLink(i, x))
.ToArray();
}
public static TriggerLink GetTriggerLink(int id)
{
if (!_triggerLinks.TryGet(id, out var triggerLink))
{
DebugLog.ToConsole($"no trigger link with id {id}", MessageType.Error);
}
return triggerLink;
}
}
}