Пример #1
0
        protected virtual WVec TurretOffset(Actor self)
        {
            if (!Info.Recoils)
            {
                return(t.Position(self));
            }

            var recoilDist = arms.Aggregate(WDist.Zero, (a, b) => a + b.Recoil);
            var recoil     = new WVec(-recoilDist, WDist.Zero, WDist.Zero);

            return(t.Position(self) + body.LocalToWorld(recoil.Rotate(t.WorldOrientation)));
        }
Пример #2
0
        protected virtual 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)));
        }
Пример #3
0
        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)));
        }
Пример #4
0
        protected virtual WVec TurretOffset(Actor self)
        {
            if (!Info.Recoils)
            {
                return(t.Position(self));
            }

            var recoilDist = 0;

            foreach (var arm in arms)
            {
                recoilDist += arm.Recoil.Length;
            }
            var recoil = new WVec(new WDist(-recoilDist), WDist.Zero, WDist.Zero);

            return(t.Position(self) + body.LocalToWorld(recoil.Rotate(t.WorldOrientation)));
        }
Пример #5
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 quantizedBody     = body.QuantizeOrientation(self, self.Orientation);
            var turretOrientation = turreted != null?turreted.WorldOrientation(self) - quantizedBody : WRot.Zero;

            var quantizedTurret = body.QuantizeOrientation(self, turretOrientation);

            return(turretOffset + body.LocalToWorld(localOffset.Rotate(quantizedTurret).Rotate(quantizedBody)));
        }
Пример #6
0
        public WithVoxelTurret(Actor self, WithVoxelTurretInfo info) : base(info)
        {
            this.self     = self;
            body          = self.Trait <BodyOrientation>();
            turreted      = self.TraitsImplementing <Turreted>().First(tt => tt.Name == Info.Turret);
            buildComplete = !self.Info.HasTraitInfo <BuildingInfo>();//always render instantly for units.

            var rv = self.Trait <RenderVoxels>();

            rv.Add(new ModelAnimation(self.World.ModelCache.GetModelSequence(rv.Image, Info.Sequence),
                                      () => turreted.Position(self), TurretRotation, () => IsTraitDisabled || !buildComplete, () => 0, info.ShowShadow));
        }
Пример #7
0
        public WithVoxelTurret(Actor self, WithVoxelTurretInfo info)
        {
            this.self = self;
            body      = self.Trait <IBodyOrientation>();
            turreted  = self.TraitsImplementing <Turreted>()
                        .First(tt => tt.Name == info.Turret);

            var rv = self.Trait <RenderVoxels>();

            rv.Add(new VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, info.Sequence),
                                      () => turreted.Position(self), () => TurretRotation(),
                                      () => false, () => 0));
        }
Пример #8
0
        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));
        }
Пример #9
0
        public WithVoxelTurret(Actor self, WithVoxelTurretInfo info)
            : base(info)
        {
            this.self = self;
            body      = self.Trait <BodyOrientation>();
            turreted  = self.TraitsImplementing <Turreted>()
                        .First(tt => tt.Name == Info.Turret);

            var rv = self.Trait <RenderVoxels>();

            rv.Add(new ModelAnimation(self.World.ModelCache.GetModelSequence(rv.Image, Info.Sequence),
                                      () => turreted.Position(self), TurretRotation,
                                      () => IsTraitDisabled, () => 0, info.ShowShadow));
        }