public NDistManagementService(INDistServiceController serviceController) { _serviceController = serviceController; _serviceController.ServiceRunningStatusChanged += ServiceController_ServiceRunningStatusChanged; _clients = new ThreadSafeSortedList <long, ConnectedClient>(); }
public NDistManagementService(INDistServiceController serviceController) { _serviceController = serviceController; _serviceController.ServiceRunningStatusChanged += ServiceController_ServiceRunningStatusChanged; _clients = new ThreadSafeSortedList<long, ConnectedClient>(); }
public static void Run() { RegisteredParticipants = new ThreadSafeSortedList <long, ClientSession>(); RegisteredGroups = new ThreadSafeSortedList <long, Group>(); PlayingGroups = new ThreadSafeSortedList <long, List <Group> >(); ServerManager.Shout(Language.Instance.GetMessageFromKey("TALENTARENA_OPEN"), true); GroupingThread groupingThread = new GroupingThread(); Observable.Timer(TimeSpan.FromSeconds(0)).Subscribe(observer => groupingThread.Run()); MatchmakingThread matchmakingThread = new MatchmakingThread(); Observable.Timer(TimeSpan.FromSeconds(3)).Subscribe(observer => matchmakingThread.Run()); IsRunning = true; Observable.Timer(TimeSpan.FromMinutes(30)).Subscribe(observer => { groupingThread.RequestStop(); matchmakingThread.RequestStop(); RegisteredParticipants.ClearAll(); RegisteredGroups.ClearAll(); IsRunning = false; ServerManager.Instance.StartedEvents.Remove(EventType.TALENTARENA); }); }
public Mate(MateDTO input) { PveLockObject = new object(); Buff = new ThreadSafeSortedList <short, Buff>(); Attack = input.Attack; CanPickUp = input.CanPickUp; CharacterId = input.CharacterId; Defence = input.Defence; Direction = input.Direction; Experience = input.Experience; Hp = input.Hp; IsSummonable = input.IsSummonable; IsTeamMember = input.IsTeamMember; Level = input.Level; Loyalty = input.Loyalty; MapX = input.MapX; MapY = input.MapY; MateId = input.MateId; MateType = input.MateType; Mp = input.Mp; Name = input.Name; NpcMonsterVNum = input.NpcMonsterVNum; Skin = input.Skin; GenerateMateTransportId(); }
public MapInstance(Map map, Guid guid, bool shopAllowed, MapInstanceType type, InstanceBag instanceBag) { Buttons = new List <MapButton>(); XpRate = 1; DropRate = 1; InstanceMusic = map.Music; ShopAllowed = shopAllowed; MapInstanceType = type; _isSleeping = true; LastUserShopId = 0; InstanceBag = instanceBag; Clock = new Clock(3); _random = new Random(); Map = map; MapInstanceId = guid; ScriptedInstances = new List <ScriptedInstance>(); OnCharacterDiscoveringMapEvents = new List <Tuple <EventContainer, List <long> > >(); OnMoveOnMapEvents = new ThreadSafeGenericList <EventContainer>(); OnAreaEntryEvents = new ThreadSafeGenericList <ZoneEvent>(); WaveEvents = new List <EventWave>(); OnMapClean = new List <EventContainer>(); _monsters = new ThreadSafeSortedList <long, MapMonster>(); _npcs = new ThreadSafeSortedList <long, MapNpc>(); _mapMonsterIds = new ThreadSafeSortedList <int, int>(); _mapNpcIds = new ThreadSafeSortedList <int, int>(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); Portals = new List <Portal>(); UnlockEvents = new List <EventContainer>(); UserShops = new Dictionary <long, MapShop>(); StartLife(); }
public Map(short mapId, Guid uniqueIdentifier, byte[] data) { _random = new Random(); MapId = mapId; ShopAllowed = true; _uniqueIdentifier = uniqueIdentifier; _monsters = new ThreadSafeSortedList <long, MapMonster>(); _mapMonsterIds = new List <int>(); Data = data; LoadZone(); IEnumerable <PortalDTO> portals = DAOFactory.PortalDAO.LoadByMap(MapId).ToList(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); MapTypes = new List <MapTypeDTO>(); foreach (MapTypeMapDTO maptypemap in DAOFactory.MapTypeMapDAO.LoadByMapId(mapId).ToList()) { MapTypeDTO maptype = DAOFactory.MapTypeDAO.LoadById(maptypemap.MapTypeId) as MapTypeDTO; MapTypes.Add(maptype); } _portals = new List <PortalDTO>(); foreach (PortalDTO portal in portals) { _portals.Add(portal as PortalDTO); } UserShops = new Dictionary <long, MapShop>(); _npcs = new List <MapNpc>(); _npcs.AddRange(ServerManager.Instance.GetMapNpcsByMapId(MapId).AsEnumerable <MapNpc>()); }
public MapMonster() { Buff = new ThreadSafeSortedList <short, Buff>(); HitQueue = new ConcurrentQueue <HitRequest>(); OnDeathEvents = new List <EventContainer>(); OnNoticeEvents = new List <EventContainer>(); }
public void LaunchEvents() { _groups = new ThreadSafeSortedList <long, Group>(); Observable.Interval(TimeSpan.FromMinutes(5)).Subscribe(x => { SaveAllProcess(); }); Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x => { GroupProcess(); }); Observable.Interval(TimeSpan.FromHours(3)).Subscribe(x => { BotProcess(); }); Observable.Interval(TimeSpan.FromSeconds(30)).Subscribe(x => { MailProcess(); }); Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(x => { RemoveItemProcess(); }); foreach (var map in _maps) { Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(x => { if (!map.Value.isSleeping) { map.Value.RemoveMapItem(); } }); foreach (MapNpc npc in map.Value.Npcs) { npc.StartLife(); } foreach (MapMonster monster in map.Value.Monsters) { monster.StartLife(); } Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(x => { if (!map.Value.isSleeping) { map.Value.RemoveMapItem(); } }); } lastGroupId = 1; }
public Map(short mapId, Guid uniqueIdentifier, byte[] data) { _random = new Random(); MapId = mapId; _uniqueIdentifier = uniqueIdentifier; _monsters = new ThreadSafeSortedList <long, MapMonster>(); _mapMonsterIds = new List <int>(); Data = data; LoadZone(); IEnumerable <PortalDTO> portals = DAOFactory.PortalDAO.LoadByMap(MapId).ToList(); _portals = new List <PortalDTO>(); DroppedList = new ConcurrentDictionary <long, MapItem>(); MapTypes = new List <MapTypeDTO>(); foreach (MapTypeMapDTO maptypemap in DAOFactory.MapTypeMapDAO.LoadByMapId(mapId).ToList()) { MapTypeDTO MT = DAOFactory.MapTypeDAO.LoadById(maptypemap.MapTypeId); // Replace by MAPPING MapTypeDTO maptype = new MapTypeDTO() { MapTypeId = MT.MapTypeId, MapTypeName = MT.MapTypeName, PotionDelay = MT.PotionDelay }; /////////////// MapTypes.Add(maptype); } UserShops = new Dictionary <long, MapShop>(); foreach (PortalDTO portal in portals) { // Replace by MAPPING _portals.Add(new PortalDTO() { DestinationMapId = portal.DestinationMapId, SourceMapId = portal.SourceMapId, SourceX = portal.SourceX, SourceY = portal.SourceY, DestinationX = portal.DestinationX, DestinationY = portal.DestinationY, Type = portal.Type, PortalId = portal.PortalId, IsDisabled = portal.IsDisabled }); ////////////////// } foreach (MapMonsterDTO monster in DAOFactory.MapMonsterDAO.LoadFromMap(MapId).ToList()) { _monsters[monster.MapMonsterId] = new MapMonster(monster, this); _mapMonsterIds.Add(monster.MapMonsterId); } IEnumerable <MapNpcDTO> npcsDTO = DAOFactory.MapNpcDAO.LoadFromMap(MapId).ToList(); _npcs = new List <MapNpc>(); npcsDTO.ToList().ForEach(s => _npcs.Add(new MapNpc(s))); }
/// <summary> /// Creates a new ScsServiceApplication object. /// </summary> /// <param name="scsServer">Underlying IScsServer object to accept and manage client connections</param> /// <exception cref="ArgumentNullException"> /// Throws ArgumentNullException if scsServer argument is null /// </exception> public ScsServiceApplication(IScsServer scsServer) { _scsServer = scsServer ?? throw new ArgumentNullException(nameof(scsServer)); _scsServer.ClientConnected += ScsServer_ClientConnected; _scsServer.ClientDisconnected += ScsServer_ClientDisconnected; _serviceObjects = new ThreadSafeSortedList <string, ServiceObject>(); _serviceClients = new ThreadSafeSortedList <long, IScsServiceClient>(); }
public Mate() { PveLockObject = new object(); Buff = new ThreadSafeSortedList <short, Buff>(); GenerateMateTransportId(); LastLoyaltyEffect = DateTime.UtcNow; IsAlive = true; }
public MapInstance(Map map, Guid guid, bool shopAllowed, MapInstanceType type, InstanceBag instanceBag, bool dropAllowed = false) { OnSpawnEvents = new List <EventContainer>(); Buttons = new List <MapButton>(); XpRate = 0; if (type == MapInstanceType.BaseMapInstance) { XpRate = map.XpRate; } //check here MinLevel = 1; MaxLevel = 99; if (type != MapInstanceType.TimeSpaceInstance && type != MapInstanceType.RaidInstance) { switch (map.MapId) { case 154: // Caligor's Realm MinLevel = 80; break; case 228: // Cylloan MinLevel = 88; break; } } DropRate = 0; DropAllowed = dropAllowed; InstanceMusic = map.Music; ShopAllowed = shopAllowed; MapInstanceType = type; _isSleeping = true; LastUserShopId = 0; InstanceBag = instanceBag; Clock = new Clock(3); _random = new Random(); Map = map; MapInstanceId = guid; ScriptedInstances = new List <ScriptedInstance>(); OnCharacterDiscoveringMapEvents = new List <Tuple <EventContainer, List <long> > >(); OnMoveOnMapEvents = new ThreadSafeGenericList <EventContainer>(); OnAreaEntryEvents = new ThreadSafeGenericList <ZoneEvent>(); WaveEvents = new List <EventWave>(); OnMapClean = new List <EventContainer>(); _monsters = new ThreadSafeSortedList <long, MapMonster>(); _delayedMonsters = new ThreadSafeSortedList <long, MapMonster>(); _npcs = new ThreadSafeSortedList <long, MapNpc>(); _mapMonsterIds = new ThreadSafeSortedList <int, int>(); _mapNpcIds = new ThreadSafeSortedList <int, int>(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); Portals = new List <Portal>(); UnlockEvents = new List <EventContainer>(); UserShops = new Dictionary <long, MapShop>(); RemovedMobNpcList = new List <object>(); StartLife(); }
public Raid(short min_lvl = 20, short max_lvl = 99, short max_players = 15) { _characters = new ThreadSafeSortedList <long, ClientSession>(); _leader = null; _min_lvl = min_lvl; _max_lvl = max_lvl; _max_players = max_players; _ave_lvl = (short)(max_lvl + 10 > 99 ? 99 : max_lvl + 10); // lvl_max_drop + 10 RaidId = ServerManager.Instance.GetNextRaidId(); }
/// <summary> /// Creates a new ScsServiceApplication object. /// /// </summary> /// <param name="scsServer">Underlying IScsServer object to accept and manage client connections</param><exception cref="T:System.ArgumentNullException">Throws ArgumentNullException if scsServer argument is null</exception> public ScsServiceApplication(IScsServer scsServer) { if (scsServer == null) { throw new ArgumentNullException("scsServer"); } this._scsServer = scsServer; this._scsServer.ClientConnected += new EventHandler <ServerClientEventArgs>(this.ScsServer_ClientConnected); this._scsServer.ClientDisconnected += new EventHandler <ServerClientEventArgs>(this.ScsServer_ClientDisconnected); this._serviceObjects = new ThreadSafeSortedList <string, ScsServiceApplication.ServiceObject>(); this._serviceClients = new ThreadSafeSortedList <long, IScsServiceClient>(); }
/// <summary> /// Creates a new ScsServiceApplication object. /// </summary> /// <param name="scsServer">Underlying IScsServer object to accept and manage client connections</param> /// <exception cref="ArgumentNullException">Throws ArgumentNullException if scsServer argument is null</exception> public ScsServiceApplication(IScsServer scsServer) { if (scsServer == null) { throw new ArgumentNullException("scsServer"); } _scsServer = scsServer; _scsServer.ClientConnected += ScsServer_ClientConnected; _scsServer.ClientDisconnected += ScsServer_ClientDisconnected; _serviceObjects = new ThreadSafeSortedList <string, ServiceObject>(); _serviceClients = new ThreadSafeSortedList <string, IScsServiceClient>(); }
public void LoadPortals() { var partitioner = Partitioner.Create(DAOFactory.PortalDAO.LoadByMap(Map.MapId), EnumerablePartitionerOptions.None); ThreadSafeSortedList <int, Portal> _portalList = new ThreadSafeSortedList <int, Portal>(); Parallel.ForEach(partitioner, portal => { Portal portal2 = portal as Portal; portal2.SourceMapInstanceId = MapInstanceId; _portalList[portal2.PortalId] = portal2; }); _portals.AddRange(_portalList.GetAllItems()); }
/// <summary> /// Creates a new ZcfServiceApplication object. /// </summary> /// <param name="zcfServer">Underlying IZcfServer object to accept and manage client connections</param> /// <exception cref="ArgumentNullException">Throws ArgumentNullException if zcfServer argument is null</exception> public ServiceApplication(IServer zcfServer) { if (zcfServer == null) { throw new ArgumentNullException("zcfServer"); } _zcfServer = zcfServer; _zcfServer.ClientConnected += ZcfServerClientConnected; _zcfServer.ClientDisconnected += ZcfServerClientDisconnected; _serviceObjects = new ThreadSafeSortedList <string, ServiceObject>(); _serviceClients = new ThreadSafeSortedList <long, IServiceClient>(); }
public MapMonster(MapMonsterDTO input) { Buff = new ThreadSafeSortedList <short, Buff>(); HitQueue = new ConcurrentQueue <HitRequest>(); OnDeathEvents = new List <EventContainer>(); OnNoticeEvents = new List <EventContainer>(); IsDisabled = input.IsDisabled; IsMoving = input.IsMoving; MapId = input.MapId; MapMonsterId = input.MapMonsterId; MapX = input.MapX; MapY = input.MapY; MonsterVNum = input.MonsterVNum; Position = input.Position; }
public Map(short mapId, Guid uniqueIdentifier, byte[] data) { _isSleeping = true; LastUserShopId = 0; _random = new Random(); MapId = mapId; ShopAllowed = true; _uniqueIdentifier = uniqueIdentifier; _monsters = new ThreadSafeSortedList <long, MapMonster>(); _mapMonsterIds = new List <int>(); Data = data; LoadZone(); IEnumerable <PortalDTO> portals = DAOFactory.PortalDAO.LoadByMap(MapId).ToList(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); MapTypes = new List <MapTypeDTO>(); foreach (MapTypeMapDTO maptypemap in DAOFactory.MapTypeMapDAO.LoadByMapId(mapId).ToList()) { MapTypeDTO maptype = DAOFactory.MapTypeDAO.LoadById(maptypemap.MapTypeId); MapTypes.Add(maptype); } if (MapTypes.Any()) { if (MapTypes.ElementAt(0).RespawnMapTypeId != null) { long?respawnMapTypeId = MapTypes.ElementAt(0).RespawnMapTypeId; long?returnMapTypeId = MapTypes.ElementAt(0).ReturnMapTypeId; if (respawnMapTypeId != null) { DefaultRespawn = DAOFactory.RespawnMapTypeDAO.LoadById((long)respawnMapTypeId); } if (returnMapTypeId != null) { DefaultReturn = DAOFactory.RespawnMapTypeDAO.LoadById((long)returnMapTypeId); } } } _portals = new List <PortalDTO>(); foreach (PortalDTO portal in portals) { _portals.Add(portal); } UserShops = new Dictionary <long, MapShop>(); _npcs = new List <MapNpc>(); _npcs.AddRange(ServerManager.Instance.GetMapNpcsByMapId(MapId).AsEnumerable()); }
public MapInstance(Map map, Guid guid, bool shopAllowed, MapInstanceType type) { ShopAllowed = shopAllowed; MapInstanceType = type; _isSleeping = true; LastUserShopId = 0; _random = new Random(); ShopAllowed = true; Map = map; MapInstanceId = guid; _monsters = new ThreadSafeSortedList <long, MapMonster>(); _mapMonsterIds = new List <int>(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); _portals = new List <Portal>(); UserShops = new Dictionary <long, MapShop>(); _npcs = new List <MapNpc>(); _npcs.AddRange(ServerManager.Instance.GetMapNpcsByMapId(Map.MapId).AsEnumerable()); }
private ServerManager() { _groups = new ThreadSafeSortedList <long, Group>(); Task autosave = new Task(SaveAllProcess); autosave.Start(); Task GroupTask = new Task(() => GroupProcess()); GroupTask.Start(); Task BotTask = new Task(() => BotProcess()); BotTask.Start(); Task TaskController = new Task(() => TaskLauncherProcess()); TaskController.Start(); lastGroupId = 1; var config = new MapperConfiguration(cfg => { cfg.CreateMap <ItemDTO, NoFunctionItem>(); cfg.CreateMap <ItemDTO, WearableItem>(); cfg.CreateMap <ItemDTO, BoxItem>(); cfg.CreateMap <ItemDTO, MagicalItem>(); cfg.CreateMap <ItemDTO, FoodItem>(); cfg.CreateMap <ItemDTO, PotionItem>(); cfg.CreateMap <ItemDTO, ProduceItem>(); cfg.CreateMap <ItemDTO, SnackItem>(); cfg.CreateMap <ItemDTO, SpecialItem>(); cfg.CreateMap <ItemDTO, TeacherItem>(); cfg.CreateMap <ItemDTO, UpgradeItem>(); cfg.CreateMap <SkillDTO, Skill>(); cfg.CreateMap <NpcMonsterDTO, NpcMonster>(); cfg.CreateMap <NpcMonsterSkillDTO, NpcMonsterSkill>(); }); _mapper = config.CreateMapper(); }
public Mate(Character owner, NpcMonster npcMonster, byte level, MateType matetype) { PveLockObject = new object(); Buff = new ThreadSafeSortedList <short, Buff>(); NpcMonsterVNum = npcMonster.NpcMonsterVNum; Monster = npcMonster; Level = level; Hp = MaxHp; Mp = MaxMp; Name = npcMonster.Name; MateType = matetype; Loyalty = 1000; PositionY = (short)(owner.PositionY + 1); PositionX = (short)(owner.PositionX + 1); MapX = (short)(owner.PositionX + 1); MapY = (short)(owner.PositionY + 1); Direction = 2; CharacterId = owner.CharacterId; Owner = owner; GenerateMateTransportId(); }
public Map(short mapId, Guid uniqueIdentifier, byte[] data) { _isSleeping = true; LastUserShopId = 0; _random = new Random(); MapId = mapId; ShopAllowed = true; _uniqueIdentifier = uniqueIdentifier; _monsters = new ThreadSafeSortedList<long, MapMonster>(); _mapMonsterIds = new List<int>(); Data = data; LoadZone(); IEnumerable<PortalDTO> portals = DAOFactory.PortalDAO.LoadByMap(MapId).ToList(); DroppedList = new ThreadSafeSortedList<long, MapItem>(); MapTypes = new List<MapTypeDTO>(); foreach (MapTypeMapDTO maptypemap in DAOFactory.MapTypeMapDAO.LoadByMapId(mapId).ToList()) { MapTypeDTO maptype = DAOFactory.MapTypeDAO.LoadById(maptypemap.MapTypeId) as MapTypeDTO; MapTypes.Add(maptype); } if (MapTypes.Any()) { if (MapTypes.ElementAt(0).RespawnMapTypeId != null) { DefaultRespawn = DAOFactory.RespawnMapTypeDAO.LoadById((long)MapTypes.ElementAt(0).RespawnMapTypeId); DefaultReturn = DAOFactory.RespawnMapTypeDAO.LoadById((long)MapTypes.ElementAt(0).ReturnMapTypeId); } } _portals = new List<PortalDTO>(); foreach (PortalDTO portal in portals) { _portals.Add(portal as PortalDTO); } UserShops = new Dictionary<long, MapShop>(); _npcs = new List<MapNpc>(); _npcs.AddRange(ServerManager.Instance.GetMapNpcsByMapId(MapId).AsEnumerable<MapNpc>()); }
private ServerManager() { _groups = new ThreadSafeSortedList <long, Group>(); Task autosave = new Task(SaveAllProcess); autosave.Start(); Task GroupTask = new Task(() => GroupProcess()); GroupTask.Start(); Task BotTask = new Task(() => BotProcess()); BotTask.Start(); Task TaskController = new Task(() => TaskLauncherProcess()); TaskController.Start(); lastGroupId = 1; }
public void Initialize() { BazaarList = new ThreadSafeSortedList <long, BazaarItemLink>(); OrderablePartitioner <BazaarItemDTO> bazaarPartitioner = Partitioner.Create(DAOFactory.BazaarItemDAO.LoadAll(), EnumerablePartitionerOptions.NoBuffering); Parallel.ForEach(bazaarPartitioner, new ParallelOptions { MaxDegreeOfParallelism = 8 }, bazaarItem => { BazaarItemLink item = new BazaarItemLink { BazaarItem = bazaarItem }; CharacterDTO chara = DAOFactory.CharacterDAO.LoadById(bazaarItem.SellerId); if (chara != null) { item.OwnerName = chara.Name; item.Item = new ItemInstance(DAOFactory.ItemInstanceDAO.LoadById(bazaarItem.ItemInstanceId)); } BazaarList[item.BazaarItem.BazaarItemId] = item; }); Logger.Info(string.Format(Language.Instance.GetMessageFromKey("BAZAAR_LOADED"), BazaarList.Count)); }
/// <summary> /// Constructor. /// </summary> public ChatService() { _clients = new ThreadSafeSortedList <long, ChatClient>(); }
public Group() { _characters = new ThreadSafeSortedList <long, ClientSession>(); GroupId = ServerManager.Instance.GetNextGroupId(); order = 0; }
protected BroadcastableBase() { LastUnregister = DateTime.Now.AddMinutes(-1); _sessions = new ThreadSafeSortedList <long, ClientSession>(); }
public Group() { _characters = new ThreadSafeSortedList<long, ClientSession>(); GroupId = ServerManager.Instance.GetNextGroupId(); _order = 0; }
public Dictionary<string, List<CollectorClient>> TickNetSymbolAccesRank; // string - Symbol int - Depth #endregion Fields #region Constructors public DataNormalizatorService() { Clients = new ThreadSafeSortedList<long, CollectorClient>(); // BusySymbols = new List<BusySymbol>(); TickNetSymbolAccesRank = new Dictionary<string, List<CollectorClient>>(); }
public Dictionary<string, List<DataClient>> TickNetSymbolAccesRank; // string - Symbol int - Depth #endregion Fields #region Constructors public DataAdminService() { Clients = new ThreadSafeSortedList<long, DataClient>(); BusySymbols = new List<BusySymbol>(); TickNetSymbolAccesRank = new Dictionary<string, List<DataClient>>(); }
/// <summary> /// Constructor. /// </summary> protected ScsServerBase() { Clients = new ThreadSafeSortedList<string, IScsServerClient>(); WireProtocolFactory = WireProtocolManager.GetDefaultWireProtocolFactory(); }
public DataNetLogService() { Clients = new ThreadSafeSortedList<long, LogClient>(); }
public void LearnSPSkill() { SpecialistInstance specialist = null; if (Inventory != null) { specialist = Inventory.LoadBySlotAndType<SpecialistInstance>((byte)EquipmentType.Sp, InventoryType.Wear); } byte SkillSpCount = (byte)SkillsSp.Count; SkillsSp = new ThreadSafeSortedList<int, CharacterSkill>(); foreach (Skill ski in ServerManager.GetAllSkill()) { if (specialist != null && ski.Class == Morph + 31 && specialist.SpLevel >= ski.LevelMinimum) { SkillsSp[ski.SkillVNum] = new CharacterSkill { SkillVNum = ski.SkillVNum, CharacterId = CharacterId }; } } if (SkillsSp.Count != SkillSpCount) { Session.SendPacket(GenerateMsg(Language.Instance.GetMessageFromKey("SKILL_LEARNED"), 0)); Session.SendPacket(GenerateSki()); Session.SendPackets(GenerateQuicklist()); } }
public void LaunchEvents() { _groups = new ThreadSafeSortedList <long, Group>(); _raids = new ThreadSafeSortedList <long, Raid>(); Observable.Interval(TimeSpan.FromMinutes(5)).Subscribe(x => { SaveAllProcess(); }); Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x => { GroupProcess(); }); Observable.Interval(TimeSpan.FromSeconds(2)).Subscribe(x => { RaidProcess(); }); Observable.Interval(TimeSpan.FromHours(3)).Subscribe(x => { BotProcess(); }); Observable.Interval(TimeSpan.FromSeconds(30)).Subscribe(x => { MailProcess(); }); Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(x => { RemoveItemProcess(); }); foreach (var map in _maps) { Observable.Interval(TimeSpan.FromSeconds(1)).Subscribe(x => { try { if (!map.Value.IsSleeping) { map.Value.RemoveMapItem(); } } catch (Exception e) { Logger.Error(e); } }); foreach (MapNpc npc in map.Value.Npcs) { npc.StartLife(); } Observable.Interval(TimeSpan.FromMilliseconds(400)).Subscribe(x => { Parallel.ForEach(map.Value.Monsters, monster => { monster.StartLife(); }); }); } ServerCommunicationClient.Instance.SessionKickedEvent += OnSessionKicked; ServerCommunicationClient.Instance.MessageSentToCharacter += OnMessageSentToCharacter; lastGroupId = 1; lastRaidId = 1; }
public BroadcastableBase() { LastUnregister = DateTime.Now.AddMinutes(-1); _sessions = new ThreadSafeSortedList<long, ClientSession>(); }
public MapInstance(Map map, Guid guid, bool shopAllowed, MapInstanceType type, InstanceBag instanceBag, bool dropAllowed = false) { OnSpawnEvents = new List <EventContainer>(); Buttons = new List <MapButton>(); XpRate = 0; if (type == MapInstanceType.BaseMapInstance) { XpRate = map.XpRate; } MinLevel = 1; MaxLevel = 99; MinHeroLevel = 0; MaxHeroLevel = 100; if (type != MapInstanceType.TimeSpaceInstance && type != MapInstanceType.RaidInstance) { switch (map.MapId) { case 154: // Caligor's Realm MinLevel = 80; break; case 170: // Desert case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: case 180: case 181: case 182: case 183: case 184: case 185: case 186: case 187: case 188: case 189: case 190: case 191: case 192: case 193: case 194: case 195: case 196: case 197: case 198: case 199: case 200: case 201: case 202: case 203: case 204: case 205: case 207: case 208: case 209: case 210: case 211: case 212: case 223: case 224: case 225: case 226: case 227: MinLevel = 70; break; case 228: //Cylloan case 229: case 230: case 231: case 232: case 233: case 234: case 235: case 236: case 237: case 238: case 239: case 240: case 241: case 242: case 243: case 244: case 245: case 246: MinLevel = 85; break; case 2628: case 2629: case 2630: case 2631: case 2632: case 2633: case 2634: case 2635: case 2636: case 2637: case 2638: case 2639: case 2640: case 2641: case 2642: case 2643: case 2644: case 2645: case 2646: case 2647: case 2648: case 2649: case 2650: MinLevel = 88; MinHeroLevel = 10; break; } } DropRate = 0; DropAllowed = dropAllowed; InstanceMusic = map.Music; ShopAllowed = shopAllowed; MapInstanceType = type; _isSleeping = true; LastUserShopId = 0; InstanceBag = instanceBag; Clock = new Clock(3); _random = new Random(); Map = map; MapInstanceId = guid; ScriptedInstances = new List <ScriptedInstance>(); OnCharacterDiscoveringMapEvents = new List <Tuple <EventContainer, List <long> > >(); OnMoveOnMapEvents = new ThreadSafeGenericList <EventContainer>(); OnAreaEntryEvents = new ThreadSafeGenericList <ZoneEvent>(); WaveEvents = new List <EventWave>(); OnMapClean = new List <EventContainer>(); _monsters = new ThreadSafeSortedList <long, MapMonster>(); _delayedMonsters = new ThreadSafeSortedList <long, MapMonster>(); _npcs = new ThreadSafeSortedList <long, MapNpc>(); _mapMonsterIds = new ThreadSafeSortedList <int, int>(); _mapNpcIds = new ThreadSafeSortedList <int, int>(); DroppedList = new ThreadSafeSortedList <long, MapItem>(); Portals = new List <Portal>(); UnlockEvents = new List <EventContainer>(); UserShops = new Dictionary <long, MapShop>(); RemovedMobNpcList = new List <object>(); StartLife(); }
/// <summary> /// Constructor. /// /// </summary> protected ScsServerBase() { this.Clients = new ThreadSafeSortedList <long, IScsServerClient>(); this.WireProtocolFactory = WireProtocolManager.GetDefaultWireProtocolFactory(); }
public void Initialize() { // parse rates XPRate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RateXp"]); DropRate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RateDrop"]); GoldRate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RateGold"]); FairyXpRate = int.Parse(System.Configuration.ConfigurationManager.AppSettings["RateFairyXp"]); // load explicite type of ItemDTO foreach (ItemDTO itemDTO in DAOFactory.ItemDAO.LoadAll()) { Item ItemGO = null; switch (itemDTO.ItemType) { case ItemType.Ammo: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Armor: ItemGO = new WearableItem(itemDTO); break; case ItemType.Box: ItemGO = new BoxItem(itemDTO); break; case ItemType.Event: ItemGO = new MagicalItem(itemDTO); break; case ItemType.Fashion: ItemGO = new WearableItem(itemDTO); break; case ItemType.Food: ItemGO = new FoodItem(itemDTO); break; case ItemType.Jewelery: ItemGO = new WearableItem(itemDTO); break; case ItemType.Magical: ItemGO = new MagicalItem(itemDTO); break; case ItemType.Main: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Map: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Part: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Potion: ItemGO = new PotionItem(itemDTO); break; case ItemType.Production: ItemGO = new ProduceItem(itemDTO); break; case ItemType.Quest1: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Quest2: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Sell: ItemGO = new NoFunctionItem(itemDTO); break; case ItemType.Shell: ItemGO = new MagicalItem(itemDTO); break; case ItemType.Snack: ItemGO = new SnackItem(itemDTO); break; case ItemType.Special: ItemGO = new SpecialItem(itemDTO); break; case ItemType.Specialist: ItemGO = new WearableItem(itemDTO); break; case ItemType.Teacher: ItemGO = new TeacherItem(itemDTO); break; case ItemType.Upgrade: ItemGO = new UpgradeItem(itemDTO); break; case ItemType.Weapon: ItemGO = new WearableItem(itemDTO); break; default: ItemGO = new NoFunctionItem(itemDTO); break; } _items.Add(ItemGO); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("ITEMS_LOADED"), _items.Count())); // intialize monsterdrops _monsterDrops = new ThreadSafeSortedList <short, List <DropDTO> >(); foreach (var monsterDropGrouping in DAOFactory.DropDAO.LoadAll().GroupBy(d => d.MonsterVNum)) { if (monsterDropGrouping.Key.HasValue) { _monsterDrops[monsterDropGrouping.Key.Value] = monsterDropGrouping.OrderBy(d => d.DropChance).ToList(); } else { _generalDrops = monsterDropGrouping.ToList(); } } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("DROPS_LOADED"), _monsterDrops.GetAllItems().Sum(i => i.Count()))); // initialiize monsterskills _monsterSkills = new ThreadSafeSortedList <short, List <NpcMonsterSkill> >(); foreach (var monsterSkillGrouping in DAOFactory.NpcMonsterSkillDAO.LoadAll().GroupBy(n => n.NpcMonsterVNum)) { _monsterSkills[monsterSkillGrouping.Key] = monsterSkillGrouping.Select(n => n as NpcMonsterSkill).ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MONSTERSKILLS_LOADED"), _monsterSkills.GetAllItems().Sum(i => i.Count()))); // initialize npcmonsters foreach (NpcMonsterDTO npcmonsterDTO in DAOFactory.NpcMonsterDAO.LoadAll()) { _npcs.Add(npcmonsterDTO as NpcMonster); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("NPCMONSTERS_LOADED"), _npcs.Count())); // intialize receipes _recipes = new ThreadSafeSortedList <int, List <Recipe> >(); foreach (var recipeGrouping in DAOFactory.RecipeDAO.LoadAll().GroupBy(r => r.MapNpcId)) { _recipes[recipeGrouping.Key] = recipeGrouping.Select(r => r as Recipe).ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("RECIPES_LOADED"), _recipes.GetAllItems().Sum(i => i.Count()))); // initialize shopitems _shopItems = new ThreadSafeSortedList <int, List <ShopItemDTO> >(); foreach (var shopItemGrouping in DAOFactory.ShopItemDAO.LoadAll().GroupBy(s => s.ShopId)) { _shopItems[shopItemGrouping.Key] = shopItemGrouping.ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("SHOPITEMS_LOADED"), _shopItems.GetAllItems().Sum(i => i.Count()))); // initialize shopskills _shopSkills = new ThreadSafeSortedList <int, List <ShopSkillDTO> >(); foreach (var shopSkillGrouping in DAOFactory.ShopSkillDAO.LoadAll().GroupBy(s => s.ShopId)) { _shopSkills[shopSkillGrouping.Key] = shopSkillGrouping.ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("SHOPSKILLS_LOADED"), _shopSkills.GetAllItems().Sum(i => i.Count()))); // initialize shops _shops = new ThreadSafeSortedList <int, Shop>(); foreach (var shopGrouping in DAOFactory.ShopDAO.LoadAll()) { _shops[shopGrouping.MapNpcId] = shopGrouping as Shop; } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("SHOPS_LOADED"), _shops.GetAllItems().Count())); // initialize teleporters _teleporters = new ThreadSafeSortedList <int, List <TeleporterDTO> >(); foreach (var teleporterGrouping in DAOFactory.TeleporterDAO.LoadAll().GroupBy(t => t.MapNpcId)) { _teleporters[teleporterGrouping.Key] = teleporterGrouping.Select(t => t).ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("TELEPORTERS_LOADED"), _teleporters.GetAllItems().Sum(i => i.Count()))); // initialize skills foreach (SkillDTO skillDTO in DAOFactory.SkillDAO.LoadAll()) { Skill skill = skillDTO as Skill; skill.Combos.AddRange(DAOFactory.ComboDAO.LoadBySkillVnum(skill.SkillVNum).ToList()); _skills.Add(skill); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("SKILLS_LOADED"), _skills.Count())); // intialize mapnpcs _mapNpcs = new ThreadSafeSortedList <short, List <MapNpc> >(); foreach (var mapNpcGrouping in DAOFactory.MapNpcDAO.LoadAll().GroupBy(t => t.MapId)) { _mapNpcs[mapNpcGrouping.Key] = mapNpcGrouping.Select(t => t as MapNpc).ToList(); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MAPNPCS_LOADED"), _mapNpcs.GetAllItems().Sum(i => i.Count()))); try { int i = 0; int monstercount = 0; foreach (MapDTO map in DAOFactory.MapDAO.LoadAll()) { Guid guid = Guid.NewGuid(); Map newMap = new Map(map.MapId, guid, map.Data); newMap.Music = map.Music; newMap.ShopAllowed = map.ShopAllowed; // register for broadcast _maps.TryAdd(guid, newMap); newMap.SetMapMapMonsterReference(); newMap.SetMapMapNpcReference(); i++; newMap.LoadMonsters(); foreach (MapMonster mapMonster in newMap.Monsters) { mapMonster.Map = newMap; newMap.AddMonster(mapMonster); } monstercount += newMap.Monsters.Count(); } if (i != 0) { Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MAPS_LOADED"), i)); } else { Logger.Log.Error(Language.Instance.GetMessageFromKey("NO_MAP")); } Logger.Log.Info(String.Format(Language.Instance.GetMessageFromKey("MAPMONSTERS_LOADED"), monstercount)); } catch (Exception ex) { Logger.Log.Error("General Error", ex); } }
/// <summary> /// Constructor. /// </summary> public ChatService() { _clients = new ThreadSafeSortedList<long, ChatClient>(); }
public void LoadSkills() { Skills = new ThreadSafeSortedList<int, CharacterSkill>(); IEnumerable<CharacterSkillDTO> characterskillDTO = DAOFactory.CharacterSkillDAO.LoadByCharacterId(CharacterId).ToList(); foreach (CharacterSkillDTO characterskill in characterskillDTO.OrderBy(s => s.SkillVNum)) { if (!Skills.ContainsKey(characterskill.SkillVNum)) { Skills[characterskill.SkillVNum] = characterskill as CharacterSkill; } } }