Ejemplo n.º 1
0
        private static float AdjustOffsetAtPeace(Thing eq, Pawn pawn, CompOversizedWeapon compOversizedWeapon, float num)
        {
            Mesh mesh;

            mesh = MeshPool.plane10;
            var offsetAtPeace = eq.def.equippedAngleOffset;

            if (compOversizedWeapon.Props != null && (!pawn.IsFighting() && compOversizedWeapon.Props.verticalFlipOutsideCombat))
            {
                offsetAtPeace += 180f;
            }
            num += offsetAtPeace;
            return(num);
        }
Ejemplo n.º 2
0
        public static Vector3 MuzzlePosition(Vector3 DrawPos, Verb_LaunchProjectile instance, Thing equipment, Thing launcher)
        {
            Vector3 result = DrawPos;

            if (equipment == null || !AMAMod.settings.AllowMuzzlePosition)
            {
                return(result);
            }
            Vector3 destination = instance.CurrentTarget.Cell.ToVector3Shifted();
            float   aimAngle    = 0f;

            if ((destination - result).MagnitudeHorizontalSquared() > 0.001f)
            {
                aimAngle = (destination - result).AngleFlat();
            }
            IDrawnWeaponWithRotation rotation = equipment as IDrawnWeaponWithRotation;

            if (rotation != null)
            {
                //    Log.Message(gunOG + " is IDrawnWeaponWithRotation with RotationOffset: "+ gunOG.RotationOffset);
                aimAngle += rotation.RotationOffset;
            }
            if (equipment.def.HasComp(typeof(OgsCompOversizedWeapon.CompOversizedWeapon)))
            {
                OgsCompOversizedWeapon.CompOversizedWeapon compOversized = equipment.TryGetCompFast <OgsCompOversizedWeapon.CompOversizedWeapon>();
                if (compOversized != null)
                {
                    bool    DualWeapon     = compOversized.Props != null && compOversized.Props.isDualWeapon;
                    Vector3 offsetMainHand = default(Vector3);
                    Vector3 offsetOffHand  = default(Vector3);
                    float   offHandAngle   = aimAngle;
                    float   mainHandAngle  = aimAngle;

                    OversizedUtil.SetAnglesAndOffsets(equipment, equipment as ThingWithComps, aimAngle, launcher, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, true, DualWeapon && !compOversized.FirstAttack);
                    Vector3 vector = DualWeapon && !compOversized.FirstAttack ? offsetOffHand : offsetMainHand;
                    //    Vector3 vector = compOversized.AdjustRenderOffsetFromDir(equippable.PrimaryVerb.CasterPawn, !compOversized.FirstAttack);
                    result += vector;
                }
            }
            result = equipment.MuzzlePositionFor(result, aimAngle);
            return(result);
        }
        private static void DrawMeshModified(Mesh mesh, Vector3 position, Quaternion rotation, Material mat, int layer, Thing eq, float aimAngle)
        {
            CompOversizedWeapon compOversized = eq.TryGetComp <CompOversizedWeapon>();
            CompEquippable      equippable    = eq.TryGetComp <CompEquippable>();
            Pawn pawn = equippable.PrimaryVerb.CasterPawn;

            if (pawn == null)
            {
                return;
            }
            if (compOversized == null || (compOversized != null && compOversized.CompDeflectorIsAnimatingNow) || pawn == null || eq == null)
            {
                Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.draw(mesh, default(Matrix4x4), mat, layer, eq, pawn, position, rotation);
                return;
            }
            Vector3 s;

            if (pawn.RaceProps.Humanlike)
            {
                if (HarmonyCompOversizedWeapon.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);
            }
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(position, rotation, s);
            Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.draw(mesh, matrix, mat, 0, eq, pawn, position, rotation);
        }
Ejemplo n.º 4
0
        private static Vector3 AdjustRenderOffsetFromDir(Rot4 curDir, CompOversizedWeapon compOversizedWeapon, bool Offhand = false)
        {
            Vector3 curOffset = Vector3.zero;

            if (compOversizedWeapon.Props != null)
            {
                curOffset = Offhand ? -compOversizedWeapon.Props.southOffset : compOversizedWeapon.Props.southOffset;
                if (curDir == Rot4.North)
                {
                    curOffset = Offhand ? -compOversizedWeapon.Props.northOffset : compOversizedWeapon.Props.northOffset;
                }
                else if (curDir == Rot4.East)
                {
                    curOffset = Offhand ? -compOversizedWeapon.Props.eastOffset : compOversizedWeapon.Props.eastOffset;
                }
                else if (curDir == Rot4.West)
                {
                    curOffset = Offhand ? -compOversizedWeapon.Props.westOffset : compOversizedWeapon.Props.westOffset;
                }
            }

            return(curOffset);
        }
