private static Vector3 OffsetFromRotation(Rot4 rotation, CompProperties_OversizedWeapon props) { if (rotation == Rot4.North) { return(props.northOffset); } if (rotation == Rot4.East) { return(props.eastOffset); } if (rotation == Rot4.West) { return(props.westOffset); } return(props.southOffset); }
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 = Verb_TryCastNextBurstShot_MuzzlePosition_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 = Vector3.zero; if (compOversized?.Props != null) { offset = offHandAiming ? -compOversized.Props.southOffset : compOversized.Props.southOffset; if (thing.Rotation == Rot4.North) { offset = offHandAiming ? -compOversized.Props.northOffset : compOversized.Props.northOffset; } else if (thing.Rotation == Rot4.East) { offset = offHandAiming ? -compOversized.Props.eastOffset : compOversized.Props.eastOffset; } else if (thing.Rotation == Rot4.West) { offset = offHandAiming ? -compOversized.Props.westOffset : compOversized.Props.westOffset; } } 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); */ } } }