mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-22 21:40:39 +00:00
do _startIlluminated checks in worldobject and not in Start
This commit is contained in:
parent
b1810c413e
commit
0efd04fd70
@ -6,6 +6,7 @@ using QSB.Patches;
|
|||||||
using QSB.WorldSync;
|
using QSB.WorldSync;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For those who come here,
|
* For those who come here,
|
||||||
@ -19,6 +20,52 @@ internal class LightSensorPatches : QSBPatch
|
|||||||
{
|
{
|
||||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(SingleLightSensor.Start))]
|
||||||
|
private static bool Start(SingleLightSensor __instance)
|
||||||
|
{
|
||||||
|
if (__instance._lightDetector != null)
|
||||||
|
{
|
||||||
|
__instance._lightSources = new List<ILightSource>();
|
||||||
|
__instance._lightSourceMask = LightSourceType.VOLUME_ONLY;
|
||||||
|
if (__instance._detectFlashlight)
|
||||||
|
{
|
||||||
|
__instance._lightSourceMask |= LightSourceType.FLASHLIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance._detectProbe)
|
||||||
|
{
|
||||||
|
__instance._lightSourceMask |= LightSourceType.PROBE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance._detectDreamLanterns)
|
||||||
|
{
|
||||||
|
__instance._lightSourceMask |= LightSourceType.DREAM_LANTERN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance._detectSimpleLanterns)
|
||||||
|
{
|
||||||
|
__instance._lightSourceMask |= LightSourceType.SIMPLE_LANTERN;
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance._lightDetector.OnLightVolumeEnter += __instance.OnLightSourceEnter;
|
||||||
|
__instance._lightDetector.OnLightVolumeExit += __instance.OnLightSourceExit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("LightSensor has no LightSourceDetector", __instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__instance._sector != null)
|
||||||
|
{
|
||||||
|
__instance.enabled = false;
|
||||||
|
__instance._lightDetector.GetShape().enabled = false;
|
||||||
|
// dont do _startIlluminated stuff here since its done in the worldobject
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(nameof(SingleLightSensor.OnSectorOccupantsUpdated))]
|
[HarmonyPatch(nameof(SingleLightSensor.OnSectorOccupantsUpdated))]
|
||||||
private static bool OnSectorOccupantsUpdated(SingleLightSensor __instance)
|
private static bool OnSectorOccupantsUpdated(SingleLightSensor __instance)
|
||||||
|
@ -35,14 +35,13 @@ public class QSBPlayerLightSensor : MonoBehaviour
|
|||||||
RequestInitialStatesMessage.SendInitialState += SendInitialState;
|
RequestInitialStatesMessage.SendInitialState += SendInitialState;
|
||||||
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
|
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
|
||||||
|
|
||||||
|
// normally done in Start, but world objects arent ready by that point
|
||||||
if (_lightSensor._sector != null)
|
if (_lightSensor._sector != null)
|
||||||
{
|
{
|
||||||
if (_lightSensor._startIlluminated)
|
if (_lightSensor._startIlluminated)
|
||||||
{
|
{
|
||||||
_locallyIlluminated = true;
|
_locallyIlluminated = true;
|
||||||
// do it manually so as not to invoke OnDetectLight, since that's handled by Start
|
new PlayerSetIlluminatedMessage(PlayerId, true).Send();
|
||||||
// BUG? should add all players to the list, not just local
|
|
||||||
_illuminatedBy.SafeAdd(PlayerId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,14 @@ internal class QSBLightSensor : WorldObject<SingleLightSensor>
|
|||||||
{
|
{
|
||||||
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
|
QSBPlayerManager.OnRemovePlayer += OnPlayerLeave;
|
||||||
|
|
||||||
|
// normally done in Start, but world objects arent ready by that point
|
||||||
if (AttachedObject._sector != null)
|
if (AttachedObject._sector != null)
|
||||||
{
|
{
|
||||||
if (AttachedObject._startIlluminated)
|
if (AttachedObject._startIlluminated)
|
||||||
{
|
{
|
||||||
_locallyIlluminated = true;
|
_locallyIlluminated = true;
|
||||||
OnDetectLocalLight?.Invoke();
|
OnDetectLocalLight?.Invoke();
|
||||||
// do it manually so as not to invoke OnDetectLight, since that's handled by Start
|
this.SendMessage(new SetIlluminatedMessage(true));
|
||||||
// BUG? should add all players to the list, not just local
|
|
||||||
_illuminatedBy.SafeAdd(QSBPlayerManager.LocalPlayerId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user