mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 06:35:45 +00:00
alarm totems: track visible players
This commit is contained in:
parent
3829211711
commit
3e4edb0bed
@ -15,5 +15,6 @@ public class VisibleForMessage : QSBWorldObjectMessage<QSBAlarmTotem, List<uint>
|
||||
{
|
||||
WorldObject.VisibleFor.Clear();
|
||||
WorldObject.VisibleFor.AddRange(Data);
|
||||
WorldObject.UpdateVisible();
|
||||
}
|
||||
}
|
||||
|
@ -94,30 +94,4 @@ public class AlarmTotemPatches : QSBPatch
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AlarmTotem), nameof(AlarmTotem.CheckPlayerVisible))]
|
||||
private static bool CheckPlayerVisible(AlarmTotem __instance, out bool __result)
|
||||
{
|
||||
if (!__instance._isFaceOpen)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
var lanternController = Locator.GetDreamWorldController().GetPlayerLantern().GetLanternController();
|
||||
var playerLightSensor = Locator.GetPlayerLightSensor();
|
||||
if (lanternController.IsHeldByPlayer() && !lanternController.IsConcealed() || playerLightSensor.IsIlluminated())
|
||||
{
|
||||
var position = Locator.GetPlayerCamera().transform.position;
|
||||
if (__instance.CheckPointInVisionCone(position) && !__instance.CheckLineOccluded(__instance._sightOrigin.position, position))
|
||||
{
|
||||
__result = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,31 @@ public class QSBAlarmTotem : WorldObject<AlarmTotem>
|
||||
{
|
||||
VisibleFor.QuickRemove(playerId);
|
||||
}
|
||||
|
||||
UpdateVisible();
|
||||
}
|
||||
|
||||
public void UpdateVisible()
|
||||
{
|
||||
if (AttachedObject._isPlayerVisible && VisibleFor.Count < 1)
|
||||
{
|
||||
Locator.GetAlarmSequenceController().IncreaseAlarmCounter();
|
||||
AttachedObject._simTotemMaterials[0] = AttachedObject._simAlarmMaterial;
|
||||
AttachedObject._simTotemRenderer.sharedMaterials = AttachedObject._simTotemMaterials;
|
||||
AttachedObject._simVisionConeRenderer.SetColor(AttachedObject._simAlarmColor);
|
||||
if (AttachedObject._isTutorialTotem)
|
||||
{
|
||||
GlobalMessenger.FireEvent("TutorialAlarmTotemTriggered");
|
||||
}
|
||||
}
|
||||
else if (!AttachedObject._isPlayerVisible && VisibleFor.Count >= 1)
|
||||
{
|
||||
Locator.GetAlarmSequenceController().DecreaseAlarmCounter();
|
||||
AttachedObject._simTotemMaterials[0] = AttachedObject._origSimEyeMaterial;
|
||||
AttachedObject._simTotemRenderer.sharedMaterials = AttachedObject._simTotemMaterials;
|
||||
AttachedObject._simVisionConeRenderer.SetColor(AttachedObject._simVisionConeRenderer.GetOriginalColor());
|
||||
AttachedObject._pulseLightController.FadeTo(0f, 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetEnabled(bool enabled)
|
||||
|
Loading…
x
Reference in New Issue
Block a user