private void RaiseOtherException(AsyncSocketState state) { if (NetError != null) { NetError.Invoke(this, new AsyncSocketEventArgs(state)); } }
/// <summary> /// Inform the enemy manager that an enemy has died. /// </summary> /// <param name="instance"></param> /// <param name="destroyObject"></param> public override void spawnableDestroyed(GameObject instance, bool destroyObject) { // Make sure the server is handling the destroyed event #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Make sure we are destroying an enemy if (enemyList.Contains(instance) == true) { // Do we have authority to destroy the instance if (destroyObject == true) { #if ULTIMATE_SPAWNER_NETWORKED == true // Destroy on remote clients NetworkServer.Destroy(instance); #endif // Destroy on local client #if ULTIMATE_SPAWNER_POOLED == true // Return the instance to the pool for reuse UltimatePool.despawn(instance); #else // Destroy the instance Destroy(instance); #endif } // Remove from list enemyList.Remove(instance); } }
public void Connect() { for (int i = 0; i < MaxConnections; i++) { var packet = new Packets.ClientPacket(); packet.Options = Options; AsyncTcpClient client; if (mSslServerName == null) { client = BeetleX.SocketFactory.CreateClient <BeetleX.Clients.AsyncTcpClient>( packet, Host, Port); } else { client = BeetleX.SocketFactory.CreateSslClient <BeetleX.Clients.AsyncTcpClient>( packet, Host, Port, mSslServerName); } client.PacketReceive = OnPacketCompleted; client.ClientError = (c, e) => { NetError?.Invoke(c, e); }; mClients.Add(client); } }
private static void CacheNiceStrings() { IEnumerator enumerator = Enum.GetValues(typeof(NetError)).GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; NetError netError = (NetError)((int)current); string str = NetErrorHelper.BuildNiceString(netError); if (str == null && netError != NetError.NoError) { Debug.LogWarning(string.Concat("NetError.", current, " has no nice string")); str = NetErrorHelper.FallbackNiceString(netError); } NetErrorHelper.niceStrings[netError] = str; } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } }
/// <summary> /// Attempt to spawn an item using current settings. /// </summary> /// <returns>The transform of the spawned item</returns> public override Transform spawn() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Make sure we can spawn if (canSpawn() == false) { // Spawn failed invokeSpawnFailedEvent(); return(null); } // Select the spawn location ISpawn spawn = this.selectSpawn(spawnMode); // Call spawn on the child Transform result = spawn.spawn(); // Trigger event if (result == null) { invokeSpawnFailedEvent(); } else { invokeSpawnedEvent(result); } return(result); }
/// <summary> /// Attempts to spawn an item at a spawn point. /// If successful the return value will be true otherwise false. /// </summary> /// <param name="toSpawn">The transform of the object to spawn</param> /// <returns>True if the spawn was successful otherwise false</returns> public virtual bool spawn(Transform toSpawn) { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Check if we can spawn if (canSpawn() == false) { // Trigger failed invokeSpawnFailedEvent(); return(false); } // Get the spawn point ISpawn spawn = this.selectSpawn(spawnMode); // Get the spawn info SpawnInfo info = spawn.getSpawnInfo(); // Spawn the item info.spawnObjectAt(toSpawn); // Success invokeSpawnedEvent(toSpawn); return(true); }
public SteamDenyEvent(ClientConnection cc, NetworkPlayerApproval approval, string strReason, NetError errornum) { this._cc = cc; this._approval = approval; this._strReason = strReason; this._errornum = errornum; }
private static void CacheNiceStrings() { IEnumerator enumerator = Enum.GetValues(typeof(NetError)).GetEnumerator(); try { while (enumerator.MoveNext()) { object current = enumerator.Current; NetError error = (NetError)((int)current); string str = BuildNiceString(error); if ((str == null) && (error != NetError.NoError)) { Debug.LogWarning("NetError." + current + " has no nice string"); str = FallbackNiceString(error); } niceStrings[error] = str; } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable == null) { } disposable.Dispose(); } }
public uint m_tableID; // NOTE: Presence of this field depends on the NetError subclass?? public static NetError read(BinaryReader binaryReader) { NetError newObj = new NetError(); newObj.m_stringID = binaryReader.ReadUInt32(); newObj.m_tableID = binaryReader.ReadUInt32(); return(newObj); }
public static string NiceString(this NetError value) { string str; if (niceStrings.TryGetValue(value, out str)) { return(str); } return(FallbackNiceString(value)); }
private void OnError(IClient client, ClientErrorArgs e) { try { NetError.Invoke(client, e); } catch { } }
/// <summary> /// Stops tracking enemies that are still alive. /// </summary> public override void reset() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif enemyList.Clear(); }
public static NetError GetLastKickReason(bool clear) { NetError?nullable = ServerManagement.kickedNetError; NetError netError = (!nullable.HasValue ? NetCull.lastError : nullable.Value); if (clear) { ServerManagement.kickedNetError = null; } return(netError); }
private void LogDisconnect(NetError error, NetworkDisconnection?disconnection = new NetworkDisconnection?()) { if (error != NetError.NoError) { Debug.LogWarning(error); } if (disconnection.HasValue) { Debug.Log(disconnection); } }
/// <summary> /// Stop spawning enemies immediatley (The current wave will be abandoned and the next call to startWave will advance to the next wave) /// </summary> public override void stopSpawning() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Stop spawning StopCoroutine(waveRountine()); }
/// <summary> /// Begin infinatley spawning enemies using the current settings /// </summary> public override void startSpawning() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Start spawning StartCoroutine(spawnRoutine()); }
void NotifyCallback(Message message, NetError error) { if (error.exception == null) { var str = System.Text.Encoding.UTF8.GetString(message.message); Debug.LogFormat("notifyCB: {0}", str); } else { Debug.Log(error.exception); } }
// Methods /// <summary> /// Called by unity on startup. /// </summary> protected override void Start() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Find all spawn points findSpawns(); base.Start(); }
public bool DoConnect(string strURL, int iPort) { unsafe { bool flag; SteamClient.Needed(); NetCull.config.timeoutDelay = 60f; if (ClientConnect.Steam_GetSteamID() == 0) { LoadingScreen.Update("connection failed (no steam detected)"); UnityEngine.Object.Destroy(base.gameObject); return(false); } byte[] numArray = new byte[1024]; IntPtr intPtr = Marshal.AllocHGlobal(1024); uint num = ClientConnect.SteamClient_GetAuth(intPtr, 1024); byte[] numArray1 = new byte[num]; Marshal.Copy(intPtr, numArray1, 0, (int)num); Marshal.FreeHGlobal(intPtr); uLink.BitStream bitStream = new uLink.BitStream(false); bitStream.WriteInt32(1069); bitStream.WriteByte(2); bitStream.WriteUInt64(ClientConnect.Steam_GetSteamID()); bitStream.WriteString(Marshal.PtrToStringAnsi(ClientConnect.Steam_GetDisplayname())); bitStream.WriteBytes(numArray1); try { NetError netError = NetCull.Connect(strURL, iPort, string.Empty, new object[] { bitStream }); if (netError == NetError.NoError) { SteamClient.SteamClient_OnJoinServer(strURL, iPort); return(true); } else { LoadingScreen.Update(string.Concat("connection failed (", netError, ")")); UnityEngine.Object.Destroy(base.gameObject); flag = false; } } catch (Exception exception) { UnityEngine.Debug.LogException(exception); UnityEngine.Object.Destroy(base.gameObject); flag = false; } return(flag); } }
public static void GetObjByNetData <T>(byte[] data, out NetError err, out T tData) where T : new() { ByteStreamBuff _tmpbuff = new ByteStreamBuff(data); string str = _tmpbuff.Read_String(); _tmpbuff.Close(); _tmpbuff = null; Debug.Log(str); bool isError = str.IndexOf("err") != -1; err = isError ? JsonUtility.FromJson <NetError> (str) : null; tData = isError ? new T() : JsonUtility.FromJson <T>(str); }
// Methods private void Start() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Launch spawn routine immediatley if (playOnStart == true) { startSpawning(); } }
public bool DoConnect(string strURL, int iPort) { SteamClient.Needed(); NetCull.config.timeoutDelay = 60f; if (Steam_GetSteamID() == 0) { LoadingScreen.Update("connection failed (no steam detected)"); Object.Destroy(base.gameObject); return(false); } byte[] buffer = new byte[0x400]; IntPtr pData = Marshal.AllocHGlobal(0x400); uint num2 = SteamClient_GetAuth(pData, 0x400); byte[] destination = new byte[num2]; Marshal.Copy(pData, destination, 0, (int)num2); Marshal.FreeHGlobal(pData); BitStream stream = new BitStream(false); stream.WriteInt32(0x42d); stream.WriteByte(2); stream.WriteUInt64(Steam_GetSteamID()); stream.WriteString(Marshal.PtrToStringAnsi(Steam_GetDisplayname())); stream.WriteBytes(destination); try { object[] loginData = new object[] { stream }; NetError error = NetCull.Connect(strURL, iPort, string.Empty, loginData); if (error != NetError.NoError) { LoadingScreen.Update("connection failed (" + error + ")"); Object.Destroy(base.gameObject); return(false); } } catch (Exception exception) { Debug.LogException(exception); Object.Destroy(base.gameObject); return(false); } FeedbackLog.Start(FeedbackLog.TYPE.StartConnect); FeedbackLog.Writer.Write(strURL); FeedbackLog.Writer.Write(iPort); FeedbackLog.End(FeedbackLog.TYPE.StartConnect); SteamClient.SteamClient_OnJoinServer(strURL, iPort); return(true); }
public void spawnableDestroyed(GameObject instance) { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Make sure we are destroying an enemy if (enemyList.Contains(instance) == true) { // Remove from the list enemyList.Remove(instance); } }
/// <summary> /// Selects an appropraite enemyinfo from the collection based on the current settings. /// </summary> /// <returns>An appropriate enemyinfo</returns> public virtual SpawnableInfo selectEnemy() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Check for empty enemies if (enemies.Length == 0) { Debug.LogError("Failed to spawn an enemy because the enemy manager does not contain any enemies"); return(null); } float accumulator = 0; // FInd the total spawn chance value foreach (SpawnableInfo info in enemies) { accumulator += info.spawnChance; } // Select a random value float value = Random.Range(0, accumulator); // Reset the accumulator accumulator = 0; // Find the selected enemy foreach (SpawnableInfo info in enemies) { // Add to the accumulator accumulator += info.spawnChance; // Check if we have found the best match if (value < accumulator) { return(info); } } // Default index return(enemies[0]); }
private void uLink_OnDisconnectedFromServer(NetworkDisconnection netDisconnect) { NetError lastKickReason = ServerManagement.GetLastKickReason(true); this.LogDisconnect(lastKickReason, new NetworkDisconnection?(netDisconnect)); DisableOnConnectedState.OnDisconnected(); ConsoleSystem.Run("gameui.show", false); this.LoadBackground(); if (lastKickReason != NetError.NoError) { this.ShowInformation("Disconnected (" + lastKickReason.NiceString() + ")"); } else { this.ShowInformation("Disconnected from server."); } LoadingScreen.Hide(); }
/// <summary> /// Resets the wave manager to the first round without starting spwning. /// </summary> public void reset(bool keepState = false) { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Reset values activeWave = null; currentIndex = 0; // Should we keep the wave state if (keepState == false) { currentWave = 0; spawnedCount = 0; } }
/// <summary> /// Returns an instance of the spawn info class representing a free spawn point at the time of calling this method. /// This can be used to access the location and rotation of the spawn point for manual spawning. /// </summary> /// <returns>An instance of the spawn info class representing a specific spawn location</returns> public override SpawnInfo getSpawnInfo() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Select a spawn using the spawn mode ISpawn spawn = this.selectSpawn(spawnMode); // Check for null if (spawn == null) { return(null); } // Get the spawn info return(spawn.getSpawnInfo()); }
/// <summary> /// Get the spawn info for this spawn point. /// </summary> /// <returns>An instance of the spawn info class representing this spawn points location and orientation</returns> public override SpawnInfo getSpawnInfo() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Check for cached info if (cachedInfo != null) { return(cachedInfo); } // Create a new spawn info cachedInfo = new SpawnInfo(this, transform); // Get the info return(cachedInfo); }
// Methods /// <summary> /// Attempt to spawn an item using the current settings. /// </summary> /// <returns>The transform of the spawned item</returns> public override Transform spawn() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif // Make sure we can spawn if (IsSpawnFree == false) { // Spawn failed invokeSpawnFailedEvent(); return(null); } // Create the spawner object Transform instance = this.createSpawnableInstance(); // Check for error if (instance == null) { // Spawn failed invokeSpawnFailedEvent(); return(null); } // Get the spawn info SpawnInfo info = getSpawnInfo(); // Spawn the item info.spawnObjectAt(instance); // Success invokeSpawnedEvent(instance); return(instance); }
// Methods private void Start() { #if ULTIMATE_SPAWNER_NETWORKED == true if (isServer == false) { NetError.raise(); } #endif if (spawnManager == null) { Debug.LogError("Wave manager has not been setup correctly. Make sure that the spawn manager field is assigned"); enabled = false; return; } // Launch wave immediatley if (playOnStart == true) { startSpawning(); } }
private static string FallbackNiceString(NetError error) { int num = (int)error; return string.Concat(error.ToString().Replace("Facepunch_", string.Empty), "(", num.ToString("X"), ")").Replace("_", " "); }
private void LogDisconnect(NetError error, uLink.NetworkDisconnection? disconnection = null) { if (error != NetError.NoError) { Debug.LogWarning(error); } if (disconnection.HasValue) { Debug.Log(disconnection); } }
public static void KickUser(NetUser player, NetError reason, bool notify) { // reson = NetError.Facepunch_Kick_Violation player.Kick(reason, notify); //player.playerClient.netUser.Kick(reason, notify); }
private static string BuildNiceString(NetError value) { NetError netError = value; switch (netError) { case NetError.ProxyTargetNotConnected: { return "Proxy target not connected"; } case NetError.ProxyTargetNotRegistered: { return "Proxy target not registered"; } case NetError.ProxyServerNotEnabled: { return "Proxy server not enabled"; } case NetError.ProxyServerOutOfPorts: { return "Proxy server out of ports"; } case NetError.Facepunch_Kick_ServerRestarting: { return "Server restarting"; } case NetError.Facepunch_Approval_Closed: { return "Not accepting new connections."; } case NetError.Facepunch_Approval_TooManyConnectedPlayersNow: { return "Authorization busy"; } case NetError.Facepunch_Approval_ConnectorAuthorizeException: { return "Server exception with authorization"; } case NetError.Facepunch_Approval_ConnectorAuthorizeExecution: { return "Aborted starting of authorization"; } case NetError.Facepunch_Approval_ConnectorDidNothing: { return "Server failed to start authorization"; } case NetError.Facepunch_Approval_ConnectorCreateFailure: { return "Server was unable to start authorization"; } case NetError.Facepunch_Approval_ServerDoesNotSupportConnector: { return "Unsupported ticket"; } case NetError.Facepunch_Approval_MissingServerManagement: { return "Server is not prepared"; } case NetError.Facepunch_Approval_ServerLoginException: { return "Server exception"; } case NetError.Facepunch_Approval_DisposedWait: { return "Aborted authorization"; } case NetError.Facepunch_Approval_DisposedLimbo: { return "Failed to run authorization"; } case NetError.Facepunch_Kick_MultipleConnections: { return "Started a different connection"; } case NetError.Facepunch_Kick_Violation: { return "Kicked because of violation"; } case NetError.Facepunch_Kick_RCON: { return "Kicked by admin"; } case NetError.Facepunch_Kick_Ban: { return "Kicked and Banned by admin"; } case NetError.Facepunch_Kick_BadName: { return "Rejected name"; } case NetError.Facepunch_Connector_InLimboState: { return "Lost connection during authorization"; } case NetError.Facepunch_Connector_WaitedLimbo: { return "Server lost you while processing ticket"; } case NetError.Facepunch_Connector_RoutineMoveException: { return "Server exception occured while awaiting authorization"; } case NetError.Facepunch_Connector_RoutineYieldException: { return "Server exception occured when checking authorization"; } case NetError.Facepunch_Connector_MissingFeatureImplementation: { return "Authorization produced an unhandled message"; } case NetError.Facepunch_Connector_Cancelled: { return "A ticket was cancelled - try again"; } case NetError.Facepunch_Connector_AuthFailure: { return "Authorization failed"; } case NetError.Facepunch_Connector_AuthException: { return "Server exception while starting authorization"; } case NetError.Facepunch_Connector_MultipleAttempts: { return "Multiple authorization attempts"; } case NetError.Facepunch_Connector_VAC_Banned: { return "VAC banned"; } case NetError.Facepunch_Connector_AuthTimeout: { return "Timed out authorizing your ticket"; } case NetError.Facepunch_Connector_Old: { return "Ticket already used"; } case NetError.Facepunch_Connector_NoConnect: { return "Lost authorization"; } case NetError.Facepunch_Connector_Invalid: { return "Ticket invalid"; } case NetError.Facepunch_Connector_Expired: { return "Ticket expired"; } case NetError.Facepunch_Connector_ConnectedElsewhere: { return "Changed connection"; } case NetError.Facepunch_API_Failure: { return "API Failure"; } case NetError.Facepunch_Whitelist_Failure: { return "Not in whitelist"; } default: { switch (netError) { case NetError.NATTargetNotConnected: { return "NAT target not connected"; } case NetError.NATTargetConnectionLost: { return "NAT target connection lost"; } case NetError.NATPunchthroughFailed: { return "NAT punchthrough"; } case NetError.IncompatibleVersions: { return "Version incompatible"; } case NetError.ConnectionTimeout: { return "Timed out"; } case NetError.LimitedPlayers: { return "Server has limited players"; } default: { switch (netError) { case NetError.ConnectionFailed: { return "Could not reach the server"; } case NetError.TooManyConnectedPlayers: { return "Full"; } case NetError.RSAPublicKeyMismatch: { return "RSA public key mismatch"; } case NetError.ConnectionBanned: { return "Banned from connecting"; } case NetError.InvalidPassword: { return "Invalid password"; } case NetError.DetectedDuplicatePlayerID: { return "Duplicate players identified"; } default: { switch (netError) { case NetError.InternalDirectConnectFailed: { return "Direct connect failed"; } case NetError.EmptyConnectTarget: { return "Invalid server"; } case NetError.IncorrectParameters: { return "Incorrect parameters"; } case NetError.CreateSocketOrThreadFailure: { return "Could not create socket or thread"; } case NetError.AlreadyConnectedToAnotherServer: { return "Already connected to different server"; } case NetError.NoError: { return null; } default: { if (netError != NetError.IsAuthoritativeServer) { if (netError == NetError.ApprovalDenied) { return "You've been denied from connecting"; } return null; } break; } } break; } } break; } } break; } } return "Authoritative server"; }