コード例 #1
0
        ///// <summary>
        ///// Prevents the user from having damage with the verb.
        ///// </summary>
        ///// <param name="__instance"></param>
        ///// <param name="__result"></param>
        ///// <param name="pawn"></param>
        //public static void GetDamageFactorForPostFix(Verb __instance, ref float __result, Pawn pawn)
        //{
        //    Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment;
        //    if (pawn_EquipmentTracker != null)
        //    {
        //        //Log.Message("2");
        //        ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);

        //        if (thingWithComps != null)
        //        {
        //            //Log.Message("3");
        //            CompActivatableEffect compActivatableEffect = thingWithComps.GetComp<CompActivatableEffect>();
        //            if (compActivatableEffect != null)
        //            {
        //                if (compActivatableEffect.CurrentState != CompActivatableEffect.State.Activated)
        //                {
        //                    //Messages.Message("DeactivatedWarning".Translate(), MessageSound.RejectInput);
        //                    __result = 0f;
        //                }
        //            }
        //        }
        //    }
        //}


        /// <summary>
        ///     Adds another "layer" to the equipment aiming if they have a
        ///     weapon with a CompActivatableEffect.
        /// </summary>
        public static IEnumerable <Gizmo> GizmoGetter(OgsCompActivatableEffect.CompActivatableEffect compActivatableEffect)
        {
            if (compActivatableEffect.GizmosOnEquip)
            {
                var enumerator = compActivatableEffect.EquippedGizmos().GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    yield return(current);
                }
            }
        }
コード例 #2
0
 public static IEnumerable <Gizmo> GizmoGetter(OgsCompActivatableEffect.CompActivatableEffect compActivatableEffect)
 {
     //Log.Message("5");
     if (compActivatableEffect.GizmosOnEquip)
     {
         //Log.Message("6");
         //Iterate EquippedGizmos
         var enumerator = compActivatableEffect.EquippedGizmos().GetEnumerator();
         while (enumerator.MoveNext())
         {
             //Log.Message("7");
             var current = enumerator.Current;
             yield return(current);
         }
     }
 }
コード例 #3
0
        public static void Prefix(Thing __instance, ref DamageInfo dinfo)
        {
            /*
             * if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
             * {
             *  return;
             * }
             */
            if (__instance == null || !__instance.Spawned || __instance.Map == null)
            {
                return;
            }
            bool rending    = AMSettings.Instance.AllowRendingMeleeEffect && dinfo.Def.rendingWeapon();
            bool power      = dinfo.Def.powerWeapon();
            bool force      = dinfo.Def.forceWeapon();
            bool witchblade = dinfo.Def.witchbladeWeapon();
            bool act        = rending || power || force || witchblade;
            Pawn hitPawn    = __instance as Pawn;
            Pawn Attacker   = dinfo.Instigator as Pawn ?? null;

            if (__instance != null && act)
            {
                if (dinfo.Instigator != null)
                {
                    if (Attacker == null || hitPawn == null)
                    {
                        return;
                    }
                    if (dinfo.Weapon != null && act)
                    {
                        //        Log.Message("Thing_TakeDamage_SpecialRules_Patch Prefix " + hitPawn + " hit by " + dinfo.Weapon);
                        Thing Weapon = null;
                        if (dinfo.Weapon.IsWeapon)
                        {
                            foreach (var item in Attacker.equipment.AllEquipmentListForReading)
                            {
                                if (item.def == dinfo.Weapon)
                                {
                                    Weapon = item;
                                }
                            }
                        }
                        else
                        if (dinfo.Weapon.IsApparel)
                        {
                            foreach (var item in Attacker.apparel.WornApparel)
                            {
                                if (item.def == dinfo.Weapon)
                                {
                                    Weapon = item;
                                }
                            }
                        }
                        if (Weapon == null)
                        {
                            Weapon = Attacker.equipment?.Primary;
                        }
                        if (Weapon == null)
                        {
                            //    Log.Warning("Thing_TakeDamage_SpecialRules_Patch Prefix Failed finding Weapon:  " + dinfo.Weapon);
                            return;
                        }
                        OgsCompActivatableEffect.CompActivatableEffect activatableEffect = Weapon.TryGetCompFast <OgsCompActivatableEffect.CompActivatableEffect>();
                        bool?activeEffect = null;
                        if (activatableEffect != null)
                        {
                            activeEffect = activatableEffect.IsActiveNow;
                        }
                        if (!activeEffect.HasValue || activeEffect.Value)
                        {
                            //    Log.Message(dinfo.Weapon.LabelCap + " activeEffect");
                            if (rending)
                            {
                                //        Log.Message(dinfo.Weapon.LabelCap + " Is Rending");
                                dinfo = GetRendingDamage(dinfo);
                            }
                            else
                            if (power || force)
                            {
                                dinfo = GetPowerDamage(dinfo);
                                return;
                            }
                            else if (witchblade)
                            {
                                dinfo = GetWitchbladeDamage(dinfo);
                                return;
                            }
                        }
                    }
                }
            }
        }