Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Screens/GameScreen.cs
2 using Barotrauma.Lights;
3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
5 using System;
6 using System.Diagnostics;
7 using System.Linq;
8 
9 namespace Barotrauma
10 {
11  partial class GameScreen : Screen
12  {
13  private RenderTarget2D renderTargetBackground;
14  private RenderTarget2D renderTarget;
15  private RenderTarget2D renderTargetWater;
16  private RenderTarget2D renderTargetFinal;
17 
18  public readonly Effect DamageEffect;
19  private readonly Texture2D damageStencil;
20  private readonly Texture2D distortTexture;
21 
22  private float fadeToBlackState;
23 
24  public Effect PostProcessEffect { get; private set; }
25  public Effect GradientEffect { get; private set; }
26  public Effect GrainEffect { get; private set; }
27  public Effect ThresholdTintEffect { get; private set; }
28  public Effect BlueprintEffect { get; set; }
29 
30  public GameScreen(GraphicsDevice graphics)
31  {
32  cam = new Camera();
33  cam.Translate(new Vector2(-10.0f, 50.0f));
34 
35  CreateRenderTargets(graphics);
37  {
38  CreateRenderTargets(graphics);
39  };
40 
41  //var blurEffect = LoadEffect("Effects/blurshader");
42  DamageEffect = EffectLoader.Load("Effects/damageshader");
43  PostProcessEffect = EffectLoader.Load("Effects/postprocess");
44  GradientEffect = EffectLoader.Load("Effects/gradientshader");
45  GrainEffect = EffectLoader.Load("Effects/grainshader");
46  ThresholdTintEffect = EffectLoader.Load("Effects/thresholdtint");
47  BlueprintEffect = EffectLoader.Load("Effects/blueprintshader");
48 
49  damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
50  DamageEffect.Parameters["xStencil"].SetValue(damageStencil);
51  DamageEffect.Parameters["aMultiplier"].SetValue(50.0f);
52  DamageEffect.Parameters["cMultiplier"].SetValue(200.0f);
53 
54  distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png");
55  PostProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture);
56  }
57 
58  private void CreateRenderTargets(GraphicsDevice graphics)
59  {
60  renderTarget?.Dispose();
61  renderTargetBackground?.Dispose();
62  renderTargetWater?.Dispose();
63  renderTargetFinal?.Dispose();
64  renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
65  renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
66  renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
67  renderTargetFinal = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None);
68  }
69 
70  public override void AddToGUIUpdateList()
71  {
72  if (Character.Controlled != null)
73  {
74  if (Character.Controlled.SelectedItem is { } selectedItem && Character.Controlled.CanInteractWith(selectedItem))
75  {
76  selectedItem.AddToGUIUpdateList();
77  }
78  if (Character.Controlled.SelectedSecondaryItem is { } selectedSecondaryItem && Character.Controlled.CanInteractWith(selectedSecondaryItem))
79  {
80  selectedSecondaryItem.AddToGUIUpdateList();
81  }
82  if (Character.Controlled.Inventory != null)
83  {
84  foreach (Item item in Character.Controlled.Inventory.AllItems)
85  {
87  {
88  item.AddToGUIUpdateList();
89  }
90  }
91  }
92  }
95  base.AddToGUIUpdateList();
96  }
97 
98  public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
99  {
100  cam.UpdateTransform(true);
101  Submarine.CullEntities(cam);
102 
103  foreach (Character c in Character.CharacterList)
104  {
105  c.AnimController.Limbs.ForEach(l => l.body.UpdateDrawPosition());
106  bool wasVisible = c.IsVisible;
107  c.DoVisibilityCheck(cam);
108  if (c.IsVisible != wasVisible)
109  {
110  foreach (var limb in c.AnimController.Limbs)
111  {
112  if (limb.LightSource is LightSource light)
113  {
114  light.Enabled = c.IsVisible;
115  }
116  }
117  }
118  }
119 
120  Stopwatch sw = new Stopwatch();
121  sw.Start();
122 
123  DrawMap(graphics, spriteBatch, deltaTime);
124 
125  sw.Stop();
126  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map", sw.ElapsedTicks);
127  sw.Restart();
128 
129  spriteBatch.Begin(SpriteSortMode.Deferred, null, GUI.SamplerState, null, GameMain.ScissorTestEnable);
130 
131  if (Character.Controlled != null && cam != null) { Character.Controlled.DrawHUD(spriteBatch, cam); }
132 
133  if (GameMain.GameSession != null) { GameMain.GameSession.Draw(spriteBatch); }
134 
135  if (Character.Controlled == null && !GUI.DisableHUD)
136  {
137  for (int i = 0; i < Submarine.MainSubs.Length; i++)
138  {
139  if (Submarine.MainSubs[i] == null) continue;
140  if (Level.Loaded != null && Submarine.MainSubs[i].WorldPosition.Y < Level.MaxEntityDepth) { continue; }
141 
143 
144  Color indicatorColor = i == 0 ? Color.LightBlue * 0.5f : GUIStyle.Red * 0.5f;
145  GUI.DrawIndicator(
146  spriteBatch, position, cam,
147  Math.Max(Submarine.MainSub.Borders.Width, Submarine.MainSub.Borders.Height),
148  GUIStyle.SubmarineLocationIcon.Value.Sprite, indicatorColor);
149  }
150  }
151 
152  if (!GUI.DisableHUD)
153  {
154  foreach (Character c in Character.CharacterList)
155  {
156  c.DrawGUIMessages(spriteBatch, cam);
157  }
158  }
159 
160  GUI.Draw(cam, spriteBatch);
161 
162  spriteBatch.End();
163 
164  sw.Stop();
165  GameMain.PerformanceCounter.AddElapsedTicks("Draw:HUD", sw.ElapsedTicks);
166  sw.Restart();
167  }
168 
169  public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch, double deltaTime)
170  {
171  foreach (Submarine sub in Submarine.Loaded)
172  {
173  sub.UpdateTransform();
174  }
175 
176  GameMain.ParticleManager.UpdateTransforms();
177 
178  Stopwatch sw = new Stopwatch();
179  sw.Start();
180 
181  if (Character.Controlled != null &&
183  {
185  }
186  else
187  {
189  }
190 
191  GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled?.CursorWorldPosition ?? Vector2.Zero);
192 
193  sw.Stop();
194  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:LOS", sw.ElapsedTicks);
195  sw.Restart();
196 
197 
198  static bool IsFromOutpostDrawnBehindSubs(Entity e)
199  => e.Submarine is { Info.OutpostGenerationParams.DrawBehindSubs: true };
200 
201  //------------------------------------------------------------------------
202  graphics.SetRenderTarget(renderTarget);
203  graphics.Clear(Color.Transparent);
204  //Draw background structures and wall background sprites
205  //(= the background texture that's revealed when a wall is destroyed) into the background render target
206  //These will be visible through the LOS effect.
207  spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
208  Submarine.DrawBack(spriteBatch, false, e => e is Structure s && (e.SpriteDepth >= 0.9f || s.Prefab.BackgroundSprite != null) && !IsFromOutpostDrawnBehindSubs(e));
209  Submarine.DrawPaintedColors(spriteBatch, false);
210  spriteBatch.End();
211 
212  sw.Stop();
213  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackStructures", sw.ElapsedTicks);
214  sw.Restart();
215 
216  graphics.SetRenderTarget(null);
217  GameMain.LightManager.RenderLightMap(graphics, spriteBatch, cam, renderTarget);
218 
219  sw.Stop();
220  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:Lighting", sw.ElapsedTicks);
221  sw.Restart();
222 
223  //------------------------------------------------------------------------
224  graphics.SetRenderTarget(renderTargetBackground);
225  if (Level.Loaded == null)
226  {
227  graphics.Clear(new Color(11, 18, 26, 255));
228  }
229  else
230  {
231  //graphics.Clear(new Color(255, 255, 255, 255));
232  Level.Loaded.DrawBack(graphics, spriteBatch, cam);
233  }
234 
235  spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
236  Submarine.DrawBack(spriteBatch, false, e => e is Structure s && (e.SpriteDepth >= 0.9f || s.Prefab.BackgroundSprite != null) && IsFromOutpostDrawnBehindSubs(e));
237  spriteBatch.End();
238 
239  //draw alpha blended particles that are in water and behind subs
240 #if LINUX || OSX
241  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
242 #else
243  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
244 #endif
245  GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend);
246  spriteBatch.End();
247 
248  //draw additive particles that are in water and behind subs
249  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.None, null, null, cam.Transform);
250  GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive);
251  spriteBatch.End();
252  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None);
253  spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
254  spriteBatch.End();
255 
256  sw.Stop();
257  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackLevel", sw.ElapsedTicks);
258  sw.Restart();
259 
260  //----------------------------------------------------------------------------
261 
262  //Start drawing to the normal render target (stuff that can't be seen through the LOS effect)
263  graphics.SetRenderTarget(renderTarget);
264 
265  graphics.BlendState = BlendState.NonPremultiplied;
266  graphics.SamplerStates[0] = SamplerState.LinearWrap;
267  GraphicsQuad.UseBasicEffect(renderTargetBackground);
268  GraphicsQuad.Render();
269 
270  //Draw the rest of the structures, characters and front structures
271  spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
272  Submarine.DrawBack(spriteBatch, false, e => !(e is Structure) || e.SpriteDepth < 0.9f);
273  DrawCharacters(deformed: false, firstPass: true);
274  spriteBatch.End();
275 
276  sw.Stop();
277  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:BackCharactersItems", sw.ElapsedTicks);
278  sw.Restart();
279 
280  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
281  DrawCharacters(deformed: true, firstPass: true);
282  DrawCharacters(deformed: true, firstPass: false);
283  DrawCharacters(deformed: false, firstPass: false);
284  spriteBatch.End();
285 
286  void DrawCharacters(bool deformed, bool firstPass)
287  {
288  //backwards order to render the most recently spawned characters in front (characters spawned later have a larger sprite depth)
289  for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
290  {
292  if (!c.IsVisible) { continue; }
293  if (c.Params.DrawLast == firstPass) { continue; }
294  if (deformed)
295  {
296  if (c.AnimController.Limbs.All(l => l.DeformSprite == null)) { continue; }
297  }
298  else
299  {
300  if (c.AnimController.Limbs.Any(l => l.DeformSprite != null)) { continue; }
301  }
302  c.Draw(spriteBatch, Cam);
303  }
304  }
305 
306  sw.Stop();
307  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:DeformableCharacters", sw.ElapsedTicks);
308  sw.Restart();
309 
310  Level.Loaded?.DrawFront(spriteBatch, cam);
311 
312  sw.Stop();
313  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontLevel", sw.ElapsedTicks);
314  sw.Restart();
315 
316  //draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
317  graphics.SetRenderTarget(renderTargetWater);
318 
319  graphics.BlendState = BlendState.Opaque;
320  graphics.SamplerStates[0] = SamplerState.LinearWrap;
321  GraphicsQuad.UseBasicEffect(renderTarget);
322  GraphicsQuad.Render();
323 
324  //draw alpha blended particles that are inside a sub
325  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
326  GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
327  spriteBatch.End();
328 
329  graphics.SetRenderTarget(renderTarget);
330 
331  //draw alpha blended particles that are not in water
332  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
333  GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.AlphaBlend);
334  spriteBatch.End();
335 
336  //draw additive particles that are not in water
337  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.None, null, null, cam.Transform);
338  GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
339  spriteBatch.End();
340 
341  graphics.DepthStencilState = DepthStencilState.DepthRead;
342  graphics.SetRenderTarget(renderTargetFinal);
343 
346  WaterRenderer.Instance.RenderWater(spriteBatch, renderTargetWater, cam);
347  WaterRenderer.Instance.RenderAir(graphics, cam, renderTarget, Cam.ShaderTransform);
348  graphics.DepthStencilState = DepthStencilState.None;
349 
350  sw.Stop();
351  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontParticles", sw.ElapsedTicks);
352  sw.Restart();
353 
354  DamageEffect.CurrentTechnique = DamageEffect.Techniques["StencilShader"];
355  spriteBatch.Begin(SpriteSortMode.Immediate,
356  BlendState.NonPremultiplied, SamplerState.LinearWrap,
357  null, null,
358  DamageEffect,
359  cam.Transform);
360  Submarine.DrawDamageable(spriteBatch, DamageEffect, false);
361  spriteBatch.End();
362 
363  sw.Stop();
364  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontDamageable", sw.ElapsedTicks);
365  sw.Restart();
366 
367  spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
368  Submarine.DrawFront(spriteBatch, false, null);
369  spriteBatch.End();
370 
371  sw.Stop();
372  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontStructuresItems", sw.ElapsedTicks);
373  sw.Restart();
374 
375  //draw additive particles that are inside a sub
376  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
377  GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
378  foreach (var discharger in Items.Components.ElectricalDischarger.List)
379  {
380  discharger.DrawElectricity(spriteBatch);
381  }
382  spriteBatch.End();
384  {
385  graphics.DepthStencilState = DepthStencilState.None;
386  graphics.SamplerStates[0] = SamplerState.LinearWrap;
387  graphics.BlendState = CustomBlendStates.Multiplicative;
388  GraphicsQuad.UseBasicEffect(GameMain.LightManager.LightMap);
389  GraphicsQuad.Render();
390  }
391 
392  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.None, null, null, cam.Transform);
393  foreach (Character c in Character.CharacterList)
394  {
395  c.DrawFront(spriteBatch, cam);
396  }
397 
399 
400  Level.Loaded?.DrawDebugOverlay(spriteBatch, cam);
401  if (GameMain.DebugDraw)
402  {
403  MapEntity.MapEntityList.ForEach(me => me.AiTarget?.Draw(spriteBatch));
404  Character.CharacterList.ForEach(c => c.AiTarget?.Draw(spriteBatch));
405  if (GameMain.GameSession?.EventManager != null)
406  {
408  }
409  }
410  spriteBatch.End();
411 
412  sw.Stop();
413  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:FrontMisc", sw.ElapsedTicks);
414  sw.Restart();
415 
416  if (GameMain.LightManager.LosEnabled && GameMain.LightManager.LosMode != LosMode.None && Lights.LightManager.ViewTarget != null)
417  {
418  GameMain.LightManager.LosEffect.CurrentTechnique = GameMain.LightManager.LosEffect.Techniques["LosShader"];
419 
420  GameMain.LightManager.LosEffect.Parameters["blurDistance"].SetValue(0.005f);
421  GameMain.LightManager.LosEffect.Parameters["xTexture"].SetValue(renderTargetBackground);
422  GameMain.LightManager.LosEffect.Parameters["xLosTexture"].SetValue(GameMain.LightManager.LosTexture);
423  GameMain.LightManager.LosEffect.Parameters["xLosAlpha"].SetValue(GameMain.LightManager.LosAlpha);
424 
425  Color losColor;
426  if (GameMain.LightManager.LosMode == LosMode.Transparent)
427  {
428  //convert the los color to HLS and make sure the luminance of the color is always the same
429  //as the luminance of the ambient light color
430  float r = Character.Controlled?.CharacterHealth == null ?
431  0.0f : Math.Min(Character.Controlled.CharacterHealth.DamageOverlayTimer * 0.5f, 0.5f);
432  Vector3 ambientLightHls = GameMain.LightManager.AmbientLight.RgbToHLS();
433  Vector3 losColorHls = Color.Lerp(GameMain.LightManager.AmbientLight, Color.Red, r).RgbToHLS();
434  losColorHls.Y = ambientLightHls.Y;
435  losColor = ToolBox.HLSToRGB(losColorHls);
436  }
437  else
438  {
439  losColor = Color.Black;
440  }
441 
442  GameMain.LightManager.LosEffect.Parameters["xColor"].SetValue(losColor.ToVector4());
443 
444  graphics.BlendState = BlendState.NonPremultiplied;
445  graphics.SamplerStates[0] = SamplerState.PointClamp;
446  graphics.SamplerStates[1] = SamplerState.PointClamp;
447  GameMain.LightManager.LosEffect.CurrentTechnique.Passes[0].Apply();
448  GraphicsQuad.Render();
449  graphics.SamplerStates[0] = SamplerState.LinearWrap;
450  graphics.SamplerStates[1] = SamplerState.LinearWrap;
451  }
452 
453  if (Character.Controlled is { } character)
454  {
455  float grainStrength = character.GrainStrength;
457  spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, effect: GrainEffect);
458  GUI.DrawRectangle(spriteBatch, screenRect, Color.White, isFilled: true);
459  GrainEffect.Parameters["seed"].SetValue(Rand.Range(0f, 1f, Rand.RandSync.Unsynced));
460  GrainEffect.Parameters["intensity"].SetValue(grainStrength);
461  GrainEffect.Parameters["grainColor"].SetValue(character.GrainColor.ToVector4());
462  spriteBatch.End();
463  }
464 
465  graphics.SetRenderTarget(null);
466 
467  float BlurStrength = 0.0f;
468  float DistortStrength = 0.0f;
469  Vector3 chromaticAberrationStrength = GameSettings.CurrentConfig.Graphics.ChromaticAberration ?
470  new Vector3(-0.02f, -0.01f, 0.0f) : Vector3.Zero;
471 
472  if (Level.Loaded?.Renderer != null)
473  {
474  chromaticAberrationStrength += new Vector3(-0.03f, -0.015f, 0.0f) * Level.Loaded.Renderer.ChromaticAberrationStrength;
475  }
476 
477  if (Character.Controlled != null)
478  {
479  BlurStrength = Character.Controlled.BlurStrength * 0.005f;
480  DistortStrength = Character.Controlled.DistortStrength;
481  if (GameSettings.CurrentConfig.Graphics.RadialDistortion)
482  {
483  chromaticAberrationStrength -= Vector3.One * Character.Controlled.RadialDistortStrength;
484  }
485  chromaticAberrationStrength += new Vector3(-0.03f, -0.015f, 0.0f) * Character.Controlled.ChromaticAberrationStrength;
486  }
487  else
488  {
489  BlurStrength = 0.0f;
490  DistortStrength = 0.0f;
491  }
492 
493  string postProcessTechnique = "";
494  if (BlurStrength > 0.0f)
495  {
496  postProcessTechnique += "Blur";
497  PostProcessEffect.Parameters["blurDistance"].SetValue(BlurStrength);
498  }
499  if (chromaticAberrationStrength != Vector3.Zero)
500  {
501  postProcessTechnique += "ChromaticAberration";
502  PostProcessEffect.Parameters["chromaticAberrationStrength"].SetValue(chromaticAberrationStrength);
503  }
504  if (DistortStrength > 0.0f)
505  {
506  postProcessTechnique += "Distort";
507  PostProcessEffect.Parameters["distortScale"].SetValue(Vector2.One * DistortStrength);
508  PostProcessEffect.Parameters["distortUvOffset"].SetValue(WaterRenderer.Instance.WavePos * 0.001f);
509  }
510 
511  graphics.BlendState = BlendState.Opaque;
512  graphics.SamplerStates[0] = SamplerState.LinearClamp;
513  graphics.DepthStencilState = DepthStencilState.None;
514  if (string.IsNullOrEmpty(postProcessTechnique))
515  {
516  GraphicsQuad.UseBasicEffect(renderTargetFinal);
517  }
518  else
519  {
520  PostProcessEffect.Parameters["MatrixTransform"].SetValue(Matrix.Identity);
521  PostProcessEffect.Parameters["xTexture"].SetValue(renderTargetFinal);
522  PostProcessEffect.CurrentTechnique = PostProcessEffect.Techniques[postProcessTechnique];
523  PostProcessEffect.CurrentTechnique.Passes[0].Apply();
524  }
525  GraphicsQuad.Render();
526 
527  Character.DrawSpeechBubbles(spriteBatch, cam);
528 
529  if (fadeToBlackState > 0.0f)
530  {
531  spriteBatch.Begin(SpriteSortMode.Deferred);
532  GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Lerp(Color.TransparentBlack, Color.Black, fadeToBlackState), isFilled: true);
533  spriteBatch.End();
534  }
535 
537  {
538  GameMain.LightManager.DebugDrawLos(spriteBatch, cam);
539  }
540 
541  sw.Stop();
542  GameMain.PerformanceCounter.AddElapsedTicks("Draw:Map:PostProcess", sw.ElapsedTicks);
543  sw.Restart();
544  }
545 
546  partial void UpdateProjSpecific(double deltaTime)
547  {
549  {
550  fadeToBlackState = Math.Min(fadeToBlackState + (float)deltaTime, 1.0f);
551  }
552  else
553  {
554  fadeToBlackState = Math.Max(fadeToBlackState - (float)deltaTime, 0.0f);
555  }
556 
557  if (!PlayerInput.PrimaryMouseButtonHeld())
558  {
559  Inventory.DraggingSlot = null;
560  Inventory.DraggingItems.Clear();
561  }
562  }
563  }
564 }
Matrix Transform
Definition: Camera.cs:136
void UpdateTransform(bool interpolate=true, bool updateListener=true)
Definition: Camera.cs:199
void Translate(Vector2 amount)
Definition: Camera.cs:164
Matrix ShaderTransform
Definition: Camera.cs:141
static void DrawSpeechBubbles(SpriteBatch spriteBatch, Camera cam)
bool CanInteractWith(Character c, float maxDist=200.0f, bool checkVisibility=true, bool skipDistanceCheck=false)
bool HasEquippedItem(Item item, InvSlotType? slotType=null, Func< InvSlotType, bool > predicate=null)
Item????????? SelectedItem
The primary selected item. It can be any device that character interacts with. This excludes items li...
Item SelectedSecondaryItem
The secondary selected item. It's an item other than a device (see SelectedItem), e....
bool IsVisible
Is the character currently visible on the camera. Refresh the value by calling DoVisibilityCheck.
virtual void DrawFront(SpriteBatch spriteBatch, Camera cam)
void DrawGUIMessages(SpriteBatch spriteBatch, Camera cam)
void Draw(SpriteBatch spriteBatch, Camera cam)
void DrawHUD(SpriteBatch spriteBatch, Camera cam, bool drawHealth=true)
Triggers a "conversation popup" with text and support for different branching options.
AITarget AiTarget
Definition: Entity.cs:55
Submarine Submarine
Definition: Entity.cs:53
static int GraphicsWidth
Definition: GameMain.cs:162
static GameSession?? GameSession
Definition: GameMain.cs:88
static RasterizerState ScissorTestEnable
Definition: GameMain.cs:195
static PerformanceCounter PerformanceCounter
Definition: GameMain.cs:37
static int GraphicsHeight
Definition: GameMain.cs:168
static Lights.LightManager LightManager
Definition: GameMain.cs:78
Action ResolutionChanged
NOTE: Use very carefully. You need to ensure that you ALWAYS unsubscribe from this when you no longer...
Definition: GameMain.cs:133
static bool DebugDraw
Definition: GameMain.cs:29
static ParticleManager ParticleManager
Definition: GameMain.cs:101
static GameMain Instance
Definition: GameMain.cs:144
void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch, double deltaTime)
override void AddToGUIUpdateList()
By default, submits the screen's main GUIFrame and, if requested upon construction,...
override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
static void UpdateVertices(Camera cam, WaterRenderer renderer)
virtual IEnumerable< Item > AllItems
All items contained in the inventory. Stacked items are returned as individual instances....
override void AddToGUIUpdateList(int order=0)
void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
void DrawDebugOverlay(SpriteBatch spriteBatch, Camera cam)
void DrawFront(SpriteBatch spriteBatch, Camera cam)
void DebugDrawLos(SpriteBatch spriteBatch, Camera cam)
void DebugDrawVertices(SpriteBatch spriteBatch)
void RenderLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, RenderTarget2D backgroundObstructor=null)
void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition)
static readonly List< MapEntity > MapEntityList
void AddElapsedTicks(string identifier, long ticks)
static void DrawFront(SpriteBatch spriteBatch, bool editing=false, Predicate< MapEntity > predicate=null)
static void DrawPaintedColors(SpriteBatch spriteBatch, bool editing=false, Predicate< MapEntity > predicate=null)
static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing=false, Predicate< MapEntity > predicate=null)
static void DrawBack(SpriteBatch spriteBatch, bool editing=false, Predicate< MapEntity > predicate=null)
Rectangle? Borders
Extents of the solid items/structures (ones with a physics body) and hulls
void RenderAir(GraphicsDevice graphicsDevice, Camera cam, RenderTarget2D texture, Matrix transform)
void RenderWater(SpriteBatch spriteBatch, RenderTarget2D texture, Camera cam)
static WaterRenderer Instance