Beispiel #1
0
 private void Start()
 {
     animator                        = GetComponentInChildren <Animator>();
     pickupable                      = GetComponent <Pickupable>();
     closedDamageModifier            = gameObject.EnsureComponent <DamageModifier>();
     closedDamageModifier.multiplier = 0.5f;
     closedDamageModifier.damageType = DamageType.Normal;
     surface = GetComponent <VFXSurface>();
 }
Beispiel #2
0
        private void OnCollisionEnter(Collision collisionInfo)
        {
            SeaMoth componentInParent = collisionInfo.gameObject.GetComponentInParent <SeaMoth>();

            GrapplingHook component = collisionInfo.gameObject.GetComponent <GrapplingHook>();

            if (staticAttached || (fixedJoint && fixedJoint.connectedBody) || componentInParent != null || component != null)
            {
                return;
            }

            Rigidbody targetRigidbody = GetTargetRigidbody(collisionInfo.gameObject);

            rb.velocity = Vector3.zero;

            if (targetRigidbody != null && JointHelper.ConnectFixed(gameObject, targetRigidbody))
            {
                staticAttached = false;
            }
            else
            {
                staticAttached = true;
                rb.isKinematic = true;
            }

            Utils.PlayFMODAsset(hitSound, transform, 5f);

            Vector3 vector = default(Vector3);

            int num = 0;

            for (int i = 0; i < collisionInfo.contacts.Length; i++)
            {
                ContactPoint contactPoint = collisionInfo.contacts[i];
                if (num == 0)
                {
                    vector = contactPoint.normal;
                }
                else
                {
                    vector += contactPoint.normal;
                }
                num++;
            }
            if (num > 0)
            {
                vector /= num;
                Vector3 eulerAngles = Quaternion.LookRotation(transform.forward, vector).eulerAngles;
                eulerAngles.z        -= 90f;
                transform.eulerAngles = eulerAngles;
            }
            VFXSurface component2 = collisionInfo.gameObject.GetComponent <VFXSurface>();

            VFXSurfaceTypeManager.main.Play(component2, VFXEventTypes.impact, transform.position, transform.rotation, null);
        }
