Beispiel #1
0
        public Ship(ShipModelType s, LocatorService ls)
        {
            _model = s;

            StatBonuses = new ShipBonusHandler();

            Debuffs = new DebuffHandler();

            switch (ShipStats.ShieldType)
            {
            case ShieldTypes.QuickRegen:
                Shields = new QuickRegenShieldHandler(ShipStats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.SlowRegen:
                Shields = new SlowRegenShieldHandler(ShipStats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.NoRegen:
                Shields = new NoRegenShieldHandler(ShipStats, StatBonuses, Debuffs);
                break;
            }

            RecalculateModuleBonuses();

            Cargo = new CargoHandler_ReadOnlyVM <CargoHandlerModel>(s.Cargo);


            _playerLocator = ls.PlayerLocator;
            _areaLocator   = ls.AreaLocator;
            _teamLocator   = ls.TeamLocator;
        }
Beispiel #2
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;
 }
Beispiel #3
0
        public Player(PlayerModel p, LocatorService ls)
        {
            _areaLocator    = ls.AreaLocator;
            _shipLocator    = ls.ShipLocator;
            _accountLocator = ls.AccountLocator;
            _teamLocator    = ls.TeamLocator;

            _model = p;
        }
Beispiel #4
0
 public WarpManager(IAreaLocator al, MessageManager mm, ChatManager chatManager, RedisServer redisServer, AccountManager accountManager, IDatabaseManager databaseManager)
 {
     _areaLocator     = al;
     _messageManager  = mm;
     _chatManager     = chatManager;
     _redisServer     = redisServer;
     _accountManager  = accountManager;
     _databaseManager = databaseManager;
 }
Beispiel #5
0
        public Ship(ShipStats stats, LocatorService ls)
        {
            _model   = new ShipModelType();
            PosX     = 0;
            PosY     = 0;
            Rotation = 0;
            VelY     = 0;
            VelX     = 0;
            _weapons = new List <Weapon>();
            _model.MissileLauncherSlot = 0;
            _weapons.Add(new MissileLauncher(ProjectileTypes.AmbassadorMissile));



            TimeOfLastCollision = 0;
            TimeOfLastDamage    = 0;
            DoCombatUpdates     = false;

            HealthUpdatePeriod = 500;

            _model.PlayerID     = null;
            _simulatingPlayerID = null;
            IsNPC = false;


            _playerLocator = ls.PlayerLocator;
            _areaLocator   = ls.AreaLocator;
            _teamLocator   = ls.TeamLocator;


            _model.Modules = new List <Module>();
            StatBonuses    = new ShipBonusHandler();

            Debuffs = new DebuffHandler();

            switch (stats.ShieldType)
            {
            case ShieldTypes.QuickRegen:
                Shields = new QuickRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.SlowRegen:
                Shields = new SlowRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;

            case ShieldTypes.NoRegen:
                Shields = new NoRegenShieldHandler(stats, StatBonuses, Debuffs);
                break;
            }
            ShipStats = stats;


            _model.Cargo = new CargoHandlerModel();
            Cargo        = new CargoHandler_ReadOnlyVM <CargoHandlerModel>(_model.Cargo);
            SetHealthAndShields(stats);
        }
 public ServerGameStateManager(IPlayerLocator pl, IAreaLocator al, ITeamLocator tl, MessageManager mm, WarpManager wm, ChatManager cm, ITradeTerminator tt)
 {
     _playerLocator = pl;
     _areaLocator = al;
     _teamLocator = tl;
     _messageManager = mm;
     _warpManager = wm;
     _chatManager = cm;
     _tradeTerminator = tt;
 }
Beispiel #7
0
        public ShipManager(MessageManager mm, IAreaLocator gm, WarpManager wm, ConnectionManager cm, IDatabaseManager dbm)
        {
            _messageManager    = mm;
            _areaLocator       = gm;
            _warpManager       = wm;
            _connectionManager = cm;
            _databaseManager   = dbm;

            _ships = new ConcurrentDictionary <int, IShip>();
        }
Beispiel #8
0
 public KillManager(CargoSynchronizer cargoSynchronizer, IPlayerLocator pl, IAreaLocator al, MessageManager mm, ConnectionManager cm, WarpManager wm, ChatManager chatManager, ITradeTerminator tradeTerminator)
 {
     _cargoSynchronizer = cargoSynchronizer;
     _messageManager    = mm;
     _connectionManager = cm;
     _warpManager       = wm;
     _areaLocator       = al;
     _playerLocator     = pl;
     _chatManager       = chatManager;
     _tradeTerminator   = tradeTerminator;
 }
        public StructureManager(IDatabaseManager dbm, IAreaLocator areaLocator, ILocalIDManager galaxyIDManager, CargoSynchronizer cargoSynchronizer) : base(dbm)
        {
            if (galaxyIDManager.IDType != IDTypes.GalaxyID)
            {
                throw new Exception("Error: LocalIDManager required for StructureManager must be of IDTypes.GalaxyID");
            }

            _galaxyIDManager   = galaxyIDManager;
            _cargoSynchronizer = cargoSynchronizer;
            _areaLocator       = areaLocator;
        }
Beispiel #10
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;
        }
