예제 #1
0
    // Token: 0x06000E26 RID: 3622 RVA: 0x0006500C File Offset: 0x0006320C
    private bool DamageArea(int hitAreaIndex, HitData hit)
    {
        ZLog.Log("hit mine rock " + hitAreaIndex);
        MineRock5.HitArea hitArea = this.GetHitArea(hitAreaIndex);
        if (hitArea == null)
        {
            ZLog.Log("Missing hit area " + hitAreaIndex);
            return(false);
        }
        this.LoadHealth();
        if (hitArea.m_health <= 0f)
        {
            ZLog.Log("Already destroyed");
            return(false);
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return(false);
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return(false);
        }
        hitArea.m_health -= totalDamage;
        this.SaveHealth();
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
        Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (hitArea.m_health <= 0f)
        {
            this.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[]
            {
                hitAreaIndex,
                hitArea.m_health
            });
            this.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
            foreach (GameObject original in this.m_dropItems.GetDropList())
            {
                Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f;
                UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity);
            }
            if (this.AllDestroyed())
            {
                this.m_nview.Destroy();
            }
            return(true);
        }
        return(false);
    }
예제 #2
0
        public static void RPC_Damage_RP(this Character __instance, long sender, HitData hit)
        {
            if (__instance.IsDebugFlying() || !__instance.m_nview.IsOwner() || __instance.GetHealth() <= 0f || __instance.IsDead() || __instance.IsTeleporting() || __instance.InCutscene() || (hit.m_dodgeable && __instance.IsDodgeInvincible()))
            {
                return;
            }
            Character attacker = hit.GetAttacker();

            if ((hit.HaveAttacker() && attacker == null) || (__instance.IsPlayer() && !__instance.IsPVPEnabled() && attacker != null && attacker.IsPlayer()))
            {
                return;
            }
            if (attacker != null && !attacker.IsPlayer())
            {
                float difficultyDamageScale = Game.instance.GetDifficultyDamageScale(__instance.transform.position);
                hit.ApplyModifier(difficultyDamageScale);
            }
            __instance.m_seman.OnDamaged(hit, attacker);
            if (__instance.m_baseAI != null && !__instance.m_baseAI.IsAlerted() && hit.m_backstabBonus > 1f && Time.time - __instance.m_backstabTime > 300f)
            {
                __instance.m_backstabTime = Time.time;
                hit.ApplyModifier(hit.m_backstabBonus);
                __instance.m_backstabHitEffects.Create(hit.m_point, Quaternion.identity, __instance.transform);
            }
            if (__instance.IsStaggering() && !__instance.IsPlayer())
            {
                hit.ApplyModifier(2f);
                __instance.m_critHitEffects.Create(hit.m_point, Quaternion.identity, __instance.transform);
            }
            if (hit.m_blockable && __instance.IsBlocking())
            {
                __instance.BlockAttack(hit, attacker);
            }
            __instance.ApplyPushback(hit);
            if (!string.IsNullOrEmpty(hit.m_statusEffect))
            {
                StatusEffect statusEffect = __instance.m_seman.GetStatusEffect(hit.m_statusEffect);
                if (statusEffect == null)
                {
                    statusEffect = __instance.m_seman.AddStatusEffect(hit.m_statusEffect);
                }
                if (statusEffect != null && attacker != null)
                {
                    statusEffect.SetAttacker(attacker);
                }
            }
            HitData.DamageModifiers damageModifiers = __instance.GetDamageModifiers();
            hit.ApplyResistance(damageModifiers, out var significantModifier);
            if (__instance.IsPlayer())
            {
                float bodyArmor = __instance.GetBodyArmor();
                hit.ApplyArmor(bodyArmor);
                __instance.DamageArmorDurability(hit);
            }
            __instance.ApplyDamage(hit, showDamageText: true, triggerEffects: true, significantModifier);
        }