Ejemplo n.º 5
0
 private static float AdjustNonCombatRotation(Pawn pawn, float num, CompOversizedWeapon compOversizedWeapon)
 {
     if (compOversizedWeapon.Props != null)
     {
         if (pawn.Rotation == Rot4.North)
         {
             num += compOversizedWeapon.Props.angleAdjustmentNorth;
         }
         else if (pawn.Rotation == Rot4.East)
         {
             num += compOversizedWeapon.Props.angleAdjustmentEast;
         }
         else if (pawn.Rotation == Rot4.West)
         {
             num += compOversizedWeapon.Props.angleAdjustmentWest;
         }
         else if (pawn.Rotation == Rot4.South)
         {
             num += compOversizedWeapon.Props.angleAdjustmentSouth;
         }
     }
     return(num);
 }
 public static void OversizedWeapon(ThingWithComps weapon, float aimAngle, Verb verb, ref Vector3 origin)
 {
     OgsCompOversizedWeapon.CompOversizedWeapon compOversized = weapon.TryGetComp <OgsCompOversizedWeapon.CompOversizedWeapon>();
     if (compOversized != null)
     {
         bool    DualWeapon     = compOversized.Props != null && compOversized.Props.isDualWeapon;
         Vector3 offsetMainHand = default(Vector3);
         Vector3 offsetOffHand  = default(Vector3);
         float   offHandAngle   = aimAngle;
         float   mainHandAngle  = aimAngle;
         Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.SetAnglesAndOffsets(compOversized.parent, compOversized.parent, aimAngle, verb.Caster, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, true, DualWeapon && !compOversized.FirstAttack);
         if (DualWeapon)
         {
             Log.Message("Throwing flash for " + compOversized.parent.LabelCap + " offsetMainHand: " + offsetMainHand + " offsetOffHand: " + offsetOffHand + " Using " + (!compOversized.FirstAttack ? "OffHand" : "MainHand") + " FirstAttack: " + compOversized.FirstAttack);
         }
         origin += DualWeapon && !compOversized.FirstAttack ? offsetOffHand : offsetMainHand;
         // origin += compOversized.AdjustRenderOffsetFromDir(equippable.PrimaryVerb.CasterPawn, !compOversized.FirstAttack);
         if (compOversized.Props.isDualWeapon)
         {
             compOversized.FirstAttack = !compOversized.FirstAttack;
         }
     }
 }
