1515import cn .jsmod2 .api .player .IPlayer ;
1616import cn .jsmod2 .api .player .Player ;
1717import cn .jsmod2 .api .team .Role ;
18+ import cn .jsmod2 .core .ApiId ;
1819import 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 ;
1923
2024import java .io .Serializable ;
25+ import java .util .HashMap ;
2126import java .util .List ;
2227import java .util .Random ;
28+ import java .util .Set ;
2329
2430//从map获取物品时,要为每个物品分配id(C#端分配),从而可以定位到
2531public class Map implements IMap , Serializable {
@@ -31,161 +37,319 @@ public class Map implements IMap, Serializable {
3137 private boolean warheadDetonated ;
3238 private boolean LCZDecontaminated ;
3339
40+ @ SuppressWarnings ("unchecked" )
3441 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 ();
3648 }
3749
3850 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 ();
4157 }
4258
59+ @ SuppressWarnings ("unchecked" )
4360 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 ();
4567 }
4668
69+ @ SuppressWarnings ("unchecked" )
4770 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" ;
5075
76+ return (List <Vector >) packet .send ();
5177
52- public List <IDoor > getDoors () {
53- return null ;
5478 }
5579
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+ }
5688
89+ @ SuppressWarnings ("unchecked" )
5790 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 ();
5996 }
6097
61-
6298 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 );
64119 }
65120
66121
67122 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 ();
69128 }
70129
71130
72131 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 ();
74138 }
75139
76140
77141 public void detonateWarhead () {
78-
142+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
143+ packet .isWrite = true ;
144+ packet .method = "DetonateWarhead" ;
145+ packet .send ();
79146 }
80147
81148
82149 public void startWarhead () {
83-
150+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
151+ packet .isWrite = true ;
152+ packet .method = "StartWarhead" ;
153+ packet .send ();
84154 }
85155
86156
87157 public void stopWarhead () {
88-
158+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
159+ packet .isWrite = true ;
160+ packet .method = "StopWarhead" ;
161+ packet .send ();
89162 }
90163
91164
92165 public void shake () {
93-
166+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
167+ packet .isWrite = true ;
168+ packet .method = "Shake" ;
169+ packet .send ();
94170 }
95171
96172
97173 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 ();
99179 }
100180
101181
102182 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 ();
104188 }
105189
106-
190+ @ SuppressWarnings ( "unchecked" )
107191 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 ();
109197 }
110198
111199
112200 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 ();
114206 }
115207
116208 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 ();
118215 }
119216
120-
217+ @ SuppressWarnings ( "unchecked" )
121218 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 ();
123224 }
124225
125226
126227 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 ();
128233 }
129234
130235
131236 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 ();
133242 }
134243
135244
136245 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 ();
138251 }
139252
140253
141254 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 ();
143260 }
144261
145262
146263 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 ();
148269 }
149270
150271
151272 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 ();
153278 }
154279
155280
156281 public void clearBroadcasts () {
157-
282+ SimpleMapMethodPacket packet = new SimpleMapMethodPacket (Void .class );
283+ packet .method = "ClearBroadcasts" ;
284+ packet .isWrite = true ;
285+ packet .send ();
158286 }
159287
160288 public boolean isWarheadLeverEnabled () {
289+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
290+ stream .isWrite = false ;
291+ stream .field = "WarheadLeverEnabled" ;
292+ warheadLeverEnabled = (Boolean ) stream .send ();
161293 return warheadLeverEnabled ;
162294 }
163295
164296 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 ();
165302 this .warheadLeverEnabled = warheadLeverEnabled ;
166303 }
167304
168305 public boolean isWarheadKeycardEntered () {
306+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
307+ stream .isWrite = false ;
308+ stream .field = "WarheadKeycardEntered" ;
309+ warheadKeycardEntered = (Boolean ) stream .send ();
169310 return warheadKeycardEntered ;
170311 }
171312
172313 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 ();
173319 this .warheadKeycardEntered = warheadKeycardEntered ;
174320 }
175321
176322 public boolean isWarheadDetonated () {
323+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
324+ stream .isWrite = false ;
325+ stream .field = "WarheadDetonated" ;
326+ warheadDetonated = (Boolean ) stream .send ();
177327 return warheadDetonated ;
178328 }
179329
180330 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 ();
181336 this .warheadDetonated = warheadDetonated ;
182337 }
183338
184339 public boolean isLCZDecontaminated () {
340+ SimpleMapFieldStream stream = new SimpleMapFieldStream (Boolean .class );
341+ stream .isWrite = false ;
342+ stream .field = "LCZDecontaminated" ;
343+ LCZDecontaminated = (Boolean ) stream .send ();
185344 return LCZDecontaminated ;
186345 }
187346
188347 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 ();
189353 this .LCZDecontaminated = LCZDecontaminated ;
190354 }
191355
0 commit comments