public override void Log(ILogMessage message) { var level = message.Level; string prefix = "[NuGet] "; var text = prefix + message.Message; switch (level) { case LogLevel.Debug: logger.LogDebug(text); break; case LogLevel.Verbose: logger.LogTrace(text); break; case LogLevel.Information: logger.LogInformation(text); break; case LogLevel.Minimal: logger.LogInformation(text); break; case LogLevel.Warning: logger.LogWarning(text); break; case LogLevel.Error: logger.LogError(text); break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } }
internal void TriggerSend(SteamPlayer player, string method, ESteamCall steamCall, ESteamPacket steamPacket, params object[] data) { try { if (player == null || player.player == null || player.playerID.steamID == CSteamID.Nil || player.player.transform == null || data == null) { return; } UnturnedPlayer unturnedPlayer = (UnturnedPlayer)playerManager.GetPlayer(player.playerID.steamID.ToString()); if (method.StartsWith("tellWear")) { //PlayerWearEvent method.Replace("tellWear", ""), (ushort)data[0], data.Count() > 1 ? (byte?)data[1] : null) return; } IEvent @event = null; switch (method) { case "tellBleeding": @event = new UnturnedPlayerUpdateBleedingEvent(unturnedPlayer, (bool)data[0]); break; case "tellBroken": @event = new UnturnedPlayerUpdateBrokenEvent(unturnedPlayer, (bool)data[0]); break; case "tellLife": @event = new UnturnedPlayerUpdateLifeEvent(unturnedPlayer, (byte)data[0]); break; case "tellFood": @event = new UnturnedPlayerUpdateFoodEvent(unturnedPlayer, (byte)data[0]); break; case "tellHealth": @event = new UnturnedPlayerUpdateHealthEvent(unturnedPlayer, (byte)data[0]); break; case "tellVirus": @event = new UnturnedPlayerUpdateVirusEvent(unturnedPlayer, (byte)data[0]); break; case "tellWater": @event = new UnturnedPlayerUpdateWaterEvent(unturnedPlayer, (byte)data[0]); break; case "tellStance": @event = new UnturnedPlayerUpdateStanceEvent(unturnedPlayer, (EPlayerStance)(byte)data[0]); break; case "tellGesture": @event = new UnturnedPlayerUpdateGestureEvent(unturnedPlayer, (EPlayerGesture)(byte)data[0]); break; case "tellStat": @event = new UnturnedPlayerUpdateStatEvent(unturnedPlayer, (EPlayerStat)(byte)data[0]); break; case "tellExperience": @event = new UnturnedPlayerUpdateExperienceEvent(unturnedPlayer, (uint)data[0]); break; case "tellRevive": @event = new PlayerRespawnEvent(unturnedPlayer); break; case "tellDead": @event = new UnturnedPlayerDeadEvent(unturnedPlayer, ((global::UnityEngine.Vector3)data[0]).ToSystemVector()); break; case "tellDeath": { var deathCause = (EDeathCause)(byte)data[0]; var limb = (ELimb)(byte)data[1]; var killerId = data[2].ToString(); playerManager.TryGetOnlinePlayerById(killerId, out var killer); @event = new UnturnedPlayerDeathEvent(unturnedPlayer, limb, deathCause, (killer as UnturnedPlayer)?.Entity); break; } } if (@event != null) { eventManager.Emit(this, @event); } } catch (Exception ex) { logger.LogError("Failed to receive packet \"" + method + "\"", ex); } }