15
15
import cn .jsmod2 .api .player .IPlayer ;
16
16
import cn .jsmod2 .api .player .Player ;
17
17
import cn .jsmod2 .api .team .Role ;
18
+ import cn .jsmod2 .core .ApiId ;
18
19
import cn .jsmod2 .core .math .Vector ;
20
+ import cn .jsmod2 .network .protocol .event .newstream .GetTypes ;
21
+ import cn .jsmod2 .network .protocol .map .map .SimpleMapFieldStream ;
22
+ import cn .jsmod2 .network .protocol .map .map .SimpleMapMethodPacket ;
19
23
20
24
import java .io .Serializable ;
25
+ import java .util .HashMap ;
21
26
import java .util .List ;
22
27
import java .util .Random ;
28
+ import java .util .Set ;
23
29
24
30
//从map获取物品时,要为每个物品分配id(C#端分配),从而可以定位到
25
31
public class Map implements IMap , Serializable {
@@ -31,161 +37,319 @@ public class Map implements IMap, Serializable {
31
37
private boolean warheadDetonated ;
32
38
private boolean LCZDecontaminated ;
33
39
40
+ @ SuppressWarnings ("unchecked" )
34
41
public List <Item > getItems (ItemType type , boolean world_only ){
35
- return null ;
42
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Item .class );
43
+ packet .isWrite = false ;
44
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
45
+ packet .method = "GetItems" ;
46
+ packet .args = new String []{"'" +type +"'" ,world_only +"" };
47
+ return (List )packet .send ();
36
48
}
37
49
38
50
public Vector getRandomSpawnPoint (Role role ){
39
- List <Vector > vectors = getSpawnPoints (role );
40
- return vectors .get (new Random ().nextInt (vectors .size ()));
51
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Vector .class );
52
+ packet .method = "GetRandomSpawnPoint" ;
53
+ packet .isWrite = false ;
54
+ packet .getTypes = GetTypes .GET ;
55
+ packet .args = new String []{"'" +role +"'" };
56
+ return (Vector )packet .send ();
41
57
}
42
58
59
+ @ SuppressWarnings ("unchecked" )
43
60
public List <Vector > getSpawnPoints (Role role ){
44
- return null ;
61
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Vector .class );
62
+ packet .method = "GetSpawnPoints" ;
63
+ packet .isWrite = false ;
64
+ packet .args = new String []{"'" +role +"'" };
65
+ packet .getTypes = GetTypes .GET_ARRAY ;
66
+ return (List )packet .send ();
45
67
}
46
68
69
+ @ SuppressWarnings ("unchecked" )
47
70
public List <Vector > getBlastDoorPoints () {
48
- return null ;
49
- }
71
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Vector .class );
72
+ packet .isWrite = false ;
73
+ packet .getTypes = GetTypes .GET_ARRAY ;
74
+ packet .method = "GetBlastDoorPoints" ;
50
75
76
+ return (List <Vector >) packet .send ();
51
77
52
- public List <IDoor > getDoors () {
53
- return null ;
54
78
}
55
79
80
+ @ SuppressWarnings ("unchecked" )
81
+ public List <IDoor > getDoors () {
82
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Door .class );
83
+ packet .isWrite = false ;
84
+ packet .method = "GetDoors" ;
85
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
86
+ return (List )packet .send ();
87
+ }
56
88
89
+ @ SuppressWarnings ("unchecked" )
57
90
public List <PocketDimensionExit > getPocketDimensionExits () {
58
- return null ;
91
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (PocketDimensionExit .class );
92
+ packet .isWrite = false ;
93
+ packet .method = "GetPocketDimensionExits" ;
94
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
95
+ return (List <PocketDimensionExit >) packet .send ();
59
96
}
60
97
61
-
62
98
public java .util .Map <Vector , Vector > getElevatorTeleportPoints () {
63
- return null ;
99
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Map .class );
100
+ packet .isWrite = false ;
101
+ packet .method = "GetElevatorTeleportPoints" ;
102
+ packet .getTypes = GetTypes .GET ;
103
+ java .util .Map <Vector ,Vector > vectorMap = new HashMap <>();
104
+ java .util .Map <String ,String > map = (java .util .Map )packet .send ();
105
+ for (java .util .Map .Entry <String ,String > entry :map .entrySet ()){
106
+ String key = entry .getKey ();
107
+ String value = entry .getValue ();
108
+ vectorMap .put (getVector (key ),getVector (value ));
109
+ }
110
+ return vectorMap ;
111
+ }
112
+
113
+ private Vector getVector (String str ){
114
+ String [] xyz = str .substring (str .indexOf ("(" )+1 ,str .lastIndexOf (")" )).split ("-" );
115
+ double x = Double .parseDouble (xyz [0 ]);
116
+ double y = Double .parseDouble (xyz [1 ]);
117
+ double z = Double .parseDouble (xyz [2 ]);
118
+ return new Vector (x ,y ,z );
64
119
}
65
120
66
121
67
122
public Generator [] getGenerators () {
68
- return new Generator [0 ];
123
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Generator .class );
124
+ packet .method = "GetGenerators" ;
125
+ packet .isWrite = false ;
126
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
127
+ return (Generator []) ((List )packet .send ()).toArray ();
69
128
}
70
129
71
130
72
131
public Room [] get079InteractionRooms (Scp079InteractionType type ) {
73
- return new Room [0 ];
132
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Room .class );
133
+ packet .method = "Get079InteractionRooms" ;
134
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
135
+ packet .isWrite = false ;
136
+ packet .args = new String []{"'" +type +"'" };
137
+ return (Room []) ((List )packet .send ()).toArray ();
74
138
}
75
139
76
140
77
141
public void detonateWarhead () {
78
-
142
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
143
+ packet .isWrite = true ;
144
+ packet .method = "DetonateWarhead" ;
145
+ packet .send ();
79
146
}
80
147
81
148
82
149
public void startWarhead () {
83
-
150
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
151
+ packet .isWrite = true ;
152
+ packet .method = "StartWarhead" ;
153
+ packet .send ();
84
154
}
85
155
86
156
87
157
public void stopWarhead () {
88
-
158
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
159
+ packet .isWrite = true ;
160
+ packet .method = "StopWarhead" ;
161
+ packet .send ();
89
162
}
90
163
91
164
92
165
public void shake () {
93
-
166
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
167
+ packet .isWrite = true ;
168
+ packet .method = "Shake" ;
169
+ packet .send ();
94
170
}
95
171
96
172
97
173
public void spawnItem (ItemType type , Vector position , Vector rotation ) {
98
-
174
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
175
+ packet .isWrite = true ;
176
+ packet .method = "SpawnItem" ;
177
+ packet .args = new String []{"'" +type +"'" ,position .toString (),rotation .toString ()};
178
+ packet .send ();
99
179
}
100
180
101
181
102
182
public void femurBreaker (boolean enable ) {
103
-
183
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
184
+ packet .isWrite = true ;
185
+ packet .method = "FemurBreaker" ;
186
+ packet .args = new String []{enable +"" };
187
+ packet .send ();
104
188
}
105
189
106
-
190
+ @ SuppressWarnings ( "unchecked" )
107
191
public List <Elevator > getElevators () {
108
- return null ;
192
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Elevator .class );
193
+ packet .method = "GetElevators" ;
194
+ packet .isWrite = false ;
195
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
196
+ return (List <Elevator >) packet .send ();
109
197
}
110
198
111
199
112
200
public void setIntercomContent (IntercomStatus intercomStatus , String content ) {
113
-
201
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
202
+ packet .method = "SetIntercomContent" ;
203
+ packet .isWrite = true ;
204
+ packet .args = new String []{"'" +intercomStatus +"'" ,content };
205
+ packet .send ();
114
206
}
115
207
116
208
public String getIntercomContent (IntercomStatus intercomStatus ) {
117
- return null ;
209
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (String .class );
210
+ packet .method = "GetIntercomContent" ;
211
+ packet .args = new String []{"'" +intercomStatus +"'" };
212
+ packet .isWrite = false ;
213
+ packet .getTypes = GetTypes .GET ;
214
+ return (String ) packet .send ();
118
215
}
119
216
120
-
217
+ @ SuppressWarnings ( "unchecked" )
121
218
public List <TeslaGate > getTeslaGates () {
122
- return null ;
219
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (TeslaGate .class );
220
+ packet .method = "GetTeslaGates" ;
221
+ packet .isWrite = false ;
222
+ packet .getTypes = GetTypes .GET_PROTOCOL_ARRAY_WITHOUT_LIST_IN ;
223
+ return (List <TeslaGate >) packet .send ();
123
224
}
124
225
125
226
126
227
public void announceNtfEntrance (int scpsLeft , int mtfNumber , char mtfLetter ) {
127
-
228
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
229
+ packet .method = "AnnounceNtfEntrance" ;
230
+ packet .isWrite = true ;
231
+ packet .args = new String []{scpsLeft +"" ,mtfNumber +"" ,mtfLetter +"" };
232
+ packet .send ();
128
233
}
129
234
130
235
131
236
public void announceScpKill (String scpNumber , IPlayer killer ) {
132
-
237
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
238
+ packet .method = "AnnounceScpKill" ;
239
+ packet .isWrite = true ;
240
+ packet .args = new String []{scpNumber ,((ApiId )killer ).getApiId ()};
241
+ packet .send ();
133
242
}
134
243
135
244
136
245
public void announceCustomMessage (String words ) {
137
-
246
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
247
+ packet .method = "AnnounceCustomMessage" ;
248
+ packet .isWrite = true ;
249
+ packet .args = new String []{words };
250
+ packet .send ();
138
251
}
139
252
140
253
141
254
public void setIntercomSpeaker (IPlayer player ) {
142
-
255
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
256
+ packet .method = "SetIntercomSpeaker" ;
257
+ packet .isWrite = true ;
258
+ packet .args = new String []{((ApiId )player ).getApiId ()};
259
+ packet .send ();
143
260
}
144
261
145
262
146
263
public Player getIntercomSpeaker () {
147
- return null ;
264
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Player .class );
265
+ packet .method = "GetIntercomSpeaker" ;
266
+ packet .isWrite = false ;
267
+ packet .getTypes = GetTypes .GET ;
268
+ return (Player ) packet .send ();
148
269
}
149
270
150
271
151
272
public void broadcast (int duration , String message , boolean isMonoSpaced ) {
152
-
273
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
274
+ packet .method = "Broadcast" ;
275
+ packet .isWrite = true ;
276
+ packet .args = new String []{duration +"" ,message ,isMonoSpaced +"" };
277
+ packet .send ();
153
278
}
154
279
155
280
156
281
public void clearBroadcasts () {
157
-
282
+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
283
+ packet .method = "ClearBroadcasts" ;
284
+ packet .isWrite = true ;
285
+ packet .send ();
158
286
}
159
287
160
288
public boolean isWarheadLeverEnabled () {
289
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
290
+ stream .isWrite = false ;
291
+ stream .field = "WarheadLeverEnabled" ;
292
+ warheadLeverEnabled = (Boolean ) stream .send ();
161
293
return warheadLeverEnabled ;
162
294
}
163
295
164
296
public void setWarheadLeverEnabled (boolean warheadLeverEnabled ) {
297
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Void .class );
298
+ stream .field = "WarheadLeverEnabled" ;
299
+ stream .isWrite = true ;
300
+ stream .value = warheadLeverEnabled ;
301
+ stream .send ();
165
302
this .warheadLeverEnabled = warheadLeverEnabled ;
166
303
}
167
304
168
305
public boolean isWarheadKeycardEntered () {
306
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
307
+ stream .isWrite = false ;
308
+ stream .field = "WarheadKeycardEntered" ;
309
+ warheadKeycardEntered = (Boolean ) stream .send ();
169
310
return warheadKeycardEntered ;
170
311
}
171
312
172
313
public void setWarheadKeycardEntered (boolean warheadKeycardEntered ) {
314
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Void .class );
315
+ stream .field = "WarheadKeycardEntered" ;
316
+ stream .isWrite = true ;
317
+ stream .value = warheadKeycardEntered ;
318
+ stream .send ();
173
319
this .warheadKeycardEntered = warheadKeycardEntered ;
174
320
}
175
321
176
322
public boolean isWarheadDetonated () {
323
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
324
+ stream .isWrite = false ;
325
+ stream .field = "WarheadDetonated" ;
326
+ warheadDetonated = (Boolean ) stream .send ();
177
327
return warheadDetonated ;
178
328
}
179
329
180
330
public void setWarheadDetonated (boolean warheadDetonated ) {
331
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Void .class );
332
+ stream .field = "WarheadDetonated" ;
333
+ stream .isWrite = true ;
334
+ stream .value = warheadDetonated ;
335
+ stream .send ();
181
336
this .warheadDetonated = warheadDetonated ;
182
337
}
183
338
184
339
public boolean isLCZDecontaminated () {
340
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
341
+ stream .isWrite = false ;
342
+ stream .field = "LCZDecontaminated" ;
343
+ LCZDecontaminated = (Boolean ) stream .send ();
185
344
return LCZDecontaminated ;
186
345
}
187
346
188
347
public void setLCZDecontaminated (boolean LCZDecontaminated ) {
348
+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Void .class );
349
+ stream .field = "LCZDecontaminated" ;
350
+ stream .isWrite = true ;
351
+ stream .value = LCZDecontaminated ;
352
+ stream .send ();
189
353
this .LCZDecontaminated = LCZDecontaminated ;
190
354
}
191
355
0 commit comments