///// <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 void DrawMeshModified(Mesh mesh, Matrix4x4 matrix, Material mat, int layer, Thing eq, Pawn pawn, Vector3 position, Quaternion rotation)
        {
            //    Log.Message("DrawMeshModified");
            ThingWithComps thingWithComps = eq as ThingWithComps;
            CompEquippable equippable     = eq.TryGetComp <CompEquippable>();

            OgsCompOversizedWeapon.CompOversizedWeapon compOversized = thingWithComps.TryGetComp <OgsCompOversizedWeapon.CompOversizedWeapon>();
            var compActivatableEffect = thingWithComps?.GetComp <CompActivatableEffect>();

            if (compActivatableEffect?.Graphic == null)
            {
                return;
            }
            if (!compActivatableEffect.IsActiveNow)
            {
                return;
            }
            var     matSingle = compActivatableEffect.Graphic.MatSingle;
            Vector3 s         = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);

            if (compOversized != null)
            {
                if (pawn.RaceProps.Humanlike)
                {
                    if (HarmonyCompActivatableEffect.enabled_AlienRaces)
                    {
                        Vector2 v = AlienRaceUtility.AlienRacesPatch(pawn, eq);
                        float   f = Mathf.Max(v.x, v.y);
                        s = new Vector3(eq.def.graphicData.drawSize.x * f, 1f, eq.def.graphicData.drawSize.y * f);
                    }
                    else
                    {
                        s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
                    }
                }
                else
                {
                    Vector2 v = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                    s = new Vector3(eq.def.graphicData.drawSize.x + v.x / 10, 1f, eq.def.graphicData.drawSize.y + v.y / 10);
                }
                //    Log.Message("DrawEquipmentAimingPostFix compOversized offset: "+ offset + " Rotation: "+rotation + " size: " + s);
            }
            Vector3 vector3 = position;

            vector3.y -= 0.0005f;
            matrix.SetTRS(vector3, rotation, s);
            Graphics.DrawMesh(mesh, matrix, matSingle, 0);
        }
Esempio n. 2
0
        public static void DrawMeshExtra(Mesh mesh, Matrix4x4 matrix, Material mat, int layer, Thing eq, Pawn pawn, Vector3 position, Quaternion rotation)
        {
            //    Log.Message("DrawMeshModified");
            ThingWithComps thingWithComps = eq as ThingWithComps;
            //    CompEquippable equippable = eq.TryGetComp<CompEquippable>();
            var compOversized         = thingWithComps.def.comps.FirstOrDefault(x => x.compClass.Name.Contains("CompOversizedWeapon"));
            var compActivatableEffect = thingWithComps?.GetComp <CompActivatableEffect>();

            if (compActivatableEffect?.Graphic == null)
            {
                return;
            }
            if (!compActivatableEffect.IsActiveNow)
            {
                return;
            }
            var     matSingle = compActivatableEffect.Graphic.MatSingle;
            Vector3 s         = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);

            if (compOversized != null)
            {
                if (pawn.RaceProps.Humanlike)
                {
                    if (HarmonyPatches_ActivatableEffect.enabled_AlienRaces)
                    {
                        Vector2 v = AlienRaceUtility.AlienRacesPatch(pawn, eq);
                        float   f = Mathf.Max(v.x, v.y);
                        s = new Vector3(eq.def.graphicData.drawSize.x * f, 1f, eq.def.graphicData.drawSize.y * f);
                    }
                    else
                    {
                        s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
                    }
                }
                else
                {
                    Vector2 v = pawn.ageTracker.CurKindLifeStage.bodyGraphicData.drawSize;
                    s = new Vector3(eq.def.graphicData.drawSize.x + v.x / 10, 1f, eq.def.graphicData.drawSize.y + v.y / 10);
                }
            }
            Vector3 vector3 = position;

            vector3.y -= 0.0005f;
            matrix.SetTRS(vector3, rotation, s);
            Graphics.DrawMesh(mesh, matrix, matSingle, 0);
        }