public static void ServerInit(IServerInitInterfaces initInterfaces) { MefServer.Init(Assembly.GetExecutingAssembly()); MefServer.AddType <IGameInfo>(new GameInfo(true)); LoadMefTypes <IServerInitInterfaces>(initInterfaces, typeof(MefServer)); MefServer.GetExportedValue <IEntityManager>().GenerateServerClasses(); var consoleManager = MefServer.GetExportedValue <NI_ConsoleManager>(); foreach (var conCommand in MefServer.GetExportedValues <IConCommand>()) { consoleManager.Register(conCommand); } foreach (var conVar in MefServer.GetExportedValues <IConVariable>()) { consoleManager.Register(conVar); } initInterfaces.ServerGameDll = MefServer.GetExportedValue <M_IServerGameDll>(); initInterfaces.ServerGameClients = MefServer.GetExportedValue <M_IServerGameClients>(); initInterfaces.ServerGameEnts = MefServer.GetExportedValue <M_IServerGameEnts>(); }
public BaseEntityClient CreateEntity(String className) { BaseEntityClient ent = null; try { ent = MefServer.GetExportedValue <BaseEntityClient>(className); ent.ClassName = className; } catch (Exception e) { _ConsoleManager.WriteLine(Color.Red, String.Format("Failed to create entity {0}: {1}", className, e.Message)); return(null); } _EntityList.Add(ent); return(ent); }
private BaseEntityServer CreateEntity(String className, IEdict edict, int index = -1) { BaseEntityServer ent = null; try { ent = MefServer.GetExportedValue <BaseEntityServer>(className); ent.ClassName = className; } catch (Exception e) { _ConsoleManager.WriteLine(Color.Red, String.Format("Failed to create entity {0}: {1}", className, e.Message)); return(null); } if (edict == null) { _EngineServer.CreateEdict(ent, index); } else { ent.Edict = edict; } _EntityList.Add(ent); ent.PostCreate(); if (ent.IsServerOnly) { Debug.Assert(false); //todo fix to work ent.Edict.SetSlotAndSerial(1, -1); } else { int slot = _EngineServer.IndexOfEdict(ent.Edict); ent.Edict.SetSlotAndSerial(slot, _EntSerials[slot]); } return(ent); }
public bool GenerateServerClasses() { var ret = new List <ServerClass>(); foreach (var c in MefServer.GetExports <BaseEntityServer>()) { object o = null; try { o = c.Value; } catch (Exception e) { _ConsoleManager.WriteLine(Color.Red, String.Format("Failed to create entity: {0}", e.Message)); continue; } var type = o.GetType(); if (type == null) { continue; } if (!ProcessServerClassType(type)) { _ConsoleManager.WriteLine(Color.Red, String.Format("Class {0} does not inheirt from BaseEntityServer. Skipping...", type.Name)); continue; } var sc = CombineServerClasses(type); ret.Add(sc); } ServerClasses = ret.ToArray(); return(true); }
public void CreateNetworkStringTables() { var gamerulesName = _GameRulesManager.StringTableName; var particalTable = _StringTable.CreateStringTable("ParticleEffectNames", (1 << 10)); var effectsTable = _StringTable.CreateStringTable("EffectDispatch", (1 << 10)); var vguiScreenTable = _StringTable.CreateStringTable("VguiScreen", (1 << 8)); var materialsTable = _StringTable.CreateStringTable("Materials", (1 << 10)); var infoPanelTable = _StringTable.CreateStringTable("InfoPanel", 128); var scenesTable = _StringTable.CreateStringTable("Scenes", (1 << 12)); var gamerulesTable = _StringTable.CreateStringTable(gamerulesName, 1); MefServer.AddTypeAndName <MI_NetworkStringTable>("ParticleEffectNames", particalTable); MefServer.AddTypeAndName <MI_NetworkStringTable>("EffectDispatch", effectsTable); MefServer.AddTypeAndName <MI_NetworkStringTable>("VguiScreen", vguiScreenTable); MefServer.AddTypeAndName <MI_NetworkStringTable>("Materials", materialsTable); MefServer.AddTypeAndName <MI_NetworkStringTable>("InfoPanel", infoPanelTable); MefServer.AddTypeAndName <MI_NetworkStringTable>("Scenes", scenesTable); MefServer.AddTypeAndName <MI_NetworkStringTable>(gamerulesName, gamerulesTable); //_MatieralManager.Precache("debug/debugempty"); //_ParticalManager.Precache("error"); }