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;
|
||||
|
||||
private bool networkUpdateSent;
|
||||
@@ -1132,6 +1135,10 @@ namespace Barotrauma
|
||||
{
|
||||
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);
|
||||
|
||||
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
|
||||
|
||||
@@ -453,13 +453,11 @@ namespace Barotrauma
|
||||
|
||||
if (pauseMenuOpen)
|
||||
{
|
||||
pauseMenu.Update(0.016f);
|
||||
pauseMenu.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (settingsMenuOpen)
|
||||
{
|
||||
GameMain.Config.SettingsFrame.Update(0.016f);
|
||||
GameMain.Config.SettingsFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
@@ -472,6 +470,16 @@ namespace Barotrauma
|
||||
|
||||
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)
|
||||
{
|
||||
var messageBox = GUIMessageBox.MessageBoxes.Peek();
|
||||
|
||||
@@ -162,38 +162,6 @@ namespace Barotrauma
|
||||
{
|
||||
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;
|
||||
//if (state == ComponentState.Hover) currColor = hoverColor;
|
||||
//if (state == ComponentState.Selected) currColor = selectedColor;
|
||||
@@ -208,5 +176,40 @@ namespace Barotrauma
|
||||
|
||||
//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;
|
||||
children[i].Update(deltaTime);
|
||||
if (!c.Visible) continue;
|
||||
c.Update(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,7 @@ namespace Barotrauma
|
||||
|
||||
if (Hull.renderer != null)
|
||||
{
|
||||
Hull.renderer.ScrollWater(deltaTime);
|
||||
Hull.renderer.RenderBack(spriteBatch, renderTarget, 0.0f);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,12 +71,15 @@ namespace Barotrauma
|
||||
|
||||
private bool hasLoaded;
|
||||
|
||||
private GameTime fixedTime;
|
||||
private double updatesToMake;
|
||||
|
||||
//public static Random localRandom;
|
||||
//public static Random random;
|
||||
|
||||
//private Stopwatch renderTimer;
|
||||
//public static int renderTimeElapsed;
|
||||
|
||||
|
||||
public Camera Cam
|
||||
{
|
||||
get { return GameScreen.Cam; }
|
||||
@@ -120,6 +123,7 @@ namespace Barotrauma
|
||||
|
||||
graphicsWidth = Config.GraphicsWidth;
|
||||
graphicsHeight = Config.GraphicsHeight;
|
||||
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
|
||||
|
||||
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
||||
|
||||
@@ -138,11 +142,16 @@ namespace Barotrauma
|
||||
IsFixedTimeStep = false;
|
||||
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
|
||||
|
||||
updatesToMake = 0.0;
|
||||
fixedTime = new GameTime();
|
||||
|
||||
World = new World(new Vector2(0, -9.82f));
|
||||
FarseerPhysics.Settings.AllowSleep = true;
|
||||
FarseerPhysics.Settings.ContinuousPhysics = false;
|
||||
FarseerPhysics.Settings.VelocityIterations = 1;
|
||||
FarseerPhysics.Settings.PositionIterations = 1;
|
||||
|
||||
Graphics.ApplyChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -282,40 +291,51 @@ namespace Barotrauma
|
||||
/// <param name="gameTime">Provides a snapshot of timing values.</param>
|
||||
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;
|
||||
PlayerInput.Update(deltaTime);
|
||||
|
||||
bool paused = false;
|
||||
|
||||
if (hasLoaded && !titleScreenOpen)
|
||||
while (updatesToMake > 0.0)
|
||||
{
|
||||
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);
|
||||
|
||||
paused = (DebugConsole.IsOpen || GUI.PauseMenuOpen || GUI.SettingsMenuOpen) &&
|
||||
(NetworkMember == null || !NetworkMember.GameStarted);
|
||||
|
||||
if (!paused) Screen.Selected.Update(deltaTime);
|
||||
|
||||
if (NetworkMember != null)
|
||||
if (hasLoaded && !titleScreenOpen)
|
||||
{
|
||||
NetworkMember.Update((float)deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetworkEvent.Events.Clear();
|
||||
SoundPlayer.Update();
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Escape)) GUI.TogglePauseMenu();
|
||||
|
||||
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 GraphicsHeight { get; set; }
|
||||
|
||||
public bool VSyncEnabled { get; set; }
|
||||
|
||||
//public bool FullScreenEnabled { get; set; }
|
||||
|
||||
public WindowMode WindowMode
|
||||
@@ -126,6 +128,7 @@ namespace Barotrauma
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
|
||||
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
|
||||
VSyncEnabled = ToolBox.GetAttributeBool(graphicsMode, "vsync", true);
|
||||
|
||||
if (GraphicsWidth==0 || GraphicsHeight==0)
|
||||
{
|
||||
@@ -253,6 +256,7 @@ namespace Barotrauma
|
||||
gMode.ReplaceAttributes(
|
||||
new XAttribute("width", GraphicsWidth),
|
||||
new XAttribute("height", GraphicsHeight),
|
||||
new XAttribute("vsync", VSyncEnabled),
|
||||
new XAttribute("displaymode", windowMode));
|
||||
}
|
||||
|
||||
@@ -349,6 +353,20 @@ namespace Barotrauma
|
||||
|
||||
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);
|
||||
GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y + 20, 150, 20), GUI.Style, 0.1f, settingsFrame);
|
||||
soundScrollBar.BarScroll = SoundVolume;
|
||||
|
||||
@@ -95,6 +95,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle WindowRect
|
||||
{
|
||||
get { return window; }
|
||||
}
|
||||
|
||||
[Editable, HasDefaultValue(false, true)]
|
||||
public bool IsOpen
|
||||
{
|
||||
|
||||
@@ -463,7 +463,9 @@ namespace Barotrauma.Items.Components
|
||||
//}
|
||||
|
||||
public virtual void DrawHUD(SpriteBatch spriteBatch, Character character) { }
|
||||
|
||||
|
||||
public virtual void UpdateHUD(Character character) { }
|
||||
|
||||
/// <returns>true if the operation was completed</returns>
|
||||
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)
|
||||
{
|
||||
GuiFrame.Update((float)Physics.step);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character)
|
||||
{
|
||||
GuiFrame.Update((float)Physics.step);
|
||||
}
|
||||
|
||||
private bool ToggleActive(GUIButton button, object obj)
|
||||
{
|
||||
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)
|
||||
{
|
||||
force = MathHelper.Lerp(force, 0.0f, 0.1f);
|
||||
|
||||
@@ -338,6 +338,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character)
|
||||
{
|
||||
FabricableItem targetItem = itemList.SelectedData as FabricableItem;
|
||||
if (targetItem != null)
|
||||
@@ -346,7 +351,6 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
GuiFrame.Update((float)Physics.step);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
private bool CanBeFabricated(FabricableItem fabricableItem, Character user)
|
||||
|
||||
@@ -155,14 +155,18 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
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)
|
||||
{
|
||||
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
||||
|
||||
@@ -438,7 +438,6 @@ namespace Barotrauma.Items.Components
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
float xOffset = (graphTimer / (float)updateGraphInterval);
|
||||
@@ -481,6 +480,11 @@ namespace Barotrauma.Items.Components
|
||||
//y = y - 260;
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character)
|
||||
{
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
}
|
||||
|
||||
private bool ToggleAutoTemp(GUITickBox tickBox)
|
||||
{
|
||||
unsentChanges = true;
|
||||
|
||||
@@ -160,8 +160,7 @@ namespace Barotrauma.Items.Components
|
||||
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
public override void UpdateHUD(Character character)
|
||||
{
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -186,6 +186,11 @@ namespace Barotrauma.Items.Components
|
||||
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)
|
||||
{
|
||||
base.ReceiveSignal(stepsTaken, signal, connection, sender, power);
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Barotrauma.Items.Components
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
light.ParentSub = item.Submarine;
|
||||
|
||||
|
||||
ApplyStatusEffects(ActionType.OnActive, deltaTime);
|
||||
|
||||
if (item.Container != null)
|
||||
|
||||
@@ -186,18 +186,23 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
CreateGUIFrame(item);
|
||||
|
||||
}
|
||||
UpdateGUIFrame(item, character);
|
||||
|
||||
if (frame == null) return;
|
||||
|
||||
frame.Update((float)Physics.step);
|
||||
frame.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Barotrauma
|
||||
|
||||
public Hull CurrentHull;
|
||||
|
||||
public bool Visible = true;
|
||||
|
||||
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
||||
|
||||
//components that determine the functionality of the item
|
||||
@@ -806,9 +808,9 @@ namespace Barotrauma
|
||||
{
|
||||
base.FlipX();
|
||||
|
||||
if (prefab.CanSpriteFlipX)
|
||||
{
|
||||
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
||||
if (prefab.CanSpriteFlipX)
|
||||
{
|
||||
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
||||
}
|
||||
|
||||
foreach (ItemComponent component in components)
|
||||
@@ -819,10 +821,11 @@ namespace Barotrauma
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
if (!Visible) return;
|
||||
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
||||
if (isHighlighted) color = Color.Orange;
|
||||
|
||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||
prefab.sprite.effects ^= SpriteEffects;
|
||||
|
||||
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)
|
||||
{
|
||||
List<T> connectedComponents = new List<T>();
|
||||
|
||||
@@ -60,6 +60,8 @@ namespace Barotrauma
|
||||
|
||||
private bool update;
|
||||
|
||||
public bool Visible = true;
|
||||
|
||||
private Sound currentFlowSound;
|
||||
private int soundIndex;
|
||||
private float soundVolume;
|
||||
@@ -559,6 +561,17 @@ namespace Barotrauma
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||
{
|
||||
//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;
|
||||
|
||||
@@ -566,7 +579,7 @@ namespace Barotrauma
|
||||
|
||||
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);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
@@ -746,6 +759,65 @@ namespace Barotrauma
|
||||
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()
|
||||
//{
|
||||
// List<Gap> gaps = new List<Gap>();
|
||||
|
||||
@@ -63,10 +63,7 @@ namespace Barotrauma
|
||||
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
|
||||
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
|
||||
//waterEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
wavePos.X += 0.0001f;
|
||||
wavePos.Y += 0.0001f;
|
||||
|
||||
|
||||
#if WINDOWS
|
||||
waterEffect.Parameters["xTexture"].SetValue(texture);
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
@@ -77,6 +74,12 @@ namespace Barotrauma
|
||||
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)
|
||||
{
|
||||
if (vertices == null) return;
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (Character.Controlled.ClosestItem != null)
|
||||
{
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
Character.Controlled.ClosestItem.Draw(spriteBatch, false, true);
|
||||
Character.Controlled.ClosestItem.IsHighlighted = true;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ namespace Barotrauma
|
||||
List<Body> bodies;
|
||||
|
||||
//sections of the wall that are supposed to be rendered
|
||||
private WallSection[] sections;
|
||||
public WallSection[] sections {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
bool isHorizontal;
|
||||
|
||||
|
||||
@@ -197,22 +197,23 @@ namespace Barotrauma.Networking
|
||||
request.AddParameter("password", string.IsNullOrWhiteSpace(password) ? 0 : 1);
|
||||
|
||||
// execute the request
|
||||
RestResponse response = (RestResponse)restClient.Execute(request);
|
||||
|
||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
restClient.ExecuteAsync(request, response =>
|
||||
{
|
||||
DebugConsole.ThrowError("Error while connecting to master server (" +response.StatusCode+": "+response.StatusDescription+")");
|
||||
return;
|
||||
}
|
||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
DebugConsole.ThrowError("Error while connecting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
if (response != null && !string.IsNullOrWhiteSpace(response.Content))
|
||||
{
|
||||
DebugConsole.ThrowError("Error while connecting to master server (" +response.Content+")");
|
||||
return;
|
||||
}
|
||||
if (response != null && !string.IsNullOrWhiteSpace(response.Content))
|
||||
{
|
||||
DebugConsole.ThrowError("Error while connecting to master server (" + response.Content + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
registeredToMaster = true;
|
||||
refreshMasterTimer = DateTime.Now + refreshMasterInterval;
|
||||
registeredToMaster = true;
|
||||
refreshMasterTimer = DateTime.Now + refreshMasterInterval;
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerable<object> RefreshMaster()
|
||||
|
||||
@@ -114,6 +114,14 @@ namespace Barotrauma
|
||||
|
||||
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 = Physics.step;
|
||||
while (Physics.accumulator >= Physics.step)
|
||||
@@ -168,9 +176,13 @@ namespace Barotrauma
|
||||
{
|
||||
cam.UpdateTransform(true);
|
||||
|
||||
if (Hull.renderer != null)
|
||||
{
|
||||
Hull.renderer.ScrollWater((float)deltaTime);
|
||||
}
|
||||
|
||||
//damageStencil = TextureLoader.FromFile("Content/Map/background.png");
|
||||
|
||||
|
||||
DrawMap(graphics, spriteBatch);
|
||||
|
||||
spriteBatch.Begin();
|
||||
|
||||
@@ -370,7 +370,7 @@ namespace Barotrauma
|
||||
{
|
||||
menu.Update((float)deltaTime);
|
||||
|
||||
GUI.Update((float)deltaTime);
|
||||
//GUI.Update((float)deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user