Beispiel #11
0
        public CollisionManager(IAreaLocator galaxyManager, MessageManager messageManager, KillManager km, ProjectileManager pm)
        {
            for (int i = 0; i < 100000; i++) //Fill the projStack with IDs
            {
                _preAllocatedCollisionObjects.Push(new CollisionObject());
            }

            _collidableObjects = new ConcurrentDictionary <int, ICollidable>();
            _galaxyManager     = galaxyManager;
            _messageManager    = messageManager;
            _killManager       = km;
            _projectileManager = pm;
        }
        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);
        }
Beispiel #13
0
        public EconomyManager(LocalIDManager transactionIDManager, IPlayerLocator pl, IAreaLocator al, CargoSynchronizer cs, ShipManager sm, IDatabaseManager databaseManager, ISlaveIDProvider slaveIDProvider)
        {
            _shipManager       = sm;
            _playerLocator     = pl;
            _areaLocator       = al;
            _cargoSynchronizer = cs;

            _tradeIDManager  = transactionIDManager;
            _databaseManager = databaseManager;
            _slaveIDProvider = slaveIDProvider;

            _shipShipTrades       = new ConcurrentDictionary <int, ShipShipTrade>();
            _shipIDToTradeID      = new ConcurrentDictionary <int, int>();
            _pendingTradeRequests = new ConcurrentDictionary <int, TradeRequest>();
            _tradingPlayerIDs     = new HashSet <int>();
        }
        /// <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);
        }
        /// <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);
        }
        public IEnumerable <Ship> GetAllShips(IPlayerLocator pl, IAreaLocator al, ITeamLocator tl)
        {
            IEnumerable <DBShip> allShips = _galacticObjectContext.Ships;

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

            foreach (DBShip s in allShips)
            {
                switch (s.PilotType)
                {
                case PilotTypes.Player:
                    acc.Add(new PlayerShip((DBPlayerShip)s, pl, al, tl));
                    break;

                default:
                    throw new Exception("Error: Deserialization not implemented for ship of PilotType " + s.PilotType);
                }
            }

            return(acc);
        }
Beispiel #17
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;
        }
        /// <summary>
        /// Returns null if ship is not found
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Ship GetShip(int id, IPlayerLocator pl, IAreaLocator al, ITeamLocator tl)
        {
            //Include is important, requires EF to load specified related entities, which otherwise aren't loaded with the DBShip, because of performance (fewer joins). The alternative is lazy loading with virtual, but this is way cooler bro.
            //Probably should use virtuals in the future, though.
            DBShip s = _galacticObjectContext.Ships.Include(e => e.PrimaryWeapon).Include(x => x.SecondaryWeapon).Include(y => y.MissileLauncher).First(ls => ls.Id == id);

            if (s == null)
            {
                return(null);
            }
            else
            {
                switch (s.PilotType)
                {
                case PilotTypes.Player:
                    return(new PlayerShip((DBPlayerShip)s, pl, al, tl));

                default:
                    throw new Exception("Error: Deserialization not implemented for ship of PilotType " + s.PilotType);
                }
            }
        }
Beispiel #19
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;
 }
        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));
        }
        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));
        }
        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));
        }
Beispiel #23
0
 public void Test(IDatabaseManager dbm, IPlayerLocator pl, IAreaLocator al, ITeamLocator tl, IShipLocator sl, IMessageManager mm, IAccountLocator acl, ITeamManager tm)
 {
 }
        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));
        }
Beispiel #25
0
 public DebugGalaxyGenerator(IPlayerLocator pl, IAreaLocator al, IShipLocator sl)
 {
     _playerLocator = pl;
     _areaLocator   = al;
     _shipLocator   = sl;
 }
        /// <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);
        }
        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));
        }