Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d9ef60d
Client manager components
Equinox- Aug 22, 2017
2c7b522
Proper delegate naming
Equinox- Aug 22, 2017
4b2fee7
Offline mode fallbacks for the chat manager.
Equinox- Aug 23, 2017
140000d
Test-time reflected event checker
Equinox- Aug 25, 2017
a36e8a4
Merge branch 'staging' into session-mgr-cmp
Equinox- Sep 10, 2017
aa784c1
Null protection in multiplayer manager detach
Equinox- Sep 10, 2017
9d8988a
MyLog logs to the Torch logging system
Equinox- Sep 11, 2017
b42d43c
Redirect Keen console to Info, all else to trace.
Equinox- Sep 11, 2017
0073e10
Fixed issues with operand replacing, and branch instructions.
Equinox- Sep 11, 2017
e57f885
Log errors in ReflectedManager
Equinox- Sep 11, 2017
57acb27
Don't crash when modifying constructor
Equinox- Sep 12, 2017
0810e76
Once the game is created we can patch it with impunity.
Equinox- Sep 12, 2017
b1145c8
Utility method to invert common load and store instructions
Equinox- Sep 12, 2017
373c476
Better guessing on the generic operand type
Equinox- Sep 12, 2017
a61b646
ReflectedMethodInfo allows non-public type names.
Equinox- Sep 12, 2017
5eceb21
Comments
Equinox- Sep 12, 2017
96f813a
IMultiplayerManager: added list of banned steam ID's
jimmble Sep 20, 2017
d8e2072
documentation added
jimmble Sep 20, 2017
f1fc49d
Merge branch 'staging' into session-mgr-cmp
jimmble Sep 20, 2017
eb7f7f4
MultiplayerManagerLobby doesn't implement IMultiplayerManagerServer
jimmble Sep 20, 2017
9c505c4
banned player list made readonly, lobby fakes support
jimmble Sep 20, 2017
205dd1a
Merge pull request #120 from blaho/session-mgr-cmp
Equinox- Sep 20, 2017
0574d59
Merge branch 'staging' into session-mgr-cmp
Equinox- Sep 22, 2017
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NLog.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
<target xsi:type="File" name="main" layout="${time} [${level:uppercase=true}] ${logger}: ${message}" fileName="Logs\Torch-${shortdate}.log" />
<target xsi:type="File" name="chat" layout="${longdate} ${message}" fileName="Logs\Chat.log" />
<target xsi:type="ColoredConsole" name="console" layout="${time} [${level:uppercase=true}] ${logger}: ${message}" />
<target xsi:type="File" name="patch" layout="${message}" fileName="Logs\patch.log"/>
</targets>

<rules>
<logger name="*" minlevel="Info" writeTo="main, console" />
<logger name="Chat" minlevel="Info" writeTo="chat" />
<!--<logger name="Torch.Managers.PatchManager.*" minlevel="Trace" writeTo="patch"/>-->
</rules>
</nlog>
31 changes: 0 additions & 31 deletions Torch.API/IChatMessage.cs

This file was deleted.

22 changes: 17 additions & 5 deletions Torch.API/ITorchBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ public interface ITorchBase
/// </summary>
ITorchConfig Config { get; }

/// <inheritdoc cref="IMultiplayerManager"/>
[Obsolete]
IMultiplayerManager Multiplayer { get; }

/// <inheritdoc cref="IPluginManager"/>
[Obsolete]
IPluginManager Plugins { get; }

/// <inheritdoc cref="IDependencyManager"/>
IDependencyManager Managers { get; }

[Obsolete("Prefer using Managers.GetManager for global managers")]
T GetManager<T>() where T : class, IManager;

[Obsolete("Prefer using Managers.AddManager for global managers")]
bool AddManager<T>(T manager) where T : class, IManager;

/// <summary>
/// The binary version of the current instance.
/// </summary>
Expand Down Expand Up @@ -101,6 +103,16 @@ public interface ITorchBase
/// Initialize the Torch instance.
/// </summary>
void Init();

/// <summary>
/// The current state of the game this instance of torch is controlling.
/// </summary>
TorchGameState GameState { get; }

/// <summary>
/// Event raised when <see cref="GameState"/> changes.
/// </summary>
event TorchGameStateChangedDel GameStateChanged;
}

/// <summary>
Expand All @@ -119,6 +131,6 @@ public interface ITorchServer : ITorchBase
/// </summary>
public interface ITorchClient : ITorchBase
{

}
}
108 changes: 108 additions & 0 deletions Torch.API/Managers/IChatManagerClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Multiplayer;
using Sandbox.Game.Multiplayer;
using VRage.Network;

