Esempio n. 1
0
        private static void DeferredInitialization([NotNull] ThingWithComps catalyst)
        {
            _pendingInit = false;

            ThingComp comp = catalyst.AllComps.FirstOrDefault(c => c.GetType().Name.Equals("CompSidearmMemory"));

            if (comp == null)
            {
                return;
            }

            try
            {
                Assembly assembly = comp.GetType().Assembly;

                _compSidearmMemory = comp.GetType();
                Type weaponPair = assembly.GetType("SimpleSidearms.rimworld.ThingDefStuffDefPair");

                _sidearmMemoryWeapons = _compSidearmMemory.GetField("rememberedWeapons");
                _thingFromPair        = weaponPair.GetField("thing");
                _stuffFromPair        = weaponPair.GetField("stuff");

                Active = true;
            }
            catch (Exception e)
            {
                TkUtils.Logger.Error("Compatibility class for Simple Sidearms failed!", e);
            }
        }
 public static void RequireTicker(this ThingComp comp, TickerType type)
 {
     if (comp.parent.def.tickerType != type)
     {
         RemoteTechController.Instance.Logger.Error($"{comp.GetType().Name} requires tickerType:{type} in def {comp.parent.def.defName}");
     }
 }
Esempio n. 3
0
 public static void RequireTicker(this ThingComp comp, TickerType type)
 {
     if (comp.parent.def.tickerType != type)
     {
         Log.Error($"{comp.GetType().Name} requires tickerType:{type} in def {comp.parent.def.defName}");
     }
 }
Esempio n. 4
0
 public static T RequireComponent <T>(this ThingComp comp, T component)
 {
     if (component == null)
     {
         Log.Error($"{comp.GetType().Name} requires {nameof(T)} in def {comp.parent.def.defName}");
     }
     return(component);
 }
 public static T RequireComponent <T>(this ThingComp comp, T component)
 {
     if (component == null)
     {
         RemoteTechController.Instance.Logger.Error($"{comp.GetType().Name} requires {nameof(T)} in def {comp.parent.def.defName}");
     }
     return(component);
 }
Esempio n. 6
0
 public void ExposeData()
 {
     if (Scribe.mode == LoadSaveMode.Saving && this.comps != null)
     {
         for (int i = 0; i < comps.Count; i++)
         {
             ThingComp comp = comps[i];
             if (Rules == null || Rules.IsCompIncluded(comp))
             {
                 comp.PostExposeData();
                 savedComps.Add(comp.GetType().FullName);
             }
         }
     }
 }
Esempio n. 7
0
        public float CalculatedBlock_ForceModifier()
        {
            float     result    = 0;
            ThingComp forceUser = this.GetPawn.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("CompForceUser"));

            if (forceUser != null)
            {
                int modifier = (int)AccessTools.Method(forceUser.GetType(), "ForceSkillLevel").Invoke(forceUser, new object[] { "PJ_LightsaberDefense" });
                if (modifier > 0)
                {
                    for (int i = 0; i < modifier; i++)
                    {
                        result += Rand.Range(this.reflectionReturnChance.min, this.reflectionReturnChance.max);
                    }
                }
                //Log.Message("Lightsabers: :: New Modifier " + modifier.ToString());
            }
            return(result);
        }
Esempio n. 8
0
        public int CalculatedAccuracy_ForceModifier()
        {
            //Log.Message("Lightsabers :: ForceModifier Called");
            int       result    = 0;
            ThingComp forceUser = this.GetPawn.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("CompForceUser"));

            if (forceUser != null)
            {
                int modifier = (int)AccessTools.Method(forceUser.GetType(), "ForceSkillLevel").Invoke(forceUser, new object[] { "PJ_LightsaberReflection" });
                if (modifier > 0)
                {
                    for (int i = 0; i < modifier; i++)
                    {
                        result += Rand.Range(15, 25);
                    }
                }
                //Log.Message("Lightsabers: :: New Modifier " + modifier.ToString());
            }
            return(result);
        }
