示例#1
0
 public void Game_Start(ModGameAPI gameAPI)
 {
     GameAPI = gameAPI;
     GameAPI.Console_Write("Mod Network Relay is Starting");
     startModServer(gameAPI);
     GameAPI.Console_Write("Mod Network Relay has been initialized");
 }
示例#2
0
        public void Game_Start(ModGameAPI dediAPI)
        {
            mDllNamesFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "DllNames.txt");
            mGameAPI          = dediAPI;
            try
            {
                mGameAPI.Console_Write($"LoadMod(start): {mDllNamesFileName}");

                mAssemblyFileNames = File.ReadAllLines(mDllNamesFileName)
                                     .Select(L => L.Trim())
                                     .Where(L => !string.IsNullOrEmpty(L) && !L.StartsWith("#"))
                                     .ToArray();

                Array.ForEach(mAssemblyFileNames, LoadAssembly);

                if (mModInstance.Count == 1)
                {
                    mSingleModInstance = mModInstance.First();
                }

                mGameAPI.Console_Write($"LoadMod(finish:{mModInstance.Count}): {mDllNamesFileName}");
            }
            catch (Exception Error)
            {
                mGameAPI.Console_Write($"LoadMod: {mDllNamesFileName} -> {Error}");
            }
        }
示例#3
0
        public ModManager(string folderPath, ModGameAPI api, Regex offlinePattern = null, bool verbose = false)
        {
            this.api     = api;
            this.verbose = verbose;
            if (offlinePattern != null)
            {
                this.offlinePattern = offlinePattern;
            }
            var cadidatePaths = getCandidateModPaths(folderPath);

            cadidatePaths.ForEach(x => OnboardMod(x, true));

            var modTable = getModTable(modDict.Values.ToList());

            api.Console_Write("\n" + modTable);

            var path = Path.GetFullPath(folderPath);

            watcher = new FileSystemWatcher()
            {
                Path = folderPath,
                IncludeSubdirectories = true,
                EnableRaisingEvents   = true,
            };
            api.Console_Write($"*** HotloaderMod now watching {path}");
            watcher.IncludeSubdirectories = true;
            watcher.Changed += Watcher_Changed;
            watcher.Created += Watcher_Created;
            watcher.Deleted += Watcher_Deleted;
            watcher.Renamed += Watcher_Renamed;
        }
        public void Game_Start(ModGameAPI dediAPI)
        {
            GameAPI = dediAPI;
            GameAPI.Console_Write($"ModClientDll: start");

            CurrentConfig = new ConfigurationManager <Configuration>()
            {
                ConfigFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "Configuration.xml")
            };
            CurrentConfig.Load();
            CurrentConfig.Current.EmpyrionToModPipeName = string.Format(CurrentConfig.Current.EmpyrionToModPipeName, Guid.NewGuid().ToString("N"));
            CurrentConfig.Current.ModToEmpyrionPipeName = string.Format(CurrentConfig.Current.ModToEmpyrionPipeName, Guid.NewGuid().ToString("N"));
            CurrentConfig.Save();

            GameAPI.Console_Write($"ModClientDll (CurrentDir:{Directory.GetCurrentDirectory()}): Config:{CurrentConfig.ConfigFilename}");

            InServerMessageHandler = new Dictionary <Type, Action <object> > {
                { typeof(EmpyrionGameEventData), M => HandleGameEvent((EmpyrionGameEventData)M) },
                { typeof(ClientHostComData), M => HandleClientHostCommunication((ClientHostComData)M) }
            };

            new Thread(() => { while (!Exit)
                               {
                                   Thread.Sleep(1000); CheckHostProcess();
                               }
                       }).Start();

            GameAPI.Console_Write($"ModClientDll: started");
        }
