Skip to content

Commit

Permalink
RaiseEvent and SafeInvoke are now in OWML
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnCorby committed Apr 25, 2024
1 parent 0ab952c commit 5c711d4
Show file tree
Hide file tree
Showing 18 changed files with 23 additions and 38 deletions.
3 changes: 2 additions & 1 deletion QSB/ConversationSync/Messages/ConversationStartEndMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.ConversationSync.WorldObjects;
using OWML.Utils;
using QSB.ConversationSync.WorldObjects;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Cysharp.Threading.Tasks;
using OWML.Utils;
using QSB.ConversationSync.Messages;
using QSB.Messaging;
using QSB.Player;
Expand Down
1 change: 1 addition & 0 deletions QSB/Menus/MenuManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Mirror;
using OWML.Common;
using OWML.Utils;
using QSB.Localization;
using QSB.Messaging;
using QSB.Player.TransformSync;
Expand Down
3 changes: 2 additions & 1 deletion QSB/OrbSync/WorldObjects/QSBOrb.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.Messaging;
using OWML.Utils;
using QSB.Messaging;
using QSB.OrbSync.Messages;
using QSB.OrbSync.TransformSync;
using QSB.Utility;
Expand Down
1 change: 1 addition & 0 deletions QSB/Patches/QSBPatchManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HarmonyLib;
using OWML.Common;
using OWML.Utils;
using QSB.Utility;
using System;
using System.Collections.Generic;
Expand Down
1 change: 1 addition & 0 deletions QSB/Player/TransformSync/PlayerTransformSync.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OWML.Common;
using OWML.Utils;
using QSB.Messaging;
using QSB.Patches;
using QSB.Player.Messages;
Expand Down
1 change: 1 addition & 0 deletions QSB/QSBSceneManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OWML.Common;
using OWML.Utils;
using QSB.Utility;
using System;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using OWML.Utils;
using QSB.Patches;
using QSB.Utility;

Expand Down
1 change: 1 addition & 0 deletions QSB/ShipSync/Patches/ShipPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using OWML.Utils;
using QSB.Messaging;
using QSB.Patches;
using QSB.ShipSync.Messages;
Expand Down
3 changes: 2 additions & 1 deletion QSB/ShipSync/WorldObjects/QSBShipComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.Messaging;
using OWML.Utils;
using QSB.Messaging;
using QSB.ShipSync.Messages.Component;
using QSB.Utility;
using QSB.WorldSync;
Expand Down
3 changes: 2 additions & 1 deletion QSB/ShipSync/WorldObjects/QSBShipHull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.Messaging;
using OWML.Utils;
using QSB.Messaging;
using QSB.ShipSync.Messages.Hull;
using QSB.Utility;
using QSB.WorldSync;
Expand Down
1 change: 1 addition & 0 deletions QSB/Tools/ProbeTool/Patches/ProbeToolPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using OWML.Utils;
using QSB.Messaging;
using QSB.Patches;
using QSB.Tools.ProbeTool.Messages;
Expand Down
1 change: 1 addition & 0 deletions QSB/Utility/DebugActions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OWML.Common;
using OWML.Utils;
using QSB.EchoesOfTheEye.DreamLantern;
using QSB.EchoesOfTheEye.DreamLantern.WorldObjects;
using QSB.ItemSync.WorldObjects.Items;
Expand Down
1 change: 1 addition & 0 deletions QSB/Utility/Deterministic/DeterministicRigidbodyPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using OWML.Utils;
using QSB.Patches;
using System.Collections.Generic;
using UnityEngine;
Expand Down
32 changes: 0 additions & 32 deletions QSB/Utility/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,6 @@ public static void SpawnWithServerOwnership(this GameObject go) =>

#region C#

public static void SafeInvoke(this MulticastDelegate multicast, params object[] args)
{
foreach (var del in multicast.GetInvocationList())
{
try
{
del.DynamicInvoke(args);
}
catch (TargetInvocationException ex)
{
DebugLog.ToConsole($"Error invoking delegate! {ex.InnerException}", MessageType.Error);
}
}
}

public static float Map(this float value, float inputFrom, float inputTo, float outputFrom, float outputTo, bool clamp)
{
var mappedValue = (value - inputFrom) / (inputTo - inputFrom) * (outputTo - outputFrom) + outputFrom;
Expand Down Expand Up @@ -165,23 +150,6 @@ public static TSource MaxBy<TSource, TKey>(this IEnumerable<TSource> source, Fun

public static bool IsInRange<T>(this IList<T> list, int index) => index >= 0 && index < list.Count;

public static void RaiseEvent<T>(this T instance, string eventName, params object[] args)
{
const BindingFlags flags = BindingFlags.Instance
| BindingFlags.Static
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.DeclaredOnly;
if (typeof(T)
.GetField(eventName, flags)?
.GetValue(instance) is not MulticastDelegate multiDelegate)
{
return;
}

multiDelegate.SafeInvoke(args);
}

public static IEnumerable<Type> GetDerivedTypes(this Type type)
{
var assemblies = QSBCore.Addons.Values
Expand Down
3 changes: 2 additions & 1 deletion QSB/WorldSync/Messages/RequestInitialStatesMessage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.Messaging;
using OWML.Utils;
using QSB.Messaging;
using QSB.Utility;
using System;

Expand Down
1 change: 1 addition & 0 deletions QSB/ZeroGCaveSync/Patches/ZeroGCavePatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HarmonyLib;
using OWML.Utils;
using QSB.Messaging;
using QSB.Patches;
using QSB.Utility;
Expand Down
3 changes: 2 additions & 1 deletion QSB/ZeroGCaveSync/WorldObjects/QSBSatelliteNode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using QSB.Messaging;
using OWML.Utils;
using QSB.Messaging;
using QSB.Utility;
using QSB.WorldSync;
using QSB.ZeroGCaveSync.Messages;
Expand Down

0 comments on commit 5c711d4

Please sign in to comment.