protected override void Update(GameTime gameTime)
 {
     OnPreUpdate.Raise(this, new GameTimeEventArgs(gameTime));
     OnUpdate.Raise(this, new GameTimeEventArgs(gameTime));
     base.Update(gameTime);
     OnPostUpdate.Raise(this, new GameTimeEventArgs(gameTime));
 }
Esempio n. 2
0
        /// <summary>
        ///     Raises the <see cref="E:GameUpdate" /> event.
        /// </summary>
        /// <param name="args">The <see cref="EventArgs" /> instance containing the event data.</param>
        private static void OnGameUpdate(EventArgs args)
        {
            try
            {
                OnPreUpdate?.Invoke(args);

                OnUpdate?.Invoke(args);

                OnPostUpdate?.Invoke(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Updates the GameObject. Applies physics and such.
 /// </summary>
 /// <param name="gameTime">Provides a snapshot of timing values.</param>
 void IGameObject.Update(GameTime gameTime)
 {
     if (OnPreUpdate != null)
     {
         foreach (Func <GameTime, bool> delg in OnPreUpdate.GetInvocationList())
         {
             if (!delg.Invoke(gameTime))
             {
                 return;
             }
         }
     }
     updatePhysics(gameTime);
     OnPostUpdate?.Invoke(gameTime);
 }
Esempio n. 4
0
        /// <summary>
        /// Executes Update events.
        /// </summary>
        internal static void CallUpdateEvents(GameTime gameTime)
        {
            TimeKeeper._elapsedTime = GameMgr.ElapsedTime;

            OnPreUpdate?.Invoke();
            foreach (var scene in Scenes)
            {
                if (scene.Enabled)
                {
                    CurrentScene = scene;

                    scene.Update();
                }
            }
            OnPostUpdate?.Invoke();
        }
Esempio n. 5
0
        private void Update()
        {
            if (m_CurVT.m_ViewTarget == null)
            {
                return;
            }

            if (!m_isWatching)
            {
                ProcessInput();
            }

            UpdateViewInfoExceptRig();

            OnPostUpdate?.Invoke(m_isWatching);
        }
Esempio n. 6
0
 public override void PostUpdate()
 {
     OnPostUpdate?.Invoke();
 }
Esempio n. 7
0
        public override void PreUpdate()
        {
            if (Main.netMode != 2)
            {
                return;
            }
            try
            {
                _timer++;
                if (_timer > 10000000)
                {
                    _timer = 0;
                }
                ServerStarted = true;
                foreach (var player in ServerSideCharacter2.PlayerCollection)
                {
                    if (player.Value.PrototypePlayer == null || !player.Value.PrototypePlayer.active)
                    {
                        player.Value.IsLogin = false;
                        player.Value.SetID(-1);
                    }
                }

                for (var i = 0; i < Main.maxPlayers; i++)
                {
                    if (TileMessageCD[i] > 0)
                    {
                        TileMessageCD[i]--;
                    }
                }
                if (_timer % 300 < 1)
                {
                    foreach (var player in Main.player)
                    {
                        if (!player.active)
                        {
                            continue;
                        }
                        var serverPlayer = player.GetServerPlayer();
                        var playerID     = player.whoAmI;
                        if (serverPlayer == null)
                        {
                            continue;
                        }
                        if (!serverPlayer.HasPassword)
                        {
                            serverPlayer.ApplyLockBuffs();
                            NetMessage.SendChatMessageToClient(NetworkText.FromLiteral("您还没有注册,请使用登录窗口注册哦~"), new Color(255, 255, 30, 30), playerID);
                        }
                        else if (serverPlayer.HasPassword && !serverPlayer.IsLogin)
                        {
                            serverPlayer.ApplyLockBuffs();
                            NetMessage.SendChatMessageToClient(NetworkText.FromLiteral("您已注册,输入密码就可以登录了!"), new Color(255, 255, 30, 30), playerID);
                        }
                    }
                }
                foreach (var p in Main.player)
                {
                    if (p.whoAmI == 255)
                    {
                        continue;
                    }
                    if (!p.active)
                    {
                        continue;
                    }
                    var player = p.GetServerPlayer();
                    if (player == null)
                    {
                        continue;
                    }
                    if (player.IsLogin)
                    {
                        player.SyncPlayerToInfo();
                    }
                    UpdateRegion(p);
                    // CommandBoardcast.ConsoleMessage($"玩家 {player.Name} 物品栏第一 {player.inventory[0].type}");
                }
                ServerSideCharacter2.MatchingSystem.Run();
                OnPostUpdate?.Invoke(this, new EventArgs());
                Ranking.CheckRankBoard();
                if (ServerSideCharacter2.Config.AutoSave && _timer % ServerSideCharacter2.Config.SaveInterval < 1)
                {
                    ThreadPool.QueueUserWorkItem(Do_Save);
                }
            }
            catch (Exception ex)
            {
                CommandBoardcast.ConsoleError(ex);
                WorldFile.saveWorld();
                Netplay.disconnect = true;
                Terraria.Social.SocialAPI.Shutdown();
            }
        }
Esempio n. 8
0
 internal static void RaisePostUpdate()
 {
     OnPostUpdate?.Invoke();
 }