예제 #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);
        }
예제 #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);
                }
            }
        }
예제 #3
0
        private void AddDamageToTarget(GameObject gameObject)
        {
            Vector3 position = gameObject.transform.position;

            if (gameObject != null)
            {
                LiveMixin liveMixin = gameObject.GetComponent <LiveMixin>();
                if (!liveMixin)
                {
                    liveMixin = Utils.FindEnabledAncestorWithComponent <LiveMixin>(gameObject);
                }
                if (liveMixin)
                {
                    if (liveMixin.IsAlive())
                    {
                        liveMixin.TakeDamage(laserDamage, position, DamageType.Normal, null);
                    }
                }
                else
                {
                    if (gameObject.GetComponent <BreakableResource>() != null)
                    {
                        gameObject.SendMessage("BreakIntoResources", null, SendMessageOptions.DontRequireReceiver);
                    }
                }
            }
        }
        private void AddDamage(GameObject gameObject)
        {
            Vector3 position = gameObject.transform.position;

            if (gameObject != null)
            {
                LiveMixin liveMixin = gameObject.GetComponent <LiveMixin>();
                if (!liveMixin)
                {
                    liveMixin = Utils.FindEnabledAncestorWithComponent <LiveMixin>(gameObject);
                }
                if (liveMixin)
                {
                    if (liveMixin.IsAlive())
                    {
                        liveMixin.TakeDamage(laserDamage, position, DamageType.Explosive, null);
                        WorldForces.AddExplosion(position, DayNightCycle.main.timePassed, 5f, 4f);
                    }
                }
                else
                {
                    if (gameObject.GetComponent <BreakableResource>() != null)
                    {
                        gameObject.SendMessage("BreakIntoResources", null, SendMessageOptions.DontRequireReceiver);
                        WorldForces.AddExplosion(position, DayNightCycle.main.timePassed, 5f, 4f);
                    }
                }
            }
        }
        public static bool IsEatableFishAlive(GameObject go)
        {
            Creature  creature  = go.GetComponent <Creature>();
            Eatable   eatable   = go.GetComponent <Eatable>();
            LiveMixin liveMixin = go.GetComponent <LiveMixin>();

            return(creature && eatable && liveMixin && liveMixin.IsAlive());
        }
예제 #6
0
        public override float Evaluate(Creature creature)
        {
            Submarine currentSubmarine       = Player.main.currentSub?.GetComponent <Submarine>();
            LiveMixin liveMixin              = currentSubmarine?.GetComponent <LiveMixin>();
            bool      pastBiteRefractoryTime = Time.time > lastBiteTime + BITE_REFRACTORTY_PERIOD;
            bool      withinRange            = distanceToMannedSub <= MAX_DISTANCE;

            bool possibleAttack = currentSubmarine != null && liveMixin != null && liveMixin.IsAlive() && pastBiteRefractoryTime && withinRange;

            return(possibleAttack ? GetEvaluatePriority() : 0f);
        }
        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 static bool Prefix(ref SubRoot __instance)
        {
            LiveMixin cyclopsLife = __instance.live;

            if (cyclopsLife == null || !cyclopsLife.IsAlive())
            {
                return(true); // safety check
            }
            var mgr = CyclopsManager.GetManager(__instance);

            if (mgr == null)
            {
                return(true); // Safety Check
            }
            mgr.Upgrade.HandleUpgrades();

            // No need to execute original method anymore
            return(false); // Completely override the method and do not continue with original execution
        }
        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);
                }
            }
        }
        private void OnTriggerEnter(Collider collider)
        {
            if (creature.Hunger.Value < 0.2f)
            {
                return;
            }
            GameObject nibbleGameObject = collider.gameObject;

            if (liveMixin.IsAlive() && !frozen)
            {
                timeStartNibbling = Time.time;
                EcoTarget ecoTarget = nibbleGameObject.GetComponentInParent <EcoTarget>();
                LiveMixin lm        = nibbleGameObject.GetComponentInParent <LiveMixin>();
                bool      isDead    = (lm != null && !lm.IsAlive()) || (ecoTarget != null && ecoTarget.type == EcoTargetType.DeadMeat);

                bool isSpecialConsumable = ecoTarget != null && ecoTarget.type == QPatch.clownPincherSpecialEdible;

                if (isDead || isSpecialConsumable)
                {
                    objectEating = collider.gameObject;
                }
            }
        }
예제 #11
0
        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;
        }
