示例#1
0
 protected Area(ModelType a, LocatorService ls)
 {
     _model          = a;
     _playerLocator  = ls.PlayerLocator;
     _areaLocator    = ls.AreaLocator;
     _shipLocator    = ls.ShipLocator;
     _structures     = new Dictionary <int, IStructure>();
     _lastUpdateTime = TimeKeeper.MsSinceInitialization;
 }
示例#2
0
        public Player(PlayerModel p, LocatorService ls)
        {
            _areaLocator    = ls.AreaLocator;
            _shipLocator    = ls.ShipLocator;
            _accountLocator = ls.AccountLocator;
            _teamLocator    = ls.TeamLocator;

            _model = p;
        }
示例#3
0
        protected Area(int ID, LocatorService ls)
        {
            _model = new ModelType();
            Id     = ID;

            _playerLocator            = ls.PlayerLocator;
            _areaLocator              = ls.AreaLocator;
            _shipLocator              = ls.ShipLocator;
            _structures               = new Dictionary <int, IStructure>();
            _model.FloatySpaceObjects = new Dictionary <int, IFloatyAreaObject>();
            _lastUpdateTime           = TimeKeeper.MsSinceInitialization;
        }
示例#4
0
        public IEnumerable <Player> GetAllPlayers(IAreaLocator al, IShipLocator sl, IAccountLocator acl, ITeamLocator tl, ITeamManager tm)
        {
            IEnumerable <DBPlayer> allPlayers = _galacticObjectContext.Players;

            List <Player> acc = new List <Player>();

            foreach (DBPlayer p in allPlayers)
            {
                acc.Add(new Player(p, al, sl, acl, tl, tm));
            }

            return(acc);
        }
示例#5
0
        /// <summary>
        /// Returns null if area is not found. Will probably be depreciated soon, because of excessive querying.
        /// Note that this method does not load nested references if they are stored as Ids (e.g. planets in systems, which are stored only by IDs: PSystem.PlanetIDs)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Area GetArea(int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm, IGalaxyRegistrationManager rm, ITeamLocator tl)
        {
            //Apparently, include is retardedly slow, so we have to use a manual workaround.
            //DBArea a = _galacticObjectContext.Areas.Include(e=>e.Warpholes).Include(se=>se.Structures).First(ee=>ee.Id == id);
            Area retArea;

            using (GalacticObjectContext context = new GalacticObjectContext())
            {
                context.SetLogger(Logger);

                if (context.Systems.Any(e => e.Id == id))
                {
                    retArea = GetSystem(context, id, pl, al, sl, mm);
                }
                else if (context.Moons.Any(e => e.Id == id))
                {
                    retArea = GetMoon(context, id, pl, al, sl, mm);
                }
                else if (context.Planets.Any(e => e.Id == id))
                {
                    retArea = GetPlanet(context, id, pl, al, sl, mm, rm, tl);
                }
                else if (context.Ports.Any(e => e.Id == id))
                {
                    retArea = GetPort(context, id, pl, al, sl, mm);
                }
                else if (context.Colonies.Any(e => e.Id == id))
                {
                    retArea = GetColony(context, id, pl, al, sl, mm);
                }
                else
                {
                    throw new Exception("Error: Area not found. Has deserialization been imlemented for this type?");
                }


                List <IHasGalaxyID> l = new List <IHasGalaxyID>();
                retArea.GetRegisterableNestedObjects(l);
                foreach (IHasGalaxyID obj in l)
                {
                    rm.RegisterObject(obj);
                }
            }
            return(retArea);
        }
示例#6
0
        public Player(int playerID, string name, Account account, LocatorService ls)
        {
            _model = new PlayerModel();

            _model.Id = playerID;
            Username  = name;

            IsOnline        = false;
            CheatEngineOpen = false;
            HackCount       = -1;

            _areaLocator    = ls.AreaLocator;
            _shipLocator    = ls.ShipLocator;
            _accountLocator = ls.AccountLocator;
            _teamLocator    = ls.TeamLocator;

            _model.AccountID = account.Id;

            _model.DefaultTeamID = ls.TeamManager.CreateNewTeam(this);
            _model.TeamIDs.Add((int)_model.DefaultTeamID);
            _model.PlayerType = PlayerTypes.Human;
        }