예제 #3
0
    // Token: 0x06000FC4 RID: 4036 RVA: 0x0006EF1C File Offset: 0x0006D11C
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        float num = this.m_nview.GetZDO().GetFloat("health", this.m_health);

        if (num <= 0f)
        {
            this.m_nview.Destroy();
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set("health", num);
        this.Shake();
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        Player closestPlayer = Player.GetClosestPlayer(base.transform.position, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (num <= 0f)
        {
            this.m_destroyedEffect.Create(base.transform.position, base.transform.rotation, base.transform, 1f);
            this.SpawnLog(hit.m_dir);
            List <GameObject> dropList = this.m_dropWhenDestroyed.GetDropList();
            for (int i = 0; i < dropList.Count; i++)
            {
                Vector2    vector   = UnityEngine.Random.insideUnitCircle * 0.5f;
                Vector3    position = base.transform.position + Vector3.up * this.m_spawnYOffset + new Vector3(vector.x, this.m_spawnYStep * (float)i, vector.y);
                Quaternion rotation = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                UnityEngine.Object.Instantiate <GameObject>(dropList[i], position, rotation);
            }
            base.gameObject.SetActive(false);
            this.m_nview.Destroy();
        }
    }
예제 #4
0
    // Token: 0x06000CDD RID: 3293 RVA: 0x0005BF10 File Offset: 0x0005A110
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsValid() || !this.m_nview.IsOwner())
        {
            return;
        }
        if (this.m_destroyed)
        {
            return;
        }
        float num = this.m_nview.GetZDO().GetFloat("health", this.m_health);

        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damages, out type);
        float totalDamage = hit.GetTotalDamage();

        if (this.m_body)
        {
            this.m_body.AddForceAtPosition(hit.m_dir * hit.m_pushForce, hit.m_point, ForceMode.Impulse);
        }
        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set("health", num);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        if (this.m_onDamaged != null)
        {
            this.m_onDamaged();
        }
        if (this.m_hitNoise > 0f)
        {
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);
            if (closestPlayer)
            {
                closestPlayer.AddNoise(this.m_hitNoise);
            }
        }
        if (num <= 0f)
        {
            this.Destroy();
        }
    }
예제 #5
0
    // Token: 0x0600102D RID: 4141 RVA: 0x000722DC File Offset: 0x000704DC
    private void RPC_Damage(long sender, HitData hit)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        if (this.m_nview.GetZDO().GetFloat("health", this.m_health) <= 0f)
        {
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damages, out type);
        float totalDamage = hit.GetTotalDamage();

        if (this.m_piece && this.m_piece.IsPlacedByPlayer())
        {
            PrivateArea.CheckInPrivateArea(base.transform.position, true);
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        this.ApplyDamage(totalDamage);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, base.transform, 1f);
        if (this.m_hitNoise > 0f)
        {
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);
            if (closestPlayer)
            {
                closestPlayer.AddNoise(this.m_hitNoise);
            }
        }
        if (this.m_onDamaged != null)
        {
            this.m_onDamaged();
        }
    }
