protected Entity(IGameServerConnection gameServerConnection, int entityId, EntityType type, string name) { _gameServerConnection = gameServerConnection; _entityId = entityId; Type = type; Name = name; }
// This is called by the mod runner before connecting to the game server during startup. public void Start(IGameServerConnection gameServerConnection) { // figure out the path to the setting file in the same folder where this DLL is located. var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "DiscordBotMod_Settings.yaml"; // save connection to game server for later use _gameServerConnection = gameServerConnection; // This deserializes the yaml config file _config = EmpyrionModApi.BaseConfiguration.GetConfiguration <Configuration>(configFilePath); // Tell the string to use for "!MODS" command. _gameServerConnection.AddVersionString(k_versionString); _discordClient = new DiscordClient(new DiscordConfiguration { Token = _config.DiscordToken, TokenType = TokenType.Bot }); // Subscribe for the chat event _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _discordClient.MessageCreated += async e => { DSharpPlus.Entities.DiscordChannel discordChannel; lock (_discordClient) { discordChannel = _discordChannel; } if (e.Author != _discordClient.CurrentUser) { if (e.Message.Content == "cb:get_online_users") { // build list of online players: string onlinePlayers = string.Join("\n", from player in _gameServerConnection.GetOnlinePlayers().Values select player.DisplayName); var dmUserChannel = await _discordClient.CreateDmAsync(e.Author); await _discordClient.SendMessageAsync(dmUserChannel, $"Online Players:\n{onlinePlayers}"); } else if (e.Channel == discordChannel) { await _gameServerConnection.SendChatMessageToAll(string.Format(_config.FromDiscordFormattingString, e.Author.Username, e.Message.Content)); } } }; _discordClient.ConnectAsync() .ContinueWith(async t => { var channel = await _discordClient.GetChannelAsync(_config.ChannelId); lock (_discordClient) { _discordChannel = channel; } }); }
public BoundingBox(IGameServerConnection gameServerConnection, BoundingBoxInfo boundingBoxInfo) { PlayersInArea = new List <Player>(); _playfield = gameServerConnection.GetPlayfield(boundingBoxInfo.Playfield); _rect = new Rect3( new Vector3(boundingBoxInfo.Rect.min.x, boundingBoxInfo.Rect.min.y, boundingBoxInfo.Rect.min.z), new Vector3(boundingBoxInfo.Rect.max.x, boundingBoxInfo.Rect.max.y, boundingBoxInfo.Rect.max.z)); }
internal Faction(IGameServerConnection gameServerConnection, FactionInfo factionInfo) { _gameServerConnection = gameServerConnection; Origin = factionInfo.origin; Id = factionInfo.factionId; Initials = factionInfo.abbrev; Name = factionInfo.name; }
internal Structure(IGameServerConnection gameServerConnection, Playfield playfield, Eleon.Modding.GlobalStructureInfo info) : base(gameServerConnection, info.id, (EntityType)info.type, info.name) { Class = info.classNr; this.Position = new WorldPosition(playfield, info.pos.ToVector3(), info.rot.ToVector3()); this.MemberOfFaction = _gameServerConnection.GetFaction(info.factionId); this.Pilot = (info.pilotId == 0) ? null : _gameServerConnection.GetOnlinePlayers()[info.pilotId]; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); _gameServerConnection = gameServerConnection; _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ConsoleCommand += OnEvent_ConsoleCommand; }
public void Start(IGameServerConnection gameServerConnection) { var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "FactionPlayfieldKickerMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_Player_ChangedPlayfield += OnEvent_Player_ChangedPlayfield; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "ShipBuyingMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
#pragma warning restore 0649 public IGameServerConnection Run() { 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(typeof(Program).Assembly), 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) { _traceSource.TraceEvent(System.Diagnostics.TraceEventType.Error, 1, compositionException.ToString()); } } return(_gameServerConnection); }
private void Form1_Load(object sender, EventArgs e) { Program prog = new Program(); _gameServerConnection = prog.Run(); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; timer_5sec.Interval = 5000; timer_5sec.Tick += new EventHandler(timer_5sec_Tick); timer_5sec.Enabled = true; sayTextBox.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnterKeyPress); }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "VotingRewardMod_Settings.yaml"; _traceSource.TraceEvent(TraceEventType.Verbose, 3, "Loaded configuration."); _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _voteLogPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\VoteLog"; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "NoKillZonesMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _jailLocation = new WorldPosition(_gameServerConnection, _config.JailLocation); _jailExitLocation = new WorldPosition(_gameServerConnection, _config.JailExitLocation); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _gameServerConnection.Event_PlayerDied += OnEvent_PlayerDied; }
public WebSocketEndpoint( GameManager gameManager, ILogger logger, IAppSettings settings, ITokenProvider tokenProvider, IGamePacketSerializer packetSerializer) { connection = new WSGameServerConnection( logger, settings, tokenProvider, packetSerializer); connection.Register("game_event", new GameEventPacketHandler(gameManager)); this.gameManager = gameManager; }
// This is called by the mod runner before connecting to the game server during startup. public void Start(IGameServerConnection gameServerConnection) { // figure out the path to the setting file in the same folder where this DLL is located. var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "SellToServerMod_Settings.yaml"; // save connection to game server for later use _gameServerConnection = gameServerConnection; // This deserializes the yaml config file _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); // Tell the string to use for "!MODS" command. _gameServerConnection.AddVersionString(k_versionString); // Subscribe for the chat event _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "FactionStorageConverterMod_Settings.yaml"; _fileStoragePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\SavedData"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); //--- Load Server Config Items LoadServerConfigItems(); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; }
public WebSocketEndpoint( IRavenNestClient client, IGameManager gameManager, ILogger logger, IAppSettings settings, ITokenProvider tokenProvider, IGamePacketSerializer packetSerializer, IGameCache gameCache) { connection = new WSGameServerConnection( logger, settings, tokenProvider, packetSerializer, gameCache); connection.Register("game_event", new GameEventPacketHandler(gameManager)); connection.OnReconnected += OnReconnected; this.client = client; this.gameManager = gameManager; }
public void Start(IGameServerConnection gameServerConnection) { _traceSource.TraceInformation("Starting up..."); var configFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "StructureOwnershipMod_Settings.yaml"; _gameServerConnection = gameServerConnection; _config = BaseConfiguration.GetConfiguration <Configuration>(configFilePath); _factionRewardTimer = new Timer(_config.CaptureRewardPeriodInMinutes * 1000.0 * 60.0); _saveState = SaveState.Load(k_saveStateFilePath); _gameServerConnection.AddVersionString(k_versionString); _gameServerConnection.Event_Faction_Changed += OnEvent_Faction_Changed; _gameServerConnection.Event_ChatMessage += OnEvent_ChatMessage; _factionRewardTimer.Elapsed += OnFactionRewardTimer_Elapsed; if (!_factionRewardTimer.Enabled) { _factionRewardTimer.Start(); } }
internal Playfield(IGameServerConnection gameServerConnection, string name) { _gameServerConnection = gameServerConnection; Name = name; }
public WorldPosition(IGameServerConnection gameServerConnection, WorldPositionInfo worldPositionInfo) { this.playfield = gameServerConnection.GetPlayfield(worldPositionInfo.Playfield); this.position = worldPositionInfo.Position.ToNumericsVector3(); this.rotation = worldPositionInfo.Rotation.ToNumericsVector3(); }