quantum-space-buddies/QSB/Events/QSBEventManager.cs

194 lines
5.2 KiB
C#
Raw Normal View History

2020-11-03 21:11:10 +00:00
using OWML.Common;
2021-04-29 18:30:45 +01:00
using QSB.Animation.NPC.Events;
2021-04-26 14:30:21 +01:00
using QSB.Animation.Player.Events;
2021-03-29 23:36:51 +01:00
using QSB.CampfireSync.Events;
2020-11-03 17:56:48 +00:00
using QSB.ConversationSync.Events;
using QSB.DeathSync.Events;
using QSB.ElevatorSync.Events;
2020-12-24 19:35:42 +00:00
using QSB.FrequencySync.Events;
2020-11-03 17:56:48 +00:00
using QSB.GeyserSync.Events;
2021-02-25 13:52:49 +00:00
using QSB.ItemSync.Events;
2020-12-19 10:56:25 +00:00
using QSB.LogSync.Events;
2020-11-03 17:56:48 +00:00
using QSB.OrbSync.Events;
2020-11-03 21:33:48 +00:00
using QSB.Player.Events;
2021-04-11 17:08:18 +01:00
using QSB.ProbeSync.Events;
2020-12-22 21:39:53 +00:00
using QSB.QuantumSync.Events;
2021-03-30 17:28:05 +01:00
using QSB.RoastingSync.Events;
2021-04-12 10:37:20 +01:00
using QSB.ShipSync.Events;
using QSB.ShipSync.Events.Component;
using QSB.ShipSync.Events.Hull;
2021-02-28 14:43:05 +00:00
using QSB.StatueSync.Events;
2020-11-03 17:56:48 +00:00
using QSB.TimeSync.Events;
using QSB.Tools.Events;
using QSB.TranslationSync.Events;
2020-11-03 21:11:10 +00:00
using QSB.Utility;
2020-08-15 20:32:58 +01:00
using System.Collections.Generic;
2020-08-12 21:58:29 +02:00
2020-12-14 16:24:52 +00:00
namespace QSB.Events
{
2020-12-02 21:23:01 +00:00
public static class QSBEventManager
{
public static bool Ready { get; private set; }
2020-08-09 14:26:33 +01:00
2020-12-02 21:23:01 +00:00
private static List<IQSBEvent> _eventList = new List<IQSBEvent>();
2020-08-15 20:32:58 +01:00
2020-12-02 21:23:01 +00:00
public static void Init()
{
_eventList = new List<IQSBEvent>
{
2020-12-23 11:26:47 +00:00
// Player
2020-12-02 21:23:01 +00:00
new PlayerReadyEvent(),
new PlayerJoinEvent(),
new PlayerSuitEvent(),
new PlayerFlashlightEvent(),
new PlayerSignalscopeEvent(),
new PlayerTranslatorEvent(),
new PlayerProbeLauncherEvent(),
new PlayerProbeEvent(),
new PlayerDeathEvent(),
new PlayerStatesRequestEvent(),
2020-12-23 11:26:47 +00:00
new ServerSendPlayerStatesEvent(),
new ChangeAnimTypeEvent(),
new ServerTimeEvent(),
2021-02-21 18:29:16 +00:00
new PlayerEntangledEvent(),
2021-03-09 16:43:41 +00:00
new PlayerKickEvent(),
2021-03-30 17:28:05 +01:00
new EnterExitRoastingEvent(),
new MarshmallowEventEvent(),
2021-04-24 00:10:29 +01:00
new AnimationTriggerEvent(),
2021-06-23 12:06:08 +01:00
new PlayerRespawnEvent(),
2021-07-04 22:34:31 +01:00
new ProbeStartRetrieveEvent(),
2020-12-23 11:26:47 +00:00
// World Objects
2020-12-02 21:23:01 +00:00
new ElevatorEvent(),
new GeyserEvent(),
new OrbSlotEvent(),
new OrbUserEvent(),
2020-12-23 11:26:47 +00:00
new SocketStateChangeEvent(),
new MultiStateChangeEvent(),
new SetAsTranslatedEvent(),
2021-01-01 10:17:35 +00:00
new QuantumShuffleEvent(),
2021-01-03 09:52:34 +00:00
new MoonStateChangeEvent(),
2021-01-18 12:33:07 +00:00
new EnterLeaveEvent(),
2021-01-26 14:07:17 +00:00
new QuantumAuthorityEvent(),
2021-02-25 13:52:49 +00:00
new DropItemEvent(),
2021-02-25 21:24:10 +00:00
new SocketItemEvent(),
2021-02-25 22:45:32 +00:00
new MoveToCarryEvent(),
2021-02-28 14:43:05 +00:00
new StartStatueEvent(),
2021-03-29 23:36:51 +01:00
new CampfireStateEvent(),
2020-12-24 19:35:42 +00:00
// Conversation/dialogue/exploration
2020-12-02 21:23:01 +00:00
new ConversationEvent(),
new ConversationStartEndEvent(),
2020-12-19 10:56:25 +00:00
new DialogueConditionEvent(),
2020-12-24 19:35:42 +00:00
new RevealFactEvent(),
new IdentifyFrequencyEvent(),
2021-04-12 10:37:20 +01:00
new IdentifySignalEvent(),
2021-05-10 14:30:38 +01:00
new NpcAnimationEvent(),
2021-04-12 10:37:20 +01:00
// Ship
2021-04-12 11:31:21 +01:00
new FlyShipEvent(),
2021-06-14 16:13:32 +01:00
new HatchEvent(),
new FunnelEnableEvent(),
new HullImpactEvent(),
new HullDamagedEvent(),
new HullChangeIntegrityEvent(),
2021-06-20 10:06:29 +01:00
new HullRepairedEvent(),
2021-06-20 12:43:02 +01:00
new HullRepairTickEvent(),
2021-06-20 09:59:02 +01:00
new ComponentDamagedEvent(),
2021-06-20 10:17:32 +01:00
new ComponentRepairedEvent(),
new ComponentRepairTickEvent()
2020-12-02 21:23:01 +00:00
};
2020-08-15 20:32:58 +01:00
2021-02-12 13:29:01 +00:00
if (UnitTestDetector.IsInUnitTest)
{
return;
}
2020-12-02 21:23:01 +00:00
_eventList.ForEach(ev => ev.SetupListener());
2020-08-18 20:47:17 +02:00
2020-12-02 21:23:01 +00:00
Ready = true;
2020-11-03 21:11:10 +00:00
2020-12-02 21:23:01 +00:00
DebugLog.DebugWrite("Event Manager ready.", MessageType.Success);
}
2020-08-15 20:32:58 +01:00
2020-12-02 21:23:01 +00:00
public static void Reset()
{
Ready = false;
_eventList.ForEach(ev => ev.CloseListener());
_eventList = new List<IQSBEvent>();
}
2021-02-10 19:34:41 +00:00
public static void FireEvent(string eventName)
{
if (!QSBCore.IsInMultiplayer)
{
return;
}
2021-06-18 22:38:32 +01:00
2021-02-10 19:34:41 +00:00
GlobalMessenger.FireEvent(eventName);
}
public static void FireEvent<T>(string eventName, T arg)
2021-02-10 19:34:41 +00:00
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
GlobalMessenger<T>.FireEvent(eventName, arg);
2021-02-10 19:34:41 +00:00
}
public static void FireEvent<T, U>(string eventName, T arg1, U arg2)
2021-02-10 19:34:41 +00:00
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
GlobalMessenger<T, U>.FireEvent(eventName, arg1, arg2);
2021-02-10 19:34:41 +00:00
}
public static void FireEvent<T, U, V>(string eventName, T arg1, U arg2, V arg3)
2021-02-10 19:34:41 +00:00
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
GlobalMessenger<T, U, V>.FireEvent(eventName, arg1, arg2, arg3);
2021-02-10 19:34:41 +00:00
}
2021-02-25 13:52:49 +00:00
public static void FireEvent<T, U, V, W>(string eventName, T arg1, U arg2, V arg3, W arg4)
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
2021-02-25 13:52:49 +00:00
GlobalMessenger<T, U, V, W>.FireEvent(eventName, arg1, arg2, arg3, arg4);
}
public static void FireEvent<T, U, V, W, X>(string eventName, T arg1, U arg2, V arg3, W arg4, X arg5)
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
2021-02-25 13:52:49 +00:00
GlobalMessenger<T, U, V, W, X>.FireEvent(eventName, arg1, arg2, arg3, arg4, arg5);
}
public static void FireEvent<T, U, V, W, X, Y>(string eventName, T arg1, U arg2, V arg3, W arg4, X arg5, Y arg6)
{
if (!QSBCore.IsInMultiplayer)
{
DebugLog.ToConsole($"Warning - Tried to send event {eventName} while not connected to/hosting server.", MessageType.Warning);
return;
}
2021-06-18 22:38:32 +01:00
2021-02-25 13:52:49 +00:00
GlobalMessenger<T, U, V, W, X, Y>.FireEvent(eventName, arg1, arg2, arg3, arg4, arg5, arg6);
}
2020-12-02 21:23:01 +00:00
}
2020-12-03 08:28:05 +00:00
}