Пример #1
0
        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 OnGlobalBackpackUpdated(ushort id, byte quality, byte[] state)
 {
     OnPlayerWear.TryInvoke(Player, Wearables.Backpack, id, quality);
     OnWear.TryInvoke(Player, Wearables.Backpack, id, quality);
 }
 private void OnGlobalGlassesUpdated(ushort id, byte quality, byte[] state)
 {
     OnPlayerWear.TryInvoke(Player, Wearables.Glasses, id, quality);
     OnWear.TryInvoke(Player, Wearables.Glasses, id, quality);
 }
 private void OnVestUpdated(ushort id, byte quality, byte[] state)
 {
     OnPlayerWear.TryInvoke(Player, Wearables.Vest, id, quality);
     OnWear.TryInvoke(Player, Wearables.Vest, id, quality);
 }
        internal static void InternalOnMaskChanged(PlayerClothing clothing)
        {
            UnturnedPlayer rp = UnturnedPlayer.FromPlayer(clothing.player);

            OnPlayerWear.TryInvoke(rp, Wearables.Mask, clothing.mask, clothing.maskQuality);
        }
        internal static void InternalOnVestChanged(PlayerClothing clothing)
        {
            UnturnedPlayer rp = UnturnedPlayer.FromPlayer(clothing.player);

            OnPlayerWear.TryInvoke(rp, Wearables.Vest, clothing.vest, clothing.vestQuality);
        }