Пример #1
0
        public static StarSystem GetStarSystem(Coords coords)
        {
            Sector sector = coords.GetSector();

            foreach (var sys in sector.Systems)
            {
                if (sys.Coords == coords)
                {
                    return(sys);
                }
            }
            return(null);
        }
Пример #2
0
        public virtual void SetCoords(Coords coords)
        {
            Sector currentSector = this._sector;
            bool   isStarSystem  = (this as StarSystem) != null;
            bool   isSystemBody  = (this as SystemBody) != null;

            if (coords != _coords && !InHiperspace && !isStarSystem && !isSystemBody)
            {
                if (_coords != null)
                {
                    OnLeaveSystem(_coords);
                }

                if (coords != null)
                {
                    OnEnterSystem(coords);
                }
            }


            _coords = coords;
            _sector = coords.GetSector();

            if (_sector != currentSector && currentSector != null && !isStarSystem && !isSystemBody)
            {
                OnLeaveSector(currentSector);
            }

            bool sysIdOk = false;

            if (!isStarSystem && !isSystemBody)
            {
                foreach (var sys in _sector.Systems)
                {
                    if (sys.Coords == coords)
                    {
                        _systemId = sys.SystemId;
                        sysIdOk   = true;
                    }
                }
            }

            if (!sysIdOk)
            {
                _systemId = new SystemId(-1, _sector.IndexX, _sector.IndexY);
            }
        }
Пример #3
0
        public GameLocation(Coords coords)
        {
            this.Sector     = null;
            this.StarSystem = null;
            this.SystemBody = null;

            this.Sector = coords.GetSector();

            foreach (var system in this.Sector.Systems)
            {
                if (coords.IsInRange(system.Coords, 0.5))
                {
                    this.StarSystem = system;
                    break;
                }
            }
        }
Пример #4
0
        public SectorObject(SerializationInfo info, StreamingContext context)
        {
            List <string> sNames = new List <string>();

            foreach (var entry in info)
            {
                sNames.Add(entry.Name);
            }

            this._coords         = (Coords)info.GetValue("coord", typeof(Coords));
            this._destination    = (Coords)info.GetValue("destination", typeof(Coords));
            this._speed          = info.GetSingle("speed");
            this._name           = info.GetString("name");
            this._sector         = _coords.GetSector();
            this._systemLocation = (SystemLocation)info.GetValue("sLoc", typeof(SystemLocation));

            if (sNames.Contains("dsLoc"))
            {
                this._dsystemLocation = (SystemLocation)info.GetValue("dsLoc", typeof(SystemLocation));
            }

            this._destinationStamp = info.GetDateTime("dStp");
            this._id         = (Guid)info.GetValue("id", typeof(Guid));
            this._lastUpdate = info.GetDateTime("stp");
            this._systemId   = (SystemId)(ulong)info.GetUInt64("sId");

            if (sNames.Contains("iHy"))
            {
                this.InHiperspace = info.GetBoolean("iHy");
            }
            if (sNames.Contains("iSp"))
            {
                this.InHiperspace = info.GetBoolean("iSp");
            }
            if (sNames.Contains("iPl"))
            {
                this.InHiperspace = info.GetBoolean("iPl");
            }
        }