Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PingMapLayer.cs
Go to the documentation of this file.
1using System;
7using Terraria.UI;
8
9namespace Terraria.Map;
10
11public class PingMapLayer : IMapLayer
12{
13 private struct Ping
14 {
15 public readonly Vector2 Position;
16
17 public readonly DateTime Time;
18
19 public Ping(Vector2 position)
20 {
21 Position = position;
23 }
24 }
25
26 private const double PING_DURATION_IN_SECONDS = 15.0;
27
28 private const double PING_FRAME_RATE = 10.0;
29
30 private readonly SlotVector<Ping> _pings = new SlotVector<Ping>(100);
31
32 public void Draw(ref MapOverlayDrawContext context, ref string text)
33 {
34 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
35 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
36 //IL_0024: Unknown result type (might be due to invalid IL or missing references)
37 //IL_0090: Unknown result type (might be due to invalid IL or missing references)
38 //IL_0091: Unknown result type (might be due to invalid IL or missing references)
39 SpriteFrame frame = new SpriteFrame(1, 5);
42 {
43 Ping value = item.Value;
44 double totalSeconds = (now - value.Time).TotalSeconds;
45 int num = (int)(totalSeconds * 10.0);
46 frame.CurrentRow = (byte)(num % frame.RowCount);
47 context.Draw(TextureAssets.MapPing.Value, value.Position, frame, Alignment.Center);
48 if (totalSeconds > 15.0)
49 {
50 _pings.Remove(item.Id);
51 }
52 }
53 }
54
55 public void Add(Vector2 position)
56 {
57 //IL_0025: Unknown result type (might be due to invalid IL or missing references)
58 if (_pings.Count != _pings.Capacity)
59 {
60 _pings.Add(new Ping(position));
61 }
62 }
63}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
static Asset< Texture2D > MapPing
void Draw(ref MapOverlayDrawContext context, ref string text)
readonly SlotVector< Ping > _pings
const double PING_DURATION_IN_SECONDS
void Add(Vector2 position)
static DateTime Now
Definition DateTime.cs:103
static readonly Alignment Center
Definition Alignment.cs:15