예제 #12
0
        public static float AddHealthOverride(LiveMixin live, float addHealth, Welder welder)
        {
            float result = 0f;

            if ((live.IsAlive() || live.canResurrect) && live.health < live.maxHealth)
            {
                float num       = live.health;
                float newHealth = Math.Min(live.health + addHealth, live.maxHealth);
                result = newHealth - num;

                SimulationOwnership simulationOwnership = NitroxServiceLocator.LocateService <SimulationOwnership>();
                NitroxId            id = NitroxEntity.GetId(live.gameObject);

                // For now, we only control the LiveMixin for vehicles (not even repair nodes at a cyclops)
                // If we change that, this if should be removed!
                Vehicle vehicle = live.GetComponent <Vehicle>();
                if (vehicle)
                {
                    if (simulationOwnership.HasAnyLockType(id))
                    {
                        result = live.AddHealth(addHealth);
                    }
                    else
                    {
                        // Another player simulates this entity. Send the weld info
                        Log.Debug($"Broadcast weld action for {id}");
                        NitroxServiceLocator.LocateService <LocalPlayer>().BroadcastWeld(id, addHealth);
                    }
                }
                else
                {
                    result = live.AddHealth(addHealth);
                }
            }
            return(result);
        }
 public override void OnTouch(Collider collider)
 {
     if (frozen)
     {
         return;
     }
     if (liveMixin.IsAlive() && Time.time > timeLastBite + biteInterval)
     {
         Creature component = GetComponent <Creature>();
         if (component.Aggression.Value >= 0.1f)
         {
             GameObject target = GetTarget(collider);
             if (!playerDeathCinematic.IsCinematicModeActive())
             {
                 Player player = target.GetComponent <Player>();
                 if (player != null)
                 {
                     if (Time.time > timeCinematicAgain && player.CanBeAttacked() && player.liveMixin.IsAlive() && !player.cinematicModeActive)
                     {
                         float num = DamageSystem.CalculateDamage(biteDamage, DamageType.Normal, player.gameObject, null);
                         if (player.liveMixin.health - num <= 0f)
                         {
                             Invoke("KillPlayer", 2.5f);
                             playerDeathCinematic.StartCinematicMode(player);
                             attackSource.clip = cinematicClipPool.GetRandomClip();
                             attackSource.Play();
                             timeCinematicAgain = Time.time + 5f;
                             timeLastBite       = Time.time;
                             return;
                         }
                     }
                 }
                 LiveMixin liveMixin = target.GetComponent <LiveMixin>();
                 if (liveMixin == null)
                 {
                     return;
                 }
                 if (!liveMixin.IsAlive())
                 {
                     return;
                 }
                 if (liveMixin == Player.main.liveMixin)
                 {
                     if (!player.CanBeAttacked())
                     {
                         return;
                     }
                 }
                 if (!CanAttackTargetFromPosition(target))
                 {
                     return;
                 }
                 liveMixin.TakeDamage(GetBiteDamage(target));
                 attackSource.clip = biteClipPool.GetRandomClip();
                 attackSource.Play();
                 timeLastBite = Time.time;
                 creature.GetAnimator().SetTrigger("bite");
                 component.Aggression.Value -= 0.15f;
             }
         }
     }
 }
예제 #14
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
            }