示例#7
0
 public LocatorService(IGalaxyRegistrationManager grm,
                       IPlayerLocator pl,
                       IAreaLocator al,
                       IShipLocator sl,
                       IAccountLocator acl,
                       ITeamLocator tl,
                       ITeamManager tm,
                       IMessageManager mm,
                       IObjectLocator <IStructure> structureManager,
                       ISlaveIDProvider slaveIDProvider)
 {
     PlayerLocator       = pl;
     ShipLocator         = sl;
     AccountLocator      = acl;
     TeamLocator         = tl;
     TeamManager         = tm;
     AreaLocator         = al;
     MessageManager      = mm;
     RegistrationManager = grm;
     StructureManager    = structureManager;
     SlaveIDProvider     = slaveIDProvider;
 }
示例#8
0
 public void Test(IDatabaseManager dbm, IPlayerLocator pl, IAreaLocator al, ITeamLocator tl, IShipLocator sl, IMessageManager mm, IAccountLocator acl, ITeamManager tm)
 {
 }
示例#9
0
        /// <summary>
        /// Returns null if player not found
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Player GetPlayer(int id, IAreaLocator al, IShipLocator sl, IAccountLocator acl, ITeamLocator tl, ITeamManager tm)
        {
            DBPlayer p = _galacticObjectContext.Players.First(ee => ee.Id == id);

            return(p != null ? new Player(p, al, sl, acl, tl, tm) : null);
        }
示例#10
0
        /// <summary>
        /// Does not load or register nested objects within systems (e.g. planets)
        /// </summary>
        /// <param name="pl"></param>
        /// <param name="al"></param>
        /// <param name="sl"></param>
        /// <param name="mm"></param>
        /// <returns></returns>
        public IEnumerable <PSystem> GetAllSystems(IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm)
        {
            IEnumerable <DBArea> allAreas = _galacticObjectContext.Systems;

            List <PSystem> acc = new List <PSystem>();

            foreach (DBArea a in allAreas)
            {
                switch (a.Type)
                {
                case AreaTypes.System:
                    acc.Add(new PSystem((DBPSystem)a, pl, al, sl, mm));
                    break;
                }
            }

            return(acc);
        }
示例#11
0
        public Colony GetColony(GalacticObjectContext context, int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm)
        {
            var a = context.Colonies.First(e3 => e3.Id == id);

            return(a == null ? null : new Colony(a, pl, al, sl, mm));
        }
示例#12
0
        public Port GetPort(GalacticObjectContext context, int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm)
        {
            var a = context.Ports.Find(id);

            return(a == null ? null : new Port(a, pl, al, sl, mm));
        }
示例#13
0
        public PSystem GetSystem(GalacticObjectContext context, int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm)
        {
            var a = context.Systems.Include(e0 => e0.Warpholes).First(e2 => e2.Id == id);

            return(a == null ? null : new PSystem(a, pl, al, sl, mm));
        }
示例#14
0
        public Moon GetMoon(GalacticObjectContext context, int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm)
        {
            var a = context.Moons.Include(e0 => e0.Warpholes).Include(e1 => e1.Structures).First(e2 => e2.Id == id);

            return(a == null ? null : new Moon(a, pl, al, sl, mm));
        }
示例#15
0
        public Planet GetPlanet(GalacticObjectContext context, int id, IPlayerLocator pl, IAreaLocator al, IShipLocator sl, IMessageManager mm, IGalaxyRegistrationManager rm, ITeamLocator tl)
        {
            var a = context.Planets.Include(e0 => e0.Warpholes).Include(e1 => e1.Structures).Include(e2 => e2.Colony).First(e3 => e3.Id == id);

            if (a != null)
            {
                Planet retArea = new Planet(a, pl, al, sl, mm, tl);
                if (a.Colony != null)
                {
                    Colony col = new Colony(a.Colony, pl, al, sl, mm);
                    rm.RegisterObject(col);

                    foreach (var s in retArea.GetStructures())
                    {
                        col.RegisterStructure(s.Value);
                    }
                }
            }


            return(a == null ? null : new Planet(a, pl, al, sl, mm, tl));
        }
示例#16
0
 public DebugGalaxyGenerator(IPlayerLocator pl, IAreaLocator al, IShipLocator sl)
 {
     _playerLocator = pl;
     _areaLocator   = al;
     _shipLocator   = sl;
 }