WVec BarrelOffset() { var localOffset = info.LocalOffset + new WVec(-armament.Recoil, WRange.Zero, WRange.Zero); var turretOffset = turreted != null?turreted.Position(self) : WVec.Zero; var turretOrientation = turreted != null?turreted.LocalOrientation(self) : WRot.Zero; var quantizedBody = body.QuantizeOrientation(self, self.Orientation); var quantizedTurret = body.QuantizeOrientation(self, turretOrientation); return(turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody))); }
IEnumerable <WRot> TurretRotation() { var b = self.Orientation; var qb = body.QuantizeOrientation(self, b); yield return(turreted.LocalOrientation(self) + WRot.FromYaw(b.Yaw - qb.Yaw)); yield return(qb); }
float2 TurretPosition(Actor self, WorldRenderer wr, Turreted t, IFacing facing) { var recoil = self.TraitsImplementing <Armament>() .Where(w => w.Info.Turret == t.Name) .Aggregate(WRange.Zero, (a, b) => a + b.Recoil); var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero); var bodyOrientation = QuantizeOrientation(self, self.Orientation); var turretOrientation = QuantizeOrientation(self, t.LocalOrientation(self)); var worldPos = t.Position(self) + LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation)); return(wr.ScreenPxOffset(worldPos)); }
WVec TurretOffset(Actor self) { if (!info.Recoils) { return(t.Position(self)); } var recoil = arms.Aggregate(WRange.Zero, (a, b) => a + b.Recoil); var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero); var bodyOrientation = body.QuantizeOrientation(self, self.Orientation); var turretOrientation = body.QuantizeOrientation(self, t.LocalOrientation(self)); return(t.Position(self) + body.LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation))); }