예제 #15
0
        public override void OnTouch(Collider collider)
        {
            if (frozen)
            {
                return;
            }
            if (liveMixin.IsAlive() && Time.time > timeLastBite + biteInterval)
            {
                Creature component = GetComponent <Creature>();

                GameObject      target          = GetTarget(collider);
                GulperBehaviour gulperBehaviour = GetComponent <GulperBehaviour>();
                if (!gulperBehaviour.IsHoldingVehicle() && !playerDeathCinematic.IsCinematicModeActive())
                {
                    Player player = target.GetComponent <Player>();
                    if (player != null)
                    {
                        if (Time.time > timeCinematicAgain && player.CanBeAttacked() && player.liveMixin.IsAlive() && !player.cinematicModeActive)
                        {
                            Invoke("KillPlayer", 0.9f);
                            playerDeathCinematic.StartCinematicMode(player);
                            attackSource.clip = clipPool.GetRandomClip();
                            attackSource.Play();
                            timeCinematicAgain = Time.time + 4f;
                            timeLastBite       = Time.time;
                            return;
                        }
                    }
                    else if (gulperBehaviour.GetCanGrabVehicle() && component.Aggression.Value > 0.1f)
                    {
                        SeaMoth seamoth = target.GetComponent <SeaMoth>();
                        if (seamoth && !seamoth.docked)
                        {
                            gulperBehaviour.GrabGenericSub(seamoth);
                            component.Aggression.Value -= 0.5f;
                            return;
                        }
                        Exosuit exosuiit = target.GetComponent <Exosuit>();
                        if (exosuiit && !exosuiit.docked)
                        {
                            gulperBehaviour.GrabExosuit(exosuiit);
                            component.Aggression.Value -= 0.5f;
                            return;
                        }
                    }
                    LiveMixin liveMixin = target.GetComponent <LiveMixin>();
                    if (liveMixin == null)
                    {
                        return;
                    }
                    if (!liveMixin.IsAlive())
                    {
                        return;
                    }
                    if (!CanAttackTargetFromPosition(target))
                    {
                        return;
                    }
                    if (CanSwallowWhole(collider.gameObject, liveMixin))
                    {
                        Destroy(liveMixin.gameObject, 0.5f);
                        var suckInWhole = collider.gameObject.AddComponent <BeingSuckedInWhole>();
                        suckInWhole.animationLength = 0.5f;
                        suckInWhole.target          = throat;
                        creature.GetAnimator().SetTrigger("bite");
                        return;
                    }
                    else
                    {
                        if (component.Aggression.Value >= 0.2f && target.GetComponentInParent <Vehicle>() == null)
                        {
                            liveMixin.TakeDamage(GetBiteDamage(target));
                            timeLastBite      = Time.time;
                            attackSource.clip = clipPool.GetRandomClip();
                            attackSource.Play();
                            creature.GetAnimator().SetTrigger("bite");
                            component.Aggression.Value = 0f;
                            return;
                        }
                    }
                }
            }
        }
        public virtual void OnTouch(Collider collider)
        {
            Debugger.Log("Attack 0");

            if (!base.enabled)
            {
                return;
            }

            if (this.frozen)
            {
                return;
            }

            if (this.creature.Aggression.Value < this.biteAggressionThreshold)
            {
                return;
            }

            if (Time.time < this.timeLastBite + this.biteInterval)
            {
                return;
            }

            GameObject target = this.GetTarget(collider);

            if (this.ignoreSameKind && global::Utils.CompareTechType(base.gameObject, target))
            {
                return;
            }

            Debugger.Log("Attack 1");

            if (this.CanBite(target))
            {
                Debugger.Log("Attack 2");

                this.timeLastBite = Time.time;

                LiveMixin component2 = target.GetComponent <LiveMixin>();

                if (component2 != null && component2.IsAlive())
                {
                    component2.TakeDamage(this.GetBiteDamage(target), default(Vector3), DamageType.Normal, null);
                    component2.NotifyCreatureDeathsOfCreatureAttack();
                }

                Vector3 position = collider.ClosestPointOnBounds(this.mouth.transform.position);

                if (this.damageFX != null)
                {
                    UnityEngine.Object.Instantiate <GameObject>(this.damageFX, position, this.damageFX.transform.rotation);
                }

                if (this.attackSound != null)
                {
                    global::Utils.PlayEnvSound(this.attackSound, position, 20f);
                }

                this.creature.Aggression.Add(-this.biteAggressionDecrement);

                if (component2 != null && !component2.IsAlive())
                {
                    this.TryEat(component2.gameObject, false);
                }

                base.gameObject.SendMessage("OnMeleeAttack", target, SendMessageOptions.DontRequireReceiver);
            }
        }
예제 #17
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();
                }
            }
        }
예제 #18
0
        public static void Prefix(ExosuitDrillArm __instance)
        {
            try
            {
                var damage = Config.Instance.AddOtherDamage;
                if (damage <= 0)
                {
                    return;
                }

                var exosuit = ExosuitField.GetValue(__instance) as Exosuit;

                if (exosuit == null)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: exosuit is null", null, true);
                    return;
                }

                if (exosuit.CanPilot() && exosuit.GetPilotingMode())
                {
                    Vector3    zero       = Vector3.zero;
                    GameObject gameObject = null;
                    Vector3    vector;
                    UWE.Utils.TraceFPSTargetPosition(exosuit.gameObject, 5f, ref gameObject, ref zero, out vector, true);

                    if (gameObject != null && gameObject && (bool)DrillingField.GetValue(__instance))
                    {
                        Drillable drillable = gameObject.FindAncestor <Drillable>();

                        if (!drillable)
                        {
                            LiveMixin liveMixin = gameObject.FindAncestor <LiveMixin>();
                            if (liveMixin)
                            {
                                liveMixin.IsAlive();
                                liveMixin.TakeDamage(damage, zero, DamageType.Drill, null);

                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "Drill Extra Damaging: " + damage, null, true);

                                // Leave this for the real one
                                // this.drillTarget = gameObject;
                            }
                            return;
                        }

                        var maxHealth = Config.Instance.MaxDrillHealth;
                        var healths   = drillable.health;

                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Hitting drillable with healths: " + healths.Length, null, true);

                        for (int i = 0; i < healths.Length; i++)
                        {
                            if (healths[i] > maxHealth)
                            {
                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Drillable health reduced from {healths[i]} to {maxHealth}", null, true);

                                healths[i] = maxHealth;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: " + ex.ToString(), ex, true);
            }
        }