ping on map feature complete
This commit is contained in:
parent
17cce56866
commit
bce97de302
19 changed files with 1002 additions and 233 deletions
|
@ -20,5 +20,6 @@ namespace Sledgemapper.Clients
|
|||
Task UpdateMap(Session player);
|
||||
Task RefreshPlayers();
|
||||
Task NewLine(Line line);
|
||||
Task Ping(Ping ping);
|
||||
}
|
||||
}
|
||||
|
|
450
Sledgemapper.Shared/Easings.cs
Normal file
450
Sledgemapper.Shared/Easings.cs
Normal file
|
@ -0,0 +1,450 @@
|
|||
|
||||
using System;
|
||||
#if UNITY
|
||||
using UnityEngine;
|
||||
using Math = UnityEngine.Mathf;
|
||||
#endif
|
||||
|
||||
static public class Easings
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant Pi.
|
||||
/// </summary>
|
||||
private const float PI = (float)(float)Math.PI;
|
||||
|
||||
/// <summary>
|
||||
/// Constant Pi / 2.
|
||||
/// </summary>
|
||||
private const float HALFPI =(float) (float)Math.PI / 2.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Easing Functions enumeration
|
||||
/// </summary>
|
||||
public enum Functions
|
||||
{
|
||||
Linear,
|
||||
QuadraticEaseIn,
|
||||
QuadraticEaseOut,
|
||||
QuadraticEaseInOut,
|
||||
CubicEaseIn,
|
||||
CubicEaseOut,
|
||||
CubicEaseInOut,
|
||||
QuarticEaseIn,
|
||||
QuarticEaseOut,
|
||||
QuarticEaseInOut,
|
||||
QuinticEaseIn,
|
||||
QuinticEaseOut,
|
||||
QuinticEaseInOut,
|
||||
SineEaseIn,
|
||||
SineEaseOut,
|
||||
SineEaseInOut,
|
||||
CircularEaseIn,
|
||||
CircularEaseOut,
|
||||
CircularEaseInOut,
|
||||
ExponentialEaseIn,
|
||||
ExponentialEaseOut,
|
||||
ExponentialEaseInOut,
|
||||
ElasticEaseIn,
|
||||
ElasticEaseOut,
|
||||
ElasticEaseInOut,
|
||||
BackEaseIn,
|
||||
BackEaseOut,
|
||||
BackEaseInOut,
|
||||
BounceEaseIn,
|
||||
BounceEaseOut,
|
||||
BounceEaseInOut
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Interpolate using the specified function.
|
||||
/// </summary>
|
||||
static public float Interpolate(float p, Functions function)
|
||||
{
|
||||
switch(function)
|
||||
{
|
||||
default:
|
||||
case Functions.Linear: return Linear(p);
|
||||
case Functions.QuadraticEaseOut: return QuadraticEaseOut(p);
|
||||
case Functions.QuadraticEaseIn: return QuadraticEaseIn(p);
|
||||
case Functions.QuadraticEaseInOut: return QuadraticEaseInOut(p);
|
||||
case Functions.CubicEaseIn: return CubicEaseIn(p);
|
||||
case Functions.CubicEaseOut: return CubicEaseOut(p);
|
||||
case Functions.CubicEaseInOut: return CubicEaseInOut(p);
|
||||
case Functions.QuarticEaseIn: return QuarticEaseIn(p);
|
||||
case Functions.QuarticEaseOut: return QuarticEaseOut(p);
|
||||
case Functions.QuarticEaseInOut: return QuarticEaseInOut(p);
|
||||
case Functions.QuinticEaseIn: return QuinticEaseIn(p);
|
||||
case Functions.QuinticEaseOut: return QuinticEaseOut(p);
|
||||
case Functions.QuinticEaseInOut: return QuinticEaseInOut(p);
|
||||
case Functions.SineEaseIn: return SineEaseIn(p);
|
||||
case Functions.SineEaseOut: return SineEaseOut(p);
|
||||
case Functions.SineEaseInOut: return SineEaseInOut(p);
|
||||
case Functions.CircularEaseIn: return CircularEaseIn(p);
|
||||
case Functions.CircularEaseOut: return CircularEaseOut(p);
|
||||
case Functions.CircularEaseInOut: return CircularEaseInOut(p);
|
||||
case Functions.ExponentialEaseIn: return ExponentialEaseIn(p);
|
||||
case Functions.ExponentialEaseOut: return ExponentialEaseOut(p);
|
||||
case Functions.ExponentialEaseInOut: return ExponentialEaseInOut(p);
|
||||
case Functions.ElasticEaseIn: return ElasticEaseIn(p);
|
||||
case Functions.ElasticEaseOut: return ElasticEaseOut(p);
|
||||
case Functions.ElasticEaseInOut: return ElasticEaseInOut(p);
|
||||
case Functions.BackEaseIn: return BackEaseIn(p);
|
||||
case Functions.BackEaseOut: return BackEaseOut(p);
|
||||
case Functions.BackEaseInOut: return BackEaseInOut(p);
|
||||
case Functions.BounceEaseIn: return BounceEaseIn(p);
|
||||
case Functions.BounceEaseOut: return BounceEaseOut(p);
|
||||
case Functions.BounceEaseInOut: return BounceEaseInOut(p);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the line y = x
|
||||
/// </summary>
|
||||
static public float Linear(float p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the parabola y = x^2
|
||||
/// </summary>
|
||||
static public float QuadraticEaseIn(float p)
|
||||
{
|
||||
return p * p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the parabola y = -x^2 + 2x
|
||||
/// </summary>
|
||||
static public float QuadraticEaseOut(float p)
|
||||
{
|
||||
return -(p * (p - 2));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise quadratic
|
||||
/// y = (1/2)((2x)^2) ; [0, 0.5)
|
||||
/// y = -(1/2)((2x-1)*(2x-3) - 1) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float QuadraticEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 2 * p * p;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (-2 * p * p) + (4 * p) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the cubic y = x^3
|
||||
/// </summary>
|
||||
static public float CubicEaseIn(float p)
|
||||
{
|
||||
return p * p * p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the cubic y = (x - 1)^3 + 1
|
||||
/// </summary>
|
||||
static public float CubicEaseOut(float p)
|
||||
{
|
||||
float f = (p - 1);
|
||||
return f * f * f + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise cubic
|
||||
/// y = (1/2)((2x)^3) ; [0, 0.5)
|
||||
/// y = (1/2)((2x-2)^3 + 2) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float CubicEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 4 * p * p * p;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = ((2 * p) - 2);
|
||||
return 0.5f * f * f * f + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the quartic x^4
|
||||
/// </summary>
|
||||
static public float QuarticEaseIn(float p)
|
||||
{
|
||||
return p * p * p * p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the quartic y = 1 - (x - 1)^4
|
||||
/// </summary>
|
||||
static public float QuarticEaseOut(float p)
|
||||
{
|
||||
float f = (p - 1);
|
||||
return f * f * f * (1 - p) + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
// Modeled after the piecewise quartic
|
||||
// y = (1/2)((2x)^4) ; [0, 0.5)
|
||||
// y = -(1/2)((2x-2)^4 - 2) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float QuarticEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 8 * p * p * p * p;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (p - 1);
|
||||
return -8 * f * f * f * f + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the quintic y = x^5
|
||||
/// </summary>
|
||||
static public float QuinticEaseIn(float p)
|
||||
{
|
||||
return p * p * p * p * p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the quintic y = (x - 1)^5 + 1
|
||||
/// </summary>
|
||||
static public float QuinticEaseOut(float p)
|
||||
{
|
||||
float f = (p - 1);
|
||||
return f * f * f * f * f + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise quintic
|
||||
/// y = (1/2)((2x)^5) ; [0, 0.5)
|
||||
/// y = (1/2)((2x-2)^5 + 2) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float QuinticEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 16 * p * p * p * p * p;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = ((2 * p) - 2);
|
||||
return 0.5f * f * f * f * f * f + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after quarter-cycle of sine wave
|
||||
/// </summary>
|
||||
static public float SineEaseIn(float p)
|
||||
{
|
||||
return (float)(float)Math.Sin((p - 1) * HALFPI) + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after quarter-cycle of sine wave (different phase)
|
||||
/// </summary>
|
||||
static public float SineEaseOut(float p)
|
||||
{
|
||||
return (float)(float)Math.Sin(p * HALFPI);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after half sine wave
|
||||
/// </summary>
|
||||
static public float SineEaseInOut(float p)
|
||||
{
|
||||
return 0.5f * (1 - (float)(float)Math.Cos(p * PI));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after shifted quadrant IV of unit circle
|
||||
/// </summary>
|
||||
static public float CircularEaseIn(float p)
|
||||
{
|
||||
return 1 - (float)Math.Sqrt(1 - (p * p));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after shifted quadrant II of unit circle
|
||||
/// </summary>
|
||||
static public float CircularEaseOut(float p)
|
||||
{
|
||||
return (float)Math.Sqrt((2 - p) * p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise circular function
|
||||
/// y = (1/2)(1 - (float)Math.Sqrt(1 - 4x^2)) ; [0, 0.5)
|
||||
/// y = (1/2)((float)Math.Sqrt(-(2x - 3)*(2x - 1)) + 1) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float CircularEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 0.5f * (1 - (float)Math.Sqrt(1 - 4 * (p * p)));
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.5f * ((float)Math.Sqrt(-((2 * p) - 3) * ((2 * p) - 1)) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the exponential function y = 2^(10(x - 1))
|
||||
/// </summary>
|
||||
static public float ExponentialEaseIn(float p)
|
||||
{
|
||||
return (p == 0.0f) ? p : (float)Math.Pow(2, 10 * (p - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the exponential function y = -2^(-10x) + 1
|
||||
/// </summary>
|
||||
static public float ExponentialEaseOut(float p)
|
||||
{
|
||||
return (p == 1.0f) ? p : 1 - (float)Math.Pow(2, -10 * p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise exponential
|
||||
/// y = (1/2)2^(10(2x - 1)) ; [0,0.5)
|
||||
/// y = -(1/2)*2^(-10(2x - 1))) + 1 ; [0.5,1]
|
||||
/// </summary>
|
||||
static public float ExponentialEaseInOut(float p)
|
||||
{
|
||||
if(p == 0.0 || p == 1.0) return p;
|
||||
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 0.5f * (float)Math.Pow(2, (20 * p) - 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -0.5f * (float)Math.Pow(2, (-20 * p) + 10) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the damped sine wave y = sin(13pi/2*x)*(float)Math.Pow(2, 10 * (x - 1))
|
||||
/// </summary>
|
||||
static public float ElasticEaseIn(float p)
|
||||
{
|
||||
return (float)Math.Sin(13 * HALFPI * p) * (float)Math.Pow(2, 10 * (p - 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the damped sine wave y = sin(-13pi/2*(x + 1))*(float)Math.Pow(2, -10x) + 1
|
||||
/// </summary>
|
||||
static public float ElasticEaseOut(float p)
|
||||
{
|
||||
return (float)Math.Sin(-13 * HALFPI * (p + 1)) * (float)Math.Pow(2, -10 * p) + 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise exponentially-damped sine wave:
|
||||
/// y = (1/2)*sin(13pi/2*(2*x))*(float)Math.Pow(2, 10 * ((2*x) - 1)) ; [0,0.5)
|
||||
/// y = (1/2)*(sin(-13pi/2*((2x-1)+1))*(float)Math.Pow(2,-10(2*x-1)) + 2) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float ElasticEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 0.5f * (float)Math.Sin(13 * HALFPI * (2 * p)) * (float)Math.Pow(2, 10 * ((2 * p) - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.5f * ((float)Math.Sin(-13 * HALFPI * ((2 * p - 1) + 1)) * (float)Math.Pow(2, -10 * (2 * p - 1)) + 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the overshooting cubic y = x^3-x*sin(x*pi)
|
||||
/// </summary>
|
||||
static public float BackEaseIn(float p)
|
||||
{
|
||||
return p * p * p - p * (float)Math.Sin(p * PI);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after overshooting cubic y = 1-((1-x)^3-(1-x)*sin((1-x)*pi))
|
||||
/// </summary>
|
||||
static public float BackEaseOut(float p)
|
||||
{
|
||||
float f = (1 - p);
|
||||
return 1 - (f * f * f - f * (float)Math.Sin(f * PI));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modeled after the piecewise overshooting cubic function:
|
||||
/// y = (1/2)*((2x)^3-(2x)*sin(2*x*pi)) ; [0, 0.5)
|
||||
/// y = (1/2)*(1-((1-x)^3-(1-x)*sin((1-x)*pi))+1) ; [0.5, 1]
|
||||
/// </summary>
|
||||
static public float BackEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
float f = 2 * p;
|
||||
return 0.5f * (f * f * f - f * (float)Math.Sin(f * PI));
|
||||
}
|
||||
else
|
||||
{
|
||||
float f = (1 - (2*p - 1));
|
||||
return 0.5f * (1 - (f * f * f - f * (float)Math.Sin(f * PI))) + 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
static public float BounceEaseIn(float p)
|
||||
{
|
||||
return 1 - BounceEaseOut(1 - p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
static public float BounceEaseOut(float p)
|
||||
{
|
||||
if(p < 4/11.0f)
|
||||
{
|
||||
return (121 * p * p)/16.0f;
|
||||
}
|
||||
else if(p < 8/11.0f)
|
||||
{
|
||||
return (363/40.0f * p * p) - (99/10.0f * p) + 17/5.0f;
|
||||
}
|
||||
else if(p < 9/10.0f)
|
||||
{
|
||||
return (4356/361.0f * p * p) - (35442/1805.0f * p) + 16061/1805.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (54/5.0f * p * p) - (513/25.0f * p) + 268/25.0f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
static public float BounceEaseInOut(float p)
|
||||
{
|
||||
if(p < 0.5f)
|
||||
{
|
||||
return 0.5f * BounceEaseIn(p*2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.5f * BounceEaseOut(p * 2 - 1) + 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,10 +27,11 @@ namespace Sledgemapper.Shared.Entities
|
|||
Overlays = new ConcurrentDictionary<string, Overlay>();
|
||||
Walls = new ConcurrentDictionary<string, Wall>();
|
||||
Notes = new ConcurrentDictionary<string, Note>();
|
||||
Lines=new ConcurrentDictionary<string, Line>();
|
||||
Rooms=new ConcurrentDictionary<string, Room>();
|
||||
Lines = new ConcurrentDictionary<string, Line>();
|
||||
Rooms = new ConcurrentDictionary<string, Room>();
|
||||
Players = new List<Player>();
|
||||
Colors = new List<string>();
|
||||
Pings = new ConcurrentDictionary<Guid, Ping>();
|
||||
}
|
||||
|
||||
public ConcurrentDictionary<string, Tile> Map { get; set; }
|
||||
|
@ -39,189 +40,190 @@ namespace Sledgemapper.Shared.Entities
|
|||
public ConcurrentDictionary<string, Note> Notes { get; set; }
|
||||
public bool IsValid { get; set; }
|
||||
public List<Player> Players { get; set; }
|
||||
public List<string> Colors { get; set; }
|
||||
public string SessionName { get; set; }
|
||||
public int SessionId { get; set; }
|
||||
public ConcurrentDictionary<string, Line> Lines { get; set; }
|
||||
public ConcurrentDictionary<string, Room> Rooms { get; set; }
|
||||
public ConcurrentDictionary<Guid, Ping> Pings { get; set; }
|
||||
public List<string> Colors { get; set; }
|
||||
public string SessionName { get; set; }
|
||||
public int SessionId { get; set; }
|
||||
public ConcurrentDictionary<string, Line> Lines { get; set; }
|
||||
public ConcurrentDictionary<string, Room> Rooms { get; set; }
|
||||
|
||||
public void NewTile(Tile selectedTile, string tileId)
|
||||
public void NewTile(Tile selectedTile, string tileId)
|
||||
{
|
||||
if (selectedTile is null || string.IsNullOrWhiteSpace(tileId))
|
||||
{
|
||||
if (selectedTile is null || string.IsNullOrWhiteSpace(tileId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tileExist = Map.TryGetValue(selectedTile.ToString(), out var tile);
|
||||
var newTile = new Tile { X = selectedTile.X, Y = selectedTile.Y, ID = tileId };
|
||||
if (tileExist)
|
||||
{
|
||||
Map.TryRemove(tile.ToString(), out var _);
|
||||
if (tile.ID == tileId)
|
||||
{
|
||||
newTile.Rotation = (tile.Rotation + 1) % 4;
|
||||
}
|
||||
}
|
||||
|
||||
Map.TryAdd(newTile.ToString(), newTile);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newTile));
|
||||
return;
|
||||
}
|
||||
|
||||
public void NewOverlay(Overlay selectedOverlay, string overlayId)
|
||||
var tileExist = Map.TryGetValue(selectedTile.ToString(), out var tile);
|
||||
var newTile = new Tile { X = selectedTile.X, Y = selectedTile.Y, ID = tileId };
|
||||
if (tileExist)
|
||||
{
|
||||
if (selectedOverlay is null || string.IsNullOrWhiteSpace(overlayId))
|
||||
Map.TryRemove(tile.ToString(), out var _);
|
||||
if (tile.ID == tileId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var overlayExist = Overlays.TryGetValue(selectedOverlay.ToString(), out var overlay);
|
||||
var newOverlay = new Overlay { X = selectedOverlay.X, Y = selectedOverlay.Y, ID = overlayId, Intersection = selectedOverlay.Intersection };
|
||||
if (overlayExist)
|
||||
{
|
||||
Overlays.TryRemove(overlay.ToString(), out var _);
|
||||
if (overlay.ID == overlayId)
|
||||
{
|
||||
newOverlay.Rotation = (overlay.Rotation + 1) % 4;
|
||||
}
|
||||
}
|
||||
|
||||
Overlays.TryAdd(newOverlay.ToString(), newOverlay);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newOverlay));
|
||||
}
|
||||
|
||||
public void NewWall(Wall selectedWall, string wallId)
|
||||
{
|
||||
if (selectedWall is null || string.IsNullOrWhiteSpace(wallId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var tileExist = Walls.TryGetValue(selectedWall.ToString(), out var wall);
|
||||
var newWall = new Wall { X = selectedWall.X, Y = selectedWall.Y, ID = wallId, Rotation = selectedWall.Rotation };
|
||||
if (tileExist)
|
||||
{
|
||||
Walls.TryRemove(wall.ToString(), out var _);
|
||||
}
|
||||
|
||||
Walls.TryAdd(newWall.ToString(), newWall);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newWall));
|
||||
}
|
||||
|
||||
public void NewNote(Note selectedNote)
|
||||
{
|
||||
if (selectedNote is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var noteExists = Notes.TryGetValue(selectedNote.ToString(), out var note);
|
||||
var newNote = new Note { X = selectedNote.X, Y = selectedNote.Y, Text=selectedNote.Text };
|
||||
if (noteExists)
|
||||
{
|
||||
Walls.TryRemove(note.ToString(), out var _);
|
||||
}
|
||||
|
||||
Notes.TryAdd(newNote.ToString(), newNote);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newNote));
|
||||
}
|
||||
|
||||
public void DeleteWall(Wall wall)
|
||||
{
|
||||
if (wall is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Walls.TryRemove(wall.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(wall));
|
||||
newTile.Rotation = (tile.Rotation + 1) % 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteNote(Note note)
|
||||
Map.TryAdd(newTile.ToString(), newTile);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newTile));
|
||||
}
|
||||
|
||||
public void NewOverlay(Overlay selectedOverlay, string overlayId)
|
||||
{
|
||||
if (selectedOverlay is null || string.IsNullOrWhiteSpace(overlayId))
|
||||
{
|
||||
if (note is null)
|
||||
return;
|
||||
}
|
||||
var overlayExist = Overlays.TryGetValue(selectedOverlay.ToString(), out var overlay);
|
||||
var newOverlay = new Overlay { X = selectedOverlay.X, Y = selectedOverlay.Y, ID = overlayId, Intersection = selectedOverlay.Intersection };
|
||||
if (overlayExist)
|
||||
{
|
||||
Overlays.TryRemove(overlay.ToString(), out var _);
|
||||
if (overlay.ID == overlayId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Notes.TryRemove(note.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(note));
|
||||
newOverlay.Rotation = (overlay.Rotation + 1) % 4;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteOverlay(Overlay overlay)
|
||||
Overlays.TryAdd(newOverlay.ToString(), newOverlay);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newOverlay));
|
||||
}
|
||||
|
||||
public void NewWall(Wall selectedWall, string wallId)
|
||||
{
|
||||
if (selectedWall is null || string.IsNullOrWhiteSpace(wallId))
|
||||
{
|
||||
if (overlay is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Overlays.TryRemove(overlay.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(overlay));
|
||||
}
|
||||
return;
|
||||
}
|
||||
var tileExist = Walls.TryGetValue(selectedWall.ToString(), out var wall);
|
||||
var newWall = new Wall { X = selectedWall.X, Y = selectedWall.Y, ID = wallId, Rotation = selectedWall.Rotation };
|
||||
if (tileExist)
|
||||
{
|
||||
Walls.TryRemove(wall.ToString(), out var _);
|
||||
}
|
||||
|
||||
public void DeleteTile(Tile tile)
|
||||
Walls.TryAdd(newWall.ToString(), newWall);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newWall));
|
||||
}
|
||||
|
||||
public void NewNote(Note selectedNote)
|
||||
{
|
||||
if (selectedNote is null)
|
||||
{
|
||||
if (tile is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Map.TryRemove(tile.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(tile));
|
||||
}
|
||||
return;
|
||||
}
|
||||
var noteExists = Notes.TryGetValue(selectedNote.ToString(), out var note);
|
||||
var newNote = new Note { X = selectedNote.X, Y = selectedNote.Y, Text = selectedNote.Text };
|
||||
if (noteExists)
|
||||
{
|
||||
Walls.TryRemove(note.ToString(), out var _);
|
||||
}
|
||||
|
||||
protected virtual void OnRaiseMapEntityAddedEvent(MapEntityAddedEventArgs e)
|
||||
Notes.TryAdd(newNote.ToString(), newNote);
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newNote));
|
||||
}
|
||||
|
||||
public void DeleteWall(Wall wall)
|
||||
{
|
||||
if (wall is null)
|
||||
{
|
||||
MapEntityAdded?.Invoke(this, e);
|
||||
return;
|
||||
}
|
||||
|
||||
protected virtual void OnRaiseMapEntityDeletedEvent(MapEntityDeletedEventArgs e)
|
||||
var removed = Walls.TryRemove(wall.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
MapEntityDeleted?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public void NewLine(Line line)
|
||||
{
|
||||
if (line is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lineExist = Lines.TryGetValue(line.ToString(), out var tile);
|
||||
var newLine = new Line { Start=line.Start, End=line.End, Width=line.Width};
|
||||
if (lineExist)
|
||||
{
|
||||
Lines.TryRemove(line.ToString(), out var _);
|
||||
}
|
||||
|
||||
Lines.TryAdd(newLine.ToString(), newLine);
|
||||
|
||||
//TODO fix this
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
|
||||
}
|
||||
|
||||
public void NewRoom(Room line)
|
||||
{
|
||||
if (line is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lineExist = Rooms.TryGetValue(line.ToString(), out var tile);
|
||||
var newLine = new Room { Start=line.Start, End=line.End, Delete=line.Delete};
|
||||
if (lineExist)
|
||||
{
|
||||
Rooms.TryRemove(line.ToString(), out var _);
|
||||
}
|
||||
|
||||
Rooms.TryAdd(newLine.ToString(), newLine);
|
||||
|
||||
//TODO fix this
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(wall));
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteNote(Note note)
|
||||
{
|
||||
if (note is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Notes.TryRemove(note.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(note));
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteOverlay(Overlay overlay)
|
||||
{
|
||||
if (overlay is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Overlays.TryRemove(overlay.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(overlay));
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteTile(Tile tile)
|
||||
{
|
||||
if (tile is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var removed = Map.TryRemove(tile.ToString(), out var _);
|
||||
if (removed)
|
||||
{
|
||||
OnRaiseMapEntityDeletedEvent(new MapEntityDeletedEventArgs(tile));
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnRaiseMapEntityAddedEvent(MapEntityAddedEventArgs e)
|
||||
{
|
||||
MapEntityAdded?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnRaiseMapEntityDeletedEvent(MapEntityDeletedEventArgs e)
|
||||
{
|
||||
MapEntityDeleted?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public void NewLine(Line line)
|
||||
{
|
||||
if (line is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lineExist = Lines.TryGetValue(line.ToString(), out var tile);
|
||||
var newLine = new Line { Start = line.Start, End = line.End, Width = line.Width };
|
||||
if (lineExist)
|
||||
{
|
||||
Lines.TryRemove(line.ToString(), out var _);
|
||||
}
|
||||
|
||||
Lines.TryAdd(newLine.ToString(), newLine);
|
||||
|
||||
//TODO fix this
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
|
||||
}
|
||||
|
||||
public void NewRoom(Room line)
|
||||
{
|
||||
if (line is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var lineExist = Rooms.TryGetValue(line.ToString(), out var tile);
|
||||
var newLine = new Room { Start = line.Start, End = line.End, Delete = line.Delete };
|
||||
if (lineExist)
|
||||
{
|
||||
Rooms.TryRemove(line.ToString(), out var _);
|
||||
}
|
||||
|
||||
Rooms.TryAdd(newLine.ToString(), newLine);
|
||||
|
||||
//TODO fix this
|
||||
OnRaiseMapEntityAddedEvent(new MapEntityAddedEventArgs(newLine));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,13 @@ namespace Sledgemapper.Shared.Entities
|
|||
public double Timestamp { get; set; }
|
||||
}
|
||||
|
||||
public class Ping : BaseMapEntity
|
||||
{
|
||||
public Player Player { get; set; }
|
||||
public int Iterations {get;set;}
|
||||
public double StartTime {get;set;}
|
||||
}
|
||||
|
||||
public class Tile : BaseMapEntity
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue