コード例 #1
0
        private void OnTakeDamage(On.RoR2.HealthComponent.orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
        {
            // If a character was killed by the world, we shouldn't do anything.
            if (!damageInfo.attacker || !damageInfo.inflictor)
            {
                orig(self, damageInfo);
                return;
            }

            // We need an inventory to do check for our item
            var count = ItemCount(this, self.body);

            if (count > 0)
            {
                //Chat.AddMessage("Reflecting projectile");
                var body   = self.GetComponent <RoR2.CharacterBody>();
                var damage = damageInfo.damage * (DamageFactor + AdditionalDamagePerStack * count) * 100;

                if (Helpers.InDebugMode())
                {
                    ModLogger.LogInfo($"Got {damageInfo.damage} damage, sending back {damage}");
                }

                // Generate projectile
                var projectileInfo = new FireProjectileInfo
                {
                    owner            = body.gameObject,
                    projectilePrefab = AspectProjectile,
                    //speedOverride = 100.0f,
                    damage             = damage,
                    damageTypeOverride = null,
                    damageColorIndex   = DamageColorIndex.Default,
                    procChainMask      = default,