LocalToWorld() 공개 메소드

public LocalToWorld ( WVec vec ) : WVec
vec WVec
리턴 WVec
예제 #1
0
        public override void Activate(Actor self, Order order, SupportPowerManager manager)
        {
            base.Activate(self, order, manager);
            PlayLaunchSounds();

            foreach (var launchpad in self.TraitsImplementing <INotifyNuke>())
            {
                launchpad.Launching(self);
            }

            var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
            var palette        = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
            var missile        = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
                                                self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
                                                targetPosition,
                                                info.FlightVelocity, info.FlightDelay, info.SkipAscent,
                                                info.FlashType);

            self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.MissileDelay, () => self.World.Add(missile))));

            if (info.CameraRange != WDist.Zero)
            {
                var type = info.RevealGeneratedShroud ? Shroud.SourceType.Visibility
                                        : Shroud.SourceType.PassiveVisibility;

                self.World.AddFrameEndTask(w => w.Add(new RevealShroudEffect(targetPosition, info.CameraRange, type, self.Owner, info.CameraStances,
                                                                             info.FlightDelay - info.CameraSpawnAdvance, info.CameraSpawnAdvance + info.CameraRemoveDelay)));
            }

            if (Info.DisplayBeacon)
            {
                var beacon = new Beacon(
                    order.Player,
                    targetPosition,
                    Info.BeaconPaletteIsPlayerPalette,
                    Info.BeaconPalette,
                    Info.BeaconImage,
                    Info.BeaconPoster,
                    Info.BeaconPosterPalette,
                    Info.ArrowSequence,
                    Info.CircleSequence,
                    Info.ClockSequence,
                    () => missile.FractionComplete,
                    Info.BeaconDelay,
                    info.FlightDelay - info.BeaconRemoveAdvance);

                self.World.AddFrameEndTask(w =>
                {
                    w.Add(beacon);
                });
            }
        }
예제 #2
0
파일: HitShape.cs 프로젝트: boyuezh/OpenRA
        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)));
        }
예제 #3
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 quantizedWorldTurret = t.WorldOrientation(self);

            return(t.Position(self) + body.LocalToWorld(localOffset.Rotate(quantizedWorldTurret)));
        }
예제 #4
0
        public void Activate(Actor self, WPos targetPosition)
        {
            foreach (var launchpad in self.TraitsImplementing <INotifyNuke>())
            {
                launchpad.Launching(self);
            }

            var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
            var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
                                         self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
                                         targetPosition, info.DetonationAltitude, info.RemoveMissileOnDetonation,
                                         info.FlightVelocity, info.MissileDelay, info.FlightDelay, info.SkipAscent,
                                         info.FlashType,
                                         info.TrailImage, info.TrailSequences, info.TrailPalette, info.TrailUsePlayerPalette, info.TrailDelay, info.TrailInterval);

            self.World.AddFrameEndTask(w => w.Add(missile));

            if (info.CameraRange != WDist.Zero)
            {
                var type = info.RevealGeneratedShroud ? Shroud.SourceType.Visibility
                                        : Shroud.SourceType.PassiveVisibility;

                self.World.AddFrameEndTask(w => w.Add(new RevealShroudEffect(targetPosition, info.CameraRange, type, self.Owner, info.CameraStances,
                                                                             info.FlightDelay - info.CameraSpawnAdvance, info.CameraSpawnAdvance + info.CameraRemoveDelay)));
            }

            if (Info.DisplayBeacon)
            {
                var beacon = new Beacon(
                    self.Owner,
                    targetPosition,
                    Info.BeaconPaletteIsPlayerPalette,
                    Info.BeaconPalette,
                    Info.BeaconImage,
                    Info.BeaconPoster,
                    Info.BeaconPosterPalette,
                    Info.BeaconSequence,
                    Info.ArrowSequence,
                    Info.CircleSequence,
                    Info.ClockSequence,
                    () => missile.FractionComplete,
                    Info.BeaconDelay,
                    info.FlightDelay - info.BeaconRemoveAdvance);

                self.World.AddFrameEndTask(w =>
                {
                    w.Add(beacon);
                });
            }
        }
예제 #5
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)));
        }
예제 #6
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)));
        }
예제 #7
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;
            }
        }
