Beispiel #1
0
        public void OnUdpUpdatePlayers(Packet packet)
        {
            List <PlayerData> playerData = new List <PlayerData>();

            while (packet.ReadBool())
            {
                int idPlayer = packet.ReadInt();
                if (client.PlayersData.ContainsKey(idPlayer))
                {
                    playerData.Add(new PlayerData(idPlayer)
                    {
                        ServerPosition = new Vector2(packet.ReadFloat(),
                                                     packet.ReadFloat()),
                        LookAtRadian = packet.ReadFloat(),
                        FeetRadian   = packet.ReadFloat()
                    });
                    //Debug.WriteLine(Client.PlayersData[idPlayer].ToString());
                }
                else
                {
                    //Debug.WriteLine("Un sync from the server, might lag a little while re syncing ");
                }
            }
            PlayerUpdateEventArgs e = new PlayerUpdateEventArgs()
            {
                MessageType = MessageType.OnUdpUpdatePlayers,
                Packet      = packet,
                Protocol    = Protocol.UDP,
                PlayerData  = playerData.ToArray(),
                RequestType = RequestType.Receive,
            };

            client.PacketReceived(e);
        }
Beispiel #2
0
        public override void OnUpdate(PlayerUpdateEventArgs e)
        {
            base.OnUpdate(e);

            if (this.Vehicle != null)
            {
                if (((Vehicle)this.Vehicle).Data.Fuel == 0)
                {
                    this.Vehicle.Engine = false;
                }
            }
            if (this.ActiveCharacter != null)
            {
                if (this.ActiveCharacter.ItemInHand != null)
                {
                    if (this.ActiveCharacter.ItemInHand is Gun)
                    {
                        if (this.ActiveCharacter.ItemInHand.Quantity == 0)
                        {
                            ItemHelper.RemoveItemFromPlayerHand(this);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        internal static bool OnUpdate(int npcid)
        {
            var fcnpc = Find(npcid);
            var e     = new PlayerUpdateEventArgs();

            fcnpc?.Update?.Invoke(fcnpc, e);
            return(!e.PreventPropagation);
        }
Beispiel #4
0
        internal bool OnPlayerUpdate(int playerid)
        {
            var args = new PlayerUpdateEventArgs();

            OnPlayerUpdate(BasePlayer.FindOrCreate(playerid), args);

            return(!args.PreventPropagation);
        }
Beispiel #5
0
            /// <summary>
            /// Invokes the Player PostUpdatePlayer event.
            /// </summary>
            /// <param name="player"></param>
            public static void InvokePostUpdatePlayer(dynamic player)
            {
                var args = new PlayerUpdateEventArgs
                {
                    Player = player
                };

                PostUpdatePlayer.Invoke(args);
            }
Beispiel #6
0
        private Task PlayerUpdated(PlayerUpdateEventArgs playerUpdateEventArgs)
        {
            TrackListAsync(playerUpdateEventArgs.Player).Wait();
            UpdateVote(playerUpdateEventArgs.Player).Wait();
            UpdatePing(playerUpdateEventArgs.Player).Wait();
            TimeAsync(playerUpdateEventArgs.Player).Wait();
            UpdateTrack(playerUpdateEventArgs.Player).Wait();

            return(Task.CompletedTask);
        }
Beispiel #7
0
        public override void OnUpdate(PlayerUpdateEventArgs e)
        {
            base.OnUpdate(e);

            if (IsPaused)
            {
                OnResumed(new ResumeEventArgs(PausedTime));
            }

            _tick = Server.GetTickCount();
        }
    protected override void OnPlayerUpdate(BasePlayer sender, PlayerUpdateEventArgs e)
    {
        var player = sender as Player;

        if (player.SpeedTime != 0 && player.SpeedTime < Time.GetTime())
        {
            player.ClearAnimations();
            player.SpeedTime = 0;
        }
        if (player.InvisibleTime != 0 && player.InvisibleTime < Time.GetTime())
        {
            player.DisableInvisibility();
            player.InvisibleTime = 0;
        }
    }
 void player_PlayerUpdate(object sender, PlayerUpdateEventArgs e)
 {
     if (this.Dispatcher.CheckAccess())
     {
         try
         {
             MoneyDisplay.Text = "Cash: $" + LocalPlayer.Money;
             PropertyDisplay.Text = String.Empty;
             SortedDictionary<int, PropertyListing>.ValueCollection Dict = LocalPlayer.GetProperties();
             foreach (PropertyListing pl in Dict)
             {
                 PropertyDisplay.Inlines.Add(new Run(pl.Name));
                 PropertyDisplay.Inlines.Add(new LineBreak());
             }
             if (Dict == null || Dict.Count == 0)
             {
                 PropertyDisplay.Inlines.Add(new Run("No Properties Owned"));
                 PropertyDisplay.Inlines.Add(new LineBreak());
             }
         }
         catch (Exception) { }
     }
     else this.Dispatcher.BeginInvoke(new Action<object, PlayerUpdateEventArgs>(player_PlayerUpdate), new object[] { sender, e });
 }
Beispiel #10
0
        internal void OnPlayerUpdate(object sender, PlayerUpdateEventArgs args)
        {
            DisableFlags disableFlags = TShock.Config.Settings.DisableSecondUpdateLogs ? DisableFlags.WriteToConsole : DisableFlags.WriteToLogAndConsole;
            bool         useItem      = args.Control.IsUsingItem;
            TSPlayer     player       = args.Player;
            string       itemName     = player.TPlayer.inventory[args.SelectedItem].Name;

            if (DataModel.ItemIsBanned(EnglishLanguage.GetItemNameById(player.TPlayer.inventory[args.SelectedItem].netID), args.Player))
            {
                player.TPlayer.controlUseItem = false;
                player.Disable($"holding banned item: {itemName}", disableFlags);

                SendCorrectiveMessage(player, itemName);

                player.TPlayer.Update(player.TPlayer.whoAmI);
                NetMessage.SendData((int)PacketTypes.PlayerUpdate, -1, player.Index, NetworkText.Empty, player.Index);

                args.Handled = true;
                return;
            }

            args.Handled = false;
            return;
        }
Beispiel #11
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 {
     _logger.ConsoleMusicLog($"Player update received for {arg.Player.VoiceChannel.Name}.");
     return(Task.CompletedTask);
 }
Beispiel #12
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 {
     //Console.WriteLine(arg.Track.Title);
     //Console.WriteLine($"Player update received for {arg.Player.VoiceChannel.Name}.");
     return(Task.CompletedTask);
 }
Beispiel #13
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 => this.LogAsync(new LogMessage(LogSeverity.Info, "Victoria", $"Player update received for {arg.Player.VoiceChannel.Name}.", null));
Beispiel #14
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 {
     return(Task.CompletedTask);
 }
Beispiel #15
0
 /// <summary>
 /// Invokes the Player PostUpdatePlayer event.
 /// </summary>
 /// <param name="player"></param>
 public static void InvokePostUpdatePlayer(dynamic player)
 {
     var args = new PlayerUpdateEventArgs
         {
             Player = player
         };
     PostUpdatePlayer.Invoke(args);
 }
Beispiel #16
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 {
     _logger.LogInformation($"Track update received for {arg.Track.Title}: {arg.Position}");
     return(Task.CompletedTask);
 }
Beispiel #17
0
 private Task OnPlayerUpdated(PlayerUpdateEventArgs arg)
 {
     this._logger.LogDebug($"Player update received for {arg.Player.VoiceChannel.Name}.");
     return(Task.CompletedTask);
 }
Beispiel #18
0
        private static bool OnPlayerUpdate(byte player, byte control, byte item, Vector2 position, Vector2 velocity, byte pulley)
        {
            if (PlayerUpdate == null)
                return false;

            var args = new PlayerUpdateEventArgs
            {
                PlayerId = player,
                Control = control,
                Item = item,
                Position = position,
                Velocity = velocity,
                Pulley = pulley
            };
            PlayerUpdate.Invoke(null, args);
            return args.Handled;
        }
Beispiel #19
0
 private async Task PlayerUpdatedAsync(PlayerUpdateEventArgs arg)
 {
     await _logger.LogMessage(new LogMessage(LogSeverity.Info,
                                             "AudioManager",
                                             $"Player update received for {arg.Player.VoiceChannel.Name}."));
 }