-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathClientPlayer.cs
52 lines (45 loc) · 1.53 KB
/
ClientPlayer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Linq;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
namespace DiscordRP {
public class ClientPlayer : ModPlayer {
internal bool dead = false;
internal string worldStaticInfo = "";
internal int nearbyNPC = 0;
public override void OnEnterWorld(Player player) {
if (player.whoAmI == Main.myPlayer) {
DiscordRPMod.Instance.pauseUpdate = false;
string wName = Main.worldName;
bool expert = Main.expertMode;
string wDiff = (expert) ? "(Expert)" : "(Normal)";
DiscordRPMod.Instance.worldStaticInfo = string.Format("Playing {0} {1}", wName, wDiff);
DiscordRPMod.Instance.ClientUpdatePlayer();
}
DiscordRPMod.Instance.UpdateLobbyInfo();
DiscordRPMod.Instance.ClientForceUpdate();
}
public override void PlayerConnect(Player player) {
DiscordRPMod.Instance.UpdateLobbyInfo();
DiscordRPMod.Instance.ClientForceUpdate();
}
public override void PlayerDisconnect(Player player) {
DiscordRPMod.Instance.UpdateLobbyInfo();
DiscordRPMod.Instance.ClientForceUpdate();
}
public override void PreUpdate() {
nearbyNPC = Main.npc.Count(npc => npc.active && npc.townNPC && Vector2.DistanceSquared(npc.position, player.Center) <= 2250000f);
}
public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource) {
if (player.whoAmI == Main.myPlayer) {
dead = true;
}
}
public override void OnRespawn(Player player) {
if (player.whoAmI == Main.myPlayer) {
dead = false;
}
}
}
}