示例#5
0
        public void Game_Start(ModGameAPI dediAPI)
        {
            mDllNamesFileName = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "DllNames.txt");
            GameAPI           = dediAPI;

            SynchronizationContext.SetSynchronizationContext(new AsyncSynchronizationContext(GameAPI));

            try
            {
                string CurrentDirectory = Directory.GetCurrentDirectory();
                GameAPI.Console_Write($"ModDispatcher(start): {mDllNamesFileName} in {CurrentDirectory}");

                mAssemblyFileNames = File.ReadAllLines(mDllNamesFileName)
                                     .Select(L => L.Trim())
                                     .Where(L => !string.IsNullOrEmpty(L) && !L.StartsWith("#"))
                                     .ToArray();

                Array.ForEach(mAssemblyFileNames, LoadAssembly);

                Directory.SetCurrentDirectory(ProgramPath);

                try{ Parallel.ForEach(mModInstance, async M => await SafeApiCall(() => M.Game_Start(GameAPI), M, "Game_Start")); }
                finally{ Directory.SetCurrentDirectory(CurrentDirectory); }

                GameAPI.Console_Write($"ModDispatcher(finish:{mModInstance.Count}): {mDllNamesFileName}");
            }
            catch (Exception Error)
            {
                GameAPI.Console_Write($"ModDispatcher: {mDllNamesFileName} -> {Error}");
            }
        }
示例#6
0
        public void Game_Start(ModGameAPI dediAPI)
        {
            GameAPI = dediAPI;
            players = new List <PlayerInfo>();

            GameAPI.Console_Write("Death Messages by joemorin73.");
            GameAPI.Console_Write("Part of the Empyrion Mod Sample collection.");

            var filePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "Messages.yaml";

            config = Config.Configuration.GetConfiguration(filePath);
        }
        public void Game_Start(ModGameAPI dediAPI)
        {
            GameAPI = dediAPI;
            GameAPI.Console_Write($"ModClientDll: start");

            CurrentConfig = new ConfigurationManager <Configuration>()
            {
                ConfigFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetAssembly(GetType()).Location), "Configuration.xml")
            };
            CurrentConfig.Load();
            CurrentConfig.Current.EmpyrionToModPipeName = string.Format(CurrentConfig.Current.EmpyrionToModPipeName, Guid.NewGuid().ToString("N"));
            CurrentConfig.Current.ModToEmpyrionPipeName = string.Format(CurrentConfig.Current.ModToEmpyrionPipeName, Guid.NewGuid().ToString("N"));
            CurrentConfig.Save();

            GameAPI.Console_Write($"ModClientDll (CurrentDir:{Directory.GetCurrentDirectory()}): Config:{CurrentConfig.ConfigFilename}");

            InServerMessageHandler = new Dictionary <Type, Action <object> > {
                { typeof(EmpyrionGameEventData), M => HandleGameEvent((EmpyrionGameEventData)M) },
                { typeof(ClientHostComData), M => HandleClientHostCommunication((ClientHostComData)M) },
                { typeof(ModComData), M => HandleModCommunication((ModComData)M) }
            };

            OutServer = new ClientMessagePipe(CurrentConfig.Current.EmpyrionToModPipeName)
            {
                log = GameAPI.Console_Write
            };
            InServer = new ServerMessagePipe(CurrentConfig.Current.ModToEmpyrionPipeName)
            {
                log = GameAPI.Console_Write
            };
            InServer.Callback = Msg => {
                if (InServerMessageHandler.TryGetValue(Msg.GetType(), out Action <object> Handler))
                {
                    Handler(Msg);
                }
            };

            new Thread(() => { while (!Exit)
                               {
                                   Thread.Sleep(1000); CheckHostProcess();
                               }
                       })
            {
                IsBackground = true
            }.Start();
            new Thread(() => ReadGlobalStructureInfoForEvent())
            {
                IsBackground = true
            }.Start();

            GameAPI.Console_Write($"ModClientDll: started");
        }
示例#8
0
        public void Game_Start(ModGameAPI dediAPI)
        {
            api = dediAPI;
            var currentDirectory = Directory.GetCurrentDirectory();

            string     codeBase    = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri         = new UriBuilder(codeBase);
            string     path        = Uri.UnescapeDataString(uri.Path);
            var        assemblyDir = Path.GetDirectoryName(path);

            api.Console_Write($"starting dummy 1 from directory: {currentDirectory}");
            api.Console_Write($"launched from assembly in directory: {assemblyDir}");
        }
示例#9
0
 private void log(Func <string> logMsg)
 {
     if (this.verbose)
     {
         GameAPI.Console_Write(logMsg());
     }
 }
 void ModInterface.Game_Start(ModGameAPI dediAPI)
 {
     Broker.api = dediAPI;
     elevated   = new HashSet <string>(adminConfig.Elevated.Select(x => x.Id));
     api        = dediAPI;
     dediAPI.Console_Write(adminConfig.Elevated.First().Id);
     modManager = new ModManager("Content/Mods/Hotloader/watched", dediAPI, verbose: false);
 }
    public void Game_Start(ModGameAPI dediAPI)
    {
        DebugMod.GameAPI = dediAPI;

        GameAPI.Console_Write("Debug Mod Launched! 12");
        unusedSettlementSequenceNumbers = new Queue <ushort>(Enumerable.Range(62000, 62500).Select(x => (ushort)x));
        broker = new EmpyrionAPIMessageBroker(dediAPI);
    }
