Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PingMapLayer.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Collections.Generic
;
3
using
Microsoft.Xna.Framework
;
4
using
ReLogic.Utilities
;
5
using
Terraria.DataStructures
;
6
using
Terraria.GameContent
;
7
using
Terraria.UI
;
8
9
namespace
Terraria.Map
;
10
11
public
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;
22
Time
=
DateTime
.
Now
;
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);
40
DateTime
now
=
DateTime
.
Now
;
41
foreach
(
ItemPair<Ping>
item
in
(
IEnumerable
<
ItemPair<Ping>
>)
_pings
)
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
}
Position
Position
Definition
ImmutableDictionary.cs:625
System.Collections.Generic.Dictionary.Remove
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
Definition
Dictionary.cs:893
System.Collections.Generic.Dictionary.Count
int Count
Definition
Dictionary.cs:682
System.Collections.Generic.Dictionary.Add
void Add(TKey key, TValue value)
Definition
Dictionary.cs:873
System.Collections.Generic.Dictionary
Definition
Dictionary.cs:14
Terraria.GameContent.TextureAssets.MapPing
static Asset< Texture2D > MapPing
Definition
TextureAssets.cs:32
Terraria.GameContent.TextureAssets
Definition
TextureAssets.cs:8
Terraria.Map.PingMapLayer.Draw
void Draw(ref MapOverlayDrawContext context, ref string text)
Definition
PingMapLayer.cs:32
Terraria.Map.PingMapLayer._pings
readonly SlotVector< Ping > _pings
Definition
PingMapLayer.cs:30
Terraria.Map.PingMapLayer.PING_FRAME_RATE
const double PING_FRAME_RATE
Definition
PingMapLayer.cs:28
Terraria.Map.PingMapLayer.PING_DURATION_IN_SECONDS
const double PING_DURATION_IN_SECONDS
Definition
PingMapLayer.cs:26
Terraria.Map.PingMapLayer.Add
void Add(Vector2 position)
Definition
PingMapLayer.cs:55
Terraria.Map.PingMapLayer
Definition
PingMapLayer.cs:12
System.Collections.Generic.IEnumerable
Definition
IEnumerable.cs:4
Terraria.Map.IMapLayer
Definition
IMapLayer.cs:4
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
ReLogic.Utilities
Definition
AttributeUtilities.cs:5
System.Collections.Generic
Definition
IHashKeyCollection.cs:1
System.ExceptionArgument.text
@ text
System.ExceptionArgument.value
@ value
System.ExceptionArgument.item
@ item
System
Definition
BlockingCollection.cs:8
Terraria.DataStructures
Definition
AEntitySource_OnHit.cs:1
Terraria.GameContent
Definition
AchievementsHelper.cs:1
Terraria.Map
Definition
IMapLayer.cs:1
Terraria.UI
Definition
ChatLine.cs:3
Microsoft.Xna.Framework.Vector2
Definition
Vector2.cs:12
System.DateTime.Now
static DateTime Now
Definition
DateTime.cs:103
System.DateTime
Definition
DateTime.cs:15
Terraria.DataStructures.SpriteFrame
Definition
SpriteFrame.cs:7
Terraria.Map.MapOverlayDrawContext
Definition
MapOverlayDrawContext.cs:9
Terraria.Map.PingMapLayer.Ping.Time
readonly DateTime Time
Definition
PingMapLayer.cs:17
Terraria.Map.PingMapLayer.Ping.Position
readonly Vector2 Position
Definition
PingMapLayer.cs:15
Terraria.Map.PingMapLayer.Ping.Ping
Ping(Vector2 position)
Definition
PingMapLayer.cs:19
Terraria.Map.PingMapLayer.Ping
Definition
PingMapLayer.cs:14
Terraria.UI.Alignment.Center
static readonly Alignment Center
Definition
Alignment.cs:15
Terraria.UI.Alignment
Definition
Alignment.cs:6
source
Terraria.Map
PingMapLayer.cs
Generated by
1.10.0