Ejemplo n.º 7
0
        public static void get_DefaultGraphic_PostFix(Thing __instance, Graphic ___graphicInt, ref Graphic __result)
        {
            if (___graphicInt == null)
            {
                return;
            }
            if (__instance.ParentHolder is Pawn)
            {
                return;
            }
            ThingWithComps withComps = __instance as ThingWithComps;

            if (withComps == null)
            {
                return;
            }
            CompOversizedWeapon compOversizedWeapon = null;

            for (int i = 0; i < withComps.AllComps.Count; i++)
            {
                compOversizedWeapon = withComps.AllComps[i] as CompOversizedWeapon;
                if (compOversizedWeapon != null)
                {
                    break;
                }
            }
            if (compOversizedWeapon != null)
            {
                //    Log.Message("am i doing anything? :" + __instance);
                //Following commented-out section is an unnecessary "optimization" that actually hurts performance due to the reflection involved.
                //var activatableEffect =
                //    thingWithComps.AllComps.FirstOrDefault(
                //        y => y.GetType().ToString().Contains("ActivatableEffect"));
                //if (activatableEffect != null)
                //{
                //    var getPawn = Traverse.Create(activatableEffect).Property("GetPawn").GetValue<Pawn>();
                //    if (getPawn != null)
                //        return;
                //}
                if (compOversizedWeapon.Props?.groundGraphic == null)
                {
                    ___graphicInt.drawSize = __instance.def.graphicData.drawSize;
                    __result = ___graphicInt;
                }
                else // compOversizedWeapon.Props.groundGraphic != null
                {
                    if (compOversizedWeapon.IsEquipped)
                    {
                        ___graphicInt.drawSize = __instance.def.graphicData.drawSize;
                        __result = ___graphicInt;
                    }
                    else
                    {
                        if (compOversizedWeapon.Props.groundGraphic.GraphicColoredFor(__instance) is Graphic
                            newResult)
                        {
                            newResult.drawSize = compOversizedWeapon.Props.groundGraphic.drawSize;
                            __result           = newResult;
                        }
                        else
                        {
                            ___graphicInt.drawSize = __instance.def.graphicData.drawSize;
                            __result = ___graphicInt;
                        }
                    }
                }
            }
        }
        public static void DrawMeshModified(Mesh mesh, Vector3 position, Quaternion rotation, Material mat, int layer, Thing eq, float aimAngle)
        {
            if (enabled_YayosCombat)
            {
                Log.Message("Yayos Oversized");
            }
            CompOversizedWeapon compOversized = eq.TryGetCompFast <CompOversizedWeapon>();
            CompEquippable      equippable    = eq.TryGetCompFast <CompEquippable>();
            Pawn pawn = equippable.PrimaryVerb.CasterPawn;

            if (pawn == null)
            {
                return;
            }
            if (compOversized == null || (compOversized != null && compOversized.CompDeflectorIsAnimatingNow) || pawn == null || eq == null)
            {
                OversizedUtil.Draw(mesh, default(Matrix4x4), mat, layer, eq, pawn, position, rotation);
                return;
            }
            ThingWithComps  thingWithComps  = eq as ThingWithComps;
            bool            DualWeapon      = compOversized.Props != null && compOversized.Props.isDualWeapon;
            float           offHandAngle    = aimAngle;
            float           mainHandAngle   = aimAngle;
            Stance_Busy     stance_Busy     = pawn.stances.curStance as Stance_Busy;
            LocalTargetInfo localTargetInfo = null;

            if (stance_Busy != null && !stance_Busy.neverAimWeapon)
            {
                localTargetInfo = stance_Busy.focusTarg;
            }
            bool    Aiming         = OversizedUtil.CurrentlyAiming(stance_Busy);
            Vector3 offsetMainHand = default(Vector3);
            Vector3 offsetOffHand  = default(Vector3);

            if (compOversized.Props != null)
            {
                OversizedUtil.SetAnglesAndOffsets(eq, thingWithComps, aimAngle, pawn, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, Aiming, DualWeapon && Aiming);
            }
            if (DualWeapon)
            {
                Vector3 drawLoc = position + offsetMainHand;
                compOversized.renderPos = drawLoc;
                PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, eq, drawLoc, offHandAngle, compOversized, equippable, pawn);
            }

            if (Aiming && localTargetInfo != null)
            {
                mainHandAngle     = OversizedUtil.GetAimingRotation(pawn, localTargetInfo);
                offsetMainHand.y += 0.1f;
                Vector3 drawLoc2 = pawn.DrawPos + new Vector3(0f, 0f, 0.4f).RotatedBy(mainHandAngle) + (DualWeapon ? offsetOffHand : offsetMainHand);
                if (DualWeapon)
                {
                    compOversized.renderPosDual = drawLoc2;
                }
                else
                {
                    compOversized.renderPos = drawLoc2;
                }
                PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, thingWithComps, drawLoc2, (DualWeapon ? mainHandAngle : aimAngle), compOversized, equippable, pawn, DualWeapon);
            }
            else
            {
                Vector3 drawLoc2 = position + (DualWeapon ? offsetOffHand : offsetMainHand);
                if (DualWeapon)
                {
                    compOversized.renderPosDual = drawLoc2;
                }
                else
                {
                    compOversized.renderPos = drawLoc2;
                }
                PawnRenderer_DrawEquipmentAiming_Vanilla_Transpiler.DrawEquipmentAimingOverride(mesh, thingWithComps, drawLoc2, (DualWeapon ? mainHandAngle : aimAngle), compOversized, equippable, pawn, false);
            }
        }
        public static void DrawEquipmentAimingOverride(Mesh mesh, Thing eq, Vector3 drawLoc, float aimAngle, CompOversizedWeapon compOversized, CompEquippable equippable, Pawn pawn, bool offhand = false)
        {
            float num = aimAngle - 90f;

            if (aimAngle > 20f && aimAngle < 160f)
            {
                mesh = MeshPool.plane10;
                num += eq.def.equippedAngleOffset;
            }
            else
            {
                if (aimAngle > 200f && aimAngle < 340f)
                {
                    mesh = offhand ? (mesh == MeshPool.plane10 ? MeshPool.plane10Flip : MeshPool.plane10) : MeshPool.plane10Flip;
                    num -= 180f;
                    num -= eq.def.equippedAngleOffset;
                }
                else
                {
                    mesh = MeshPool.plane10;
                    num += eq.def.equippedAngleOffset;
                }
            }
            num %= 360f;
            Vector3 s;

            if (pawn.RaceProps.Humanlike)
            {
                if (HarmonyPatches_OversizedWeapon.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);
            }
            Matrix4x4  matrix   = default(Matrix4x4);
            Quaternion rotation = Quaternion.AngleAxis(num, Vector3.up);

            matrix.SetTRS(drawLoc, rotation, s);
            Graphic_StackCount graphic_StackCount = eq.Graphic as Graphic_StackCount;
            bool     flag3 = graphic_StackCount != null;
            Material matSingle;

            if (flag3)
            {
                matSingle = graphic_StackCount.SubGraphicForStackCount(1, eq.def).MatSingle;
            }
            else
            {
                matSingle = eq.Graphic.MatSingle;
            }
            OversizedUtil.Draw(mesh, matrix, matSingle, 0, eq, pawn, drawLoc, rotation);
        }