示例#12
0
        public void Game_Start(ModGameAPI dediAPI)
        {
            GameAPI = dediAPI;

            var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "Settings.yaml";
            var config         = Configuration.GetConfiguration <Configuration>(configFilePath);

            var modPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Extensions";

            using (var catalog = new AggregateCatalog(
                       new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly()),
                       new DirectoryCatalog(modPath, "*Mod.dll")))
            {
                // iterate over all directories in .\Plugins dir and add all Plugin* dirs to catalogs
                foreach (var path in System.IO.Directory.EnumerateDirectories(modPath, "*", System.IO.SearchOption.TopDirectoryOnly))
                {
                    catalog.Catalogs.Add(new DirectoryCatalog(path, "*Mod.dll"));
                }

                _container = new CompositionContainer(catalog);

                try
                {
                    this._container.ComposeParts(this);

                    //using (_gameServerConnection = new GameServerConnection(config))
                    //{
                    _gameServerConnection = new GameServerConnection(config);

                    foreach (var gameMod in _gameMods)
                    {
                        gameMod.Start(_gameServerConnection);
                    }

                    _gameServerConnection.Connect();

                    //                        // wait until the user presses Enter.
                    //                        string input = Console.ReadLine();
                    //
                    //                        foreach (var gameMod in _gameMods)
                    //                        {
                    //                            gameMod.Stop();
                    //                        }

                    //                    }
                }
                catch (CompositionException compositionException)
                {
                    GameAPI.Console_Write($"NCMR ModHost: {compositionException}");
                }
            }
        }
 private void writeGlobalStructureList(GlobalStructureList data)
 {
     foreach (var kvp in data.globalStructures)
     {
         foreach (var y in kvp.Value)
         {
             string message = $"playfield: {kvp.Key}; struct: ${Serializer.Serialize(y)}";
             GameAPI.Console_Write(message);
             AlertMessage("sending to log");
         }
     }
 }
 public void StartListen(string ip, int port, ModProtocol.DelegatePackageReceived nPackageReceivedDelegate)
 {
     try
     {
         packageReceivedDelegate = nPackageReceivedDelegate;
         tcpListener             = new TcpListener(IPAddress.Parse(ip), port);
         listenThread            = ModThreadHelper.StartThread(ListenForConnections, System.Threading.ThreadPriority.Lowest);
         gameAPI.Console_Write("Now listening on port " + port);
     }
     catch (Exception e)
     {
         ModLoging.Log_Exception(e, "MTP: StartListen");
     }
 }
        public void Game_Start(ModGameAPI dediAPI)
        {
            GameAPI = dediAPI;
            dediAPI.Console_Write("!!CREW PROGRESSION MOD LOADED!!");
            broker = new MessageBroker(dediAPI);
            var accounts = Account.AccountsFromFile("Content/Mods/CPM/accounts.json");

            settings = CrewProgressionManagerSettings.SettingsFromFile("Content/Mods/CPM/settings.json");
            GameAPI.Console_Write($"SETTINGS****: {Serializer.Serialize(settings)}");

            cpm = new CrewProgressionManager(broker, accounts, settings);

            ccm = new ChatCommandManager(cpm.generateInitialChatCommands());
        }
示例#16
0
        public void Game_Event(CmdId eventId, ushort seqNr, object data)
        {
            //Console.WriteLine("Game_Event: {0} : {1}",eventId, data);
            try
            {
                switch (eventId)
                {
                case CmdId.Event_GlobalStructure_List:
                {
                    sList = (GlobalStructureInfo)data;
                    //pInfo.playfield
                    foreach (var h in sList.)
                    {
                        h.Value.ForEach(Action <GlobalStructureInfo>).;
                    }
                    pInfo.playfield.SpawnTestPlayer(new Vector3(0, 0, 0));
                }
                break;

                case CmdId.Event_Playfield_List:
                {
                    PlayfieldList pList = (PlayfieldList)data;
                    foreach (var a in pList.playfields)
                    {
                        a.
                        Console.WriteLine("Playfields Loaded{0}", plist);
                    }
                }
                break;
                }
            }

            catch (Exception ex)
            {
                legacyModApi.Console_Write(ex.Message);
            }
        }
