Example #1
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)));
        }
Example #2
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)));
        }
Example #3
0
        public IEnumerable <IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable <IRenderable> r)
        {
            foreach (var rr in r)
            {
                yield return(rr);
            }

            var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
            var pos             = self.CenterPosition;
            int i = 0;

            foreach (var c in cargo.Passengers)
            {
                var cargoFacing = c.TraitOrDefault <IFacing>();
                if (facing != null && cargoFacing != null)
                {
                    cargoFacing.Facing = facing.Facing;
                }

                var cargoPassenger = c.Trait <Passenger>();
                if (cargoInfo.DisplayTypes.Contains(cargoPassenger.info.CargoType))
                {
                    var offset = pos - c.CenterPosition + body.LocalToWorld(positions[i++ % positions.Length].Rotate(bodyOrientation));
                    foreach (var cr in c.Render(wr))
                    {
                        yield return(cr.OffsetBy(offset).WithZOffset(1));
                    }
                }
            }
        }
Example #4
0
        public IEnumerable <IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable <IRenderable> r)
        {
            foreach (var rr in r)
            {
                yield return(rr);
            }

            var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);
            var pos             = self.CenterPosition;
            var i = 0;

            foreach (var c in cargo.Passengers)
            {
                var cargoPassenger = c.Trait <Passenger>();
                if (cargoInfo.DisplayTypes.Contains(cargoPassenger.Info.CargoType))
                {
                    var index       = cargo.PassengerCount > 1 ? i++ % cargoInfo.LocalOffset.Length : cargoInfo.LocalOffset.Length / 2;
                    var localOffset = cargoInfo.LocalOffset[index];
                    var offset      = pos - c.CenterPosition + body.LocalToWorld(localOffset.Rotate(bodyOrientation));
                    foreach (var cr in c.Render(wr))
                    {
                        yield return(cr.OffsetBy(offset).WithZOffset(1));
                    }
                }
            }
        }
Example #5
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);
        }
        public void 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 Smoke(w, pos, info.Sprite)));
                }

                ticks = info.Interval;
            }
        }
Example #7
0
        public void Tick(Actor self)
        {
            var local = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));

            trail.Update(self.CenterPosition + body.LocalToWorld(local));
        }
Example #8
0
        // Turret offset in world-space
        public WVec Position(Actor self)
        {
            var bodyOrientation = body.QuantizeOrientation(self, self.Orientation);

            return(body.LocalToWorld(Offset.Rotate(bodyOrientation)));
        }