Esempio n. 9
0
        //
        #region ForceUsers

        public override bool TrySpecialMeleeBlock()
        {
            bool      result    = false;
            ThingComp forceUser = this.GetPawn.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("CompForceUser"));

            if (forceUser != null)
            {
                int modifier    = (int)AccessTools.Method(forceUser.GetType(), "ForceSkillLevel").Invoke(forceUser, new object[] { "PJ_LightsaberDefense" });
                int blockChance = 0;
                if (modifier > 0)
                {
                    for (int i = 0; i < modifier; i++)
                    {
                        blockChance += this.defenseMeleeBlockChance;
                    }
                    if (blockChance > Rand.Range(0, 100))
                    {
                        result = true;
                        MoteMaker.ThrowText(forceUser.parent.Position.ToVector3(), forceUser.parent.Map, "SWSaber_Block".Translate(), 2f);
                    }
                }
            }
            return(result);
        }
Esempio n. 10
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>
        /// <param name="__instance"></param>
        /// <param name="eq"></param>
        /// <param name="drawLoc"></param>
        /// <param name="aimAngle"></param>
        public static void DrawEquipmentAimingPostFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance);

            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);
                ThingWithComps thingWithComps = pawn_EquipmentTracker.Primary; //(ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);

                if (thingWithComps != null)
                {
                    //Log.Message("3");
                    CompActivatableEffect compActivatableEffect = thingWithComps.GetComp <CompActivatableEffect>();
                    if (compActivatableEffect != null)
                    {
                        //Log.Message("4");
                        if (compActivatableEffect.Graphic != null)
                        {
                            if (compActivatableEffect.CurrentState == CompActivatableEffect.State.Activated)
                            {
                                float num  = aimAngle - 90f;
                                bool  flip = false;

                                if (aimAngle > 20f && aimAngle < 160f)
                                {
                                    //mesh = MeshPool.GridPlaneFlip(thingWithComps.def.graphicData.drawSize);
                                    num += eq.def.equippedAngleOffset;
                                }
                                else if (aimAngle > 200f && aimAngle < 340f)
                                {
                                    //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize);
                                    flip = true;
                                    num -= 180f;
                                    num -= eq.def.equippedAngleOffset;
                                }
                                else
                                {
                                    //mesh = MeshPool.GridPlaneFlip(thingWithComps.def.graphicData.drawSize);
                                    num += eq.def.equippedAngleOffset;
                                }

                                if (eq is ThingWithComps eqComps)
                                {
                                    ThingComp deflector = eqComps.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("Deflect"));
                                    if (deflector != null)
                                    {
                                        bool isActive = (bool)AccessTools.Property(deflector.GetType(), "IsAnimatingNow").GetValue(deflector, null);
                                        if (isActive)
                                        {
                                            float numMod = (int)AccessTools.Property(deflector.GetType(), "AnimationDeflectionTicks").GetValue(deflector, null);
                                            //float numMod2 = new float();
                                            //numMod2 = numMod;
                                            if (numMod > 0)
                                            {
                                                if (!flip)
                                                {
                                                    num += ((numMod + 1) / 2);
                                                }
                                                else
                                                {
                                                    num -= ((numMod + 1) / 2);
                                                }
                                            }
                                        }
                                    }
                                }
                                num %= 360f;

                                //ThingWithComps eqComps = eq as ThingWithComps;
                                //if (eqComps != null)
                                //{
                                //    ThingComp deflector = eqComps.AllComps.FirstOrDefault<ThingComp>((ThingComp y) => y.GetType().ToString() == "CompDeflector.CompDeflector");
                                //    if (deflector != null)
                                //    {
                                //        float numMod = (float)((int)AccessTools.Property(deflector.GetType(), "AnimationDeflectionTicks").GetValue(deflector, null));
                                //        //Log.ErrorOnce("NumMod " + numMod.ToString(), 1239);
                                //numMod = (numMod + 1) / 2;
                                //if (subtract) num -= numMod;
                                //else num += numMod;
                                //    }
                                //}

                                Material matSingle = compActivatableEffect.Graphic.MatSingle;
                                //if (mesh == null) mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize);

                                Vector3   s      = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
                                Matrix4x4 matrix = default(Matrix4x4);
                                matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s);
                                if (!flip)
                                {
                                    Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0);
                                }
                                else
                                {
                                    Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0);
                                }
                                //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        protected override void Initialize()
        {
            object raceSettings    = AlienRaceUtil.GetAlienRaceSettings(base.Pawn);
            object generalSettings = AlienRaceUtil.GetGeneralSettings(base.Pawn);
            object hairSettings    = AlienRaceUtil.GetHairSettings(base.Pawn);

            foreach (ThingComp tc in base.Pawn.GetComps <ThingComp>())
            {
#if ALIEN_DEBUG
                Log.Warning(" comp: " + tc.GetType().Namespace + "." + tc.GetType().Name);
#endif
                if (tc.GetType().Namespace.EqualsIgnoreCase("AlienRace") &&
                    tc.GetType().Name.EqualsIgnoreCase("AlienComp"))
                {
                    this.alienComp = tc;
#if ALIEN_DEBUG
                    Log.Warning("Alien Comp found!");
#endif
                    break;
                }
            }

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeMirrorAlienSkinColor))
            {
                if (PrimarySkinColorFieldInfo == null && SecondarySkinColorFieldInfo == null &&
                    PrimaryHairColorFieldInfo == null && SecondaryHairColorFieldInfo == null)
                {
                    PrimarySkinColorFieldInfo   = alienComp.GetType().GetField("skinColor");
                    SecondarySkinColorFieldInfo = alienComp.GetType().GetField("skinColorSecond");
                    SecondaryHairColorFieldInfo = alienComp.GetType().GetField("hairColorSecond");
#if ALIEN_DEBUG
                    Log.Warning("Field Info for primary skin color found: " + (PrimarySkinColorFieldInfo != null).ToString());
                    Log.Warning("Field Info for secondary skin color found: " + (SecondarySkinColorFieldInfo != null).ToString());
                    Log.Warning("Field Info for secondary hair color found: " + (SecondaryHairColorFieldInfo != null).ToString());
#endif
                }

#if ALIEN_DEBUG
                Log.Warning("AlienDresserDTO.initialize - start");
#endif
                if (this.alienComp != null)
                {
                    if (PrimarySkinColorFieldInfo != null)
                    {
                        base.AlienSkinColorPrimary = new SelectionColorWidgetDTO((Color)PrimarySkinColorFieldInfo.GetValue(this.alienComp));
                        base.AlienSkinColorPrimary.SelectionChangeListener += this.PrimarySkinColorChange;
                    }

                    if (SecondarySkinColorFieldInfo != null)
                    {
                        base.AlienSkinColorSecondary = new SelectionColorWidgetDTO((Color)SecondarySkinColorFieldInfo.GetValue(this.alienComp));
                        base.AlienSkinColorPrimary.SelectionChangeListener += this.SecondarySkinColorChange;
                    }

                    base.HairColorSelectionDto = new HairColorSelectionDTO(this.Pawn.story.hairColor, IOUtil.LoadColorPresets(ColorPresetType.Hair));
                    base.HairColorSelectionDto.SelectionChangeListener += this.PrimaryHairColorChange;

                    /*if (SecondaryHairColorFieldInfo != null)
                     * {
                     *  base.AlienHairColorSecondary = new HairColorSelectionDTO((Color)SecondarySkinColorFieldInfo.GetValue(this.alienComp), IOUtil.LoadColorPresets(ColorPresetType.Hair));
                     *  base.AlienHairColorSecondary.SelectionChangeListener += this.SecondaryHairColorChange;
                     * }*/
                }
            }

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeMirrorHair))
            {
                if (raceSettings != null)
                {
                    base.HasHair = AlienRaceUtil.HasHair(base.Pawn);
#if ALIEN_DEBUG
                    Log.Warning("initialize - got hair settings: HasHair = " + base.HasHair);
#endif
                    if (base.HasHair)
                    {
                        List <string> hairTags = AlienRaceUtil.GetHairTags(base.Pawn);
                        if (hairTags != null)
                        {
                            IEnumerable <HairDef> hairDefs = from hair in DefDatabase <HairDef> .AllDefs
                                                             where hair.hairTags.SharesElementWith(hairTags)
                                                             select hair;
#if ALIEN_DEBUG
                            System.Text.StringBuilder sb = new System.Text.StringBuilder("Hair Defs: ");
                            foreach (HairDef d in hairDefs)
                            {
                                sb.Append(d.defName);
                                sb.Append(", ");
                            }
                            Log.Warning("initialize - " + sb.ToString());
#endif

                            /*if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeDresserHair))
                             * {
                             *  if (hairSettings != null)
                             *  {
                             *      List<string> filter = (List<string>)hairSettings.GetType().GetField("hairTags")?.GetValue(hairSettings);
                             *      base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, filter);
                             *  }
                             * }*/
                            base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender, hairDefs);
                        }
                        else
                        {
                            base.HairStyleSelectionDto = new HairStyleSelectionDTO(this.Pawn.story.hairDef, this.Pawn.gender);
                        }
                    }
                    else
                    {
#if ALIEN_DEBUG
                        Log.Warning("initialize - remove hair editors");
#endif
                        base.EditorTypeSelectionDto.Remove(CurrentEditorEnum.ChangeMirrorHair);//, CurrentEditorEnum.ChangeDresserAlienHairColor);
#if ALIEN_DEBUG
                        Log.Warning("initialize - hair editors removed");
#endif
                    }
                }
            }

            if (this.EditorTypeSelectionDto.Contains(CurrentEditorEnum.ChangeMirrorBody))
            {
                float maleGenderProbability = 0.5f;
                if (AlienRaceUtil.HasMaleGenderProbability(base.Pawn))
                {
#if ALIEN_DEBUG
                    Log.Warning("initialize - generalSettings found");
#endif
                    FieldInfo fi = generalSettings.GetType().GetField("MaleGenderProbability");
                    if (fi != null)
                    {
                        maleGenderProbability = AlienRaceUtil.GetMaleGenderProbability(base.Pawn);
#if ALIEN_DEBUG
                        Log.Warning("initialize - male gender prob = " + maleGenderProbability);
#endif
                    }

                    fi = generalSettings.GetType().GetField("alienPartGenerator");
                    if (fi != null)
                    {
                        object alienPartGenerator = fi.GetValue(generalSettings);
                        if (alienPartGenerator != null)
                        {
                            fi = alienPartGenerator.GetType().GetField("aliencrowntypes");
                            if (fi != null && alienComp != null)
                            {
                                List <string> crownTypes = (List <string>)fi.GetValue(alienPartGenerator);
                                fi = alienComp.GetType().GetField("crownType");
                                if (fi != null)
                                {
                                    string crownType = (string)fi.GetValue(alienComp);
                                    if (crownTypes != null && crownType != null && crownTypes.Count > 1)
                                    {
                                        this.HeadTypeSelectionDto = new HeadTypeSelectionDTO(crownType, this.Pawn.gender, crownTypes);
                                    }
                                }
                            }

                            fi = alienPartGenerator.GetType().GetField("alienbodytypes");
                            if (fi != null)
                            {
                                List <BodyTypeDef> alienbodytypes = (List <BodyTypeDef>)fi.GetValue(alienPartGenerator);
                                if (alienbodytypes != null)
                                {
                                    this.BodyTypeSelectionDto = new BodyTypeSelectionDTO(this.Pawn.story.bodyType, this.Pawn.gender, alienbodytypes);
                                }
                            }
                        }
                    }
                }
                if (maleGenderProbability > 0f && maleGenderProbability < 1f)
                {
                    base.GenderSelectionDto = new GenderSelectionDTO(base.Pawn.gender);
                    base.GenderSelectionDto.SelectionChangeListener += GenderChange;
                }
#if ALIEN_DEBUG
                Log.Warning("initialize - done");
#endif
            }
        }
        // CompActivatableEffect.HarmonyCompActivatableEffect
        /// <summary>
        ///     Adds another "layer" to the equipment aiming if they have a
        ///     weapon with a CompActivatableEffect.
        /// </summary>
        /// <param name="eq"></param>
        /// <param name="drawLoc"></param>
        /// <param name="aimAngle"></param>
        /// <param name="pawn"></param>
        /// <param name="__instance"></param>
        public static void DrawEquipmentAimingPostFix(HumanBipedDrawer __instance, Thing equipment,
                                                      ref Vector3 weaponDrawLoc,
                                                      ref float aimAngle,
                                                      bool portrait, ref bool flipped)
        {
            Pawn pawn = __instance.Pawn;

            ThingWithComps primary = pawn.equipment?.Primary;

            //Log.Message("2");
            //ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);
            //(ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);

            //Log.Message("3");
            CompActivatableEffect.CompActivatableEffect compActivatableEffect =
                primary?.GetComp <CompActivatableEffect.CompActivatableEffect>();
            if (compActivatableEffect?.Graphic == null)
            {
                return;
            }

            if (compActivatableEffect.CurrentState !=
                CompActivatableEffect.CompActivatableEffect.State.Activated)
            {
                return;
            }

            if (equipment is ThingWithComps eqComps)
            {
                ThingComp deflector = eqComps.AllComps.FirstOrDefault(y =>
                                                                      y.GetType().ToString().Contains("Deflect"));
                if (deflector != null)
                {
                    bool isActive = (bool)AccessTools
                                    .Property(deflector.GetType(), "IsAnimatingNow").GetValue(deflector, null);
                    if (isActive)
                    {
                        float numMod = (int)AccessTools
                                       .Property(deflector.GetType(), "AnimationDeflectionTicks")
                                       .GetValue(deflector, null);
                        //float numMod2 = new float();
                        //numMod2 = numMod;
                        if (numMod > 0)
                        {
                            if (!flipped)
                            {
                                aimAngle += (numMod + 1) / 2;
                            }
                            else
                            {
                                aimAngle -= (numMod + 1) / 2;
                            }
                        }
                    }
                }
            }

            aimAngle %= 360f;

            //ThingWithComps eqComps = eq as ThingWithComps;
            //if (eqComps != null)
            //{
            //    ThingComp deflector = eqComps.AllComps.FirstOrDefault<ThingComp>((ThingComp y) => y.GetType().ToString() == "CompDeflector.CompDeflector");
            //    if (deflector != null)
            //    {
            //        float numMod = (float)((int)AccessTools.Property(deflector.GetType(), "AnimationDeflectionTicks").GetValue(deflector, null));
            //        //Log.ErrorOnce("NumMod " + numMod.ToString(), 1239);
            //numMod = (numMod + 1) / 2;
            //if (subtract) num -= numMod;
            //else num += numMod;
            //    }
            //}

            Material matSingle = compActivatableEffect.Graphic.MatSingle;
            //if (mesh == null) mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize);

            Vector3   s      = new Vector3(equipment.def.graphicData.drawSize.x, 1f, equipment.def.graphicData.drawSize.y);
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(weaponDrawLoc, Quaternion.AngleAxis(aimAngle, Vector3.up), s);
            Graphics.DrawMesh(!flipped ? MeshPool.plane10 : MeshPool.plane10Flip, matrix, matSingle, 0);

            //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0);
        }
