Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions Intersect.Client.Core/Maps/ActionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ namespace Intersect.Client.Maps;

public partial class ActionMessage : IActionMessage
{
public Color Color { get; init; }

public Color Color { get; set; } = new Color();
public IMapInstance Map { get; init; }

public IMapInstance Map { get; set; }
public string Text { get; init; }

public string Msg { get; set; } = "";
public long TransmissionTimer { get; init; }

public long TransmissionTimer { get; set; }
public int X { get; init; }

public int X { get; set; }
public int XOffset { get; init; }

public int XOffset { get; set; }
public int Y { get; init; }

public int Y { get; set; }

public ActionMessage(MapInstance map, int x, int y, string message, Color color)
public ActionMessage(MapInstance map, int x, int y, string text, Color color)
{
Map = map;
X = x;
Y = y;
Msg = message;
Text = text;
Color = color;
XOffset = Globals.Random.Next(-30, 30); //+- 16 pixels so action msg's don't overlap!
TransmissionTimer = Timing.Global.MillisecondsUtc + 1000;
Expand All @@ -37,7 +36,7 @@ public void TryRemove()
{
if (TransmissionTimer <= Timing.Global.MillisecondsUtc)
{
(Map as MapInstance).ActionMessages.Remove(this);
(Map as MapInstance)?.ActionMessages.Remove(this);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Intersect.Client.Core/Maps/MapInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1505,13 +1505,13 @@ public void DrawActionMsgs()
for (var n = ActionMessages.Count - 1; n > -1; n--)
{
var actionMessage = ActionMessages[n];
var x = (Y + actionMessage.X * _tileWidth + actionMessage.XOffset);
var x = (X + actionMessage.X * _tileWidth + actionMessage.XOffset);
var y = Y + actionMessage.Y * _tileHeight - _tileHeight * 2 *
(1000 - (int)(actionMessage.TransmissionTimer - Timing.Global.MillisecondsUtc)) / 1000;
var textWidth = Graphics.Renderer.MeasureText(actionMessage.Msg, Graphics.ActionMsgFont, 1).X;
var textWidth = Graphics.Renderer.MeasureText(actionMessage.Text, Graphics.ActionMsgFont, 1).X;

Graphics.Renderer.DrawString(
actionMessage.Msg,
actionMessage.Text,
Graphics.ActionMsgFont,
x - textWidth / 2f,
y,
Expand Down
14 changes: 7 additions & 7 deletions Intersect.Client.Framework/Maps/IActionMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

public interface IActionMessage
{
Color Color { get; set; }
IMapInstance Map { get; set; }
string Msg { get; set; }
long TransmissionTimer { get; set; }
int X { get; set; }
int XOffset { get; set; }
int Y { get; set; }
Color Color { get; init; }
IMapInstance Map { get; init; }
string Text { get; init; }
long TransmissionTimer { get; init; }
int X { get; init; }
int XOffset { get; init; }
int Y { get; init; }

void TryRemove();
}
Loading