Пример #1
0
        public WDist DistanceFromEdge(Actor self, WPos pos)
        {
            var origin      = turret != null ? self.CenterPosition + turret.Position(self) : self.CenterPosition;
            var orientation = turret != null ? turret.WorldOrientation : self.Orientation;

            return(Info.Type.DistanceFromEdge(pos, origin, orientation));
        }
Пример #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
        public WDist DistanceFromEdge(Actor self, WPos pos)
        {
            var origin      = self.CenterPosition;
            var orientation = self.Orientation;

            if (turret != null)
            {
                origin     += turret.Position(self);
                orientation = turret.WorldOrientation(self);
            }

            return(Info.Type.DistanceFromEdge(pos, origin, orientation));
        }
Пример #4
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)));
        }
Пример #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 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)));
        }
Пример #6
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));
        }
Пример #7
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 VoxelAnimation(VoxelProvider.GetVoxel(rv.Image, Info.Sequence),
                                      () => turreted.Position(self), TurretRotation,
                                      () => IsTraitDisabled || !buildComplete, () => 0));
        }