예제 #8
0
        public void Activate(Actor self, WPos targetPosition)
        {
            var palette    = Info.IsPlayerPalette ? Info.MissilePalette + self.Owner.InternalName : Info.MissilePalette;
            var skipAscent = Info.SkipAscent || body == null;
            var launchPos  = skipAscent ? WPos.Zero : self.CenterPosition + body.LocalToWorld(Info.SpawnOffset);

            var missile = new NukeLaunch(self.Owner, Info.MissileWeapon, Info.WeaponInfo, palette, Info.MissileUp, Info.MissileDown,
                                         launchPos,
                                         targetPosition, Info.DetonationAltitude, Info.RemoveMissileOnDetonation,
                                         Info.FlightVelocity, Info.MissileDelay, Info.FlightDelay, skipAscent,
                                         Info.TrailImage, Info.TrailSequences, Info.TrailPalette, Info.TrailUsePlayerPalette, Info.TrailDelay, Info.TrailInterval);

            self.World.AddFrameEndTask(w => w.Add(missile));

            if (Info.CameraRange != WDist.Zero)
            {
                var type = Info.RevealGeneratedShroud ? Shroud.SourceType.Visibility
                                        : Shroud.SourceType.PassiveVisibility;

                self.World.AddFrameEndTask(w => w.Add(new RevealShroudEffect(targetPosition, Info.CameraRange, type, self.Owner, Info.CameraRelationships,
                                                                             Info.FlightDelay - Info.CameraSpawnAdvance, Info.CameraSpawnAdvance + Info.CameraRemoveDelay)));
            }

            if (Info.DisplayBeacon)
            {
                var beacon = new Beacon(
                    self.Owner,
                    targetPosition,
                    Info.BeaconPaletteIsPlayerPalette,
                    Info.BeaconPalette,
                    Info.BeaconImage,
                    Info.BeaconPosters.First(bp => bp.Key == GetLevel()).Value,
                    Info.BeaconPosterPalette,
                    Info.BeaconSequence,
                    Info.ArrowSequence,
                    Info.CircleSequence,
                    Info.ClockSequence,
                    () => missile.FractionComplete,
                    Info.BeaconDelay,
                    Info.FlightDelay - Info.BeaconRemoveAdvance);

                self.World.AddFrameEndTask(w =>
                {
                    w.Add(beacon);
                });
            }
        }
예제 #9
0
파일: Armament.cs 프로젝트: reaperrr/OpenRA
        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)));
        }
예제 #10
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)));
        }
예제 #11
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);
            }
        }
예제 #13
0
        public override void Activate(Actor self, Order order, SupportPowerManager manager)
        {
            base.Activate(self, order, manager);

            if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
            {
                Game.Sound.Play(Info.LaunchSound);
            }
            else
            {
                Game.Sound.Play(Info.IncomingSound);
            }

            if (!string.IsNullOrEmpty(info.ActivationSequence))
            {
                var wsb = self.Trait <WithSpriteBody>();
                wsb.PlayCustomAnimation(self, info.ActivationSequence, () => wsb.CancelCustomAnimation(self));
            }

            var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
            var palette        = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
            var missile        = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
                                                self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
                                                targetPosition,
                                                info.FlightVelocity, info.FlightDelay, info.SkipAscent,
                                                info.FlashType);

            self.World.AddFrameEndTask(w => w.Add(missile));

            if (info.CameraActor != null)
            {
                var camera = self.World.CreateActor(false, info.CameraActor, new TypeDictionary
                {
                    new LocationInit(order.TargetLocation),
                    new OwnerInit(self.Owner),
                });

                camera.QueueActivity(new Wait(info.CameraSpawnAdvance + info.CameraRemoveDelay));
                camera.QueueActivity(new RemoveSelf());

                Action addCamera = () => self.World.AddFrameEndTask(w => w.Add(camera));
                self.World.AddFrameEndTask(w => w.Add(new DelayedAction(info.FlightDelay - info.CameraSpawnAdvance, addCamera)));
            }

            if (Info.DisplayBeacon)
            {
                var beacon = new Beacon(
                    order.Player,
                    targetPosition,
                    Info.BeaconPaletteIsPlayerPalette,
                    Info.BeaconPalette,
                    Info.BeaconImage,
                    Info.BeaconPoster,
                    Info.BeaconPosterPalette,
                    Info.ArrowSequence,
                    Info.CircleSequence,
                    Info.ClockSequence,
                    () => missile.FractionComplete);

                Action removeBeacon = () => self.World.AddFrameEndTask(w =>
                {
                    w.Remove(beacon);
                    beacon = null;
                });

                self.World.AddFrameEndTask(w =>
                {
                    w.Add(beacon);
                    w.Add(new DelayedAction(info.FlightDelay - info.BeaconRemoveAdvance, removeBeacon));
                });
            }
        }
예제 #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));
        }