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);
        }
Beispiel #2
0
        public 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)
            {
                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         = Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.CurrentlyAiming(stance_Busy);
            Vector3 offsetMainHand = default(Vector3);
            Vector3 offsetOffHand  = default(Vector3);

            if (compOversized.Props != null)
            {
                Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.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;
                Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.DrawEquipmentAimingOverride(mesh, eq, drawLoc, offHandAngle, compOversized, equippable, pawn);
            }

            if (Aiming && localTargetInfo != null)
            {
                mainHandAngle     = Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.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;
                }
                Harmony_PawnRenderer_DrawEquipmentAiming_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;
                }
                Harmony_PawnRenderer_DrawEquipmentAiming_Transpiler.DrawEquipmentAimingOverride(mesh, thingWithComps, drawLoc2, (DualWeapon ? mainHandAngle : aimAngle), compOversized, equippable, pawn, false);
            }
        }
Beispiel #3
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);
                     */
                }
            }
        }