Backported vsync changes from new-netcode, WIP hull visibility culling
The hull culling functions are there, they just aren't being used right now because there are some annoying bugs.
This commit is contained in:
@@ -58,6 +58,9 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hull PreviousHull = null;
|
||||||
|
public Hull CurrentHull = null;
|
||||||
|
|
||||||
public readonly bool IsNetworkPlayer;
|
public readonly bool IsNetworkPlayer;
|
||||||
|
|
||||||
private bool networkUpdateSent;
|
private bool networkUpdateSent;
|
||||||
@@ -1132,6 +1135,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Enabled) return;
|
if (!Enabled) return;
|
||||||
|
|
||||||
|
PreviousHull = CurrentHull;
|
||||||
|
CurrentHull = Hull.FindHull(WorldPosition, CurrentHull, true);
|
||||||
|
//if (PreviousHull != CurrentHull && Character.Controlled == this) Hull.DetectItemVisibility(this); //WIP item culling
|
||||||
|
|
||||||
speechBubbleTimer = Math.Max(0.0f, speechBubbleTimer - deltaTime);
|
speechBubbleTimer = Math.Max(0.0f, speechBubbleTimer - deltaTime);
|
||||||
|
|
||||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||||
|
|||||||
@@ -453,13 +453,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (pauseMenuOpen)
|
if (pauseMenuOpen)
|
||||||
{
|
{
|
||||||
pauseMenu.Update(0.016f);
|
|
||||||
pauseMenu.Draw(spriteBatch);
|
pauseMenu.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsMenuOpen)
|
if (settingsMenuOpen)
|
||||||
{
|
{
|
||||||
GameMain.Config.SettingsFrame.Update(0.016f);
|
|
||||||
GameMain.Config.SettingsFrame.Draw(spriteBatch);
|
GameMain.Config.SettingsFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,6 +470,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void Update(float deltaTime)
|
public static void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
if (pauseMenuOpen)
|
||||||
|
{
|
||||||
|
pauseMenu.Update(0.016f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settingsMenuOpen)
|
||||||
|
{
|
||||||
|
GameMain.Config.SettingsFrame.Update(0.016f);
|
||||||
|
}
|
||||||
|
|
||||||
if (GUIMessageBox.MessageBoxes.Count > 0)
|
if (GUIMessageBox.MessageBoxes.Count > 0)
|
||||||
{
|
{
|
||||||
var messageBox = GUIMessageBox.MessageBoxes.Peek();
|
var messageBox = GUIMessageBox.MessageBoxes.Peek();
|
||||||
|
|||||||
@@ -162,38 +162,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (!Visible) return;
|
if (!Visible) return;
|
||||||
|
|
||||||
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
|
|
||||||
{
|
|
||||||
state = ComponentState.Hover;
|
|
||||||
if (PlayerInput.LeftButtonHeld())
|
|
||||||
{
|
|
||||||
if (OnPressed != null)
|
|
||||||
{
|
|
||||||
if (OnPressed()) state = ComponentState.Selected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (PlayerInput.LeftButtonClicked())
|
|
||||||
{
|
|
||||||
GUI.PlayUISound(GUISoundType.Click);
|
|
||||||
|
|
||||||
if (OnClicked != null)
|
|
||||||
{
|
|
||||||
if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Selected = !Selected;
|
|
||||||
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
state = Selected ? ComponentState.Selected : ComponentState.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame.State = state;
|
|
||||||
|
|
||||||
//Color currColor = color;
|
//Color currColor = color;
|
||||||
//if (state == ComponentState.Hover) currColor = hoverColor;
|
//if (state == ComponentState.Hover) currColor = hoverColor;
|
||||||
//if (state == ComponentState.Selected) currColor = selectedColor;
|
//if (state == ComponentState.Selected) currColor = selectedColor;
|
||||||
@@ -208,5 +176,40 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
|
//if (!Enabled) GUI.DrawRectangle(spriteBatch, rect, Color.Gray*0.5f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Update(float deltaTime)
|
||||||
|
{
|
||||||
|
if (!Visible) return;
|
||||||
|
base.Update(deltaTime);
|
||||||
|
if (rect.Contains(PlayerInput.MousePosition) && CanBeSelected && Enabled && (MouseOn == null || MouseOn == this || IsParentOf(MouseOn)))
|
||||||
|
{
|
||||||
|
state = ComponentState.Hover;
|
||||||
|
if (PlayerInput.LeftButtonHeld())
|
||||||
|
{
|
||||||
|
if (OnPressed != null)
|
||||||
|
{
|
||||||
|
if (OnPressed()) state = ComponentState.Selected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (PlayerInput.LeftButtonClicked())
|
||||||
|
{
|
||||||
|
GUI.PlayUISound(GUISoundType.Click);
|
||||||
|
if (OnClicked != null)
|
||||||
|
{
|
||||||
|
if (OnClicked(this, UserData) && CanBeSelected) state = ComponentState.Selected;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Selected = !Selected;
|
||||||
|
// state = state == ComponentState.Selected ? ComponentState.None : ComponentState.Selected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
state = Selected ? ComponentState.Selected : ComponentState.None;
|
||||||
|
}
|
||||||
|
frame.State = state;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,10 +317,13 @@ namespace Barotrauma
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < children.Count; i++)
|
//use a fixed list since children can change their order in the main children list
|
||||||
|
//TODO: maybe find a more efficient way of handling changes in list order
|
||||||
|
List<GUIComponent> fixedChildren = new List<GUIComponent>(children);
|
||||||
|
foreach (GUIComponent c in fixedChildren)
|
||||||
{
|
{
|
||||||
if (!children[i].Visible) continue;
|
if (!c.Visible) continue;
|
||||||
children[i].Update(deltaTime);
|
c.Update(deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (Hull.renderer != null)
|
if (Hull.renderer != null)
|
||||||
{
|
{
|
||||||
|
Hull.renderer.ScrollWater(deltaTime);
|
||||||
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
|
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,12 +71,15 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool hasLoaded;
|
private bool hasLoaded;
|
||||||
|
|
||||||
|
private GameTime fixedTime;
|
||||||
|
private double updatesToMake;
|
||||||
|
|
||||||
//public static Random localRandom;
|
//public static Random localRandom;
|
||||||
//public static Random random;
|
//public static Random random;
|
||||||
|
|
||||||
//private Stopwatch renderTimer;
|
//private Stopwatch renderTimer;
|
||||||
//public static int renderTimeElapsed;
|
//public static int renderTimeElapsed;
|
||||||
|
|
||||||
public Camera Cam
|
public Camera Cam
|
||||||
{
|
{
|
||||||
get { return GameScreen.Cam; }
|
get { return GameScreen.Cam; }
|
||||||
@@ -120,6 +123,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
graphicsWidth = Config.GraphicsWidth;
|
graphicsWidth = Config.GraphicsWidth;
|
||||||
graphicsHeight = Config.GraphicsHeight;
|
graphicsHeight = Config.GraphicsHeight;
|
||||||
|
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
|
||||||
|
|
||||||
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
||||||
|
|
||||||
@@ -138,11 +142,16 @@ namespace Barotrauma
|
|||||||
IsFixedTimeStep = false;
|
IsFixedTimeStep = false;
|
||||||
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
|
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
|
||||||
|
|
||||||
|
updatesToMake = 0.0;
|
||||||
|
fixedTime = new GameTime();
|
||||||
|
|
||||||
World = new World(new Vector2(0, -9.82f));
|
World = new World(new Vector2(0, -9.82f));
|
||||||
FarseerPhysics.Settings.AllowSleep = true;
|
FarseerPhysics.Settings.AllowSleep = true;
|
||||||
FarseerPhysics.Settings.ContinuousPhysics = false;
|
FarseerPhysics.Settings.ContinuousPhysics = false;
|
||||||
FarseerPhysics.Settings.VelocityIterations = 1;
|
FarseerPhysics.Settings.VelocityIterations = 1;
|
||||||
FarseerPhysics.Settings.PositionIterations = 1;
|
FarseerPhysics.Settings.PositionIterations = 1;
|
||||||
|
|
||||||
|
Graphics.ApplyChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -282,40 +291,51 @@ namespace Barotrauma
|
|||||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||||
protected override void Update(GameTime gameTime)
|
protected override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
base.Update(gameTime);
|
double realDeltaTime = gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
|
double deltaTime = 0.016;
|
||||||
|
updatesToMake += realDeltaTime;
|
||||||
|
|
||||||
double deltaTime = gameTime.ElapsedGameTime.TotalSeconds;
|
while (updatesToMake > 0.0)
|
||||||
PlayerInput.Update(deltaTime);
|
|
||||||
|
|
||||||
bool paused = false;
|
|
||||||
|
|
||||||
if (hasLoaded && !titleScreenOpen)
|
|
||||||
{
|
{
|
||||||
SoundPlayer.Update();
|
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
|
||||||
|
TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16);
|
||||||
|
fixedTime.ElapsedGameTime = addTime;
|
||||||
|
fixedTime.TotalGameTime.Add(addTime);
|
||||||
|
base.Update(fixedTime);
|
||||||
|
|
||||||
|
PlayerInput.Update(deltaTime);
|
||||||
|
|
||||||
if (PlayerInput.KeyHit(Keys.Escape)) GUI.TogglePauseMenu();
|
bool paused = false;
|
||||||
|
|
||||||
DebugConsole.Update(this, (float)deltaTime);
|
if (hasLoaded && !titleScreenOpen)
|
||||||
|
|
||||||
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
|
|
||||||
(NetworkMember == null || !NetworkMember.GameStarted);
|
|
||||||
|
|
||||||
if (!paused) Screen.Selected.Update(deltaTime);
|
|
||||||
|
|
||||||
if (NetworkMember != null)
|
|
||||||
{
|
{
|
||||||
NetworkMember.Update((float)deltaTime);
|
SoundPlayer.Update();
|
||||||
}
|
|
||||||
else
|
if (PlayerInput.KeyHit(Keys.Escape)) GUI.TogglePauseMenu();
|
||||||
{
|
|
||||||
NetworkEvent.Events.Clear();
|
DebugConsole.Update(this, (float)deltaTime);
|
||||||
|
|
||||||
|
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
|
||||||
|
(NetworkMember == null || !NetworkMember.GameStarted);
|
||||||
|
|
||||||
|
if (!paused) Screen.Selected.Update(deltaTime);
|
||||||
|
|
||||||
|
if (NetworkMember != null)
|
||||||
|
{
|
||||||
|
NetworkMember.Update((float)deltaTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetworkEvent.Events.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI.Update((float)deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI.Update((float)deltaTime);
|
CoroutineManager.Update((float)deltaTime, paused ? 0.0f : (float)deltaTime);
|
||||||
|
|
||||||
|
updatesToMake -= deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoroutineManager.Update((float)deltaTime, paused ? 0.0f : (float)deltaTime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ namespace Barotrauma
|
|||||||
public int GraphicsWidth { get; set; }
|
public int GraphicsWidth { get; set; }
|
||||||
public int GraphicsHeight { get; set; }
|
public int GraphicsHeight { get; set; }
|
||||||
|
|
||||||
|
public bool VSyncEnabled { get; set; }
|
||||||
|
|
||||||
//public bool FullScreenEnabled { get; set; }
|
//public bool FullScreenEnabled { get; set; }
|
||||||
|
|
||||||
public WindowMode WindowMode
|
public WindowMode WindowMode
|
||||||
@@ -126,6 +128,7 @@ namespace Barotrauma
|
|||||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||||
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
|
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
|
||||||
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
|
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
|
||||||
|
VSyncEnabled = ToolBox.GetAttributeBool(graphicsMode, "vsync", true);
|
||||||
|
|
||||||
if (GraphicsWidth==0 || GraphicsHeight==0)
|
if (GraphicsWidth==0 || GraphicsHeight==0)
|
||||||
{
|
{
|
||||||
@@ -253,6 +256,7 @@ namespace Barotrauma
|
|||||||
gMode.ReplaceAttributes(
|
gMode.ReplaceAttributes(
|
||||||
new XAttribute("width", GraphicsWidth),
|
new XAttribute("width", GraphicsWidth),
|
||||||
new XAttribute("height", GraphicsHeight),
|
new XAttribute("height", GraphicsHeight),
|
||||||
|
new XAttribute("vsync", VSyncEnabled),
|
||||||
new XAttribute("displaymode", windowMode));
|
new XAttribute("displaymode", windowMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +353,20 @@ namespace Barotrauma
|
|||||||
|
|
||||||
y += 70;
|
y += 70;
|
||||||
|
|
||||||
|
GUITickBox vsyncTickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Enable vertical sync", Alignment.CenterY | Alignment.Left, settingsFrame);
|
||||||
|
vsyncTickBox.OnSelected = (GUITickBox box) =>
|
||||||
|
{
|
||||||
|
VSyncEnabled = !VSyncEnabled;
|
||||||
|
GameMain.Graphics.SynchronizeWithVerticalRetrace = VSyncEnabled;
|
||||||
|
GameMain.Graphics.ApplyChanges();
|
||||||
|
UnsavedSettings = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
vsyncTickBox.Selected = VSyncEnabled;
|
||||||
|
|
||||||
|
y += 70;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", GUI.Style, settingsFrame);
|
new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", GUI.Style, settingsFrame);
|
||||||
GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y + 20, 150, 20), GUI.Style, 0.1f, settingsFrame);
|
GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y + 20, 150, 20), GUI.Style, 0.1f, settingsFrame);
|
||||||
soundScrollBar.BarScroll = SoundVolume;
|
soundScrollBar.BarScroll = SoundVolume;
|
||||||
|
|||||||
@@ -95,6 +95,11 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Rectangle WindowRect
|
||||||
|
{
|
||||||
|
get { return window; }
|
||||||
|
}
|
||||||
|
|
||||||
[Editable, HasDefaultValue(false, true)]
|
[Editable, HasDefaultValue(false, true)]
|
||||||
public bool IsOpen
|
public bool IsOpen
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -463,7 +463,9 @@ namespace Barotrauma.Items.Components
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
|
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
|
||||||
|
|
||||||
|
public virtual void UpdateHUD(Character character) { }
|
||||||
|
|
||||||
/// <returns>true if the operation was completed</returns>
|
/// <returns>true if the operation was completed</returns>
|
||||||
public virtual bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
|
public virtual bool AIOperate(float deltaTime, Character character, AIObjectiveOperateItem objective)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -82,10 +82,14 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||||
{
|
{
|
||||||
GuiFrame.Update((float)Physics.step);
|
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update((float)Physics.step);
|
||||||
|
}
|
||||||
|
|
||||||
private bool ToggleActive(GUIButton button, object obj)
|
private bool ToggleActive(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
SetActive(!IsActive);
|
SetActive(!IsActive);
|
||||||
|
|||||||
@@ -119,6 +119,11 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public override void UpdateBroken(float deltaTime, Camera cam)
|
public override void UpdateBroken(float deltaTime, Camera cam)
|
||||||
{
|
{
|
||||||
force = MathHelper.Lerp(force, 0.0f, 0.1f);
|
force = MathHelper.Lerp(force, 0.0f, 0.1f);
|
||||||
|
|||||||
@@ -338,6 +338,11 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
{
|
{
|
||||||
FabricableItem targetItem = itemList.SelectedData as FabricableItem;
|
FabricableItem targetItem = itemList.SelectedData as FabricableItem;
|
||||||
if (targetItem != null)
|
if (targetItem != null)
|
||||||
@@ -346,7 +351,6 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
|
|
||||||
GuiFrame.Update((float)Physics.step);
|
GuiFrame.Update((float)Physics.step);
|
||||||
GuiFrame.Draw(spriteBatch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanBeFabricated(FabricableItem fabricableItem, Character user)
|
private bool CanBeFabricated(FabricableItem fabricableItem, Character user)
|
||||||
|
|||||||
@@ -155,14 +155,18 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
int x = GuiFrame.Rect.X;
|
int x = GuiFrame.Rect.X;
|
||||||
int y = GuiFrame.Rect.Y;
|
int y = GuiFrame.Rect.Y;
|
||||||
|
|
||||||
GuiFrame.Update(1.0f / 60.0f);
|
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
spriteBatch.DrawString(GUI.Font, "Pumping speed: " + (int)flowPercentage + " %", new Vector2(x + 40, y + 85), Color.White);
|
spriteBatch.DrawString(GUI.Font, "Pumping speed: " + (int)flowPercentage + " %", new Vector2(x + 40, y + 85), Color.White);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f)
|
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power=0.0f)
|
||||||
{
|
{
|
||||||
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
||||||
|
|||||||
@@ -438,7 +438,6 @@ namespace Barotrauma.Items.Components
|
|||||||
int x = GuiFrame.Rect.X;
|
int x = GuiFrame.Rect.X;
|
||||||
int y = GuiFrame.Rect.Y;
|
int y = GuiFrame.Rect.Y;
|
||||||
|
|
||||||
GuiFrame.Update(1.0f / 60.0f);
|
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
float xOffset = (graphTimer / (float)updateGraphInterval);
|
float xOffset = (graphTimer / (float)updateGraphInterval);
|
||||||
@@ -481,6 +480,11 @@ namespace Barotrauma.Items.Components
|
|||||||
//y = y - 260;
|
//y = y - 260;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
private bool ToggleAutoTemp(GUITickBox tickBox)
|
private bool ToggleAutoTemp(GUITickBox tickBox)
|
||||||
{
|
{
|
||||||
unsentChanges = true;
|
unsentChanges = true;
|
||||||
|
|||||||
@@ -160,8 +160,7 @@ namespace Barotrauma.Items.Components
|
|||||||
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
||||||
int x = GuiFrame.Rect.X;
|
int x = GuiFrame.Rect.X;
|
||||||
int y = GuiFrame.Rect.Y;
|
int y = GuiFrame.Rect.Y;
|
||||||
|
|
||||||
GuiFrame.Update(1.0f / 60.0f);
|
|
||||||
GuiFrame.Draw(spriteBatch);
|
GuiFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
if (voltage < minVoltage && powerConsumption > 0.0f) return;
|
if (voltage < minVoltage && powerConsumption > 0.0f) return;
|
||||||
@@ -210,6 +209,11 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateAutoPilot(float deltaTime)
|
private void UpdateAutoPilot(float deltaTime)
|
||||||
{
|
{
|
||||||
if (posToMaintain != null)
|
if (posToMaintain != null)
|
||||||
|
|||||||
@@ -246,6 +246,11 @@ namespace Barotrauma.Items.Components
|
|||||||
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", new Vector2(x + 30, y + 95), Color.White);
|
spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed) * 100.0f) + " %", new Vector2(x + 30, y + 95), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message)
|
||||||
{
|
{
|
||||||
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed / MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
message.WriteRangedSingle(MathHelper.Clamp(rechargeSpeed / MaxRechargeSpeed, 0.0f, 1.0f), 0.0f, 1.0f, 8);
|
||||||
|
|||||||
@@ -186,6 +186,11 @@ namespace Barotrauma.Items.Components
|
|||||||
spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad + " kW", new Vector2(x + 30, y + 100), Color.White);
|
spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad + " kW", new Vector2(x + 30, y + 100), Color.White);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
GuiFrame.Update(1.0f / 60.0f);
|
||||||
|
}
|
||||||
|
|
||||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power)
|
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power)
|
||||||
{
|
{
|
||||||
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Barotrauma.Items.Components
|
|||||||
base.Update(deltaTime, cam);
|
base.Update(deltaTime, cam);
|
||||||
|
|
||||||
light.ParentSub = item.Submarine;
|
light.ParentSub = item.Submarine;
|
||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnActive, deltaTime);
|
ApplyStatusEffects(ActionType.OnActive, deltaTime);
|
||||||
|
|
||||||
if (item.Container != null)
|
if (item.Container != null)
|
||||||
|
|||||||
@@ -186,18 +186,23 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void DrawHud(SpriteBatch spriteBatch, Item item, Character character)
|
public static void DrawHud(SpriteBatch spriteBatch, Item item, Character character)
|
||||||
|
{
|
||||||
|
if (frame == null) return;
|
||||||
|
|
||||||
|
frame.Draw(spriteBatch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateHud(Item item, Character character)
|
||||||
{
|
{
|
||||||
if (frame == null || frame.UserData != item)
|
if (frame == null || frame.UserData != item)
|
||||||
{
|
{
|
||||||
CreateGUIFrame(item);
|
CreateGUIFrame(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
UpdateGUIFrame(item, character);
|
UpdateGUIFrame(item, character);
|
||||||
|
|
||||||
if (frame == null) return;
|
if (frame == null) return;
|
||||||
|
|
||||||
frame.Update((float)Physics.step);
|
frame.Update((float)Physics.step);
|
||||||
frame.Draw(spriteBatch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Hull CurrentHull;
|
public Hull CurrentHull;
|
||||||
|
|
||||||
|
public bool Visible = true;
|
||||||
|
|
||||||
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
||||||
|
|
||||||
//components that determine the functionality of the item
|
//components that determine the functionality of the item
|
||||||
@@ -806,9 +808,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
base.FlipX();
|
base.FlipX();
|
||||||
|
|
||||||
if (prefab.CanSpriteFlipX)
|
if (prefab.CanSpriteFlipX)
|
||||||
{
|
{
|
||||||
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ItemComponent component in components)
|
foreach (ItemComponent component in components)
|
||||||
@@ -819,10 +821,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||||
{
|
{
|
||||||
|
if (!Visible) return;
|
||||||
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
||||||
if (isHighlighted) color = Color.Orange;
|
if (isHighlighted) color = Color.Orange;
|
||||||
|
|
||||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||||
prefab.sprite.effects ^= SpriteEffects;
|
prefab.sprite.effects ^= SpriteEffects;
|
||||||
|
|
||||||
if (prefab.sprite != null)
|
if (prefab.sprite != null)
|
||||||
@@ -1076,6 +1079,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void UpdateHUD(Character character)
|
||||||
|
{
|
||||||
|
if (condition <= 0.0f)
|
||||||
|
{
|
||||||
|
FixRequirement.UpdateHud(this, character);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach (ItemComponent ic in components)
|
||||||
|
{
|
||||||
|
ic.UpdateHUD(character);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<T> GetConnectedComponents<T>(bool recursive = false)
|
public List<T> GetConnectedComponents<T>(bool recursive = false)
|
||||||
{
|
{
|
||||||
List<T> connectedComponents = new List<T>();
|
List<T> connectedComponents = new List<T>();
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool update;
|
private bool update;
|
||||||
|
|
||||||
|
public bool Visible = true;
|
||||||
|
|
||||||
private Sound currentFlowSound;
|
private Sound currentFlowSound;
|
||||||
private int soundIndex;
|
private int soundIndex;
|
||||||
private float soundVolume;
|
private float soundVolume;
|
||||||
@@ -559,6 +561,17 @@ namespace Barotrauma
|
|||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||||
{
|
{
|
||||||
//if (back) return;
|
//if (back) return;
|
||||||
|
Rectangle drawRect;
|
||||||
|
if (!Visible)
|
||||||
|
{
|
||||||
|
drawRect =
|
||||||
|
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||||
|
|
||||||
|
GUI.DrawRectangle(spriteBatch,
|
||||||
|
new Vector2(drawRect.X, -drawRect.Y),
|
||||||
|
new Vector2(rect.Width, rect.Height),
|
||||||
|
Color.Black,true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ShowHulls && !GameMain.DebugDraw) return;
|
if (!ShowHulls && !GameMain.DebugDraw) return;
|
||||||
|
|
||||||
@@ -566,7 +579,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (aiTarget != null) aiTarget.Draw(spriteBatch);
|
if (aiTarget != null) aiTarget.Draw(spriteBatch);
|
||||||
|
|
||||||
Rectangle drawRect =
|
drawRect =
|
||||||
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height);
|
||||||
|
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
@@ -746,6 +759,65 @@ namespace Barotrauma
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void DetectItemVisibility(Character c=null)
|
||||||
|
{
|
||||||
|
if (c==null)
|
||||||
|
{
|
||||||
|
foreach (Item it in Item.ItemList)
|
||||||
|
{
|
||||||
|
it.Visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hull h = c.CurrentHull;
|
||||||
|
hullList.ForEach(j => j.Visible = false);
|
||||||
|
List<Hull> visibleHulls;
|
||||||
|
if (h == null || c.Submarine == null)
|
||||||
|
{
|
||||||
|
visibleHulls = hullList.FindAll(j => j.CanSeeOther(null, false));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
visibleHulls = hullList.FindAll(j => h.CanSeeOther(j, true));
|
||||||
|
}
|
||||||
|
visibleHulls.ForEach(j => j.Visible = true);
|
||||||
|
foreach (Item it in Item.ItemList)
|
||||||
|
{
|
||||||
|
if (it.CurrentHull == null || visibleHulls.Contains(it.CurrentHull)) it.Visible = true;
|
||||||
|
else it.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanSeeOther(Hull other,bool allowIndirect=true)
|
||||||
|
{
|
||||||
|
if (other == this) return true;
|
||||||
|
|
||||||
|
if (other != null && other.Submarine==Submarine)
|
||||||
|
{
|
||||||
|
bool retVal = false;
|
||||||
|
foreach (Gap g in ConnectedGaps)
|
||||||
|
{
|
||||||
|
if (g.ConnectedWall != null && g.ConnectedWall.CastShadow) continue;
|
||||||
|
List<Hull> otherHulls = Hull.hullList.FindAll(h => h.ConnectedGaps.Contains(g) && h!=this);
|
||||||
|
retVal = otherHulls.Any(h => h == other);
|
||||||
|
if (!retVal && allowIndirect) retVal = otherHulls.Any(h => h.CanSeeOther(other, false));
|
||||||
|
if (retVal) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (Gap g in ConnectedGaps)
|
||||||
|
{
|
||||||
|
if (g.ConnectedDoor != null && !hullList.Any(h => h.ConnectedGaps.Contains(g) && h!=this)) return true;
|
||||||
|
}
|
||||||
|
List<MapEntity> structures = MapEntity.mapEntityList.FindAll(me => me is Structure && me.Rect.Intersects(Rect));
|
||||||
|
return structures.Any(st => !(st as Structure).CastShadow);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//public List<Gap> FindGaps()
|
//public List<Gap> FindGaps()
|
||||||
//{
|
//{
|
||||||
// List<Gap> gaps = new List<Gap>();
|
// List<Gap> gaps = new List<Gap>();
|
||||||
|
|||||||
@@ -63,10 +63,7 @@ namespace Barotrauma
|
|||||||
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
|
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
|
||||||
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
|
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
|
||||||
//waterEffect.CurrentTechnique.Passes[0].Apply();
|
//waterEffect.CurrentTechnique.Passes[0].Apply();
|
||||||
|
|
||||||
wavePos.X += 0.0001f;
|
|
||||||
wavePos.Y += 0.0001f;
|
|
||||||
|
|
||||||
#if WINDOWS
|
#if WINDOWS
|
||||||
waterEffect.Parameters["xTexture"].SetValue(texture);
|
waterEffect.Parameters["xTexture"].SetValue(texture);
|
||||||
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||||
@@ -77,6 +74,12 @@ namespace Barotrauma
|
|||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ScrollWater(float deltaTime)
|
||||||
|
{
|
||||||
|
wavePos.X += 0.006f * deltaTime;
|
||||||
|
wavePos.Y += 0.006f * deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
public void Render(GraphicsDevice graphicsDevice, Camera cam, RenderTarget2D texture, Matrix transform)
|
public void Render(GraphicsDevice graphicsDevice, Camera cam, RenderTarget2D texture, Matrix transform)
|
||||||
{
|
{
|
||||||
if (vertices == null) return;
|
if (vertices == null) return;
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ namespace Barotrauma.Lights
|
|||||||
{
|
{
|
||||||
if (Character.Controlled.ClosestItem != null)
|
if (Character.Controlled.ClosestItem != null)
|
||||||
{
|
{
|
||||||
|
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||||
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
|
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
|
||||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ namespace Barotrauma
|
|||||||
List<Body> bodies;
|
List<Body> bodies;
|
||||||
|
|
||||||
//sections of the wall that are supposed to be rendered
|
//sections of the wall that are supposed to be rendered
|
||||||
private WallSection[] sections;
|
public WallSection[] sections {
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
bool isHorizontal;
|
bool isHorizontal;
|
||||||
|
|
||||||
|
|||||||
@@ -197,22 +197,23 @@ namespace Barotrauma.Networking
|
|||||||
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
||||||
|
|
||||||
// execute the request
|
// execute the request
|
||||||
RestResponse response = (RestResponse)restClient.Execute(request);
|
restClient.ExecuteAsync(request, response =>
|
||||||
|
|
||||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while connecting to master server (" +response.StatusCode+": "+response.StatusDescription+")");
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
return;
|
{
|
||||||
}
|
DebugConsole.ThrowError("Error while connecting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (response != null && !string.IsNullOrWhiteSpace(response.Content))
|
if (response != null && !string.IsNullOrWhiteSpace(response.Content))
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while connecting to master server (" +response.Content+")");
|
DebugConsole.ThrowError("Error while connecting to master server (" + response.Content + ")");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
registeredToMaster = true;
|
registeredToMaster = true;
|
||||||
refreshMasterTimer = DateTime.Now + refreshMasterInterval;
|
refreshMasterTimer = DateTime.Now + refreshMasterInterval;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<object> RefreshMaster()
|
private IEnumerable<object> RefreshMaster()
|
||||||
|
|||||||
@@ -114,6 +114,14 @@ namespace Barotrauma
|
|||||||
|
|
||||||
Character.UpdateAll(cam, (float)deltaTime);
|
Character.UpdateAll(cam, (float)deltaTime);
|
||||||
|
|
||||||
|
if (Character.Controlled != null && Character.Controlled.SelectedConstruction != null)
|
||||||
|
{
|
||||||
|
if (Character.Controlled.SelectedConstruction == Character.Controlled.ClosestItem)
|
||||||
|
{
|
||||||
|
Character.Controlled.SelectedConstruction.UpdateHUD(Character.Controlled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 6);
|
Physics.accumulator = Math.Min(Physics.accumulator, Physics.step * 6);
|
||||||
//Physics.accumulator = Physics.step;
|
//Physics.accumulator = Physics.step;
|
||||||
while (Physics.accumulator >= Physics.step)
|
while (Physics.accumulator >= Physics.step)
|
||||||
@@ -168,9 +176,13 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
cam.UpdateTransform(true);
|
cam.UpdateTransform(true);
|
||||||
|
|
||||||
|
if (Hull.renderer != null)
|
||||||
|
{
|
||||||
|
Hull.renderer.ScrollWater((float)deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
//damageStencil = TextureLoader.FromFile("Content/Map/background.png");
|
//damageStencil = TextureLoader.FromFile("Content/Map/background.png");
|
||||||
|
|
||||||
DrawMap(graphics, spriteBatch);
|
DrawMap(graphics, spriteBatch);
|
||||||
|
|
||||||
spriteBatch.Begin();
|
spriteBatch.Begin();
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
menu.Update((float)deltaTime);
|
menu.Update((float)deltaTime);
|
||||||
|
|
||||||
GUI.Update((float)deltaTime);
|
//GUI.Update((float)deltaTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user