-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTimeLimitPlayer.cs
68 lines (50 loc) · 1.5 KB
/
TimeLimitPlayer.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using Terraria;
using Terraria.ModLoader;
namespace TimeLimit {
partial class TimeLimitPlayer : ModPlayer {
public bool HasSyncedModSettings;
public bool HasSyncedModData;
////////////////
public override void Initialize() {
this.HasSyncedModSettings = false;
this.HasSyncedModData = false;
}
public override void clientClone( ModPlayer clientClone ) {
var clone = (TimeLimitPlayer)clientClone;
clone.HasSyncedModSettings = this.HasSyncedModSettings;
clone.HasSyncedModData = this.HasSyncedModData;
}
// Required, do not remove.
public override void SendClientChanges( ModPlayer clientPlayer ) {
}
////////////////
public override void SyncPlayer( int toWho, int fromWho, bool newPlayer ) {
var mymod = (TimeLimitMod)this.Mod;
if( Main.netMode == 2 ) {
if( toWho == -1 && fromWho == this.Player.whoAmI ) {
this.OnConnectServer();
}
}
}
public override void OnEnterWorld( Player player ) {
if( player.whoAmI != Main.myPlayer ) { return; }
if( this.Player.whoAmI != Main.myPlayer ) { return; }
var mymod = (TimeLimitMod)this.Mod;
if( Main.netMode == 0 ) { // NOT client
this.OnConnectSingle();
}
if( Main.netMode == 1 ) {
this.OnConnectCurrentClient();
}
}
////////////////
public override void PreUpdate() {
if( this.Player.whoAmI == Main.myPlayer ) {
if( Main.netMode == 1 ) { // Client
var myworld = ModContent.GetInstance<TimeLimitSystem>();
myworld.Logic.Update();
}
}
}
}
}