Beispiel #1
0
        public static IHelm Load(HelmDefinition that)
        {
            var shipClass = Catalog.Instance.GetShipClass(that.ClassName);

            if (shipClass == null)
            {
                throw new NullReferenceException("Undefined ship class " + that.ClassName);
            }
            MissileClass missileClass = null;

            if (!string.IsNullOrEmpty(that.MissileName))
            {
                missileClass = Catalog.Instance.GetMissileClass(that.MissileName);
                if (missileClass == null)
                {
                    throw new NullReferenceException("Undefined Missile class " + that.MissileName);
                }
            }
            var shipDynamics = new Dynamics(shipClass, that, TimeSpan.Zero);

            return(new Helm
            {
                Id = that.Id == Guid.Empty ? Guid.NewGuid() : that.Id,
                Class = shipClass,
                Name = that.Name,
                Nation = that.Nation,
                Dynamics = shipDynamics,
                Missile = missileClass,
                Missiles = that.Missiles,
                State = that.State,
                Health = that.Health,
            });
        }
Beispiel #2
0
        public static IHelm Load(HelmDefinition that)
        {
            var shipClass = Catalog.Instance.GetShipClass(that.ClassName);

            if (shipClass == null)
            {
                throw new NullReferenceException("Undefined ship class " + that.ClassName);
            }
            MissileClass missileClass = null;

            if (!string.IsNullOrEmpty(that.MissileName))
            {
                missileClass = Catalog.Instance.GetMissileClass(that.MissileName);
                if (missileClass == null)
                {
                    throw new NullReferenceException("Undefined Missile class " + that.MissileName);
                }
            }
            var shipDynamics = new Dynamics(shipClass, that, TimeSpan.Zero);

            return(new Helm
            {
                Ship = new Ship
                {
                    Name = that.ShipName,
                    Class = shipClass,
                    Nation = that.Nation,
                    Dynamics = shipDynamics,
                    Missile = missileClass,
                    Missiles = that.MissileNumber,
                },
            });
        }