internal static void InternalOnRevived(PlayerLife sender) { UnturnedPlayerEvents instance = sender.GetComponent <UnturnedPlayerEvents>(); UnturnedPlayer rp = UnturnedPlayer.FromPlayer(sender.player); // First parameter of tellLife was health. OnPlayerUpdateLife.TryInvoke(rp, sender.health); instance.OnUpdateLife.TryInvoke(rp, sender.health); // Ideally avoid using this angleToByte method in new code. Please. Vector3 position = sender.transform.position; byte angle = MeasurementTool.angleToByte(sender.transform.rotation.eulerAngles.y); OnPlayerRevive.TryInvoke(rp, position, angle); instance.OnRevive.TryInvoke(rp, position, angle); }
internal static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R) { try { if (s == null || s.Player == null || s.Player.transform == null || R == null) { return; } UnturnedPlayerEvents instance = s.Player.transform.GetComponent <UnturnedPlayerEvents>(); UnturnedPlayer rp = UnturnedPlayer.FromSteamPlayer(s); #if DEBUG //string o = ""; //foreach (object r in R) //{ // o += r.ToString(); //} //Logger.Log("Send+" + s.SteamPlayerID.CSteamID.ToString() + ": " + W + " - " + o); #endif if (W.StartsWith("tellWear")) { OnPlayerWear.TryInvoke(rp, Enum.Parse(typeof(Wearables), W.Replace("tellWear", "")), (ushort)R[0], R.Count() > 1 ? (byte?)R[1] : null); } switch (W) { case "tellBleeding": OnPlayerUpdateBleeding.TryInvoke(rp, (bool)R[0]); instance.OnUpdateBleeding.TryInvoke(rp, (bool)R[0]); break; case "tellBroken": OnPlayerUpdateBroken.TryInvoke(rp, (bool)R[0]); instance.OnUpdateBroken.TryInvoke(rp, (bool)R[0]); break; case "tellLife": OnPlayerUpdateLife.TryInvoke(rp, (byte)R[0]); instance.OnUpdateLife.TryInvoke(rp, (byte)R[0]); break; case "tellFood": OnPlayerUpdateFood.TryInvoke(rp, (byte)R[0]); instance.OnUpdateFood.TryInvoke(rp, (byte)R[0]); break; case "tellHealth": OnPlayerUpdateHealth.TryInvoke(rp, (byte)R[0]); instance.OnUpdateHealth.TryInvoke(rp, (byte)R[0]); break; case "tellVirus": OnPlayerUpdateVirus.TryInvoke(rp, (byte)R[0]); instance.OnUpdateVirus.TryInvoke(rp, (byte)R[0]); break; case "tellWater": OnPlayerUpdateWater.TryInvoke(rp, (byte)R[0]); instance.OnUpdateWater.TryInvoke(rp, (byte)R[0]); break; case "tellStance": OnPlayerUpdateStance.TryInvoke(rp, (byte)R[0]); instance.OnUpdateStance.TryInvoke(rp, (byte)R[0]); break; case "tellGesture": OnPlayerUpdateGesture.TryInvoke(rp, (PlayerGesture)Enum.Parse(typeof(PlayerGesture), R[0].ToString())); instance.OnUpdateGesture.TryInvoke(rp, (PlayerGesture)Enum.Parse(typeof(PlayerGesture), R[0].ToString())); break; case "tellStat": OnPlayerUpdateStat.TryInvoke(rp, (EPlayerStat)(byte)R[0]); instance.OnUpdateStat.TryInvoke(rp, (EPlayerStat)(byte)R[0]); break; case "tellExperience": OnPlayerUpdateExperience.TryInvoke(rp, (uint)R[0]); instance.OnUpdateExperience.TryInvoke(rp, (uint)R[0]); break; case "tellRevive": OnPlayerRevive.TryInvoke(rp, (Vector3)R[0], (byte)R[1]); instance.OnRevive.TryInvoke(rp, (Vector3)R[0], (byte)R[1]); break; case "tellDead": OnPlayerDead.TryInvoke(rp, (Vector3)R[0]); instance.OnDead.TryInvoke(rp, (Vector3)R[0]); break; case "tellDeath": OnPlayerDeath.TryInvoke(rp, (EDeathCause)(byte)R[0], (ELimb)(byte)R[1], new CSteamID(ulong.Parse(R[2].ToString()))); instance.OnDeath.TryInvoke(rp, (EDeathCause)(byte)R[0], (ELimb)(byte)R[1], new CSteamID(ulong.Parse(R[2].ToString()))); break; default: #if DEBUG // Logger.Log("Send+" + s.SteamPlayerID.CSteamID.ToString() + ": " + W + " - " + String.Join(",",R.Select(e => e.ToString()).ToArray())); #endif break; } return; } catch (Exception ex) { Logger.LogException(ex, "Failed to receive packet \"" + W + "\""); } }
private void OnLifeUpdated(bool isdead) { OnPlayerUpdateLife.TryInvoke(Player, isdead); OnUpdateLife.TryInvoke(Player, isdead); }