Beispiel #3
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);
                }
            }
        }
        new public void OnHit()
        {
            Exosuit componentInParent = base.GetComponentInParent <Exosuit>();

            if (componentInParent.CanPilot() && componentInParent.GetPilotingMode())
            {
                Vector3    position   = default;
                GameObject gameObject = null;
                Vector3    vector;
                UWE.Utils.TraceFPSTargetPosition(componentInParent.gameObject, 6.5f, ref gameObject, ref position, out vector, 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 (liveMixin)
                    {
                        liveMixin.IsAlive();
                        liveMixin.TakeDamage(50f, position, DamageType.Normal, null);
                        // Originally the change was from Normal to Electrical, but there should be a Normal component and an Electrical.
                        // Without a Normal component to the damage, Eye Jellies (to use one example) give no f***s about being twatted in the eye with a Lightning Claw.
                        // That's not right; even if the electrical damage does nothing for them, it's a chunk of heavy metal being propelled at high speed by precision hydraulics.
                        Log.LogDebug($"ExosuitLightningClaw: inflicting Electrical damage on target {gameObject.ToString()}");
                        liveMixin.TakeDamage(30f, position, DamageType.Electrical, null);                         // Animals treat this as over 1000 damage when deciding whether to flee or not.
                        // Curiously, Snow Stalkers appear to give no f***s about any sort of damage, and will continue pursuing until you either get beyond their
                        // "bollocks to this" range, or until they are dead.
                        global::Utils.PlayFMODAsset(base.hitFishSound, this.front, 50f);
                    }
                    else
                    {
                        global::Utils.PlayFMODAsset(base.hitTerrainSound, this.front, 50f);
                    }
                    VFXSurface component2 = gameObject.GetComponent <VFXSurface>();
                    Vector3    euler      = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    VFXSurfaceTypeManager.main.Play(component2, base.vfxEventType, position, Quaternion.Euler(euler), componentInParent.gameObject.transform);
                    gameObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        public void OnHit()
        {
            if (TruckHelper.IsPiloted())
            {
                Vector3    position     = default(Vector3);
                GameObject targetObject = null;

                UWE.Utils.TraceFPSTargetPosition(TruckHelper.MainCab, 6.5f, ref targetObject, ref position, out Vector3 normal, true);

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

                    if (component != null && component.GetMostRecent() != null)
                    {
                        targetObject = component.GetMostRecent().gameObject;
                    }
                }
                if (targetObject)
                {
                    LiveMixin liveMixin = targetObject.FindAncestor <LiveMixin>();

                    if (liveMixin)
                    {
                        bool flag = liveMixin.IsAlive();
                        liveMixin.TakeDamage(50f, position, DamageType.Normal, null);
                        Utils.PlayFMODAsset(hitFishSound, front, 50f);
                    }
                    else
                    {
                        Utils.PlayFMODAsset(hitTerrainSound, front, 50f);
                    }

                    VFXSurface component2 = targetObject.GetComponent <VFXSurface>();

                    Vector3 euler = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);

                    VFXSurfaceTypeManager.main.Play(component2, vfxEventType, position, Quaternion.Euler(euler), TruckHelper.MainCab.transform);

                    targetObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        void OnHit()
        {
            if (seamoth.CanPilot() && seamoth.GetPilotingMode())
            {
                Vector3    position   = default(Vector3);
                GameObject gameObject = null;
                UWE.Utils.TraceFPSTargetPosition(seamoth.gameObject, 6.5f, 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 (liveMixin)
                    {
                        bool flag = liveMixin.IsAlive();
                        liveMixin.TakeDamage(50f, position, DamageType.Normal, null);
                        global::Utils.PlayFMODAsset(hitFishSound, this.front, 5f);
                    }
                    else
                    {
                        global::Utils.PlayFMODAsset(hitTerrainSound, this.front, 5f);
                    }
                    VFXSurface component2 = gameObject.GetComponent <VFXSurface>();
                    Vector3    euler      = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0f);
                    VFXSurfaceTypeManager.main.Play(component2, VFXEventTypes.impact, position, Quaternion.Euler(euler), seamoth.gameObject.transform);
                    gameObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                }
            }

            this.cooldownTime = Time.time + cooldownHit;
        }
Beispiel #7
0
        public void OnHit()
        {
            if (Exosuit.CanPilot() && Exosuit.GetPilotingMode())
            {
                Vector3    pos       = Vector3.zero;
                GameObject hitObject = null;
                drillTarget = null;

                UWE.Utils.TraceFPSTargetPosition(Exosuit.gameObject, attackDist, ref hitObject, ref pos, true);

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

                    if (component != null && component.GetMostRecent() != null)
                    {
                        hitObject = component.GetMostRecent().gameObject;
                    }
                }
                if (hitObject && drilling)
                {
                    var drillable = hitObject.FindAncestor <Drillable>();

                    loopHit.Play();

                    if (drillable)
                    {
                        drillable.OnDrill(fxSpawnPoint.position, Exosuit, out GameObject gameObject2);

                        if (!gameObject2)
                        {
                            StopEffects();
                        }

                        drillTarget = gameObject2;

                        if (fxControl.emitters[0].fxPS != null && !fxControl.emitters[0].fxPS.emission.enabled)
                        {
                            fxControl.Play(0);
                        }
                    }
                    else
                    {
                        LiveMixin liveMixin = hitObject.FindAncestor <LiveMixin>();

                        if (liveMixin)
                        {
                            bool flag = liveMixin.IsAlive();
                            liveMixin.TakeDamage(4f, pos, DamageType.Drill, null);
                            drillTarget = hitObject;
                        }

                        VFXSurface component2 = hitObject.GetComponent <VFXSurface>();

                        if (drillFXinstance == null)
                        {
                            drillFXinstance = VFXSurfaceTypeManager.main.Play(component2, vfxEventType, fxSpawnPoint.position, fxSpawnPoint.rotation, fxSpawnPoint);
                        }
                        else if (component2 != null && prevSurfaceType != component2.surfaceType)
                        {
                            VFXLateTimeParticles component3 = drillFXinstance.GetComponent <VFXLateTimeParticles>();
                            component3.Stop();
                            Destroy(drillFXinstance.gameObject, 1.6f);
                            drillFXinstance = VFXSurfaceTypeManager.main.Play(component2, vfxEventType, fxSpawnPoint.position, fxSpawnPoint.rotation, fxSpawnPoint);
                            prevSurfaceType = component2.surfaceType;
                        }

                        hitObject.SendMessage("BashHit", this, SendMessageOptions.DontRequireReceiver);
                    }
                }
                else
                {
                    StopEffects();
                }
            }
        }
Beispiel #8
0
        public override void OnToolUseAnim(GUIHand hand)
        {
            Vector3    position   = new Vector3();
            GameObject closestObj = null;

#if SUBNAUTICA_STABLE
            UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, this.attackDist, ref closestObj, ref position);
#elif BELOWZERO
            Vector3 normal = new Vector3();

            UWE.Utils.TraceFPSTargetPosition(Player.main.gameObject, this.attackDist, ref closestObj, ref position, out normal);
#endif
            if (closestObj == null)
            {
                InteractionVolumeUser component = Player.main.gameObject.GetComponent <InteractionVolumeUser>();
                if (component != null && component.GetMostRecent() != null)
                {
                    closestObj = component.GetMostRecent().gameObject;
                }
            }



            if (closestObj != null)
            {
                LiveMixin ancestor = closestObj.FindAncestor <LiveMixin>();
                if (Knife.IsValidTarget(ancestor))
                {
                    if (ancestor != null)
                    {
                        bool  wasAlive   = ancestor.IsAlive();
                        float thisDamage = this.damage * (closestObj.GetComponent <Creature>() != null ? FaunaDamageMultiplier : 1f);
                        ancestor.TakeDamage(thisDamage, position, this.damageType);
                        this.GiveResourceOnDamage(closestObj, ancestor.IsAlive(), wasAlive);
                    }
#if SUBNAUTICA_STABLE
                    Utils.PlayFMODAsset(this.attackSound, this.transform);
                    VFXSurface component = closestObj.GetComponent <VFXSurface>();
                    Vector3    euler     = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0.0f);
                    VFXSurfaceTypeManager.main.Play(component, this.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform);
                }
                else
                {
                    closestObj = (GameObject)null;
                }
#elif BELOWZERO
                }

                VFXSurface component = closestObj.GetComponent <VFXSurface>();
                Vector3 euler        = MainCameraControl.main.transform.eulerAngles + new Vector3(300f, 90f, 0.0f);
                VFXSurfaceTypeManager.main.Play(component, this.vfxEventType, position, Quaternion.Euler(euler), Player.main.transform);
                VFXSurfaceTypes vfxSurfaceTypes = Utils.GetObjectSurfaceType(closestObj);
                if (vfxSurfaceTypes == VFXSurfaceTypes.none)
                {
                    vfxSurfaceTypes = Utils.GetTerrainSurfaceType(position, normal, VFXSurfaceTypes.sand);
                }
                EventInstance fmodEvent = Utils.GetFMODEvent(this.hitSound, this.transform.position);
                int num1 = (int)fmodEvent.setParameterValueByIndex(this.surfaceParamIndex, (float)vfxSurfaceTypes);
                int num2 = (int)fmodEvent.start();
                int num3 = (int)fmodEvent.release();
#endif
            }