Ejemplo n.º 1
0
 public Contrail(Actor self, ContrailInfo info)
 {
     contrailTurret = new Turret(info.ContrailOffset);
     history = new ContrailHistory(info.TrailLength,
         info.UsePlayerColor ? ContrailHistory.ChooseColor(self) : info.Color);
     facing = self.Trait<IFacing>();
     move = self.Trait<IMove>();
 }
Ejemplo n.º 2
0
        public Turret Turret; // where this weapon is mounted -- possibly shared

        #endregion Fields

        #region Constructors

        public Weapon(string weaponName, Turret turret, int[] localOffset, int recoil)
        {
            Info = Rules.Weapons[weaponName.ToLowerInvariant()];
            Burst = Info.Burst;
            Turret = turret;
            Recoil = recoil;

            var barrels = new List<Barrel>();
            for (var i = 0; i < localOffset.Length / 5; i++)
                barrels.Add(new Barrel
                {
                    TurretSpaceOffset = new PVecInt(localOffset[5 * i], localOffset[5 * i + 1]),
                    ScreenSpaceOffset = new PVecInt(localOffset[5 * i + 2], localOffset[5 * i + 3]),
                    Facing = localOffset[5 * i + 4]
                });

            // if no barrels specified, the default is "turret position; turret facing".
            if (barrels.Count == 0)
                barrels.Add(new Barrel { TurretSpaceOffset = PVecInt.Zero, ScreenSpaceOffset = PVecInt.Zero, Facing = 0 });

            Barrels = barrels.ToArray();
        }
Ejemplo n.º 3
0
        public static PVecInt GetTurretPosition(Actor self, IFacing facing, Turret turret)
        {
            if (facing == null) return turret.ScreenSpacePosition;	/* things that don't have a rotating base don't need the turrets repositioned */

            var ru = self.TraitOrDefault<RenderUnit>();
            var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
            var bodyFacing = facing.Facing;
            var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);

            return (PVecInt) ((PVecFloat)(Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f)
                + GetRecoil(self, turret.Recoil))
                + turret.ScreenSpacePosition);
        }
Ejemplo n.º 4
0
        // gets the screen-space position of a barrel.
        public static PVecInt GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
        {
            var turreted = self.TraitOrDefault<Turreted>();

            if (turreted == null && facing == null)
                return PVecInt.Zero;

            var turretFacing = turreted != null  ? turreted.turretFacing : facing.Facing;

            return GetTurretPosition(self, facing, turret) + barrel.ScreenSpaceOffset
                + (PVecInt)(PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f);
        }
Ejemplo n.º 5
0
 public SmokeTrailWhenDamaged(Actor self, SmokeTrailWhenDamagedInfo info)
 {
     smokeTurret = new Turret(info.Offset);
     interval = info.Interval;
 }