1 | using AllocsFixes.PersistentData;
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using UnityEngine;
|
---|
5 |
|
---|
6 | namespace AllocsFixes
|
---|
7 | {
|
---|
8 | public class AllocsLogFunctions
|
---|
9 | {
|
---|
10 | public static void RequestToSpawnPlayer (GameManager manager, int _clientId, string _name, string _playerClassname, string _skinTexture, int _chunkViewDim)
|
---|
11 | {
|
---|
12 | try {
|
---|
13 | ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId);
|
---|
14 | int entityId = CommonMappingFunctions.GetEntityID (ci);
|
---|
15 | EntityPlayer ep = CommonMappingFunctions.GetEntityPlayer (ci);
|
---|
16 | string steamId = CommonMappingFunctions.GetSteamID (ci);
|
---|
17 |
|
---|
18 | string ip = ci.networkPlayer.ipAddress;
|
---|
19 | string name = string.Empty;
|
---|
20 |
|
---|
21 | if (ep != null)
|
---|
22 | name = ep.EntityName;
|
---|
23 |
|
---|
24 | Log.Out ("Player connected, clientid=" + _clientId +
|
---|
25 | ", entityid=" + entityId +
|
---|
26 | ", name=" + name +
|
---|
27 | ", steamid=" + steamId +
|
---|
28 | ", ip=" + ip
|
---|
29 | );
|
---|
30 |
|
---|
31 | PersistentContainer.Instance.Players[steamId].SetOnline(ci);
|
---|
32 | } catch (Exception e) {
|
---|
33 | Log.Out ("Error in AllocsLogFunctions.RequestToSpawnPlayer: " + e);
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public static void PlayerDisconnected (GameManager manager, int _clientId) {
|
---|
38 | try {
|
---|
39 | ClientInfo ci = CommonMappingFunctions.GetClientInfoFromClientID (_clientId);
|
---|
40 | string steamId = CommonMappingFunctions.GetSteamID (ci);
|
---|
41 | Players players = PersistentContainer.Instance.Players;
|
---|
42 | if (players.SteamIDs.Contains(steamId))
|
---|
43 | players[steamId].SetOffline();
|
---|
44 | } catch (Exception e) {
|
---|
45 | Log.Out ("Error in AllocsLogFunctions.PlayerDisconnected: " + e);
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|