Exemplo n.º 1
0
        public Armament(Actor self, ArmamentInfo info)
        {
            this.self = self;
            Info      = info;

            // We can't resolve these until runtime
            Turret      = Exts.Lazy(() => self.TraitsImplementing <Turreted>().FirstOrDefault(t => t.Name == info.Turret));
            Coords      = Exts.Lazy(() => self.Trait <IBodyOrientation>());
            limitedAmmo = Exts.Lazy(() => self.TraitOrDefault <LimitedAmmo>());

            Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];
            Burst  = Weapon.Burst;

            if (info.LocalOffset.Length % 3 != 0)
            {
                throw new InvalidOperationException("Invalid LocalOffset array length");
            }

            var barrels = new List <Barrel>();

            for (var i = 0; i < info.LocalOffset.Length / 3; i++)
            {
                barrels.Add(new Barrel
                {
                    Offset = new WVec(info.LocalOffset[3 * i], info.LocalOffset[3 * i + 1], info.LocalOffset[3 * i + 2]),
                    Yaw    = info.LocalYaw.Length > i ? info.LocalYaw[i] : WAngle.Zero
                });
            }

            if (barrels.Count == 0)
            {
                barrels.Add(new Barrel {
                    Offset = WVec.Zero, Yaw = WAngle.Zero
                });
            }

            Barrels = barrels.ToArray();
        }
Exemplo n.º 2
0
        public Armament(Actor self, ArmamentInfo info)
        {
            this.self = self;
            Info      = info;

            // We can't resolve these until runtime
            Turret      = Exts.Lazy(() => self.TraitsImplementing <Turreted>().FirstOrDefault(t => t.Name == info.Turret));
            Coords      = Exts.Lazy(() => self.Trait <IBodyOrientation>());
            limitedAmmo = Exts.Lazy(() => self.TraitOrDefault <LimitedAmmo>());

            Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];
            Burst  = Weapon.Burst;

            var barrels = new List <Barrel>();

            for (var i = 0; i < info.LocalOffset.Length; i++)
            {
                barrels.Add(new Barrel
                {
                    Offset = info.LocalOffset[i],
                    Yaw    = info.LocalYaw.Length > i ? info.LocalYaw[i] : WAngle.Zero
                });
            }

            if (barrels.Count == 0)
            {
                barrels.Add(new Barrel {
                    Offset = WVec.Zero, Yaw = WAngle.Zero
                });
            }

            Barrels = barrels.ToArray();

            // Disable if an upgrade is required
            requiresUpgrade = info.RequiresUpgrade != null;
        }