Esempio n. 13
0
 public bool IsCompIncluded(ThingComp comp)
 {
     return(IsCompIncluded(comp.GetType().FullName));
 }
        //public static void DrawEquipmentAimingPostFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle)
        //{
        //    Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance);

        //    Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment;
        //    if (pawn_EquipmentTracker != null)
        //    {
        //        ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);
        //        if (thingWithComps != null)
        //        {
        //            CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp<CompOversizedWeapon>();
        //            if (compOversizedWeapon != null)
        //            {
        //                bool flip = false;
        //                float num = aimAngle - 90f;
        //                Mesh mesh;
        //                if (aimAngle > 20f && aimAngle < 160f)
        //                {
        //                    mesh = MeshPool.plane10;
        //                    num += eq.def.equippedAngleOffset;
        //                }
        //                else if (aimAngle > 200f && aimAngle < 340f)
        //                {
        //                    mesh = MeshPool.plane10Flip;
        //                    flip = true;
        //                    num -= 180f;
        //                    num -= eq.def.equippedAngleOffset;
        //                }
        //                else
        //                {
        //                    mesh = MeshPool.plane10;
        //                    num += eq.def.equippedAngleOffset;
        //                }
        //                num %= 360f;
        //                Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount;
        //                Material matSingle;
        //                if (graphic_StackCount != null)
        //                {
        //                    matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle;
        //                }
        //                else
        //                {
        //                    matSingle = eq.Graphic.MatSingle;
        //                }
        //                //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize);
        //                //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0);
        //                //Log.Message("Oversized Draw");

        //                //Vector3 s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
        //                //Matrix4x4 matrix = default(Matrix4x4);
        //                //matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s);
        //                //if (!flip) Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0);
        //                //else Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0);
        //                //Log.Message("Oversized Called");

        //            }
        //        }
        //    }
        //}
        /// <summary>
        /// Adds another "layer" to the equipment aiming if they have a
        /// weapon with a CompActivatableEffect.
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="eq"></param>
        /// <param name="drawLoc"></param>
        /// <param name="aimAngle"></param>
        public static bool DrawEquipmentAimingPreFix(PawnRenderer __instance, Thing eq, Vector3 drawLoc, float aimAngle)
        {
            Pawn pawn = (Pawn)AccessTools.Field(typeof(PawnRenderer), "pawn").GetValue(__instance);

            Pawn_EquipmentTracker pawn_EquipmentTracker = pawn.equipment;

            if (pawn_EquipmentTracker != null)
            {
                ThingWithComps thingWithComps = (ThingWithComps)AccessTools.Field(typeof(Pawn_EquipmentTracker), "primaryInt").GetValue(pawn_EquipmentTracker);
                if (thingWithComps != null)
                {
                    //If the deflector is active, it's already using this code.
                    ThingComp deflector = thingWithComps.AllComps.FirstOrDefault <ThingComp>((ThingComp y) => y.GetType().ToString().Contains("Deflect"));
                    if (deflector != null)
                    {
                        //Log.Message("Prefix");
                        bool isAnimatingNow = (bool)AccessTools.Property(deflector.GetType(), "IsAnimatingNow").GetValue(deflector, null);
                        if (isAnimatingNow)
                        {
                            return(false);
                        }
                    }
                }
                CompOversizedWeapon compOversizedWeapon = thingWithComps.TryGetComp <CompOversizedWeapon>();
                if (compOversizedWeapon != null)
                {
                    bool  flip = false;
                    float num  = aimAngle - 90f;
                    Mesh  mesh;
                    if (aimAngle > 20f && aimAngle < 160f)
                    {
                        mesh = MeshPool.plane10;
                        num += eq.def.equippedAngleOffset;
                    }
                    else if (aimAngle > 200f && aimAngle < 340f)
                    {
                        mesh = MeshPool.plane10Flip;
                        flip = true;
                        num -= 180f;
                        num -= eq.def.equippedAngleOffset;
                    }
                    else
                    {
                        mesh = MeshPool.plane10;
                        num += eq.def.equippedAngleOffset;
                    }
                    num %= 360f;
                    Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount;
                    Material           matSingle;
                    if (graphic_StackCount != null)
                    {
                        matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle;
                    }
                    else
                    {
                        matSingle = eq.Graphic.MatSingle;
                    }
                    //mesh = MeshPool.GridPlane(thingWithComps.def.graphicData.drawSize);
                    //Graphics.DrawMesh(mesh, drawLoc, Quaternion.AngleAxis(num, Vector3.up), matSingle, 0);
                    //Log.Message("Oversized Draw");

                    Vector3   s      = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
                    Matrix4x4 matrix = default(Matrix4x4);
                    matrix.SetTRS(drawLoc, Quaternion.AngleAxis(num, Vector3.up), s);
                    if (!flip)
                    {
                        Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, 0);
                    }
                    else
                    {
                        Graphics.DrawMesh(MeshPool.plane10Flip, matrix, matSingle, 0);
                    }
                    return(false);
                    //Log.Message("Oversized Called");
                }
            }
            return(true);
        }