CheckPlayerVisible

This commit is contained in:
JohnCorby 2022-08-19 18:09:44 -07:00
parent 8bf212c02d
commit ea5477cc15

View File

@ -3,6 +3,7 @@ using QSB.EchoesOfTheEye.AlarmTotemSync.Messages;
using QSB.EchoesOfTheEye.AlarmTotemSync.WorldObjects;
using QSB.Messaging;
using QSB.Patches;
using QSB.Player;
using QSB.WorldSync;
using UnityEngine;
@ -83,6 +84,38 @@ public class AlarmTotemPatches : QSBPatch
}
*/
[HarmonyPrefix]
[HarmonyPatch(typeof(AlarmTotem), nameof(AlarmTotem.CheckPlayerVisible))]
private static bool CheckPlayerVisible(AlarmTotem __instance, out bool __result)
{
if (!__instance._isFaceOpen)
{
__result = false;
return false;
}
foreach (var player in QSBPlayerManager.PlayerList)
{
var lanternController = player.AssignedSimulationLantern?.AttachedObject?._lanternController;
if (!lanternController)
{
continue;
}
var playerLightSensor = player.LightSensor;
if ((lanternController.IsHeldByPlayer() && !lanternController.IsConcealed()) || playerLightSensor.IsIlluminated())
{
var position = player.Camera.transform.position;
if (__instance.CheckPointInVisionCone(position) && !__instance.CheckLineOccluded(__instance._sightOrigin.position, position))
{
__result = true;
return false;
}
}
}
__result = false;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(AlarmBell), nameof(AlarmBell.OnEntry))]
private static bool OnEntry(AlarmBell __instance, GameObject hitObj)