QuantizeOrientation() public method

public QuantizeOrientation ( Actor self, WRot orientation ) : WRot
self Actor
orientation WRot
return WRot
示例#1
0
        WVec BarrelOffset()
        {
            var b                 = self.Orientation;
            var qb                = body.QuantizeOrientation(self, b);
            var localOffset       = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.Zero);
            var turretLocalOffset = turreted != null ? turreted.Offset : WVec.Zero;
            var turretOrientation = turreted != null?turreted.WorldOrientation(self) - b + WRot.FromYaw(b.Yaw - qb.Yaw) : WRot.Zero;

            return(body.LocalToWorld((turretLocalOffset + localOffset.Rotate(turretOrientation)).Rotate(qb)));
        }
示例#2
0
		WVec TurretOffset(Actor self)
		{
			if (!Info.Recoils)
				return t.Position(self);

			var recoil = arms.Aggregate(WDist.Zero, (a, b) => a + b.Recoil);
			var localOffset = new WVec(-recoil, WDist.Zero, WDist.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));
		}
示例#3
0
        WVec BarrelOffset()
        {
            var localOffset  = Info.LocalOffset + new WVec(-armament.Recoil, WDist.Zero, WDist.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)));
        }
示例#4
0
        public WVec MuzzleOffset(Actor self, Barrel b)
        {
            var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
            var localOffset     = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);

            if (turret != null)
            {
                var turretOrientation = coords.QuantizeOrientation(self, turret.LocalOrientation(self));
                localOffset  = localOffset.Rotate(turretOrientation);
                localOffset += turret.Offset;
            }

            return(coords.LocalToWorld(localOffset.Rotate(bodyOrientation)));
        }
示例#5
0
        IEnumerable <IRenderable> IRender.Render(Actor self, WorldRenderer wr)
        {
            if (State == CarryallState.Carrying && !Carryable.IsDead)
            {
                if (carryablePreview == null)
                {
                    var carryableInits = new TypeDictionary()
                    {
                        new OwnerInit(Carryable.Owner),
                        new DynamicFacingInit(() => facing.Facing),
                    };

                    foreach (var api in Carryable.TraitsImplementing <IActorPreviewInitModifier>())
                    {
                        api.ModifyActorPreviewInit(Carryable, carryableInits);
                    }

                    var init = new ActorPreviewInitializer(Carryable.Info, wr, carryableInits);
                    carryablePreview = Carryable.Info.TraitInfos <IRenderActorPreviewInfo>()
                                       .SelectMany(rpi => rpi.RenderPreview(init))
                                       .ToArray();
                }

                var offset             = body.LocalToWorld(CarryableOffset.Rotate(body.QuantizeOrientation(self, self.Orientation)));
                var previewRenderables = carryablePreview
                                         .SelectMany(p => p.Render(wr, self.CenterPosition + offset))
                                         .OrderBy(WorldRenderer.RenderableZPositionComparisonKey);

                foreach (var r in previewRenderables)
                {
                    yield return(r);
                }
            }
        }
示例#6
0
        void ITick.Tick(Actor self)
        {
            // We want to update the trails' position even while the trait is disabled,
            // otherwise we might get visual 'jumps' when the trait is re-enabled.
            var local = info.Offset.Rotate(body.QuantizeOrientation(self.Orientation));

            trail.Update(self.CenterPosition + body.LocalToWorld(local));
        }
示例#7
0
        protected virtual WVec CalculateMuzzleOffset(Actor self, Barrel b)
        {
            var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
            var localOffset     = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);

            if (turret != null)
            {
                // WorldOrientation is quantized to satisfy the *Fudges.
                // Need to then convert back to a pseudo-local coordinate space, apply offsets,
                // then rotate back at the end
                var turretOrientation = turret.WorldOrientation(self) - bodyOrientation;
                localOffset  = localOffset.Rotate(turretOrientation);
                localOffset += turret.Offset;
            }

            return(coords.LocalToWorld(localOffset.Rotate(bodyOrientation)));
        }
示例#8
0
        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);
        }
示例#9
0
        WVec CalculateTargetableOffset(Actor self, WVec offset)
        {
            var localOffset = offset;
            var quantizedBodyOrientation = orientation.QuantizeOrientation(self, self.Orientation);

            if (turret != null)
            {
                localOffset  = localOffset.Rotate(turret.LocalOrientation);
                localOffset += turret.Offset;
            }

            return(orientation.LocalToWorld(localOffset.Rotate(quantizedBodyOrientation)));
        }
示例#10
0
        void ITick.Tick(Actor self)
        {
            if (--ticks <= 0)
            {
                var position = self.CenterPosition;
                if (position.Z > 0 && self.GetDamageState() >= info.MinDamage && !self.World.FogObscures(self))
                {
                    var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
                    var pos    = position + body.LocalToWorld(offset);
                    self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, info.Sprite, info.Sequence, info.Palette, facing: getFacing)));
                }

                ticks = info.Interval;
            }
        }
示例#11
0
文件: HitShape.cs 项目: praetp/OpenRA
        WVec CalculateTargetableOffset(Actor self, WVec offset)
        {
            var localOffset = offset;
            var quantizedBodyOrientation = orientation.QuantizeOrientation(self, self.Orientation);

            if (turret != null)
            {
                // WorldOrientation is quantized to satisfy the *Fudges.
                // Need to then convert back to a pseudo-local coordinate space, apply offsets,
                // then rotate back at the end
                var turretOrientation = turret.WorldOrientation(self) - quantizedBodyOrientation;
                localOffset  = localOffset.Rotate(turretOrientation);
                localOffset += turret.Offset;
            }

            return(orientation.LocalToWorld(localOffset.Rotate(quantizedBodyOrientation)));
        }
示例#12
0
        protected virtual WVec CalculateMuzzleOffset(Actor self, Barrel b)
        {
            // Weapon offset in turret coordinates
            var localOffset = b.Offset + new WVec(-Recoil, WDist.Zero, WDist.Zero);

            // Turret coordinates to body coordinates
            var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);

            if (turret != null)
            {
                localOffset = localOffset.Rotate(turret.WorldOrientation) + turret.Offset.Rotate(bodyOrientation);
            }
            else
            {
                localOffset = localOffset.Rotate(bodyOrientation);
            }

            // Body coordinates to world coordinates
            return(coords.LocalToWorld(localOffset));
        }
        IEnumerable <WPos> ITargetablePositions.TargetablePositions(Actor self)
        {
            if (IsTraitDisabled)
            {
                yield break;
            }

            if (Info.UseTargetableCellsOffsets && targetableCells != null)
            {
                foreach (var c in targetableCells.TargetableCells())
                {
                    yield return(self.World.Map.CenterOfCell(c.First));
                }
            }

            foreach (var o in Info.TargetableOffsets)
            {
                var offset = orientation.LocalToWorld(o.Rotate(orientation.QuantizeOrientation(self, self.Orientation)));
                yield return(self.CenterPosition + offset);
            }
        }
示例#14
0
        // Turret offset in world-space
        public WVec Position(Actor self)
        {
            var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);

            return(body.LocalToWorld(Offset.Rotate(bodyOrientation)));
        }
        void ITick.Tick(Actor self)
        {
            var local = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));

            trail.Update(self.CenterPosition + body.LocalToWorld(local));
        }