コード例 #1
0
 public override void Update(double delta)
 {
     if (loading)
     {
         if (loader.Update(delta))
         {
             loading = false;
             loader  = null;
             FinishLoad();
         }
         return;
     }
     session.GameplayUpdate(this);
     if (session.Update())
     {
         return;
     }
     if (ShowHud && (Thn == null || !Thn.Running))
     {
         ui.Update(Game);
     }
     if (ui.KeyboardGrabbed)
     {
         Game.EnableTextInput();
     }
     else
     {
         Game.DisableTextInput();
     }
     world.Update(paused ? 0 : delta);
     if (Thn != null && Thn.Running)
     {
         sysrender.Camera = Thn.CameraHandle;
     }
     else
     {
         sysrender.Camera = camera;
     }
     if (frameCount < 2)
     {
         frameCount++;
         if (frameCount == 2)
         {
             session.BeginUpdateProcess();
         }
     }
     else
     {
         if (session.Popups.Count > 0 && session.Popups.TryDequeue(out var popup))
         {
             FLLog.Debug("Space", "Displaying popup");
             if (!session.Multiplayer)
             {
                 paused = true;
             }
             session.Pause();
             ui.Event("Popup", popup.Title, popup.Contents, popup.ID);
         }
     }
 }
コード例 #2
0
        public void _Update(double delta)
        {
            var sound = game.GetService<SoundManager>();
            if (Running)
            {
                var pos = camera.Transform.Position;
                var forward = Vector3.TransformNormal(-Vector3.UnitZ, camera.Transform.Orientation);
                var up = Vector3.TransformNormal(Vector3.UnitY, camera.Transform.Orientation);
                sound.UpdateListener(delta, pos, forward, up);
            }
			currentTime += delta;
            foreach (var obj in sceneObjects.Values) obj.UpdateIfMain();
            if (text != null)
            {
                if (currentTime > text.Start)
                {
                    game.GetService<Interface.Typewriter>().PlayString(gameData.GetString(text.TextIDS));
                    text = null;
                }
            }
            //
            foreach (var instance in instances)
            {
                instance.Update(delta);
            }
            //
            foreach (var obj in sceneObjects.Values) obj.Update();
            camera.Update();
            if(Renderer != null)
			    World.Update(delta);
		}
コード例 #3
0
        public void _Update(TimeSpan delta)
        {
            var sound = game.GetService <SoundManager>();

            if (Running)
            {
                var pos     = camera.Transform.Position;
                var forward = camera.Transform.Orientation.Transform(Vector3.Forward);
                var up      = camera.Transform.Orientation.Transform(Vector3.Up);
                sound.UpdateListener(delta, pos, forward, up);
            }
            currentTime += delta.TotalSeconds;
            for (int i = (Coroutines.Count - 1); i >= 0; i--)
            {
                if (!Coroutines[i].Run(this, delta.TotalSeconds))
                {
                    Coroutines.RemoveAt(i);
                    i--;
                }
            }
            while (events.Count > 0 && events.Peek().Time <= currentTime)
            {
                var ev = events.Dequeue();
                ProcessEvent(ev);
            }
            foreach (var obj in Objects.Values)
            {
                obj.Update();
            }
            camera.Update();
            if (Renderer != null)
            {
                World.Update(delta);
            }
        }
コード例 #4
0
 public void _Update(TimeSpan delta)
 {
     currentTime += delta.TotalSeconds;
     for (int i = (Coroutines.Count - 1); i >= 0; i--)
     {
         if (!Coroutines[i].Run(this, delta.TotalSeconds))
         {
             Coroutines.RemoveAt(i);
             i--;
         }
     }
     while (events.Count > 0 && events.Peek().Time <= currentTime)
     {
         var ev = events.Dequeue();
         ProcessEvent(ev);
     }
     foreach (var obj in Objects.Values)
     {
         obj.Update();
     }
     camera.Update();
     if (Renderer != null)
     {
         World.Update(delta);
     }
 }
