public XmlData(string path = "data") { ObjectTypeToElement = new ReadOnlyDictionary <ushort, XElement>( type2elem_obj = new Dictionary <ushort, XElement>()); ObjectTypeToId = new ReadOnlyDictionary <ushort, string>( type2id_obj = new Dictionary <ushort, string>()); IdToObjectType = new ReadOnlyDictionary <string, ushort>( id2type_obj = new Dictionary <string, ushort>(StringComparer.InvariantCultureIgnoreCase)); TileTypeToElement = new ReadOnlyDictionary <ushort, XElement>( type2elem_tile = new Dictionary <ushort, XElement>()); TileTypeToId = new ReadOnlyDictionary <ushort, string>( type2id_tile = new Dictionary <ushort, string>()); IdToTileType = new ReadOnlyDictionary <string, ushort>( id2type_tile = new Dictionary <string, ushort>(StringComparer.InvariantCultureIgnoreCase)); Tiles = new ReadOnlyDictionary <ushort, TileDesc>( tiles = new Dictionary <ushort, TileDesc>()); Items = new ReadOnlyDictionary <ushort, Item>( items = new Dictionary <ushort, Item>()); ObjectDescs = new ReadOnlyDictionary <ushort, ObjectDesc>( objDescs = new Dictionary <ushort, ObjectDesc>()); Portals = new ReadOnlyDictionary <ushort, PortalDesc>( portals = new Dictionary <ushort, PortalDesc>()); TypeToPet = new ReadOnlyDictionary <ushort, PetStruct>( type2pet = new Dictionary <ushort, PetStruct>()); IdToPetSkin = new ReadOnlyDictionary <string, PetSkin>( id2pet_skin = new Dictionary <string, PetSkin>()); SetTypeSkins = new ReadOnlyDictionary <ushort, SetTypeSkin>( setTypeSkins = new Dictionary <ushort, SetTypeSkin>()); addition = new XElement("ExtData"); assign = new AutoAssign(this); string basePath = Path.Combine(AssemblyDirectory, path); Console.WriteLine("Loading game data from '{0}'...", basePath); string[] xmls = Directory.EnumerateFiles(basePath, "*.xml", SearchOption.AllDirectories).ToArray(); for (int i = 0; i < xmls.Length; i++) { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Loading '{0}'({1}/{2})...", xmls[i], i + 1, xmls.Length); } using (Stream stream = File.OpenRead(xmls[i])) ProcessXml(XElement.Load(stream)); } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Finish loading game data."); Console.WriteLine("{0} Items", items.Count); Console.WriteLine("{0} Tiles", tiles.Count); Console.WriteLine("{0} Objects", objDescs.Count); Console.WriteLine("{0} Portals", portals.Count); Console.WriteLine("{0} Additions", addition.Elements().Count()); } }
/// <summary> /// 添加配置 /// </summary> /// <param name="newConfiguration"></param> /// <returns></returns> public async Task <JsonDataMsg <string> > UserAddConfigurationToToolAsync(ToolConfigDto newConfiguration) { //参数为空检查 if (null == newConfiguration) { NLogMgr.DebugLog(_programLog, "后台接收配置数据失败"); return(new JsonDataMsg <string>(null, false, "后台接收数据失败")); } //使用mapper装换成聚合根 MapperConfiguration cfg = EntityAutoMapper.Instance.AutoMapperConfig(nameof(JobConfiguration)); CheckConfig checkConfig = EntityAutoMapper.Instance.GetMapperResult <CheckConfig>(cfg, newConfiguration); var success = await Repository.AddConfigDataAsync(checkConfig); if (!success) { NLogMgr.DebugLog(_programLog, "增添配置异常"); return(new JsonDataMsg <string>(null, success, "增添配置异常")); } //异步IPC通知工具客户端配置已变化 _client.InvokeAsync(p => p.ConfigWasModify()); NLogMgr.DebugLog(_programLog, "已经为您加入该配置"); return(new JsonDataMsg <string>(null, success, "已经为您加入该配置")); }
protected virtual void RaiseCheckConfig() { Execute.BeginOnThreadPool(() => { CheckConfig?.Invoke(this, EventArgs.Empty); }); }
static void ShowResult() { CheckConfig window = (CheckConfig)EditorWindow.GetWindow(typeof(CheckConfig)); window.position = new Rect((Screen.currentResolution.width - windowWidth) / 2, (Screen.currentResolution.height - windowHeight) / 2, windowWidth, windowHeight); string title = check.result.platform + "配置检查"; try { if (MsdkUtil.isUnityEarlierThan("5.1")) { PropertyInfo info = window.GetType().GetProperty("title"); info.SetValue(window, title, null); } else { PropertyInfo info = window.GetType().GetProperty("titleContent"); info.SetValue(window, new GUIContent(title), null); } } catch (Exception e) { Debug.LogException(e); } window.Show(); }
public void JobConfigurationAutoMapper() { MapperConfiguration cfg = EntityAutoMapper.Instance.AutoMapperConfig(nameof(JobConfiguration)); Assert.IsNotNull(cfg); cfg.AssertConfigurationIsValid(); string startTime = "2019-08-25 16:00:05"; string endTime = "2019-08-25 17:30:00"; CheckConfig result = EntityAutoMapper.Instance.GetMapperResult<CheckConfig>(cfg, new JobConfiguration(){ StartToWrokTime = DateTime.Parse(startTime), StopToWorkTime = DateTime.Parse(endTime), WorkSpan = 3000, PresetTimeout = 1000, PingSendCount = 4 }); Assert.IsNotNull(result); Assert.AreEqual(startTime, (result.StartToWrokTime ?? DateTime.MinValue).ToString("yyyy-MM-dd HH:mm:ss")); Assert.AreEqual(endTime, (result.StopToWorkTime ?? DateTime.MaxValue).ToString("yyyy-MM-dd HH:mm:ss")); Assert.AreEqual(3000, result.WorkSpan); Assert.AreEqual(1000, result.PresetTimeout); Assert.AreEqual(4, result.PingSendCount); }
public bool RemovePortal(World world) { if (world == null) { return(false); } lock (worldLock) { var portal = portals.FirstOrDefault(p => p.Value.WorldInstance == world); if (portal.Value == null) { return(false); } if (CheckConfig.IsDebugOn()) { Console.WriteLine($"Portal {portal.Key}({portal.Value.WorldInstance.Name}) removed."); } nexus.LeaveWorld(portal.Value); portals.Remove(portal.Key); world.isLinked = false; return(true); } }
public void TimedSpawn() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Players in Realm: " + world.Players.Count); //checks players in realm } if (world.Players.Count > 0) //Makes sure player is in the realm { var evt = events[rand.Next(0, events.Count)]; SpawnEvent(evt.Item1, evt.Item2); TauntData?dat = null; dat = null; foreach (var i in criticalEnemies) { if (evt.Item1 == i.Item1) { dat = i.Item2; break; } } if (dat == null) { return; } if (dat.Value.spawn != null) { var arr = dat.Value.spawn; var msg = arr[rand.Next(0, arr.Length)]; BroadcastMsg(msg); //Taunt that bish } } world.Timers.Add(new WorldTimer(300000, (ww, tt) => { TimedSpawn(); })); //New Event every 5 minutes }
private static Assembly getImpleAssembly(ServicePackageInfo info) { string[] strs = info.ImpleAssemblyName.Split('\\'); string names = (strs[strs.Length - 1]); string[] arrname = (names.Split('.')); int i = 1; string name = arrname[0]; while (i < arrname.Length - 1) { name += "." + arrname[i]; i++; } Assembly impleAssembly; try { impleAssembly = AppDomain.CurrentDomain.Load(name); } catch { impleAssembly = CheckConfig.GetAssembly(ConfigUtil.GetBizPluginFullPath(info.ImpleAssemblyName)); } return(impleAssembly); }
public void TickLoop() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Procces: Starting network loop."); } Work work; while (true) { if (Manager.Terminating) { break; } loopLock.Reset(); while (pendings.TryDequeue(out work)) { if (Manager.Terminating) { return; } try { if (work.Item1.Stage == ProtocalStage.Disconnected) { Client client; var accId = work.Item1?.Account?.AccountId; if (accId != null) { Manager.Clients.TryRemove(accId, out client); } continue; } } catch (Exception e) { Console.WriteLine(e); throw; } try { Packet packet = Packet.Packets[work.Item2].CreateInstance(); packet.Read(work.Item1, work.Item3, 0, work.Item3.Length); work.Item1.ProcessPacket(packet); } catch { } } while (pendings.Count == 0 && !Manager.Terminating) { loopLock.SpinOnce(); } } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Procces: Stopping network loop."); } }
public void Start() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Starting server..."); } Socket.Bind(new IPEndPoint(IPAddress.Any, Program.Settings.GetValue <int>("port"))); Socket.Listen(0xff); Socket.BeginAccept(Listen, null); }
public void Stop() { if (CheckConfig.IsDebugOn()) { if (!_started) { return; } } Console.WriteLine("Stopping policy server..."); _listener.Stop(); }
private static void createCache(string key, DungeonTemplate template) { if (CheckConfig.IsDebugOn()) { Console.WriteLine($"Generating cache for dungeon: {key}"); } cachedMaps.Add(key, new List <string>()); for (var i = 0; i < 3; i++) //Keep at least 3 maps in cache { cachedMaps[key].Add(generateNext(0, template)); } }
public void Init() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Oryx is controlling world {0}({1})...", world.Id, world.Name); } var w = world.Map.Width; var h = world.Map.Height; var stats = new int[12]; for (var y = 0; y < h; y++) { for (var x = 0; x < w; x++) { var tile = world.Map[x, y]; if (tile.Terrain != WmapTerrain.None) { stats[(int)tile.Terrain - 1]++; } } } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Spawning minions..."); } foreach (var i in spawn) { var terrain = i.Key; var idx = (int)terrain - 1; var enemyCount = stats[idx] / i.Value.Item1; enemyMaxCounts[idx] = enemyCount; enemyCounts[idx] = 0; for (var j = 0; j < enemyCount; j++) { var objType = GetRandomObjType(i.Value.Item2); if (objType == 0) { continue; } enemyCounts[idx] += Spawn(world.Manager.GameData.ObjectDescs[objType], terrain, w, h); if (enemyCounts[idx] >= enemyCount) { break; } } } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Oryx is done."); } }
public void WorldClosed(World world) { lock (worldLock) { Portal portal = portals[world]; nexus.LeaveWorld(portal); portals.Remove(world); if (CheckConfig.IsDebugOn()) { Console.WriteLine("World {0}({1}) closed.", world.Id, world.Name); } } }
private async Task <bool> LoadToolParamAsync() { var toolSetting = await LoadToolConfigAsync(); if (null == toolSetting) { return(false); } RunParam = CheckConfig.GetRunParam(toolSetting); return(null != RunParam); }
public void Stop() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Stoping server..."); } foreach (Client i in Manager.Clients.Values.ToArray()) { i.Save(); i.Disconnect(Client.DisconnectReason.STOPPING_SERVER); } Socket.Close(); }
public async void Stop() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Stoping server..."); } foreach (Client i in Manager.Clients.Values.ToArray()) { await i.Save(); i.Disconnect(); } Socket.Close(); }
public void Oryx(World world, string text) { world.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "#Oryx the Mad God", Text = text.ToSafeText() }, null); if (CheckConfig.IsDebugOn()) { Console.WriteLine("[{0}({1})] <Oryx the Mad God> {2}", world.Name, world.Id, text); } }
public void InitCloseRealm() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Oryx has closed realm {0}...", world.Name); } ClosingStarted = true; foreach (var i in world.Players.Values) { SendMsg(i, "I HAVE CLOSED THIS REALM!", "#Oryx the Mad God"); SendMsg(i, "YOU WILL NOT LIVE TO SEE THE LIGHT OF DAY!", "#Oryx the Mad God"); } world.Timers.Add(new WorldTimer(120000, (ww, tt) => { CloseRealm(); })); world.Manager.GetWorld(World.NEXUS_ID).Timers.Add(new WorldTimer(130000, (w, t) => Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => w.Manager.AddWorld(_.Result), TaskScheduler.Default))); world.Manager.CloseWorld(world); }
//private static int DistSqr(IntPoint a, IntPoint b) //{ // return (a.X - b.X)*(a.X - b.X) + (a.Y - b.Y)*(a.Y - b.Y); //} public static void ApplySetPieces(World world) { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Applying set pieces to world {0}({1}).", world.Id, world.Name); } Wmap map = world.Map; int w = map.Width, h = map.Height; Random rand = new Random(); HashSet <Rect> rects = new HashSet <Rect>(); foreach (Tuple <ISetPiece, int, int, WmapTerrain[]> dat in setPieces) { int size = dat.Item1.Size; int count = rand.Next(dat.Item2, dat.Item3); for (int i = 0; i < count; i++) { IntPoint pt = new IntPoint(); Rect rect; int max = 50; do { pt.X = rand.Next(0, w); pt.Y = rand.Next(0, h); rect = new Rect { x = pt.X, y = pt.Y, w = size, h = size }; max--; } while ((Array.IndexOf(dat.Item4, map[pt.X, pt.Y].Terrain) == -1 || rects.Any(_ => Rect.Intersects(rect, _))) && max > 0); if (max <= 0) { continue; } dat.Item1.RenderSetPiece(world, pt); rects.Add(rect); } } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Set pieces applied."); } }
public void News(string text) { foreach (var i in manager.Clients.Values) { i.SendPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "#Zylixel News", Text = text.ToSafeText() }); } if (CheckConfig.IsDebugOn()) { Console.WriteLine("<Zylixel News> {0}", text); } }
public void WorldRemoved(World world) { lock (worldLock) { if (portals.ContainsKey(world)) { Portal portal = portals[world]; nexus.LeaveWorld(portal); RealmManager.Realms.Add(portal.PortalName); RealmManager.CurrentPortalNames.Remove(portal.PortalName); portals.Remove(world); if (CheckConfig.IsDebugOn()) { Console.WriteLine("World {0}({1}) removed from monitor.", world.Id, world.Name); } } } }
/// <summary> /// 修改配置 /// </summary> /// <param name="newConfiguration"></param> /// <returns></returns> public async Task <object> UserAlterConfigurationToToolAsync(ToolConfigDto newConfiguration) { //使用mapper装换成聚合根 MapperConfiguration cfg = EntityAutoMapper.Instance.AutoMapperConfig(nameof(JobConfiguration)); CheckConfig checkConfig = EntityAutoMapper.Instance.GetMapperResult <CheckConfig>(cfg, newConfiguration); var success = await Repository.UpdateConfigDataAsync(checkConfig); if (!success) { NLogMgr.DebugLog(_programLog, "更改配置发生异常"); return(new JsonDataMsg <string>(null, success, "更改配置发生异常")); } //异步IPC通知工具客户端配置已变化 _client.InvokeAsync(p => p.ConfigWasModify()); NLogMgr.DebugLog(_programLog, "您已成功更改配置"); return(new JsonDataMsg <string>(null, success, "您已成功更改配置")); }
public void Start() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Starting policy server..."); } try { _listener.Start(); _listener.BeginAcceptTcpClient(ServePolicyFile, _listener); _started = true; } catch (ObjectDisposedException) { } catch (Exception ex) { Console.WriteLine(ex); Console.WriteLine("Could not start Socket Policy Server, is port 843 occupied?"); _started = false; } }
public void WorldAdded(World world) { lock (worldLock) { Position pos = GetRandPosition(); Portal portal = new Portal(manager, 0x0712, null) { Size = 80, WorldInstance = world, Name = world.Name }; portal.Move(pos.X + 0.5f, pos.Y + 0.5f); nexus.EnterWorld(portal); portals.Add(world, portal); if (CheckConfig.IsDebugOn()) { Console.WriteLine("World {0}({1}) added to monitor.", world.Id, world.Name); } } }
public void WorldOpened(World world) { lock (worldLock) { Position pos = GetRandPosition(); Portal portal = new Portal(manager, 0x71c, null) { Size = 150, WorldInstance = world, Name = world.Name }; portal.Move(pos.X, pos.Y); nexus.EnterWorld(portal); portals.Add(world, portal); if (CheckConfig.IsDebugOn()) { Console.WriteLine("World {0}({1}) opened.", world.Id, world.Name); } } }
public bool AddPortal(World world) { lock (worldLock) { if (portals.ContainsKey(world)) { return(false); } if (world == null) { return(false); } Position pos = GetRandPosition(); Portal portal = new Portal(manager, 0x0712, null) { Size = 80, WorldInstance = world, Name = world.Name + " Link" }; portal.Move(pos.X + 0.5f, pos.Y + 0.5f); nexus.EnterWorld(portal); portals.Add(world, portal); RealmManager.CurrentPortalNames.Add(world.Name + " Link"); world.isLinked = true; if (CheckConfig.IsDebugOn()) { Console.WriteLine("World {0}({1}) added to monitor.", world.Id, world.Name); } foreach (var i in manager.Clients.Values) { if (i.Player.Owner != world) { i.Player.SendInfo($"A Link to {world.Name} has spawned in the nexus!"); } } return(true); } }
public RealmPortalMonitor(RealmManager manager) { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Initalizing Portal Monitor..."); } this.manager = manager; nexus = manager.Worlds[World.NEXUS_ID] as Nexus; lock (worldLock) foreach (KeyValuePair <int, World> i in manager.Worlds) { if (i.Value is GameWorld) { WorldAdded(i.Value); } } if (CheckConfig.IsDebugOn()) { Console.WriteLine("Portal Monitor initialized."); } }
private void SpawnEvent(string name, ISetPiece setpiece) { var pt = new IntPoint(); do { pt.X = rand.Next(0, world.Map.Width); pt.Y = rand.Next(0, world.Map.Height); } while ((world.Map[pt.X, pt.Y].Terrain <WmapTerrain.Mountains || world.Map[pt.X, pt.Y].Terrain> WmapTerrain.MidForest) || !world.IsPassable(pt.X, pt.Y) || world.AnyPlayerNearby(pt.X, pt.Y)); pt.X -= (setpiece.Size - 1) / 2; pt.Y -= (setpiece.Size - 1) / 2; setpiece.RenderSetPiece(world, pt); if (CheckConfig.IsDebugOn()) { Console.WriteLine("Oryx spawned {0} at ({1}, {2}).", name, pt.X, pt.Y); } }
public async Task <bool> AddConfigDataAsync(CheckConfig config) { try { JobConfiguration jobConfiguration = EntityAutoMapper.Instance.GetMapperResult <JobConfiguration>(_mapperCfg, config); if (null == jobConfiguration) { return(false); } using (HealthManjuuCoreContext context = new HealthManjuuCoreContext()) { return(await AddConfigDataAsync(context, jobConfiguration)); } } catch (System.Exception ex) { NLogMgr.ErrorExLog(_errorLog, "添加检测工具配置异常", ex); return(false); } }