Ejemplo n.º 10
0
        // Token: 0x0600007D RID: 125 RVA: 0x00006190 File Offset: 0x00004390
        public static void SetAnglesAndOffsets(Thing eq, ThingWithComps offHandEquip, float aimAngle, Thing thing, ref Vector3 offsetMainHand, ref Vector3 offsetOffHand, ref float mainHandAngle, ref float offHandAngle, bool mainHandAiming, bool offHandAiming)
        {
            CompOversizedWeapon compOversized = eq.TryGetComp <CompOversizedWeapon>();

            CompProperties_OversizedWeapon PropsOversized = compOversized.Props;

            Pawn pawn = thing as Pawn;

            bool Melee = pawn != null;

            if (Melee)
            {
                Melee = Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.IsMeleeWeapon(pawn.equipment.Primary);
            }

            bool Dual = false;

            if (PropsOversized != null)
            {
                Dual = PropsOversized.isDualWeapon;
            }
            float   num    = meleeMirrored ? (360f - meleeAngle) : meleeAngle;
            float   num2   = rangedMirrored ? (360f - rangedAngle) : rangedAngle;
            Vector3 offset = AdjustRenderOffsetFromDir(thing.Rotation, compOversized, offHandAiming);

            if (thing.Rotation == Rot4.East)
            {
                offsetMainHand.z += offset.z;
                offsetMainHand.x += offset.x;
                offsetOffHand.y   = -1f;
                offsetOffHand.z   = 0.1f;
                offsetOffHand.z  += offset.z;
                offsetOffHand.x  += offset.x;
                if (PropsOversized != null)
                {
                    mainHandAngle += PropsOversized.angleAdjustmentEast;
                }
                offHandAngle = mainHandAngle;
            }
            else
            {
                if (thing.Rotation == Rot4.West)
                {
                    if (Dual)
                    {
                        offsetMainHand.y = -1f;
                    }
                    offsetMainHand.z += offset.z;
                    offsetMainHand.x += offset.x;
                    offsetOffHand.z   = -0.1f;
                    offsetOffHand.z  += offset.z;
                    offsetOffHand.x  += offset.x;
                    if (PropsOversized != null)
                    {
                        mainHandAngle += PropsOversized.angleAdjustmentWest;
                    }
                    offHandAngle = mainHandAngle;
                }
                else
                {
                    if (thing.Rotation == Rot4.North)
                    {
                        if (!mainHandAiming)
                        {
                            offsetMainHand.x = offset.x + (Dual ? (Melee ? meleeXOffset : rangedXOffset) : 0);
                            offsetOffHand.x  = -offset.x + (Melee ? -meleeXOffset : -rangedXOffset);
                            offsetMainHand.z = offset.z + (Dual ? (Melee ? meleeZOffset : rangedZOffset) : 0);
                            offsetOffHand.z  = offset.z + (Melee ? meleeZOffset : rangedZOffset);
                            if (PropsOversized != null)
                            {
                                offHandAngle  = PropsOversized.angleAdjustmentNorth + (Melee ? meleeAngle : rangedAngle);
                                mainHandAngle = -PropsOversized.angleAdjustmentNorth + (Melee ? num : num2);
                            }
                        }
                        else
                        {
                            offsetOffHand.x = -0.1f;
                        }
                    }
                    else
                    {
                        if (!mainHandAiming)
                        {
                            offsetMainHand.y = 1f;
                            offsetMainHand.x = -offset.x + (Dual ? (Melee ? -meleeXOffset : -rangedXOffset) : 0);
                            offsetOffHand.x  = offset.x + (Melee ? meleeXOffset : rangedXOffset);
                            offsetMainHand.z = offset.z + (Dual ? (Melee ? meleeZOffset : rangedZOffset) : 0);
                            offsetOffHand.z  = offset.z + (Melee ? meleeZOffset : rangedZOffset);
                            if (PropsOversized != null)
                            {
                                offHandAngle  = -PropsOversized.angleAdjustmentSouth + (Melee ? num : num2);
                                mainHandAngle = PropsOversized.angleAdjustmentSouth + (Melee ? meleeAngle : rangedAngle);
                            }
                        }
                        else
                        {
                            offsetOffHand.y = 1f;
                            offHandAngle    = (!Melee ? num : num2);
                            offsetOffHand.x = 0.1f;
                        }
                    }
                }
            }
            if (!thing.Rotation.IsHorizontal)
            {
                if (compOversized.Props != null)
                {
                    /*
                     *
                     * offHandAngle += (float)((pawn.Rotation == Rot4.North) ? record.extraRotation : (-(float)record.extraRotation));
                     * mainHandAngle += (float)((pawn.Rotation == Rot4.North) ? (-(float)compOversized.extraRotation) : compOversized.extraRotation);
                     */
                }
            }
        }
