9
9
using ModLibsCore . Libraries . DotNET . Extensions ;
10
10
using ModLibsCore . Libraries . TModLoader ;
11
11
using ModLibsCore . Libraries . World ;
12
- using MountedMagicMirrors . Net ;
13
12
using MountedMagicMirrors . DataStructures ;
14
13
15
14
@@ -51,97 +50,15 @@ public DiscoveredMirrors CurrentWorldDiscoveredMirrorTiles {
51
50
52
51
53
52
54
- ////////////////
55
-
56
- internal void OnCurrentClientEnter ( ) {
57
- PlayerDataProtocol . Broadcast ( this . DiscoveredMirrorTilesPerWorld ) ;
58
- }
59
-
60
- /*public override void SyncPlayer( int toWho, int fromWho, bool newPlayer ) {
61
- if( Main.netMode == 1 ) {
62
- if( newPlayer ) {
63
- //PlayerDataProtocol.SendToServer( this.DiscoveredMirrorTilesPerWorld );
64
- PlayerDataProtocol.Broadcast( this.DiscoveredMirrorTilesPerWorld );
65
- }
66
- } else {
67
- //PlayerDataProtocol.SendToClients( toWho, fromWho, this.DiscoveredMirrorTilesPerWorld );
68
- }
69
- }*/
70
-
71
- public override void clientClone ( ModPlayer clientClone ) {
72
- var myclone = ( MMMPlayer ) clientClone ;
73
-
74
- myclone . _CurrentWorldDiscoveredMirrorTiles = null ;
75
-
76
- foreach ( ( string worldUid , DiscoveredMirrors mirrors ) in this . DiscoveredMirrorTilesPerWorld ) {
77
- myclone . DiscoveredMirrorTilesPerWorld [ worldUid ] = new DiscoveredMirrors ( ) ;
78
-
79
- foreach ( ( int tileX , ISet < int > tileYs ) in mirrors ) {
80
- myclone . DiscoveredMirrorTilesPerWorld [ worldUid ] [ tileX ] = new HashSet < int > ( tileYs ) ;
81
- }
82
- }
83
- }
84
-
85
- ////////////////
86
-
87
- public override void SendClientChanges ( ModPlayer clientPlayer ) {
88
- if ( clientPlayer . player . whoAmI != Main . myPlayer ) {
89
- return ;
90
- }
91
-
92
- var myclone = ( MMMPlayer ) clientPlayer ;
93
- var thisDict = this . DiscoveredMirrorTilesPerWorld ;
94
- var thatDict = myclone . DiscoveredMirrorTilesPerWorld ;
95
-
96
- if ( ! DiscoveredMirrors . WorldMirrorsEquals ( thisDict , thatDict ) ) {
97
- if ( Main . netMode == NetmodeID . MultiplayerClient ) {
98
- PlayerDataProtocol . Broadcast ( this . DiscoveredMirrorTilesPerWorld ) ;
99
- }
100
- else {
101
- //PlayerDataProtocol.SendToClients( -1, -1, this.DiscoveredMirrorTilesPerWorld );
102
- }
103
- }
104
- }
105
-
106
-
107
53
////////////////
108
54
109
55
public override void Load ( TagCompound tag ) {
110
- int count = 0 ;
56
+ this . DiscoveredMirrorTilesPerWorld . Clear ( ) ;
111
57
112
58
if ( ! tag . ContainsKey ( "world_count" ) ) {
113
- if ( tag . ContainsKey ( "discovery_count" ) ) {
114
- this . DiscoveredMirrorTilesPerWorld . Clear ( ) ;
115
- count = this . LoadOld ( tag ) ;
116
- }
117
- } else {
118
- this . DiscoveredMirrorTilesPerWorld . Clear ( ) ;
119
- count = this . LoadNew ( tag ) ;
120
- }
121
-
122
- LogLibraries . Log ( "Loaded " + count + " discovered mirrors for " + this . player . name + " (" + this . player . whoAmI + ")" ) ;
123
- }
124
-
125
- private int LoadOld ( TagCompound tag ) {
126
- int count = tag . GetInt ( "discovery_count" ) ;
127
-
128
- this . DiscoveredMirrorTilesPerWorld [ "_" ] = new DiscoveredMirrors ( ) ;
129
-
130
- for ( int i = 0 ; i < count ; i ++ ) {
131
- int tileX = tag . GetInt ( "discovery_x_" + i ) ;
132
- int tileY = tag . GetInt ( "discovery_y_" + i ) ;
133
-
134
- this . DiscoveredMirrorTilesPerWorld [ "_" ] . Set2D ( tileX , tileY ) ;
135
-
136
- if ( MMMConfig . Instance . DebugModeInfo ) {
137
- LogLibraries . Log ( "(Old) Loaded mirror at " + tileX + ", " + tileY ) ;
138
- }
59
+ return ;
139
60
}
140
61
141
- return count ;
142
- }
143
-
144
- private int LoadNew ( TagCompound tag ) {
145
62
int worldCount = tag . GetInt ( "world_count" ) ;
146
63
int totalMirrorCount = 0 ;
147
64
@@ -165,7 +82,7 @@ private int LoadNew( TagCompound tag ) {
165
82
totalMirrorCount += mirrorCount ;
166
83
}
167
84
168
- return totalMirrorCount ;
85
+ LogLibraries . Log ( "Loaded " + totalMirrorCount + " discovered mirrors for " + this . player . name + " (" + this . player . whoAmI + ")" ) ;
169
86
}
170
87
171
88
@@ -184,6 +101,7 @@ public override TagCompound Save() {
184
101
string myWorldUid = worldUid ;
185
102
if ( worldUid == "_" ) {
186
103
myWorldUid = WorldIdentityLibraries . GetUniqueIdForCurrentWorld ( true ) ;
104
+
187
105
if ( MMMConfig . Instance . DebugModeInfo ) {
188
106
LogLibraries . Log ( "Saving for world UID " + myWorldUid ) ;
189
107
}
0 commit comments