3 using Microsoft.Xna.Framework;
4 using System.Threading;
5 using FarseerPhysics.Dynamics;
8 using Microsoft.Xna.Framework.Input;
15 private object updateLock =
new object();
16 private double physicsTime;
19 private readonly
Camera cam;
28 get {
return Camera.Instance; }
42 cam.Translate(
new Vector2(-10.0f, 50.0f));
54 cam.UpdateTransform(
true);
59 cam.UpdateTransform(
true);
66 #if RUN_PHYSICS_IN_SEPARATE_THREAD
67 var physicsThread =
new Thread(ExecutePhysics)
69 Name =
"Physics thread",
72 physicsThread.Start();
80 var config = GameSettings.CurrentConfig;
83 GameSettings.SetCurrentConfig(config);
84 GameSettings.SaveCurrentConfig();
90 DebugConsole.DeactivateCheats();
99 public override void Update(
double deltaTime)
101 #if RUN_PHYSICS_IN_SEPARATE_THREAD
102 physicsTime += deltaTime;
109 if (
GameMain.
GameSession !=
null && !DebugConsole.IsOpen && GUI.KeyboardDispatcher.Subscriber ==
null)
115 Vector2 targetMovement = Vector2.Zero;
121 if (targetMovement != Vector2.Zero)
142 var sw =
new System.Diagnostics.Stopwatch();
166 if (controlled.SelectedItem !=
null && controlled.CanInteractWith(controlled.SelectedItem))
168 controlled.SelectedItem.UpdateHUD(cam, controlled, (
float)deltaTime);
170 if (controlled.Inventory !=
null)
172 foreach (
Item item
in controlled.Inventory.AllItems)
174 if (controlled.HasEquippedItem(item))
176 item.
UpdateHUD(cam, controlled, (
float)deltaTime);
207 Vector2 targetPos = Lights.LightManager.ViewTarget.WorldPosition;
221 screenOffset.Y = -screenOffset.Y;
222 targetPos -= screenOffset / cam.Zoom;
224 cam.TargetPos = targetPos;
272 sub.
Update((
float)deltaTime);
281 #if !RUN_PHYSICS_IN_SEPARATE_THREAD
286 catch (WorldLockedException e)
288 string errorMsg =
"Attempted to modify the state of the physics simulation while a time step was running.";
289 DebugConsole.ThrowError(errorMsg, e);
290 GameAnalyticsManager.AddErrorEventOnce(
"GameScreen.Update:WorldLockedException" + e.Message, GameAnalyticsManager.ErrorSeverity.Critical, errorMsg);
299 UpdateProjSpecific(deltaTime);
301 #if RUN_PHYSICS_IN_SEPARATE_THREAD
306 partial
void UpdateProjSpecific(
double deltaTime);
308 private void ExecutePhysics()
312 while (physicsTime >= Timing.Step)
317 physicsTime -= Timing.Step;
static CharacterHealth?? OpenHealthWindow
static void UpdateAnimAll(float deltaTime)
static Character? Controlled
void UpdateLocalCursor(Camera cam)
static void UpdateAll(float deltaTime, Camera cam)
static bool PreferChatBoxOpen
Triggers a "conversation popup" with text and support for different branching options.
Responsible for keeping track of the characters in the player crew, saving and loading their orders,...
static bool PreferCrewMenuOpen
static bool? IsCommandInterfaceOpen
virtual Vector2 WorldPosition
static GameSession?? GameSession
static PerformanceCounter PerformanceCounter
static int GraphicsHeight
static Lights.LightManager LightManager
static ParticleManager ParticleManager
static Sounds.SoundManager SoundManager
override void Update(double deltaTime)
Allows the game to run logic such as updating the world, checking for collisions, gathering input,...
void Update(float deltaTime)
static bool IsMouseOnInventory
void UpdateHUD(Camera cam, Character character, float deltaTime)
void Update(float deltaTime, Camera cam)
static void UpdateAll(float deltaTime, Camera cam)
Call Update() on every object in Entity.list
static void ClearHighlightedEntities()
void SetPrevTransform(Vector2 simPosition, float rotation)
static List< PhysicsBody > List
static void UpdateAll(float deltaTime, Camera cam)
StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in ...
static void UpdateAll(float deltaTime)
readonly PhysicsBody Body
void SetPrevTransform(Vector2 position)
override Vector2? WorldPosition
void Update(float deltaTime)
static List< Submarine > Loaded
void ApplyForce(Vector2 force)
override Vector2? Position
static Submarine FindClosest(Vector2 worldPosition, bool ignoreOutposts=false, bool ignoreOutsideLevel=true, bool ignoreRespawnShuttle=false, CharacterTeamType? teamType=null)
If has value, the sub must match the team type.