示例#17
0
        public void Game_Event(CmdId eventId, ushort seqNr, object data)
        {
            try
            {
                switch (eventId)
                {
                case    CmdId.Event_Playfield_Loaded:
                {
                    mGameAPI.Console_Write("Event_Playfield_Loaded actually happens");
                    break;
                }

                case    CmdId.Event_Playfield_List:
                {
                    PlayfieldList pfl = data as PlayfieldList;
                    foreach (string pf in pfl.playfields)
                    {
                        mGameAPI.Console_Write("Playfield: " + pf);
                    }
                }
                break;

                case    CmdId.Event_GlobalStructure_List:
                {
                    HandleGlobalStructureList(data as GlobalStructureList);
                }
                break;

                case    CmdId.Event_Structure_BlockStatistics:
                {
                    IdStructureBlockInfo idsbi = (IdStructureBlockInfo)data;
                    mGameAPI.Console_Write("Got block stats for id: " + idsbi.id);
                    foreach (KeyValuePair <int, int> stat in idsbi.blockStatistics)
                    {
                        if (stat.Key == SolarBattery)
                        {
                            mGameAPI.Console_Write("Building has " + stat.Value + " solar batteries...");
                        }
                    }
                }
                break;

                case    CmdId.Event_ChatMessage:
                {
                    ChatInfo ci = (ChatInfo)data;
                    if (ci == null)
                    {
                        break;
                    }

                    if (ci.type != 8 && ci.type != 7 && ci.msg == "!MODS")
                    {
                        PrivateMessage(ci.playerId, "Solar Helper by Kharzette");
                    }
                }
                break;

                case CmdId.Event_Playfield_Entity_List:
                {
                    PlayfieldEntityList pfel = (PlayfieldEntityList)data;
                    if (pfel == null)
                    {
                        break;
                    }

                    mGameAPI.Console_Write("Entity list for playfield " + pfel.playfield);
                    foreach (EntityInfo ei in pfel.entities)
                    {
                        mGameAPI.Console_Write("ID: " + ei.id + ", Pos: " + ei.pos + ", Type: " + ei.type);
                    }
                }
                break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                mGameAPI.Console_Write(ex.Message);
            }
        }
 public void Game_Start(ModGameAPI dediAPI)
 {
     api = dediAPI;
     api.Console_Write("starting dummy 2");
 }
示例#19
0
 public void Game_Start(ModGameAPI dediAPI)
 {
     GameAPI = dediAPI;
     GameAPI.Console_Write("Empyrion Dedi Server Info By ihatetn931/shadowpot Loaded");
 }
示例#20
0
        private void Watcher_Renamed(object sender, RenamedEventArgs e)
        {
            log(() => "detected rename");
            if (offlinePattern.IsMatch(e.OldFullPath) && !offlinePattern.IsMatch(e.FullPath))
            {
                OnboardMod(e.FullPath);
            }
            if (!modDict.ContainsKey(e.OldFullPath))
            {
                return;
            }
            var mod = modDict[e.OldFullPath];

            api.Console_Write($"detected rename of mod: {mod.title}@\"{e.OldFullPath}\"");
            if (offlinePattern.IsMatch(e.FullPath))
            {
                api.Console_Write($"mod invalidated using pattern: \"{offlinePattern.ToString()}\"");
                UnloadMod(mod);
            }
            api.Console_Write($"mod record transferred from \"{e.OldFullPath}\" to \"{e.FullPath}\"");
            modDict.Remove(e.OldFullPath);
            modDict[e.FullPath] = mod;
        }
示例#21
0
        public void Game_Event(CmdId eventId, ushort seqNr, object data)
        {
            try
            {
                switch (eventId)
                {
                case CmdId.Event_Dedi_Stats:
                    DediStats dStats = (DediStats)data;
                    ServerStats(dStats);
                    break;

                case CmdId.Event_Player_Connected:
                {
                    int entityId = ((Id)data).id;
                    lock (playerIds)
                    {
                        playerIds.Add(entityId);
                    }
                }
                break;

                case CmdId.Event_Player_Disconnected:
                {
                    int entityId = ((Id)data).id;
                    lock (playerIds)
                    {
                        playerIds.Remove(entityId);
                    }
                }
                break;

                case CmdId.Event_Player_List:
                {
                    if (data != null)
                    {          // empyt list is null?!
                        lock (playerIds)
                        {
                            playerIds = ((IdList)data).list;
                        }
                        for (int i = 0; i < playerIds.Count; i++)
                        {
                            //GameAPI.Console_Write(string.Format("{0} Player with id {1}", i + 1, playerIds[i]));
                            if (i > 0)
                            {
                                GetPlayerInfo();
                            }
                        }
                    }
                    else
                    {
                        GameAPI.Console_Write("No players connected");
                    }
                }
                break;

                case CmdId.Event_Player_Info:
                {
                    // DediStats sStats = (DediStats)data;
                    PlayerInfo pInfo = (PlayerInfo)data;
                    if (pInfo == null)
                    {
                        break;
                    }
                    Json.AddAndUpdatePlayer(pInfo);
                }
                break;
                }
            }
            catch (Exception ex)
            {
                GameAPI.Console_Write(ex.Message);
            }
        }
示例#22
0
    private void HandleSettlementWokflowEvent(ModGameAPI GameAPI, SettlementOperation operation, CmdId eventType, object data)
    {
        var operationPayload = Serializer.Serialize(operation);

        var message = $"*** processing operation {operation.seqNr}\n *** cmdid:{eventType} \n *** " +
                      $"last operation: {operation.stage} \n***  payload: {operationPayload}";

        GameAPI.Console_Write(message);


        switch (eventType)
        {
        case CmdId.Event_GlobalStructure_List:
            var structureList = (GlobalStructureList)data;
            operation = updateOperationFromStructureList(operation, structureList);
            if (operation.stage != SettlementStage.IdentifiedReplacement)
            {
                deprovisionOperation(operation.seqNr);
                return;
            }
            settlementOperations[operation.seqNr] = operation;
            GameAPI.Game_Request(CmdId.Request_NewEntityId, operation.seqNr, null);
            break;

        case CmdId.Event_NewEntityId:
            var newId = (Id)data;

            GameAPI.Console_Write($"*** new id: {Serializer.Serialize(newId)} ***");

            operation.newStructureId = newId;
            EntitySpawnInfo newInfo = new EntitySpawnInfo()
            {
                forceEntityId = newId.id,
                playfield     = operation.playfieldName,
                pos           = operation.originalStructureInfo.pos,
                rot           = operation.originalStructureInfo.rot,
                name          = operation.newStructureName,
                prefabName    = "Test-Bed (Settled)",
                type          = operation.originalStructureInfo.type,
            };

            GameAPI.Console_Write($"*** requesting spawn: {Serializer.Serialize(newInfo)} ***");
            operation.newStructureInfo            = newInfo;
            operation.stage                       = SettlementStage.ProvisionedReplacement;
            operation.stage                       = SettlementStage.RequestedDemolition;
            settlementOperations[operation.seqNr] = operation;
            Id outId = new Id(operation.originalStructureInfo.id);
            GameAPI.Game_Request(CmdId.Request_Entity_Destroy, operation.seqNr, outId);

            break;

        case CmdId.Event_Ok:
            if (operation.stage == SettlementStage.RequestedDemolition)
            {
                operation.stage = SettlementStage.EmplacedNewSettlement;
                settlementOperations[operation.seqNr] = operation;
                GameAPI.Console_Write($"*** new settlement info:{Serializer.Serialize(operation.newStructureInfo)}");
                GameAPI.Game_Request(CmdId.Request_Entity_Spawn, operation.seqNr, operation.newStructureInfo);
            }
            else if (operation.stage == SettlementStage.EmplacedNewSettlement)
            {
                operation.stage = SettlementStage.SettlementComplete;
                settlementOperations[operation.seqNr] = operation;
                deprovisionOperation(operation.seqNr);
                GameAPI.Console_Write("*** settlement complete!!! ***");
            }
            break;

        case CmdId.Event_Error:
            var error = (ErrorInfo)data;
            GameAPI.Console_Write($"*** error: {Serializer.Serialize(error)} ***");

            deprovisionOperation(operation.seqNr);
            break;
        }
    }
示例#23
0
 public void Game_Event(CmdId eventId, ushort seqNr, object data)
 {
     api.Console_Write("dummy 1 event");
     api.Console_Write(data.ToString());
 }
 // Called once early when the game starts (but not again if player quits from game to title menu and starts (or resumes) a game again
 // Hint: treat this like a constructor for your mod
 public void Game_Start(ModGameAPI legacyAPI)
 {
     legacyApi = legacyAPI;
     legacyApi?.Console_Write("EmpyrionScripting Mod started: Game_Start");
 }
示例#25
0
 public void LogMessage(string component, string message)
 {
     _modGameApi.Console_Write("[PythonApi:" + component + "] " + message);
 }
示例#26
0
 public void output(string s)
 {
     GameAPI.Console_Write(s);
 }
示例#27
0
        public void Game_Event(CmdId eventId, ushort seqNr, object data)
        {
            try
            {
                switch (eventId)
                {
                case CmdId.Event_Player_Info:
                    if (players.Where(e => e.entityId == ((PlayerInfo)data).entityId).Count() == 0)
                    {
                        players.Add((PlayerInfo)data);
                    }
                    break;

                case CmdId.Event_Player_Connected:
                    GameAPI.Game_Request(CmdId.Request_Player_Info, (ushort)CmdId.Request_Player_Info, (Id)data);
                    break;

                case CmdId.Event_Player_Disconnected:
                    players.Remove(players.FirstOrDefault(e => e.entityId == ((Id)data).id));
                    break;

                case CmdId.Event_Statistics:

                    StatisticsParam stats = (StatisticsParam)data;

                    if (stats.type == StatisticsType.PlayerDied)
                    {
                        String msg = String.Empty;

                        PlayerInfo result = players.FirstOrDefault(e => e.entityId == stats.int1);

                        String user = "******";

                        if (result != null)
                        {
                            user = ((PlayerInfo)result).playerName;
                        }
                        else
                        {
                            GameAPI.Game_Request(CmdId.Request_Player_Info, (ushort)CmdId.Request_Player_Info, new Id(stats.int1));
                        }

                        msg = String.Format(config.Messages.GetNextMessage(stats.int2), user);

                        PlayerInfo killer = players.FirstOrDefault(e => e.entityId == stats.int3);

                        if (killer != null)
                        {
                            msg += String.Format(config.Messages.GetNextMessage(-1), killer.playerName);
                        }

                        AlertMessage(msg);
                        if (config.MessageInChat)
                        {
                            ChatMessage(msg);
                        }
                    }
                    break;

                case CmdId.Event_ChatMessage:
                    ChatInfo ci = (ChatInfo)data;
                    if (ci == null)
                    {
                        break;
                    }

                    if (ci.type != 8 && ci.type != 7 && ci.msg == "!MODS")
                    {
                        ChatMessage("Death Messages by joemorin73.");
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                GameAPI.Console_Write(ex.Message);
            }
        }
示例#28
0
        public void Game_Event(CmdId cmdId, ushort seqNr, object data)
        {
            try
            {
                switch (cmdId)
                {
                case CmdId.Event_Player_Connected:
                    Id pc = (Id)data;
                    try { string[]    bagLines      = System.IO.File.ReadAllLines("Content\\Mods\\Xango\\players\\EID" + pc.id + "\\VirtualBackpack.txt");
                          int         itemStackSize = bagLines.Count();
                          ItemStack[] itStack       = new ItemStack[itemStackSize];
                          for (int i = 0; i < itemStackSize; ++i)
                          {
                              string[] bagLinesSplit = bagLines[i].Split(',');
                              itStack[i]         = new ItemStack(Convert.ToInt32(bagLinesSplit[1]), Convert.ToInt32(bagLinesSplit[2])); //1=ItemNumber, 2=StackSize
                              itStack[i].slotIdx = Convert.ToByte(bagLinesSplit[0]);                                                    //0=SlotNumber
                              itStack[i].ammo    = Convert.ToInt32(bagLinesSplit[3]);                                                   //3=Ammo
                              itStack[i].decay   = Convert.ToInt32(bagLinesSplit[4]);                                                   //4=Decay
                          }
                          vBackpackDictionary.Add(pc.id, itStack); }
                    catch { };
                    LogFile("chat.txt", "Player " + pc.id + " Connected");
                    try { System.IO.Directory.CreateDirectory("Content\\Mods\\Xango\\players\\EID" + pc.id); }
                    catch { };
                    break;

                case CmdId.Event_Player_Disconnected:
                    Id pd = (Id)data;
                    LogFile("chat.txt", "Player " + pd.id + " DisConnected");
                    vBackpackDictionary.Remove(pd.id);
                    break;

                case CmdId.Event_Player_Info:
                    PlayerInfo PlayerInfoReceived = (PlayerInfo)data;
                    if (BackpackChatDictionary.ContainsKey(PlayerInfoReceived.entityId))
                    {
                        BackpackChatDictionary.Remove(PlayerInfoReceived.entityId);
                        if (vBackpackDictionary.ContainsKey(PlayerInfoReceived.entityId))
                        {
                            BackpackChatDictionary.Remove(PlayerInfoReceived.entityId);
                            LogFile("Chat.txt", "show backpack");
                            GameAPI.Game_Request(CmdId.Request_Player_ItemExchange, (ushort)CmdId.Request_Player_ItemExchange, new ItemExchangeInfo(PlayerInfoReceived.entityId, "Virtual Backpack", "Extra Inventory Space, Yay!", "Save", vBackpackDictionary[PlayerInfoReceived.entityId]));
                            step = "Request ItemExchange";
                        }
                        else
                        {
                            if (System.IO.File.Exists("Content\\Mods\\Xango\\players\\EID" + Convert.ToString(PlayerInfoReceived.entityId) + "\\VirtualBackpack.txt"))
                            {
                                LogFile("Chat.txt", "Build Blank Backpack");
                                System.IO.File.Create("Content\\Mods\\Xango\\players\\EID" + Convert.ToString(PlayerInfoReceived.entityId) + "\\VirtualBackpack.txt");
                                buildItemStack(PlayerInfoReceived.entityId, "blank");
                            }
                            else
                            {
                                LogFile("Chat.txt", "Show Blank Backpack");
                                GameAPI.Game_Request(CmdId.Request_Player_ItemExchange, (ushort)CmdId.Request_Player_ItemExchange, new ItemExchangeInfo(PlayerInfoReceived.entityId, "Virtual Backpack", "Extra Inventory Space, Yay!", "Save", EmptyExchange));
                                step = "Request ItemExchange";
                            }
                        }
                    }
                    break;

                case CmdId.Event_Player_ItemExchange:
                    ItemExchangeInfo exchangeInfo = (ItemExchangeInfo)data;
                    vBackpackDictionary[exchangeInfo.id] = exchangeInfo.items;
                    System.IO.File.WriteAllText("Content\\Mods\\Xango\\players\\EID" + exchangeInfo.id + "\\VirtualBackpack.txt", string.Empty);
                    for (int i = 0; i <= exchangeInfo.items.Count(); i++)
                    {
                        LogFile("players\\EID" + exchangeInfo.id + "\\VirtualBackpack.txt", Convert.ToString(exchangeInfo.items[i].slotIdx) + "," + Convert.ToString(exchangeInfo.items[i].id) + "," + Convert.ToString(exchangeInfo.items[i].count) + "," + Convert.ToString(exchangeInfo.items[i].ammo) + "," + Convert.ToString(exchangeInfo.items[i].decay));
                    }
                    step = "itemExchange complete";
                    break;

                case CmdId.Event_Player_DisconnectedWaiting:
                    Id pdw = new Id();
                    GameAPI.Console_Write("Player " + pdw.id + " Failed Login Attempt");
                    break;

                case CmdId.Event_ChatMessage:
                    ChatInfo ci = (ChatInfo)data;
                    LogFile("Chat.txt", ci.playerId + " SAYS: " + ci.msg);
                    if (ci.msg.StartsWith("s! "))
                    {
                        ci.msg = ci.msg.Remove(0, 3);
                    }
                    ci.msg = ci.msg.ToLower();
                    if (ci.msg.StartsWith("/backpack"))
                    {
                        BackpackChatDictionary[ci.playerId] = ci.msg;
                        GameAPI.Game_Request(CmdId.Request_Player_Info, (ushort)CmdId.Request_Player_Info, new Eleon.Modding.Id(ci.playerId));
                        step = "Request Playerinfo";
                    }
                    break;

                case CmdId.Event_Error:
                    ErrorInfo err  = (ErrorInfo)data;
                    ErrorType err2 = (ErrorType)data;
                    LogFile("ERROR.txt", Convert.ToString(err2) + ": " + Convert.ToString(err));
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                GameAPI.Console_Write(ex.Message);
            }
        }