mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-22 03:40:54 +00:00
qsbLightSensor.Illuminated
This commit is contained in:
parent
d92d9ae561
commit
b20955f24e
@ -12,11 +12,6 @@ internal class LightSensorPatches : QSBPatch
|
||||
{
|
||||
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
||||
|
||||
/// <summary>
|
||||
/// its okay for this to be here. it's just temporary storage
|
||||
/// </summary>
|
||||
private static bool _illuminated;
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(nameof(SingleLightSensor.ManagedFixedUpdate))]
|
||||
private static bool ManagedFixedUpdate(SingleLightSensor __instance)
|
||||
@ -38,9 +33,8 @@ internal class LightSensorPatches : QSBPatch
|
||||
}
|
||||
|
||||
var locallyIlluminated = qsbLightSensor.LocallyIlluminated;
|
||||
var illuminated = _illuminated;
|
||||
var illuminated = qsbLightSensor._illuminated;
|
||||
__instance.UpdateIllumination();
|
||||
__instance._illuminated = _illuminated; // temp
|
||||
if (!locallyIlluminated && qsbLightSensor.LocallyIlluminated)
|
||||
{
|
||||
qsbLightSensor.OnDetectLocalLight?.Invoke();
|
||||
@ -50,11 +44,12 @@ internal class LightSensorPatches : QSBPatch
|
||||
qsbLightSensor.OnDetectLocalDarkness?.Invoke();
|
||||
}
|
||||
|
||||
if (!illuminated && _illuminated)
|
||||
__instance._illuminated = qsbLightSensor._illuminated;
|
||||
if (!illuminated && qsbLightSensor._illuminated)
|
||||
{
|
||||
__instance.OnDetectLight.Invoke();
|
||||
}
|
||||
else if (illuminated && !_illuminated)
|
||||
else if (illuminated && !qsbLightSensor._illuminated)
|
||||
{
|
||||
__instance.OnDetectDarkness.Invoke();
|
||||
}
|
||||
@ -77,7 +72,7 @@ internal class LightSensorPatches : QSBPatch
|
||||
}
|
||||
|
||||
qsbLightSensor.LocallyIlluminated = false;
|
||||
_illuminated = false;
|
||||
qsbLightSensor._illuminated = false;
|
||||
__instance._illuminatingDreamLanternList?.Clear();
|
||||
if (__instance._lightSources == null || __instance._lightSources.Count == 0)
|
||||
{
|
||||
@ -105,7 +100,7 @@ internal class LightSensorPatches : QSBPatch
|
||||
if (owlight.CheckIlluminationAtPoint(vector, __instance._sensorRadius, __instance._maxDistance)
|
||||
&& !__instance.CheckOcclusion(owlight.transform.position, vector, sensorWorldDir, occludableLight))
|
||||
{
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -118,7 +113,7 @@ internal class LightSensorPatches : QSBPatch
|
||||
&& !__instance.CheckOcclusion(position, vector, sensorWorldDir))
|
||||
{
|
||||
qsbLightSensor.LocallyIlluminated = true;
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -133,7 +128,7 @@ internal class LightSensorPatches : QSBPatch
|
||||
&& !__instance.CheckOcclusion(probe.GetLightSourcePosition(), vector, sensorWorldDir))
|
||||
{
|
||||
qsbLightSensor.LocallyIlluminated = true;
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -149,7 +144,7 @@ internal class LightSensorPatches : QSBPatch
|
||||
__instance._illuminatingDreamLanternList.Add(dreamLanternController);
|
||||
var dreamLanternItem = dreamLanternController.GetComponent<DreamLanternItem>();
|
||||
qsbLightSensor.LocallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == dreamLanternItem;
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -164,14 +159,14 @@ internal class LightSensorPatches : QSBPatch
|
||||
{
|
||||
var simpleLanternItem = (SimpleLanternItem)lightSource;
|
||||
qsbLightSensor.LocallyIlluminated |= QSBPlayerManager.LocalPlayer.HeldItem?.AttachedObject == simpleLanternItem;
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case LightSourceType.VOLUME_ONLY:
|
||||
_illuminated = true;
|
||||
qsbLightSensor._illuminated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,18 @@ namespace QSB.EchoesOfTheEye.LightSensorSync.WorldObjects;
|
||||
|
||||
internal class QSBLightSensor : WorldObject<SingleLightSensor>
|
||||
{
|
||||
/// <summary>
|
||||
/// illuminated specifically by the player
|
||||
/// </summary>
|
||||
public bool LocallyIlluminated;
|
||||
|
||||
public Action OnDetectLocalLight;
|
||||
public Action OnDetectLocalDarkness;
|
||||
|
||||
/// <summary>
|
||||
/// illuminated on the client (replacement for base game code)
|
||||
/// </summary>
|
||||
internal bool _illuminated;
|
||||
|
||||
public override void SendInitialState(uint to) { }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user