public void UpdateTailParts()
        {
            GameObject Tail         = ParentObject;
            GameObject Owner        = Tail.Equipped;
            Mutations  PMu          = Owner.GetPart <Mutations>();
            ThickTail  TailMutation = base.ParentObject.Equipped.GetPart <Mutations>().GetMutation("ThickTail") as ThickTail;
            int        ChimeraBoost = ((Owner.StatMod("Strength") + Owner.StatMod("Toughness") + Owner.StatMod("Agility")) / 3);

            if (Owner == null)
            {
                return;
            }
            if (PMu.HasMutation("Chimera"))
            {
                SynergyConstruct Construct;
                bool             SynergizedChi = SynergyEffects.TryGetValue("Chimera", out Construct);
                if (SynergizedChi && Construct.IsActive == false)
                {
                    Construct.Effect.Invoke(ParentObject);
                    Construct.IsActive = true;
                }
            }
            foreach (BaseMutation Mut in PMu.MutationList)
            {
                SynergyConstruct Construct;
                bool             Synergized = SynergyEffects.TryGetValue(Mut.Name, out Construct);
                if (Synergized && Construct.IsActive == false)
                {
                    Construct.Effect.Invoke(ParentObject);
                    Construct.IsActive = true;
                }
            }
        }
        public override bool HandleEvent(GetSwimmingPerformanceEvent E)
        {
            GameObject Tail         = ParentObject;
            GameObject Owner        = Tail.Equipped;
            Mutations  PMu          = Owner.GetPart <Mutations>();
            ThickTail  TailMutation = base.ParentObject.Equipped.GetPart <Mutations>().GetMutation("ThickTail") as ThickTail;
            var        data         = TailMutation.GetData(TailMutation.Level);

            if (PMu.HasMutation("Amphibious"))
            {
                E.MoveSpeedPenalty -= data.SwimSpeed;
            }
            return(base.HandleEvent(E));
        }
        public void TailStrike(XRL.World.GameObject Defender, int Hitbonus)
        {
            ThickTail Tail = base.ParentObject.Equipped.GetPart <Mutations>().GetMutation("ThickTail") as ThickTail;

            var       TailSource         = ParentObject;
            var       Owner              = TailSource.Equipped;
            Mutations HasSynergyMutation = Owner.GetPart <Mutations>();

            if (Defender != null && Defender.PhaseAndFlightMatches(Owner) && Defender.CurrentCell != null && Owner.CurrentCell != null && Owner.DistanceTo(Defender) <= 1)
            {
                if (Defender.pBrain != null)
                {
                    Defender.pBrain.GetAngryAt(Owner, -20);
                }
                if (Stat.Random(1, 20) + Hitbonus + Owner.StatMod("Agility", 0) > Stats.GetCombatDV(Defender))
                {
                    var    data            = Tail.GetData(Tail.Level);
                    int    PenetrationCont = Stat.RollDamagePenetrations(Stats.GetCombatAV(Defender), (Stat.Roll(data.Penetration, null) + Stat.Roll(data.BonusPen)), Stat.Roll(data.Penetration, null) + Stat.Roll(data.BonusPen));
                    string resultColor     = Stat.GetResultColor(PenetrationCont);
                    int    DamageBaseInit  = 0;

                    if (PenetrationCont > 0)
                    {
                        for (int i = 0; i < PenetrationCont; i++)
                        {
                            DamageBaseInit += Stat.Roll(data.BaseDamage, null);
                            CombatJuice.punch(Owner, Defender);
                        }
                        Damage damage = new Damage(DamageBaseInit);
                        damage.AddAttribute("Physical");
                        damage.AddAttribute("Bludgeoning");
                        Event @event = Event.New("TakeDamage", 0, 0, 0);
                        @event.AddParameter("Damage", damage);
                        @event.AddParameter("Owner", Owner);
                        @event.AddParameter("Attacker", Owner);
                        if (HasSynergyMutation.HasMutation("Quills"))
                        {
                            @event.AddParameter("Damage", data.BonusDamage);
                        }
                        if (DamageBaseInit > 0 && Defender.FireEvent(@event))
                        {
                            if (Owner.IsPlayer())
                            {
                                IComponent <GameObject> .AddPlayerMessage(string.Concat(new string[]
                                {
                                    "&gYou strike ",
                                    resultColor,
                                    "(x",
                                    PenetrationCont.ToString(),
                                    ")&y for ",
                                    damage.Amount.ToString(),
                                    " &ydamage with your " + base.ParentObject.DisplayName + "!"
                                }));
                            }
                            else if (Defender.IsPlayer())
                            {
                                IComponent <GameObject> .AddPlayerMessage(string.Concat(new string[]
                                {
                                    ParentObject.The,
                                    ParentObject.ShortDisplayName,
                                    " &r",
                                    ParentObject.GetVerb("strike", false, false),
                                    " ",
                                    resultColor,
                                    "(x",
                                    PenetrationCont.ToString(),
                                    ")&r for ",
                                    damage.Amount.ToString(),
                                    " &ydamage with ",
                                    ParentObject.its,
                                    " tail!"
                                }));
                            }
                        }
                        else if (Owner.IsPlayer())
                        {
                            IComponent <GameObject> .AddPlayerMessage("&rYou fail to deal damage to " + Defender.the + Defender.DisplayNameOnly + " &rwith your " + base.ParentObject.DisplayName + "!");
                        }
                        else if (Defender.IsPlayer())
                        {
                            IComponent <GameObject> .AddPlayerMessage(string.Concat(new string[]
                            {
                                ParentObject.The,
                                ParentObject.DisplayName,
                                " &g",
                                ParentObject.GetVerb("fail", false, false),
                                " to damage you with ",
                                ParentObject.its,
                                " tail!"
                            }));
                        }
                    }
                }
            }
        }
        public override bool FireEvent(Event E)
        {
            var Owner = ParentObject?.Equipped;

            if (Owner == null)
            {
                return(base.FireEvent(E));
            }
            Mutations HasSynergyMutation = Owner.GetPart <Mutations>();
            ThickTail TailMutation       = base.ParentObject.Equipped.GetPart <Mutations>().GetMutation("ThickTail") as ThickTail; if (E.ID == "MutationAdded")

            {
                UpdateTailParts();
                GameObject Tail      = ParentObject;
                int        Synergies = SynergyMutations.Count(HasSynergyMutation.HasMutation);
                if (Synergies == 3)
                {
                    NeedsSynergyPrefix = false;
                    Tail.DisplayName   = "{{blue|bizarre}} tail";
                }
                else if (Synergies == 4)
                {
                    NeedsSynergyPrefix = false;
                    Tail.DisplayName   = "{{zetachrome|zenith}} tail";
                }
                else if (Synergies >= 5)
                {
                    NeedsSynergyPrefix = false;
                    Tail.DisplayName   = "{{shyrhak|chimeraen}} tail";
                }
            }
            if (E.ID == "Equipped")
            {
                GameObject EventOwner = E.GetGameObjectParameter("EquippingObject");
                EventOwner.RegisterPartEvent(this, "PerformingMeleeAttack");
                EventOwner.RegisterPartEvent(this, "GetDefenderHitDice");
                UpdateTailParts();
            }
            else if (E.ID == "Unequipped")
            {
                GameObject EventOwner = E.GetGameObjectParameter("UnequippingObject");
                EventOwner.UnregisterPartEvent(this, "PerformingMeleeAttack");
                EventOwner.UnregisterPartEvent(this, "GetDefenderHitDice");
                UpdateTailParts();
            }

            if (E.ID == "PerformingMeleeAttack")
            {
                GameObject Defender = E.GetGameObjectParameter("Defender");
                if (Stat.Random(1, 100) <= 20 + (TailMutation.Level * 5))
                {
                    TailStrike(Defender, 2 + TailMutation.Level);
                    if (HasSynergyMutation.HasMutation("Quills"))
                    {
                        AddPlayerMessage("Your quilled tail delivers extra damage!");
                    }
                }
            }
            if (E.ID == "GetDefenderHitDice" && HasSynergyMutation.HasMutation("RoughScales"))
            {
                GameObject Attacker   = E.GetGameObjectParameter("Attacker");
                GameObject Tail       = ParentObject;
                var        TailShield = Tail.RequirePart <Shield>();
                if (TailShield == null)
                {
                    return(true);
                }
                if (E.HasParameter("ShieldBlocked"))
                {
                    return(true);
                }
                if (!Owner.CanMoveExtremities(null, false, false, false))
                {
                    return(true);
                }
                if (Stat.Random(1, 100) <= 15 + (5 * TailMutation.Level))
                {
                    E.SetParameter("ShieldBlocked", true);
                    if (Owner.IsPlayer())
                    {
                        IComponent <GameObject> .AddPlayerMessage("You deflect an attack with your " + base.ParentObject.DisplayName + "!" + "(" + TailShield.AV + " AV)", 'g');
                    }
                    else
                    {
                        Owner.ParticleText(string.Concat(new object[]
                        {
                            "{{",
                            IComponent <GameObject> .ConsequentialColor(Owner, null),
                            "|Block! (+",
                            TailShield.AV,
                            " AV)}}"
                        }), ' ', false, 1.5f, -8f);
                    }
                    E.SetParameter("AV", E.GetIntParameter("AV", 0) + TailShield.AV);
                }
            }
            return(base.FireEvent(E));
        }