コード例 #5
0
ファイル: ServerWorld.cs プロジェクト: Regenhardt/Librelancer
        public bool Update(double delta)
        {
            //Avoid locks during Update
            Action act;

            while (actions.Count > 0 && actions.TryDequeue(out act))
            {
                act();
            }
            //pause
            if (paused)
            {
                return(true);
            }
            TotalTime += delta;
            //Update
            GameWorld.Update(delta);
            //projectiles
            if (GameWorld.Projectiles.HasQueued)
            {
                var queue = GameWorld.Projectiles.GetQueue();
                foreach (var p in Players)
                {
                    p.Key.RemoteClient.SpawnProjectiles(queue);
                }
            }
            //Network update tick
            current  += delta;
            tickTime += delta;
            if (tickTime > (LNetConst.MAX_TICK_MS / 1000.0))
            {
                tickTime -= (LNetConst.MAX_TICK_MS / 1000.0);
            }
            var tick = (uint)(tickTime * 1000.0);

            if (current >= UPDATE_RATE)
            {
                current -= UPDATE_RATE;
                //Send multiplayer updates (less)
                SendPositionUpdates(true, tick);
            }
            SendPositionUpdates(false, tick);
            //Despawn after 2 seconds of nothing
            if (PlayerCount == 0)
            {
                noPlayersTime += delta;
                return(noPlayersTime < maxNoPlayers);
            }
            else
            {
                noPlayersTime = 0;
                return(true);
            }
        }
コード例 #6
0
        public void Update(TimeSpan delta)
        {
            //Avoid locks during Update
            Action act;

            while (actions.Count > 0 && actions.TryDequeue(out act))
            {
                act();
            }
            //Update
            GameWorld.Update(delta);
        }
コード例 #7
0
ファイル: DemoSystemView.cs プロジェクト: gp-alex/Librelancer
 public override void Update(TimeSpan delta)
 {
     if (current_msg != "")
     {
         msg_current_time -= delta.TotalSeconds;
         if (msg_current_time < 0)
         {
             current_msg = "";
         }
     }
     if (!textEntry)
     {
         ProcessInput(delta);
     }
     else
     {
         if (Game.Keyboard.IsKeyDown(Keys.Enter))
         {
             textEntry = false;
             Game.DisableTextInput();
             if (Game.GameData.SystemExists(currentText.Trim()))
             {
                 sys = Game.GameData.GetSystem(currentText.Trim());
                 world.LoadSystem(sys, Game.ResourceManager);
                 camera.Free = false;
                 camera.Update(TimeSpan.FromSeconds(1));
                 camera.Free = true;
                 Game.Sound.PlayMusic(sys.MusicSpace);
             }
             else
             {
                 msg_current_time = MSG_TIMER;
                 current_msg      = string.Format("{0} is not a valid system", currentText.Trim());
             }
         }
         if (Game.Keyboard.IsKeyDown(Keys.Escape))
         {
             textEntry = false;
         }
     }
     camera.Update(delta);
     camera.Free = true;
     world.Update(delta);
 }
コード例 #8
0
ファイル: Cutscene.cs プロジェクト: HaydnTrigg/Librelancer
        public void _Update(TimeSpan delta)
        {
            var sound = game.GetService <SoundManager>();

            if (Running)
            {
                var pos     = camera.Transform.Position;
                var forward = Vector3.TransformNormal(-Vector3.UnitZ, camera.Transform.Orientation);
                var up      = Vector3.TransformNormal(Vector3.UnitY, camera.Transform.Orientation);
                sound.UpdateListener(delta, pos, forward, up);
            }
            currentTime += delta.TotalSeconds;
            if (text != null)
            {
                if (currentTime > text.Start)
                {
                    game.GetService <Interface.Typewriter>().PlayString(gameData.GetString(text.TextIDS));
                    text = null;
                }
            }

            for (int i = (Coroutines.Count - 1); i >= 0; i--)
            {
                if (!Coroutines[i].Run(this, delta.TotalSeconds))
                {
                    Coroutines.RemoveAt(i);
                    i--;
                }
            }
            while (events.Count > 0 && events.Peek().Time <= currentTime)
            {
                var ev = events.Dequeue();
                ProcessEvent(ev);
            }
            foreach (var obj in Objects.Values)
            {
                obj.Update();
            }
            camera.Update();
            if (Renderer != null)
            {
                World.Update(delta);
            }
        }
