Example #1
0
 public SystemEventArgs(StarSystem system)
 {
     this.StarSystem = system;
     this.Coords     = system.Coords;
 }
Example #2
0
 public SystemObject(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.starSystem = (StarSystem)info.GetValue("starSystem", typeof(StarSystem));
 }
Example #3
0
 public SystemObject(StarSystem starSystem)
     : base(starSystem.Sector, starSystem.Coords)
 {
     this.starSystem = starSystem;
     base.SystemId   = starSystem.SystemId;
 }
Example #4
0
        public StarSystemUtils(StarSystem starSystem)
        {
            this.starSystem = starSystem;

            //need to actually force the creation of the planets so we can calculate some params

            int habitability = 0;

            foreach (SystemBody body in starSystem.SystemBodies)
            {
                switch (body.BodyType)
                {
                case SystemBodyType.Asteroid:
                    if (body.Temperature < 70 && body.Temperature > -150)
                    {
                        habitability += 1;
                    }
                    break;

                case SystemBodyType.GasGiant:
                    break;

                case SystemBodyType.IceWorld:
                    habitability += 50;
                    break;

                case SystemBodyType.Inferno:
                    break;

                case SystemBodyType.RingedGasGiant:
                    break;

                case SystemBodyType.RockyPlanetoid:
                    if (body.Temperature < 70 && body.Temperature > -150)
                    {
                        habitability += 5;
                    }
                    break;

                case SystemBodyType.RockyWorld:
                    if (body.Temperature < 70 && body.Temperature > -150)
                    {
                        habitability += 10;
                    }
                    break;

                case SystemBodyType.SubGasGiant:
                    break;

                case SystemBodyType.Terrestrial:
                    habitability += 100; break;

                case SystemBodyType.Venuzian:
                    break;

                case SystemBodyType.WaterWorld:
                    habitability += 80; break;
                }
            }

            sysSeed systemSeed = new sysSeed();

            systemSeed.w0 = (uint)(starSystem.SystemId);
            systemSeed.w1 = (uint)(starSystem.Coords.Sector.X << 10 | (int)starSystem.SystemId);
            systemSeed.w2 = (uint)(starSystem.Coords.Sector.Y << 10 | (int)starSystem.SystemId);

            tweakSeed(ref systemSeed);
            tweakSeed(ref systemSeed);
            tweakSeed(ref systemSeed);
            tweakSeed(ref systemSeed);

            planSys  = this.MakeSystemBaseInfo(systemSeed, habitability);
            rnd_seed = planSys.goatsoupseed;
            seed     = (int)(systemSeed.w0 << 16 & systemSeed.w1);
        }
Example #5
0
        private void goat_soup(string source, StarSystem sys, StringBuilder sbuilder)
        {
            for (int n = 0; n < source.Length; n++)
            {
                uint c = (uint)(source[n]) & 0xFF;

                if (c == '\0')
                {
                    break;
                }

                if (c < 0x80)
                {
                    sbuilder.Append((char)c);
                }

                else
                {
                    if (c <= 0xAF)
                    {
                        int rnd = gen_rnd_number();
                        goat_soup(
                            desc_list[c - 0x81][
                                ((rnd >= 0x33) ? 0 : 1) +
                                ((rnd >= 0x66) ? 0 : 1) +
                                ((rnd >= 0x99) ? 0 : 1) +
                                ((rnd >= 0xCC) ? 0 : 1)
                            ], sys, sbuilder);
                    }
                    else
                    {
                        switch (c)
                        {
                        case 0xB0:                                 /* system name */
                            sbuilder.Append(sys.Name.ToLower());
                            break;

                        case 0xB1:                                 /* <system name>ian */
                            sbuilder.AppendFormat("{0}ian", sys.CommonName.ToLower());
                            break;

                        case 0xB2:                                 /* random name */
                            int i;
                            int len = gen_rnd_number() & 3;
                            for (i = 0; i <= len; i++)
                            {
                                int x = gen_rnd_number() & 0x3e;

                                if (pairs0[x] != '.')
                                {
                                    sbuilder.Append(pairs0[x].ToString().ToLower());
                                }

                                if (i != 0 && (pairs0[x + 1] != '.'))
                                {
                                    sbuilder.Append(pairs0[x + 1].ToString().ToLower());
                                }
                            }
                            break;

                        default: sbuilder.AppendFormat("<bad char in data {0:X}>", (char)c);
                            return;
                        } /* endswitch */
                    }
                }         /* endelse */
            }             /* endwhile */
        }                 /* endfunc */
Example #6
0
        public GameLocation(string locationCode, bool isBase36)
        {
            string[] tokens = locationCode.Split('.');

            this.Sector     = null;
            this.StarSystem = null;
            this.SystemBody = null;

            if (tokens.Length >= 2)
            {
                uint sX = 0, sY = 0;

                if (isBase36)
                {
                    sX = (uint)Base36.Decode(tokens[0]);
                    sY = (uint)Base36.Decode(tokens[1]);
                }
                else
                {
                    uint.TryParse(tokens[0], out sX);
                    uint.TryParse(tokens[1], out sY);
                }

                this.Sector = new Sector(sX, sY);
            }

            if (tokens.Length >= 3)
            {
                int systemNum;

                if (isBase36)
                {
                    systemNum = (int)Base36.Decode(tokens[2]);
                }
                else
                {
                    int.TryParse(tokens[2], out systemNum);
                }

                if (this.Sector.Systems.Count > systemNum)
                {
                    this.StarSystem = this.Sector.Systems[systemNum];
                }
                else
                {
                    this.StarSystem = StarSystem.GetStarSystem(this.Sector, systemNum);
                }
            }

            if (tokens.Length >= 4)
            {
                int systemBodyId;

                if (isBase36)
                {
                    systemBodyId = (int)Base36.Decode(tokens[3]);
                }
                else
                {
                    int.TryParse(tokens[3], out systemBodyId);
                }

                if (this.StarSystem.SystemBodies.Length > systemBodyId)
                {
                    this.SystemBody = this.StarSystem.SystemBodies[systemBodyId];
                }
                else
                {
                    this.SystemBody = new SystemBody(StarSystem, systemBodyId);
                }
            }

            if (tokens.Length >= 5)
            {
                this.PlanetSector = tokens[4];
            }

            if (tokens.Length >= 6)
            {
                this.Zone = tokens[5];
            }
        }