mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-11 06:40:39 +00:00
Revert "send le LightSensorAuthorityMessage"
This reverts commit a6400f3d11852a1d7e0e2e73788ce8802f3f00e0.
This commit is contained in:
parent
283bf05887
commit
b825fc588b
@ -1,7 +1,5 @@
|
||||
using HarmonyLib;
|
||||
using QSB.EchoesOfTheEye.LightSensorSync.Messages;
|
||||
using QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
||||
using QSB.Messaging;
|
||||
using QSB.Patches;
|
||||
using QSB.Player;
|
||||
using QSB.Tools.FlashlightTool;
|
||||
@ -16,80 +14,6 @@ internal class LightSensorPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SingleLightSensor.Start))]
|
||||
private static void Start(SingleLightSensor __instance)
|
||||
{
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!__instance.TryGetWorldObject(out QSBLightSensor qsbLightSensor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (__instance._sector != null)
|
||||
{
|
||||
if (__instance._startIlluminated)
|
||||
{
|
||||
qsbLightSensor.OnDetectLocalLight?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(SingleLightSensor.OnSectorOccupantsUpdated))]
|
||||
private static bool OnSectorOccupantsUpdated(SingleLightSensor __instance)
|
||||
{
|
||||
if (!QSBWorldSync.AllObjectsReady)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!__instance.TryGetWorldObject(out QSBLightSensor qsbLightSensor))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var containsAnyOccupants = __instance._sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe);
|
||||
if (containsAnyOccupants && !__instance.enabled)
|
||||
{
|
||||
__instance.enabled = true;
|
||||
__instance._lightDetector.GetShape().enabled = true;
|
||||
if (__instance._preserveStateWhileDisabled)
|
||||
{
|
||||
__instance._fixedUpdateFrameDelayCount = 10;
|
||||
}
|
||||
|
||||
qsbLightSensor.SendMessage(new LightSensorAuthorityMessage(QSBPlayerManager.LocalPlayerId));
|
||||
}
|
||||
else if (!containsAnyOccupants && __instance.enabled)
|
||||
{
|
||||
__instance.enabled = false;
|
||||
__instance._lightDetector.GetShape().enabled = false;
|
||||
if (!__instance._preserveStateWhileDisabled)
|
||||
{
|
||||
if (__instance._illuminated)
|
||||
{
|
||||
__instance.OnDetectDarkness.Invoke();
|
||||
}
|
||||
|
||||
if (qsbLightSensor.LocallyIlluminated)
|
||||
{
|
||||
qsbLightSensor.OnDetectLocalDarkness?.Invoke();
|
||||
}
|
||||
|
||||
__instance._illuminated = false;
|
||||
}
|
||||
|
||||
qsbLightSensor.SendMessage(new LightSensorAuthorityMessage(0));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(SingleLightSensor.UpdateIllumination))]
|
||||
private static bool UpdateIllumination(SingleLightSensor __instance)
|
||||
|
Loading…
x
Reference in New Issue
Block a user