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

            _model = p;
        }
Exemple #3
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;
 }
Exemple #5
0
        public GalaxyManager(int solID, ITeamLocator tl)
        {
            idToSystem = new ConcurrentDictionary <int, PSystem>();
            AllAreas   = new ConcurrentDictionary <int, IArea>();

            _localSystems = new ConcurrentDictionary <int, PSystem>();

            SolAreaID = solID;

            _teamLocator = tl;
        }
Exemple #6
0
        public Planet(IArea parentArea, int ID, LocatorService ls)
            : base(ID, ls)
        {
            ParentAreaID = parentArea.Id;
            _teamLocator = ls.TeamLocator;
            _areaLocator = ls.AreaLocator;

            _shipCache          = new Dictionary <int, IShip>();
            _model.ShipIDs      = new HashSet <int>();
            _model.StructureIDs = new HashSet <int>();
            Scale         = 10;
            SecurityLevel = 0;
            Warpholes     = new List <Warphole>(1);
        }
Exemple #7
0
        public Planet(PlanetModel p, PlanetLayout layout, LocatorService ls)
            : base(p, ls)
        {
            Gravity     = p.Gravity;
            HasMoons    = p.HasMoons;
            IsColonized = p.IsColonized;
            //ColonyID = p.Colony == null? null : (int?)p.Colony.Id;
            ColonyID   = p.ColonyID;
            Layout     = layout;
            Mass       = p.Mass;
            PlanetType = p.PlanetType;
            Scale      = p.Scale;

            _shipCache = new Dictionary <int, IShip>();

            _teamLocator = ls.TeamLocator;
        }
        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);
        }
Exemple #9
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;
        }
 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;
 }
        /// <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);
                }
            }
        }
Exemple #12
0
 public void Test(IDatabaseManager dbm, IPlayerLocator pl, IAreaLocator al, ITeamLocator tl, IShipLocator sl, IMessageManager mm, IAccountLocator acl, ITeamManager tm)
 {
 }
        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);
        }
        /// <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));
        }
        /// <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);
        }