示例#1
0
        private static bool Prefix(Scp079PlayerScript __instance, ushort cameraId, bool lookatRotation)
        {
            try
            {
                if (!__instance._interactRateLimit.CanExecute(true))
                {
                    return(false);
                }

                if (!__instance.iAm079)
                {
                    return(false);
                }

                Camera079 camera = API.Features.Map.GetCameraById(cameraId);

                if (camera == null)
                {
                    return(false);
                }

                float num                  = __instance.CalculateCameraSwitchCost(camera.transform.position);
                bool  isAllowed            = num <= __instance.curMana;
                ChangingCameraEventArgs ev = new ChangingCameraEventArgs(API.Features.Player.Get(__instance.gameObject), camera, num, isAllowed);
                Scp079.OnChangingCamera(ev);
                if (ev.IsAllowed)
                {
                    __instance.RpcSwitchCamera(ev.Camera.cameraId, lookatRotation);
                    __instance.Mana          = Mathf.Clamp(__instance.Mana - ev.APCost, 0, __instance.maxMana);
                    __instance.currentCamera = ev.Camera;
                }
                else if (ev.APCost > __instance.curMana)
                {
                    __instance.RpcNotEnoughMana(ev.APCost, __instance.curMana);
                }

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"{typeof(ChangingCamera).FullName}.{nameof(Prefix)}:\n{e}");

                return(true);
            }
        }