Beispiel #1
0
        public static bool send(SteamChannel __instance, string name, ESteamCall mode, Vector3 point, float radius, ESteamPacket type, params object[] arguments)
        {
            var caller = GetCaller();

            if (caller != null && !IsInternal(caller))
            {
                lock (Logger)
                    Logger?.TryRegisterCaller(name, caller, __instance);
                return(!BlockCalls);
            }
            return(true);
        }
Beispiel #2
0
        public void send(string name, ESteamCall mode, byte x, byte y, byte area, ESteamPacket type, params object[] arguments)
        {
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacket(type, call, out size, out packet, arguments);
            this.send(mode, x, y, area, type, size, packet);
        }
Beispiel #3
0
        public void send(string name, ESteamCall mode, ESteamPacket type, byte[] bytes, int length)
        {
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacket(type, call, out size, out packet, bytes, length);
            this.send(mode, type, size, packet);
        }
Beispiel #4
0
        public void sendVoice(string name, ESteamCall mode, Vector3 point, float radius, ESteamPacket type, byte[] bytes, int length)
        {
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacketVoice(type, call, out size, out packet, bytes, length);
            this.send(mode, point, radius, type, size, packet);
        }
Beispiel #5
0
        public void send(string name, ESteamCall mode, Vector3 point, float radius, ESteamPacket type, params object[] arguments)
        {
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacket(type, call, out size, out packet, arguments);
            this.send(mode, point, radius, type, size, packet);
        }
        public void OnTriggerSend(SteamPlayer player, string name, ESteamCall mode, ESteamPacket type, params object[] arguments)
        {
            if (name != "tellVehicleLock")
            {
                return;
            }
            var vehicle = VehicleManager.getVehicle((uint)arguments[0]);

            if (vehicle.asset.engine != EEngine.TRAIN || (bool)arguments[3] == false)
            {
                return;
            }
            UnturnedChat.Say((CSteamID)arguments[1], Translate("trainunlocker_undid_lock"), Color.red);
            StartCoroutine(DelayedUnlockVehicle(vehicle, 1f));
        }
Beispiel #7
0
        public static bool send(SteamChannel __instance, ESteamCall mode, Vector3 point, float radius, ESteamPacket type, int size, byte[] packet)
        {
            if (type == ESteamPacket.KICKED)
            {
                return(true);                             // ID collision bug
            }
            var caller = GetCaller();

            if (caller != null && !IsInternal(caller))
            {
                lock (Logger)
                    Logger?.TryRegisterCaller(type.ToString(), caller, __instance);
                return(!BlockCalls);
            }
            return(true);
        }
Beispiel #8
0
        private void OnTriggerSend(SteamPlayer player, string s, ESteamCall mode, ESteamPacket type, object[] arguments)
        {
            if (s != "askToss")
            {
                return;
            }

            UnturnedPlayer pla = UnturnedPlayer.FromSteamPlayer(player);

            if (!Configuration.Instance.WhitelistedIds.Contains(pla.Player.clothing.glasses))
            {
                return;
            }

            playersToIgnore.Add(pla.CSteamID);
        }
Beispiel #9
0
        public void send(string name, ESteamCall mode, ESteamPacket type, params object[] arguments)
        {
            if (SteamChannel.onTriggerSend != null)
            {
                SteamChannel.onTriggerSend(this.owner, name, mode, type, arguments);
            }
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacket(type, call, out size, out packet, arguments);
            this.send(mode, type, size, packet);
        }
Beispiel #10
0
        public void closeWrite(string name, ESteamCall mode, ESteamPacket type)
        {
            if (!Provider.isChunk(type))
            {
                Debug.LogError("Failed to stream non chunk.");
                return;
            }
            int call = this.getCall(name);

            if (call == -1)
            {
                return;
            }
            int size;

            byte[] packet;
            this.getPacket(type, call, out size, out packet);
            this.send(mode, type, size, packet);
        }
