public bool StopResource(string resourceName, Resource[] resourceParent = null) { Resource ourRes; lock (RunningResources) { ourRes = RunningResources.FirstOrDefault(r => r.DirectoryName == resourceName); if (ourRes == null) { return(false); } Program.Output("Stopping " + resourceName); RunningResources.Remove(ourRes); } ourRes.Engines.ForEach(en => en.InvokeResourceStop()); var msg = Server.CreateMessage(); msg.Write((byte)PacketType.StopResource); msg.Write(resourceName); Server.SendToAll(msg, NetDeliveryMethod.ReliableOrdered); if (Gamemode == ourRes) { if (CurrentMap != null && CurrentMap != ourRes) { StopResource(CurrentMap.DirectoryName); CurrentMap = null; } Gamemode = null; } if (ourRes.MapEntities != null) { foreach (var entity in ourRes.MapEntities) { PublicAPI.deleteEntity(entity); } } if (CurrentMap == ourRes) { CurrentMap = null; } var gPool = ExportedFunctions as IDictionary <string, object>; if (gPool != null && gPool.ContainsKey(ourRes.DirectoryName)) { gPool.Remove(ourRes.DirectoryName); } CommandHandler.Unregister(ourRes.DirectoryName); FileModule.ExportedFiles.Remove(resourceName); lock (RunningResources) { foreach (var resource in RunningResources) { resource.Engines.ForEach(en => en.InvokeServerResourceStop(ourRes.DirectoryName)); } } Program.Output("Stopped " + resourceName + "!"); return(true); }