Ejemplo n.º 1
0
        /// <summary>
        /// Prefix of <see cref="Scp106PlayerScript.CallCmdMakePortal"/>.
        /// </summary>
        /// <param name="__instance">The <see cref="Scp106PlayerScript"/> instance.</param>
        /// <returns>Returns a value indicating whether the original method has to be executed or not.</returns>
        private static bool Prefix(Scp106PlayerScript __instance)
        {
            if (!__instance._interactRateLimit.CanExecute(true) || !__instance.GetComponent <FallDamage>().isGrounded)
            {
                return(false);
            }

            bool rayCastHit = Physics.Raycast(new Ray(__instance.transform.position, -__instance.transform.up), out RaycastHit raycastHit, 10f, __instance.teleportPlacementMask);

            var ev = new CreatingPortalEventArgs(API.Features.Player.Get(__instance.gameObject), raycastHit.point - Vector3.up);

            Scp106.OnCreatingPortal(ev);

            Debug.DrawRay(__instance.transform.position, -__instance.transform.up, Color.red, 10f);

            if (ev.IsAllowed && __instance.iAm106 && !__instance.goingViaThePortal && rayCastHit)
            {
                __instance.SetPortalPosition(ev.Position);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public static bool Prefix(Scp106PlayerScript __instance)
        {
            if (EventPlugin.Scp106CreatedPortalEventDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._interactRateLimit.CanExecute(true) || !__instance.GetComponent <FallDamage>().isGrounded)
                {
                    return(false);
                }

                bool rayCastHit = Physics.Raycast(new Ray(__instance.transform.position, -__instance.transform.up), out RaycastHit raycastHit, 10f, __instance.teleportPlacementMask);

                bool    allow          = true;
                Vector3 portalPosition = raycastHit.point - Vector3.up;

                Events.InvokeScp106CreatedPortal(__instance.gameObject, ref allow, ref portalPosition);

                Debug.DrawRay(__instance.transform.position, -__instance.transform.up, Color.red, 10f);

                if (allow && __instance.iAm106 && !__instance.goingViaThePortal && rayCastHit)
                {
                    __instance.SetPortalPosition(portalPosition);
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp106CreatedPortalEvent error: {exception}");
                return(true);
            }
        }