Exemplo n.º 1
0
        public bool Init(bool isDedicated, IPAddress ip, ushort port, ushort queryPort, ushort masterServerPort, ushort spectatorPort, EServerMode serverMode, string serverName, string spectatorServerName, string regionName, string gameName, string gameDescription, string gameVersion, string mapName, ushort maxClients, bool isPassworded, string modDir, OnGameServerClientApproved onGameServerClientApproved, OnGameServerClientDenied onGameServerClientDenied, OnGameServerClientKick onGameServerClientKick)
        {
            byte[] addressBytes = ip.GetAddressBytes();
            uint   ip1          = (uint)((int)addressBytes[0] << 24 | (int)addressBytes[1] << 16 | (int)addressBytes[2] << 8) | (uint)addressBytes[3];

            this._playersPendingAuth.Clear();
            this._playersConnected.Clear();
            this._botsConnected.Clear();
            this._onGameServerClientApproved = onGameServerClientApproved;
            this._onGameServerClientDenied   = onGameServerClientDenied;
            this._onGameServerClientKick     = onGameServerClientKick;
            if (this._internalOnGameServerClientApproved == null)
            {
                this._internalOnGameServerClientApproved = new OnGameServerClientApprovedBySteam(this.OnGameServerClientApprovedCallback);
                this._internalOnGameServerClientDenied   = new OnGameServerClientDeniedBySteam(this.OnGameServerClientDeniedCallback);
                this._internalOnGameServerClientKick     = new OnGameServerClientKickFromSteam(this.OnGameServerClientKickCallback);
                this._internalOnGameServerPolicyResponse = new OnGameServerPolicyResponseFromSteam(this.OnGameServerPolicyResponseCallback);
            }
            GameServer.SteamUnityAPI_SteamGameServer_SetCallbacks(Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientApproved), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientDenied), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerClientKick), Marshal.GetFunctionPointerForDelegate((Delegate)this._internalOnGameServerPolicyResponse));
            if (!GameServer.SteamUnityAPI_SteamGameServer_Init(ip1, masterServerPort, port, queryPort, serverMode, gameVersion))
            {
                return(false);
            }
            this._isInitialized       = true;
            this._gameServer          = GameServer.SteamUnityAPI_SteamGameServer();
            this._isDedicated         = isDedicated;
            this._serverName          = serverName;
            this._spectatorServerName = spectatorServerName;
            this._spectatorPort       = spectatorPort;
            this._mapName             = mapName;
            this._regionName          = regionName;
            this._gameName            = gameName;
            this._gameDescription     = gameDescription;
            this._maxClients          = maxClients;
            this._isPassworded        = isPassworded;
            this._modDir = modDir;
            this.SendBasicServerStatus();
            GameServer.SteamUnityAPI_SteamGameServer_LogOnAnonymous(this._gameServer);
            this.SendUpdatedServerStatus();
            return(true);
        }
Exemplo n.º 2
0
 public bool Init(bool isDedicated, IPAddress ip, ushort port, ushort queryPort, ushort masterServerPort, ushort spectatorPort, EServerMode serverMode, string serverName, string spectatorServerName, string regionName, string gameName, string gameDescription, string gameVersion, string mapName, ushort maxClients, bool isPassworded, OnGameServerClientApproved onGameServerClientApproved, OnGameServerClientDenied onGameServerClientDenied, OnGameServerClientKick onGameServerClientKick)
 {
     return(this.Init(isDedicated, ip, port, queryPort, masterServerPort, spectatorPort, serverMode, serverName, spectatorServerName, regionName, gameName, gameDescription, gameVersion, mapName, maxClients, isPassworded, string.Empty, onGameServerClientApproved, onGameServerClientDenied, onGameServerClientKick));
 }