Ejemplo n.º 11
0
        public static void ThrowMuzzleFlash(IntVec3 cell, Map map, FleckDef moteDef, float scale, Verb verb)
        {
            bool skip = false;

            if (!AMAMod.settings.AllowMuzzlePosition)
            {
                skip = true;
            }
            if (verb.GetProjectile() != null)
            {
                if (verb.GetProjectile() as Lasers.LaserBeamDef != null)
                {
                    skip = true;
                }
                if (verb.GetProjectile().GetType().ToString().Contains("Lasers.LaserBeamDef"))
                {
                    skip = true;
                }
            }
            if (verb.EquipmentSource != null && !skip)
            {
                if (verb.verbProps.range > 1.48f)
                {
                    FleckDef       mote       = moteDef;
                    CompEquippable equippable = verb.EquipmentCompSource;
                    Vector3        origin     = verb.CasterIsPawn ? verb.CasterPawn.Drawer.DrawPos : verb.Caster.DrawPos;
                    Vector3        a          = verb.CurrentTarget.CenterVector3;
                    float          aimAngle   = 0f;
                    if ((a - origin).MagnitudeHorizontalSquared() > 0.001f)
                    {
                        aimAngle = (a - origin).AngleFlat();
                    }
                    if (verb.Caster is Building_TurretGun _TurretGun)
                    {
                        origin += new Vector3(_TurretGun.def.building.turretTopOffset.x, 0, _TurretGun.def.building.turretTopOffset.y);
                    }
                    else
                    {
                        OgsCompOversizedWeapon.CompOversizedWeapon compOversized = verb.EquipmentSource.TryGetCompFast <CompOversizedWeapon>();
                        if (compOversized != null)
                        {
                            bool    DualWeapon     = compOversized.Props != null && compOversized.Props.isDualWeapon;
                            Vector3 offsetMainHand = default(Vector3);
                            Vector3 offsetOffHand  = default(Vector3);
                            float   offHandAngle   = aimAngle;
                            float   mainHandAngle  = aimAngle;
                            OversizedUtil.SetAnglesAndOffsets(compOversized.parent, compOversized.parent, aimAngle, verb.Caster, ref offsetMainHand, ref offsetOffHand, ref offHandAngle, ref mainHandAngle, true, DualWeapon && !compOversized.FirstAttack);
                            //    if (DualWeapon && AMAMod.Dev) Log.Message("Throwing flash for " + compOversized.parent.LabelCap + " offsetMainHand: " + offsetMainHand + " offsetOffHand: " + offsetOffHand + " Using " + (!compOversized.FirstAttack ? "OffHand" : "MainHand") + " FirstAttack: " + compOversized.FirstAttack);
                            origin += DualWeapon && !compOversized.FirstAttack ? offsetOffHand : offsetMainHand;
                            // origin += compOversized.AdjustRenderOffsetFromDir(equippable.PrimaryVerb.CasterPawn, !compOversized.FirstAttack);
                            if (compOversized.Props.isDualWeapon)
                            {
                                compOversized.FirstAttack = !compOversized.FirstAttack;
                            }
                        }
                    }

                    origin = verb.MuzzlePositionFor(aimAngle, true);
                    if (verb.GetProjectile() != null)
                    {
                        origin.y = verb.GetProjectile().Altitude;
                    }
                    AdeptusFleckMaker.Static(origin, map, mote, scale);
                    return;
                }
            }

            {
                AdeptusFleckMaker.Static(cell.ToVector3Shifted(), map, moteDef, scale);
            }
        }