예제 #6
0
        public static bool MineRock5_DamageArea_Prefix(MineRock5 __instance, HitData hit, int hitAreaIndex, ref EffectList ___m_destroyedEffect, ref EffectList ___m_hitEffect, out float __state, ref bool __result)
        {
            bool isVeinmined = false;

            MineRock5.HitArea hitArea = __instance.GetHitArea(hitAreaIndex);
            __state = hitArea.m_health;

            if (VeinMine.enableSpreadDamage.Value)
            {
                hit = SpreadDamage(hit);
            }
            if (Input.GetKey(VeinMine.veinMineKey.Value))
            {
                isVeinmined = true;
            }

            ZLog.Log("hit mine rock " + hitAreaIndex);
            if (hitArea == null)
            {
                ZLog.Log("Missing hit area " + hitAreaIndex);
                __result = false;
                return(false);
            }
            __instance.LoadHealth();
            if (hitArea.m_health <= 0f)
            {
                ZLog.Log("Already destroyed");
                __result = false;
                return(false);
            }
            HitData.DamageModifier type;
            hit.ApplyResistance(__instance.m_damageModifiers, out type);
            float totalDamage = hit.GetTotalDamage();

            if (hit.m_toolTier < __instance.m_minToolTier)
            {
                DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
                __result = false;
                return(false);
            }
            DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
            if (totalDamage <= 0f)
            {
                __result = false;
                return(false);
            }
            hitArea.m_health -= totalDamage;
            __instance.SaveHealth();
            if (!VeinMine.removeEffects.Value)
            {
                __instance.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
            }
            Player closestPlayer = Player.GetClosestPlayer(hit.m_point, 10f);

            if (closestPlayer)
            {
                closestPlayer.AddNoise(100f);
            }
            if (hitArea.m_health <= 0f)
            {
                __instance.m_nview.InvokeRPC(ZNetView.Everybody, "SetAreaHealth", new object[]
                {
                    hitAreaIndex,
                    hitArea.m_health
                });
                if (!VeinMine.removeEffects.Value)
                {
                    __instance.m_destroyedEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
                }
                foreach (GameObject gameObject in __instance.m_dropItems.GetDropList())
                {
                    if (isVeinmined)
                    {
                        Vector3 position = Player.m_localPlayer.GetTransform().position + new Vector3 {
                            x = 0, y = 2, z = 0
                        } +UnityEngine.Random.insideUnitSphere * 0.3f;
                        UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity);
                        hit.m_point = Player.m_localPlayer.GetTransform().position + new Vector3 {
                            x = 0, y = 2, z = 0
                        };
                    }
                    else if (!isVeinmined)
                    {
                        Vector3 position = hit.m_point + UnityEngine.Random.insideUnitSphere * 0.3f;
                        UnityEngine.Object.Instantiate <GameObject>(gameObject, position, Quaternion.identity);
                    }
                }
                if (__instance.AllDestroyed())
                {
                    __instance.m_nview.Destroy();
                }
                __result = true;
                return(false);
            }
            __result = false;
            return(false);
        }
예제 #7
0
    // Token: 0x06000E15 RID: 3605 RVA: 0x000644D0 File Offset: 0x000626D0
    private void RPC_Hit(long sender, HitData hit, int hitAreaIndex)
    {
        if (!this.m_nview.IsOwner())
        {
            return;
        }
        Collider hitArea = this.GetHitArea(hitAreaIndex);

        if (hitArea == null)
        {
            ZLog.Log("Missing hit area " + hitAreaIndex);
            return;
        }
        string name = "Health" + hitAreaIndex.ToString();
        float  num  = this.m_nview.GetZDO().GetFloat(name, this.m_health);

        if (num <= 0f)
        {
            ZLog.Log("Already destroyed");
            return;
        }
        HitData.DamageModifier type;
        hit.ApplyResistance(this.m_damageModifiers, out type);
        float totalDamage = hit.GetTotalDamage();

        if (hit.m_toolTier < this.m_minToolTier)
        {
            DamageText.instance.ShowText(DamageText.TextType.TooHard, hit.m_point, 0f, false);
            return;
        }
        DamageText.instance.ShowText(type, hit.m_point, totalDamage, false);
        if (totalDamage <= 0f)
        {
            return;
        }
        num -= totalDamage;
        this.m_nview.GetZDO().Set(name, num);
        this.m_hitEffect.Create(hit.m_point, Quaternion.identity, null, 1f);
        Player closestPlayer = Player.GetClosestPlayer(base.transform.position, 10f);

        if (closestPlayer)
        {
            closestPlayer.AddNoise(100f);
        }
        if (this.m_onHit != null)
        {
            this.m_onHit();
        }
        if (num <= 0f)
        {
            this.m_destroyedEffect.Create(hitArea.bounds.center, Quaternion.identity, null, 1f);
            this.m_nview.InvokeRPC(ZNetView.Everybody, "Hide", new object[]
            {
                hitAreaIndex
            });
            foreach (GameObject original in this.m_dropItems.GetDropList())
            {
                Vector3 position = hit.m_point - hit.m_dir * 0.2f + UnityEngine.Random.insideUnitSphere * 0.3f;
                UnityEngine.Object.Instantiate <GameObject>(original, position, Quaternion.identity);
            }
            if (this.m_removeWhenDestroyed && this.AllDestroyed())
            {
                this.m_nview.Destroy();
            }
        }
    }