Beispiel #1
0
        public static bool Prefix(ref Knife __instance, GUIHand hand)
        {
            if (!Config.NONVIOLENT.Equals(DeathRun.config.nonViolent))
            {
                return(true);
            }

            Vector3    position   = default(Vector3);
            GameObject gameObject = null;

            UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, __instance.attackDist, ref gameObject, ref position, true);
            if (gameObject == null)
            {
                InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>();
                if (component != null && component.GetMostRecent() != null)
                {
                    gameObject = component.GetMostRecent().gameObject;
                }
            }
            if (gameObject)
            {
                LiveMixin liveMixin = gameObject.FindAncestor <LiveMixin>();
                if (Knife.IsValidTarget(liveMixin))
                {
                    if (liveMixin)
                    {
                        bool     wasAlive = liveMixin.IsAlive();
                        TechType t        = CraftData.GetTechType(gameObject);
                        if ((t == TechType.GenericJeweledDisk) ||
                            (t == TechType.BlueJeweledDisk) ||
                            (t == TechType.GreenJeweledDisk) ||
                            (t == TechType.PurpleJeweledDisk) ||
                            (t == TechType.RedJeweledDisk))
                        {
                            liveMixin.TakeDamage(__instance.damage, position, __instance.damageType, null);
                        }
                        __instance.GiveResourceOnDamage(gameObject, liveMixin.IsAlive(), wasAlive);
                    }
                    global::Utils.PlayFMODAsset(__instance.attackSound, __instance.transform, 20f);
                    //VFXSurface component2 = gameObject.GetComponent<VFXSurface>();
                    //Vector3 euler = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    //VFXSurfaceTypeManager.main.Play(component2, __instance.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform);
                }
                else
                {
                    gameObject = null;
                }
            }
            if (gameObject == null && hand.GetActiveTarget() == null)
            {
                if (Player.main.IsUnderwater())
                {
                    global::Utils.PlayFMODAsset(__instance.underwaterMissSound, __instance.transform, 20f);
                    return(false);
                }
                global::Utils.PlayFMODAsset(__instance.surfaceMissSound, __instance.transform, 20f);
            }
            return(false);
        }
Beispiel #2
0
        public override void OnToolUseAnim(GUIHand guiHand)
        {
            Vector3    position      = default(Vector3);
            GameObject closestObject = null;

            UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, attackDist, ref closestObject, ref position, true);

            if (closestObject == null)
            {
                InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>();

                if (component != null && component.GetMostRecent() != null)
                {
                    closestObject = component.GetMostRecent().gameObject;
                }
            }

            if (closestObject)
            {
                LiveMixin mixin = closestObject.FindAncestor <LiveMixin>();

                if (IsTarget(mixin))
                {
                    if (mixin)
                    {
                        bool alive = mixin.IsAlive();
                        mixin.TakeDamage(damage, position, damageType, null);
                        GiveResource(closestObject, mixin.IsAlive(), alive);
                    }

                    //Utils.PlayFMODAsset(swingSound, transform, 20f);
                    VFXSurface component2 = closestObject.GetComponent <VFXSurface>();
                    Vector3    euler      = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    VFXSurfaceTypeManager.main.Play(component2, vfxEventType, position, Quaternion.Euler(euler), Player.main.transform);
                }

                else
                {
                    closestObject = null;
                }
            }

            if (closestObject == null && guiHand.GetActiveTarget() == null)
            {
                if (Player.main.IsUnderwater())
                {
                    //Utils.PlayFMODAsset(missSoundWater, transform, 20f);
                }
                else
                {
                    //Utils.PlayFMODAsset(missSoundNoWater, transform, 20f);
                }
            }
        }
        public static void OnUpdate_Postfix(GUIHand __instance)
        {
            if (GameInput.GetButtonHeld(GameInput.Button.AltTool) && GameInput.GetButtonDown(GameInput.Button.LeftHand))
            {
                check = !check;
            }

            if (HandReticle.main.iconType == HandReticle.IconType.Default && HandReticle.main._icons.TryGetValue(HandReticle.IconType.Default, out var icon))
            {
                icon.SetActive((__instance.GetActiveTarget() != null && !Player.main.IsPiloting()) || !check, 0.1f);
            }
        }
        public static void Postfix(GUIHand __instance)
        {
            if (GameInput.GetButtonHeld(GameInput.Button.AltTool) && GameInput.GetButtonDown(GameInput.Button.LeftHand))
            {
                NoCrosshair.check = !NoCrosshair.check;
            }

            if (HandReticle.main.iconType == HandReticle.IconType.Default)
            {
                if ((__instance.GetActiveTarget() == null || Player.main.IsPiloting()) && NoCrosshair.check)
                {
                    NoCrosshair.ChangeCrosshair(false);
                }
                else
                {
                    NoCrosshair.ChangeCrosshair(true);
                }
            }
        }