コード例 #9
0
 public void _Update(TimeSpan delta)
 {
     currentTime += delta.TotalSeconds;
     for (int i = (coroutines.Count - 1); i >= 0; i--)
     {
         if (!coroutines[i].Run(this, delta.TotalSeconds))
         {
             coroutines.RemoveAt(i);
             i--;
         }
     }
     while (events.Count > 0 && events.Peek().Time <= currentTime)
     {
         var ev = events.Dequeue();
         ProcessEvent(ev);
     }
     camera.Update();
     World.Update(delta);
 }
コード例 #10
0
 public override void Update(TimeSpan delta)
 {
     if (loading)
     {
         if (loader.Update(delta))
         {
             loading = false;
             loader  = null;
             FinishLoad();
         }
         return;
     }
     session.GameplayUpdate(this);
     if (session.Update())
     {
         return;
     }
     if (ShowHud && (Thn == null || !Thn.Running))
     {
         ui.Update(Game);
     }
     if (ui.KeyboardGrabbed)
     {
         Game.EnableTextInput();
     }
     else
     {
         Game.DisableTextInput();
     }
     if (Thn != null && Thn.Running)
     {
         Thn.Update(delta);
         sysrender.Camera = Thn.CameraHandle;
     }
     else
     {
         sysrender.Camera = camera;
     }
     world.Update(delta);
 }
コード例 #11
0
        public bool Update(TimeSpan delta)
        {
            //Avoid locks during Update
            Action act;

            while (actions.Count > 0 && actions.TryDequeue(out act))
            {
                act();
            }
            //Update
            GameWorld.Update(delta);
            //Network update tick
            current  += delta.TotalSeconds;
            tickTime += delta.TotalSeconds;
            if (tickTime > (LNetConst.MAX_TICK_MS / 1000.0))
            {
                tickTime -= (LNetConst.MAX_TICK_MS / 1000.0);
            }
            var tick = (uint)(tickTime * 1000.0);

            if (current >= UPDATE_RATE)
            {
                current -= UPDATE_RATE;
                //Send multiplayer updates (less)
                SendPositionUpdates(true, tick);
            }
            //Despawn after 2 seconds of nothing
            if (PlayerCount == 0)
            {
                noPlayersTime += delta;
                return(noPlayersTime < maxNoPlayers);
            }
            else
            {
                noPlayersTime = TimeSpan.Zero;
                return(true);
            }
        }
コード例 #12
0
 public override void Update(TimeSpan delta)
 {
     if (loading)
     {
         if (loader.Update(delta))
         {
             loading = false;
             loader  = null;
             FinishLoad();
         }
         return;
     }
     if (session.Update(this, delta))
     {
         return;
     }
     if (newHud)
     {
         hud.Dispose();
         ConstructHud();
         newHud = false;
     }
     if (ShowHud && (Thn == null || !Thn.Running))
     {
         hud.Update(delta);
     }
     if (Thn != null && Thn.Running)
     {
         Thn.Update(delta);
         sysrender.Camera = Thn.CameraHandle;
     }
     else
     {
         sysrender.Camera = camera;
     }
     world.Update(delta);
 }
コード例 #13
0
 public override void Update(TimeSpan delta)
 {
     //hud.Velocity = Velocity;
     hud.Update(delta, camera);
     world.Update(delta);
 }