namespace Torch.API.Managers
{
/// <summary>
/// Represents a scripted or user chat message.
/// </summary>
public struct TorchChatMessage
{
/// <summary>
/// Creates a new torch chat message with the given author and message.
/// </summary>
/// <param name="author">Author's name</param>
/// <param name="message">Message</param>
public TorchChatMessage(string author, string message)
{
Timestamp = DateTime.Now;
AuthorSteamId = null;
Author = author;
Message = message;
Font = "Blue";
}

/// <summary>
/// Creates a new torch chat message with the given author and message.
/// </summary>
/// <param name="authorSteamId">Author's steam ID</param>
/// <param name="message">Message</param>
public TorchChatMessage(ulong authorSteamId, string message)
{
Timestamp = DateTime.Now;
AuthorSteamId = authorSteamId;
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
Message = message;
Font = "Blue";
}

/// <summary>
/// This message's timestamp.
/// </summary>
public DateTime Timestamp;
/// <summary>
/// The author's steam ID, if available. Else, null.
/// </summary>
public ulong? AuthorSteamId;
/// <summary>
/// The author's name, if available. Else, null.
/// </summary>
public string Author;
/// <summary>
/// The message contents.
/// </summary>
public string Message;
/// <summary>
/// The font, or null if default.
/// </summary>
public string Font;
}

/// <summary>
/// Callback used to indicate that a messaage has been recieved.
/// </summary>
/// <param name="msg"></param>
/// <param name="consumed">If true, this event has been consumed and should be ignored</param>
public delegate void MessageRecievedDel(TorchChatMessage msg, ref bool consumed);

/// <summary>
/// Callback used to indicate the user is attempting to send a message locally.
/// </summary>
/// <param name="msg">Message the user is attempting to send</param>
/// <param name="consumed">If true, this event has been consumed and should be ignored</param>
public delegate void MessageSendingDel(string msg, ref bool consumed);

public interface IChatManagerClient : IManager
{
/// <summary>
/// Event that is raised when a message addressed to us is recieved. <see cref="MessageRecievedDel"/>
/// </summary>
event MessageRecievedDel MessageRecieved;

/// <summary>
/// Event that is raised when we are attempting to send a message. <see cref="MessageSendingDel"/>
/// </summary>
event MessageSendingDel MessageSending;

/// <summary>
/// Triggers the <see cref="MessageSending"/> event,
/// typically raised by the user entering text into the chat window.
/// </summary>
/// <param name="message">The message to send</param>
void SendMessageAsSelf(string message);

/// <summary>
/// Displays a message on the UI given an author name and a message.
/// </summary>
/// <param name="author">Author name</param>
/// <param name="message">Message content</param>
/// <param name="font">font to use</param>
void DisplayMessageOnSelf(string author, string message, string font = "Blue" );
}
}
45 changes: 45 additions & 0 deletions Torch.API/Managers/IChatManagerServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VRage.Network;

namespace Torch.API.Managers
{

/// <summary>
/// Callback used to indicate the server has recieved a message to process and forward on to others.
/// </summary>
/// <param name="authorId">Steam ID of the user sending a message</param>
/// <param name="msg">Message the user is attempting to send</param>
/// <param name="consumed">If true, this event has been consumed and should be ignored</param>
public delegate void MessageProcessingDel(TorchChatMessage msg, ref bool consumed);

public interface IChatManagerServer : IChatManagerClient
{
/// <summary>
/// Event triggered when the server has recieved a message and should process it. <see cref="MessageProcessingDel"/>
/// </summary>
event MessageProcessingDel MessageProcessing;


/// <summary>
/// Sends a message with the given author and message to the given player, or all players by default.
/// </summary>
/// <param name="authorId">Author's steam ID</param>
/// <param name="message">The message to send</param>
/// <param name="targetSteamId">Player to send the message to, or everyone by default</param>
void SendMessageAsOther(ulong authorId, string message, ulong targetSteamId = 0);


/// <summary>
/// Sends a scripted message with the given author and message to the given player, or all players by default.
/// </summary>
/// <param name="author">Author name</param>
/// <param name="message">The message to send</param>
/// <param name="font">Font to use</param>
/// <param name="targetSteamId">Player to send the message to, or everyone by default</param>
void SendMessageAsOther(string author, string message, string font, ulong targetSteamId = 0);
}
}
61 changes: 0 additions & 61 deletions Torch.API/Managers/IMultiplayerManager.cs

This file was deleted.

41 changes: 41 additions & 0 deletions Torch.API/Managers/IMultiplayerManagerBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using VRage.Game;
using VRage.Game.ModAPI;

namespace Torch.API.Managers
{
/// <summary>
/// API for multiplayer related functions common to servers and clients.
/// </summary>
public interface IMultiplayerManagerBase : IManager
{
/// <summary>
/// Fired when a player joins.
/// </summary>
event Action<IPlayer> PlayerJoined;

/// <summary>
/// Fired when a player disconnects.
/// </summary>
event Action<IPlayer> PlayerLeft;

/// <summary>
/// Gets a player by their Steam64 ID or returns null if the player isn't found.
/// </summary>
IMyPlayer GetPlayerBySteamId(ulong id);

/// <summary>
/// Gets a player by their display name or returns null if the player isn't found.
/// </summary>
IMyPlayer GetPlayerByName(string name);

/// <summary>
/// Gets the steam username of a member's steam ID
/// </summary>
/// <param name="steamId">steam ID</param>
/// <returns>steam username</returns>
string GetSteamUsername(ulong steamId);
}
}
12 changes: 12 additions & 0 deletions Torch.API/Managers/IMultiplayerManagerClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Torch.API.Managers
{
public interface IMultiplayerManagerClient : IMultiplayerManagerBase
{
}
}
24 changes: 24 additions & 0 deletions Torch.API/Managers/IMultiplayerManagerServer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Torch.API.Managers
{
/// <summary>
/// API for multiplayer functions that exist on servers and lobbies
/// </summary>
public interface IMultiplayerManagerServer : IMultiplayerManagerBase
{
/// <summary>
/// Kicks the player from the game.
/// </summary>
void KickPlayer(ulong steamId);

/// <summary>
/// Bans or unbans a player from the game.
/// </summary>
void BanPlayer(ulong steamId, bool banned = true);
}
}
Loading