Beispiel #11
0
        internal static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R)
        {
            try
            {
                if (s == null || s.player == null || s.playerID.steamID == CSteamID.Nil || s.player.transform == null || R == null)
                {
                    return;
                }
                Player plr = GamemodeLoader.Utilities.Tools.GetPlayer(s);

                if (W == "tellDeath")
                {
                    ServerEvents.PlayerDeath(plr, (EDeathCause)(byte)R[0], (ELimb)(byte)R[1], new CSteamID(ulong.Parse(R[2].ToString())));
                }
            }
            catch (Exception ex)
            {
                GamemodeLoader.Utilities.Tools.SendConsole(ex + "Failed to receive packet \"" + W + "\"", ConsoleColor.Red);
            }
        }
        private void OnTriggerSend(SteamPlayer player, string name, ESteamCall mode, ESteamPacket type, params object[] arguments)
        {
            if (name == "tellGesture")
            {
                var up = UnturnedPlayer.FromSteamPlayer(player);
                var id = int.Parse(arguments[0].ToString());
                if (id == 8)
                {
                    if (!Configuration.Instance.UsePermissions || up.HasPermission("pickpocket"))
                    {
                        Player victimPlayer = RaycastHelper.GetPlayerFromHits(up.Player, Configuration.Instance.MaxDistance);

                        if (victimPlayer != null)
                        {
                            if (Cooldowns.TryGetValue(up.Id.ToString(), out DateTime expireDate) && expireDate > DateTime.Now)
                            {
                                UnturnedChat.Say(up.CSteamID, Translate("COOLDOWN", System.Math.Truncate((expireDate - DateTime.Now).TotalSeconds)), MessageColor);
                            }
                            else
                            {
                                if (expireDate != null)
                                {
                                    Cooldowns.Remove(up.Id);
                                }
                                UnturnedPlayer victim = UnturnedPlayer.FromPlayer(victimPlayer);
                                if (victim.HasPermission("bypass.pickpocket"))
                                {
                                    UnturnedChat.Say(up, Translate("BYPASS"), MessageColor);
                                    return;
                                }
                                PickpocketComponent comp = up.Player.gameObject.AddComponent <PickpocketComponent>();
                                comp.Initialize(up, victim, this);
                                Cooldowns.Add(up.Id, DateTime.Now.AddSeconds(Configuration.Instance.PickpocketCooldown));
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Sets the position of an audio
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="pos">The target position (local if attached; global if not)</param>
 public void SetPosition(ESteamCall target, AudioHandle handle, Vector3 pos)
 {
     channel.send(nameof(AudioSteamCall_SetPosition), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, pos);
 }
        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);
            }
        }
        internal static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R)
        {
            try
            {
                if (s == null || s.player == null || s.playerID.steamID == CSteamID.Nil || 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)
            {
                Core.Logging.Logger.LogException(ex,"Failed to receive packet \""+W+"\"");
            }
        }
 /// <summary>
 /// Destroys an audio to free resources
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 public void Destroy(ESteamCall target, AudioHandle handle)
 {
     channel.send(nameof(AudioSteamCall_Destroy), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle);
 }
 /// <summary>
 /// Sets the min distance of an audio
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="minDistance">The max distance of the audio</param>
 public void SetMinDistance(ESteamCall target, AudioHandle handle, float minDistance)
 {
     channel.send(nameof(AudioSteamCall_SetMinDistance), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, minDistance);
 }
Beispiel #18
0
 public static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R)
 {
     UnturnedPlayerEvents.TriggerSend(s, W, X, l, R);
 }
 /// <summary>
 /// Sets the interval of when the audio should refresh stream
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="interval">The interval</param>
 public void SetInterval(ESteamCall target, AudioHandle handle, float interval)
 {
     channel.send(nameof(AudioSteamCall_SetInterval), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, interval);
 }
Beispiel #20
0
 public void send(ESteamCall mode, ESteamPacket type, int size, byte[] packet)
 {
     if (mode == ESteamCall.SERVER)
     {
         if (Provider.isServer)
         {
             this.receive(Provider.server, packet, 0, size);
         }
         else
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
     }
     else if (mode == ESteamCall.ALL)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int i = 0; i < Provider.clients.Count; i++)
         {
             if (Provider.clients[i].playerID.steamID != Provider.client)
             {
                 Provider.send(Provider.clients[i].playerID.steamID, type, packet, size, this.id);
             }
         }
         if (Provider.isServer)
         {
             this.receive(Provider.server, packet, 0, size);
         }
         else
         {
             this.receive(Provider.client, packet, 0, size);
         }
     }
     else if (mode == ESteamCall.OTHERS)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int j = 0; j < Provider.clients.Count; j++)
         {
             if (Provider.clients[j].playerID.steamID != Provider.client)
             {
                 Provider.send(Provider.clients[j].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
     else if (mode == ESteamCall.OWNER)
     {
         if (this.isOwner)
         {
             this.receive(this.owner.playerID.steamID, packet, 0, size);
         }
         else
         {
             Provider.send(this.owner.playerID.steamID, type, packet, size, this.id);
         }
     }
     else if (mode == ESteamCall.NOT_OWNER)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int k = 0; k < Provider.clients.Count; k++)
         {
             if (Provider.clients[k].playerID.steamID != this.owner.playerID.steamID)
             {
                 Provider.send(Provider.clients[k].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
     else if (mode == ESteamCall.CLIENTS)
     {
         for (int l = 0; l < Provider.clients.Count; l++)
         {
             if (Provider.clients[l].playerID.steamID != Provider.client)
             {
                 Provider.send(Provider.clients[l].playerID.steamID, type, packet, size, this.id);
             }
         }
         if (Provider.isClient)
         {
             this.receive(Provider.client, packet, 0, size);
         }
     }
     else if (mode == ESteamCall.PEERS)
     {
         for (int m = 0; m < Provider.clients.Count; m++)
         {
             if (Provider.clients[m].playerID.steamID != Provider.client)
             {
                 Provider.send(Provider.clients[m].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
 }
 /// <summary>
 /// Destroys all audio objects
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 public void DestroyAll(ESteamCall target)
 {
     channel.send(nameof(AudioSteamCall_DestroyAll), target, ESteamPacket.UPDATE_RELIABLE_BUFFER);
 }
 /// <summary>
 ///	Sets the spread angle to 3D stereo or multichannel sound in speaker space.
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="spread">Spread amount</param>
 public void SetSpread(ESteamCall target, AudioHandle handle, float spread)
 {
     channel.send(nameof(AudioSteamCall_SetSpread), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, spread);
 }
 /// <summary>
 /// Mutes or unmutes an audio
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="mute">Mute audio?</param>
 public void SetMute(ESteamCall target, AudioHandle handle, bool mute)
 {
     channel.send(nameof(AudioSteamCall_SetMute), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, mute);
 }
 /// <summary>
 /// Sets the volume of an audio
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="volume">The volume to set</param>
 public void SetVolume(ESteamCall target, AudioHandle handle, float volume)
 {
     channel.send(nameof(AudioSteamCall_SetVolume), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, volume);
 }
 public static void TriggerSend(SteamPlayer s, string W, ESteamCall X, ESteamPacket l, params object[] R)
 {
     UnturnedPlayerEvents.TriggerSend(s, W, X, l, R);
 }
 /// <summary>
 ///	Determines how much doppler effect will be applied to this audio source (if is set to 0, then no effect is applied
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="level">Doppler level</param>
 public void SetDopplerLevel(ESteamCall target, AudioHandle handle, float level)
 {
     channel.send(nameof(AudioSteamCall_SetDopplerLevel), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, level);
 }
 /// <summary>
 /// Attaches an audio to a vehicle (position gets reset)
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="targetVehicle">The id of the vehicle to attach to</param>
 public void AttachToVehicle(ESteamCall target, AudioHandle handle, InteractableVehicle targetVehicle)
 {
     channel.send(nameof(AudioSteamCall_AttachToVehicle), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, targetVehicle.instanceID);
 }
 /// <summary>
 /// Sets if an audio should loop
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="loop">Loop audio?</param>
 public void SetLoop(ESteamCall target, AudioHandle handle, bool loop)
 {
     channel.send(nameof(AudioSteamCall_SetLoop), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, loop);
 }
 /// <summary>
 /// Attaches an audio to a player (position gets reset)
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="targetPlayer">The player to attach to</param>
 public void AttachToPlayer(ESteamCall target, AudioHandle handle, SteamPlayer targetPlayer)
 {
     channel.send(nameof(AudioSteamCall_AttachToPlayer), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, targetPlayer.playerID.steamID);
 }
Beispiel #30
0
 public void send(ESteamCall mode, Vector3 point, float radius, ESteamPacket type, int size, byte[] packet)
 {
     radius *= radius;
     if (mode == ESteamCall.SERVER)
     {
         if (Provider.isServer)
         {
             this.receive(Provider.server, packet, 0, size);
         }
         else
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
     }
     else if (mode == ESteamCall.ALL)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int i = 0; i < Provider.clients.Count; i++)
         {
             if (Provider.clients[i].playerID.steamID != Provider.client && Provider.clients[i].player != null && (Provider.clients[i].player.transform.position - point).sqrMagnitude < radius)
             {
                 Provider.send(Provider.clients[i].playerID.steamID, type, packet, size, this.id);
             }
         }
         if (Provider.isServer)
         {
             this.receive(Provider.server, packet, 0, size);
         }
         else
         {
             this.receive(Provider.client, packet, 0, size);
         }
     }
     else if (mode == ESteamCall.OTHERS)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int j = 0; j < Provider.clients.Count; j++)
         {
             if (Provider.clients[j].playerID.steamID != Provider.client && Provider.clients[j].player != null && (Provider.clients[j].player.transform.position - point).sqrMagnitude < radius)
             {
                 Provider.send(Provider.clients[j].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
     else if (mode == ESteamCall.OWNER)
     {
         if (this.isOwner)
         {
             this.receive(this.owner.playerID.steamID, packet, 0, size);
         }
         else
         {
             Provider.send(this.owner.playerID.steamID, type, packet, size, this.id);
         }
     }
     else if (mode == ESteamCall.NOT_OWNER)
     {
         if (!Provider.isServer)
         {
             Provider.send(Provider.server, type, packet, size, this.id);
         }
         for (int k = 0; k < Provider.clients.Count; k++)
         {
             if (Provider.clients[k].playerID.steamID != this.owner.playerID.steamID && Provider.clients[k].player != null && (Provider.clients[k].player.transform.position - point).sqrMagnitude < radius)
             {
                 Provider.send(Provider.clients[k].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
     else if (mode == ESteamCall.CLIENTS)
     {
         for (int l = 0; l < Provider.clients.Count; l++)
         {
             if (Provider.clients[l].playerID.steamID != Provider.client && Provider.clients[l].player != null && (Provider.clients[l].player.transform.position - point).sqrMagnitude < radius)
             {
                 Provider.send(Provider.clients[l].playerID.steamID, type, packet, size, this.id);
             }
         }
         if (Provider.isClient)
         {
             this.receive(Provider.client, packet, 0, size);
         }
     }
     else if (mode == ESteamCall.PEERS)
     {
         for (int m = 0; m < Provider.clients.Count; m++)
         {
             if (Provider.clients[m].playerID.steamID != Provider.client && Provider.clients[m].player != null && (Provider.clients[m].player.transform.position - point).sqrMagnitude < radius)
             {
                 Provider.send(Provider.clients[m].playerID.steamID, type, packet, size, this.id);
             }
         }
     }
 }
Beispiel #31
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 + "\"");
            }
        }
 /// <summary>
 /// Sets the audio rolloff mode. Custom is not supported.
 /// </summary>
 /// <param name="target">The SteamCall target</param>
 /// <param name="handle">The audio handle</param>
 /// <param name="mode">The target audio rolloff mode</param>
 public void SetRolloffMode(ESteamCall target, AudioHandle handle, AudioRolloffMode mode)
 {
     channel.send(nameof(AudioSteamCall_SetRolloffMode), target, ESteamPacket.UPDATE_RELIABLE_BUFFER, (int)handle, (int)mode);
 }