Popup message notifications. (#125)
* Popup message system v1 * Networking for the popup notifications. Ship it.
This commit is contained in:
committed by
GitHub
parent
b0f212bad5
commit
f91488fa27
@@ -72,6 +72,7 @@
|
||||
<Compile Include="GameObjects\ContentNetIDs.cs" />
|
||||
<Compile Include="GameObjects\EntitySystemMessages\VerbSystemMessages.cs" />
|
||||
<Compile Include="GameObjects\PhysicalConstants.cs" />
|
||||
<Compile Include="Interfaces\ISharedNotifyManager.cs" />
|
||||
<Compile Include="GameObjects\Verb.cs" />
|
||||
<Compile Include="Physics\CollisionGroup.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -107,6 +108,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<Compile Include="Input\ContentKeyFunctions.cs" />
|
||||
<Compile Include="SharedNotifyManager.cs" />
|
||||
<Compile Include="Utility\ContentHelpers.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\SharedSmesComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\SharedApcComponent.cs" />
|
||||
|
||||
20
Content.Shared/Interfaces/ISharedNotifyManager.cs
Normal file
20
Content.Shared/Interfaces/ISharedNotifyManager.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.IoC;
|
||||
using SS14.Shared.Map;
|
||||
|
||||
namespace Content.Shared.Interfaces
|
||||
{
|
||||
public interface ISharedNotifyManager
|
||||
{
|
||||
void PopupMessage(IEntity source, IEntity viewer, string message);
|
||||
void PopupMessage(GridLocalCoordinates coordinates, IEntity viewer, string message);
|
||||
}
|
||||
|
||||
public static class NotifyManagerExt
|
||||
{
|
||||
public static void PopupMessage(this IEntity source, IEntity viewer, string message)
|
||||
{
|
||||
IoCManager.Resolve<ISharedNotifyManager>().PopupMessage(source, viewer, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
48
Content.Shared/SharedNotifyManager.cs
Normal file
48
Content.Shared/SharedNotifyManager.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Content.Shared.Interfaces;
|
||||
using Lidgren.Network;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.Network;
|
||||
using SS14.Shared.Map;
|
||||
using SS14.Shared.Network;
|
||||
using SS14.Shared.Network.Messages;
|
||||
|
||||
namespace Content.Shared
|
||||
{
|
||||
public abstract class SharedNotifyManager : ISharedNotifyManager
|
||||
{
|
||||
public void PopupMessage(IEntity source, IEntity viewer, string message)
|
||||
{
|
||||
// TODO: we might eventually want for this to pass the actual entity,
|
||||
// so the notify could track the entity movement visually.
|
||||
PopupMessage(source.Transform.LocalPosition, viewer, message);
|
||||
}
|
||||
|
||||
public abstract void PopupMessage(GridLocalCoordinates coordinates, IEntity viewer, string message);
|
||||
|
||||
protected class MsgDoNotify : NetMessage
|
||||
{
|
||||
#region REQUIRED
|
||||
|
||||
public const MsgGroups GROUP = MsgGroups.Command;
|
||||
public const string NAME = nameof(MsgDoNotify);
|
||||
public MsgDoNotify(INetChannel channel) : base(NAME, GROUP) { }
|
||||
|
||||
#endregion
|
||||
|
||||
public string Message { get; set; }
|
||||
public GridLocalCoordinates Coordinates;
|
||||
|
||||
public override void ReadFromBuffer(NetIncomingMessage buffer)
|
||||
{
|
||||
Message = buffer.ReadString();
|
||||
Coordinates = buffer.ReadGridLocalCoordinates();
|
||||
}
|
||||
|
||||
public override void WriteToBuffer(NetOutgoingMessage buffer)
|
||||
{
|
||||
buffer.Write(Message);
|
||||
buffer.Write(Coordinates);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user