예제 #1
0
 public static bool LoadAll(BinaryReader load)
 {
     lock (stargates)
     {
         int count = load.ReadInt32();
         for (int i = 0; i < count; i++)
         {
             Stargate gate = new Stargate(load);
             stargates[gate.stargateID] = gate;
         }
     }
     return(true);
 }
예제 #2
0
 private static bool GenerateDestinations()
 {
     // Prevent multiple initializations.
     lock (systemDestinations)
     {
         if (systemDestinations.Count > 0)
         {
             // Already initialized.
             return(true);
         }
         foreach (SolarSystem system in SolarSystem.solarSystems.Values)
         {
             // Are there any stargates?
             if (system.stargates.Count > 0)
             {
                 // Create the destination list.
                 systemDestinations[system.solarSystemID] = new List <int>();
                 foreach (int gateID in system.stargates)
                 {
                     // Get the stargate.
                     Stargate gate = Stargate.GetStargate(gateID);
                     if (gate != null)
                     {
                         // Get the destination gate.
                         gate = Stargate.GetStargate(gate.destination);
                         if (gate != null)
                         {
                             int         destinationSystemID = gate.solarSystemID;
                             SolarSystem destinationSystem   = GetSystem(destinationSystemID);
                             // If this is a high security system or we don't care.
                             if (destinationSystem != null)
                             {
                                 // Add the system.
                                 systemDestinations[system.solarSystemID].Add(destinationSystemID);
                             }
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
예제 #3
0
        public static List <int> LoadYAML(YamlNode yaml, int _solarSystemID)
        {
            if (yaml == null)
            {
                return(null);
            }
            List <int>      gates   = new List <int>();
            YamlMappingNode mapping = (YamlMappingNode)yaml;

            foreach (var entry in mapping.Children)
            {
                int      _stargateID = Int32.Parse(entry.Key.ToString());
                Stargate gate        = new Stargate(entry.Value, _stargateID, _solarSystemID);
                lock (stargates)
                {
                    stargates[gate.stargateID] = gate;
                }
                gates.Add(_stargateID);
            }
            return(gates);
        }
예제 #4
0
        private SolarSystem(YamlNode node)
        {
            YamlNode        gateNode         = null;
            YamlNode        planetNode       = null;
            YamlNode        starNode         = null;
            YamlNode        secondarySunNode = null;
            YamlMappingNode mapping          = (YamlMappingNode)node;

            foreach (var entry in mapping.Children)
            {
                string paramName = entry.Key.ToString();
                switch (paramName)
                {
                case "solarSystemID":
                    solarSystemID = Int32.Parse(entry.Value.ToString());
                    break;

                case "solarSystemNameID":
                    solarSystemNameID = Int32.Parse(entry.Value.ToString());
                    break;

                case "regional":
                    regional = Boolean.Parse(entry.Value.ToString());
                    break;

                case "border":
                    border = Boolean.Parse(entry.Value.ToString());
                    break;

                case "corridor":
                    corridor = Boolean.Parse(entry.Value.ToString());
                    break;

                case "fringe":
                    fringe = Boolean.Parse(entry.Value.ToString());
                    break;

                case "hub":
                    hub = Boolean.Parse(entry.Value.ToString());
                    break;

                case "international":
                    international = Boolean.Parse(entry.Value.ToString());
                    break;

                case "luminosity":
                    luminosity = Double.Parse(entry.Value.ToString());
                    break;

                case "radius":
                    radius = Double.Parse(entry.Value.ToString());
                    break;

                case "security":
                    security = Double.Parse(entry.Value.ToString());
                    break;

                case "sunTypeID":
                    sunTypeID = Int32.Parse(entry.Value.ToString());
                    break;

                case "center":
                    center = Location.ParseLocation(entry.Value);
                    break;

                case "max":
                    max = Location.ParseLocation(entry.Value);
                    break;

                case "min":
                    min = Location.ParseLocation(entry.Value);
                    break;

                case "wormholeClassID":
                    wormholeClassID = Int32.Parse(entry.Value.ToString());
                    break;

                case "descriptionID":
                    descriptionID = Int32.Parse(entry.Value.ToString());
                    break;

                case "factionID":
                    factionID = Int32.Parse(entry.Value.ToString());
                    break;

                case "securityClass":
                    securityClass = entry.Value.ToString();
                    break;

                case "disallowedAnchorCategories":
                    disallowedAnchorCategories = new List <int>();
                    YamlSequenceNode seq = (YamlSequenceNode)entry.Value;
                    foreach (YamlNode seqNode in seq.Children)
                    {
                        disallowedAnchorCategories.Add(Int32.Parse(seqNode.ToString()));
                    }
                    break;

                case "planets":
                    planetNode = entry.Value;
                    break;

                case "star":
                    starNode = entry.Value;
                    break;

                case "stargates":
                    gateNode = entry.Value;
                    break;

                case "secondarySun":
                    secondarySunNode = entry.Value;
                    break;

                case "visualEffect":
                    visualEffect = entry.Value.ToString();
                    break;

                case "disallowedAnchorGroups":
                    disallowedAnchorGroups = YamlUtils.LoadIntList(entry.Value);
                    break;

                default:
                    System.Diagnostics.Debug.WriteLine("SolarSystem unknown value:" + entry.Key + " = " + entry.Value);
                    break;
                }
            }
            // Parse these here so we can know we have the solarSystemID.
            if (gateNode != null)
            {
                stargates = Stargate.LoadYAML(gateNode, solarSystemID);
            }
            if (planetNode != null)
            {
                planets = OrbitalBody.LoadYAML(planetNode, solarSystemID);
            }
            if (starNode != null)
            {
                star = new Star(starNode, solarSystemID);
            }
            if (secondarySunNode != null)
            {
                secondarySun = new SecondarySun(secondarySunNode, solarSystemID);
            }
        }