Skip to content

Commit 2501aff

Browse files
author
magiclu550
committed
[proxy] a event handler
1 parent a6d29c8 commit 2501aff

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ProxyHandler作为一个Smod2插件运行在multiAdmin,并确保在启动jsmod
2121

2222
2.已经实现解析实体的协议:
2323
```
24-
Event(%3)
24+
2525
Map (%0)
2626
PocketDimensionExit (%0)
2727
Room (%0)
@@ -40,6 +40,10 @@ ProxyHandler作为一个Smod2插件运行在multiAdmin,并确保在启动jsmod
4040
(Smod2)Server (%100)
4141
Elevator (%100)
4242
Generator (%100)
43+
Event(%100)
4344
4445
```
46+
3. 对于一些特殊情况的处理
47+
48+
如Component GameObject等Object类型,目前暂不写,未来将修复他们
4549

jsmod2/NetworkHandler.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static NetworkHandler()
8181
handlers.Add(131,new HandleGeneratorUnlock());
8282
handlers.Add(180,new EventHandler());
8383
handlers.Add(181,new EventHandler());
84+
handlers.Add(182,new HandlePlayerContain106GetScp106s());
8485
}
8586
public static void handleJsmod2(int id, String json,Dictionary<string,string> mapper,TcpClient client)
8687
{
@@ -198,6 +199,24 @@ public interface Handler
198199
JsonSetting[] handle(object api,Dictionary<string,string> mapper);
199200
}
200201

202+
public class HandlePlayerContain106GetScp106s : Handler
203+
{
204+
public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
205+
{
206+
PlayerContain106Event e = api as PlayerContain106Event;
207+
Player[] players = e.SCP106s;
208+
JsonSetting[] settings = new JsonSetting[players.Length];
209+
for (int i = 0; i < settings.Length; i++)
210+
{
211+
settings[i] = new JsonSetting(Lib.getInt(mapper["id"]),null,
212+
new IdMapping().appendId(Lib.ID,Guid.NewGuid().ToString(),players[i]).appendId(Lib.PLAYER_SCPDATA_ID,Guid.NewGuid().ToString(),players[i].Scp079Data).appendId(Lib.PLAYER_TEAM_ROLE_ID,Guid.NewGuid().ToString(),players[i].TeamRole)
213+
);
214+
}
215+
216+
return settings;
217+
}
218+
}
219+
201220
public class EventHandler : Handler
202221
{
203222
public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
@@ -217,17 +236,6 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
217236
{
218237
return Utils.getOne(mapper["id"], obj, null);
219238
}
220-
if (returnType == typeof(List<Vector>))
221-
{
222-
List<Vector> vectors = (List<Vector>) obj;
223-
JsonSetting[] settings = new JsonSetting[vectors.Count];
224-
for (int i = 0; i < settings.Length; i++)
225-
{
226-
settings[i] = new JsonSetting(Lib.getInt(mapper["id"]),vectors[i],null);
227-
}
228-
229-
return settings;
230-
}
231239
return null;
232240
}
233241

0 commit comments

Comments
 (0)