(f36b3a111) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev
This commit is contained in:
@@ -138,6 +138,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
hudProgressBars = new Dictionary<object, HUDProgressBar>();
|
||||
}
|
||||
|
||||
partial void UpdateLimbLightSource(Limb limb)
|
||||
{
|
||||
if (limb.LightSource != null)
|
||||
@@ -146,12 +149,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private bool wasFiring;
|
||||
|
||||
/// <summary>
|
||||
/// Control the Character according to player input
|
||||
/// </summary>
|
||||
public void ControlLocalPlayer(float deltaTime, Camera cam, bool moveCam = true)
|
||||
{
|
||||
if (DisableControls)
|
||||
if (DisableControls || GUI.PauseMenuOpen || GUI.SettingsMenuOpen)
|
||||
{
|
||||
foreach (Key key in keys)
|
||||
{
|
||||
@@ -161,10 +166,25 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
wasFiring |= keys[(int)InputType.Aim].Held && keys[(int)InputType.Shoot].Held;
|
||||
for (int i = 0; i < keys.Length; i++)
|
||||
{
|
||||
keys[i].SetState();
|
||||
}
|
||||
//if we were firing (= pressing the aim and shoot keys at the same time)
|
||||
//and the fire key is the same as Select or Use, reset the key to prevent accidentally selecting/using items
|
||||
if (wasFiring && !keys[(int)InputType.Shoot].Held)
|
||||
{
|
||||
if (GameMain.Config.KeyBind(InputType.Shoot).Equals(GameMain.Config.KeyBind(InputType.Select)))
|
||||
{
|
||||
keys[(int)InputType.Select].Reset();
|
||||
}
|
||||
if (GameMain.Config.KeyBind(InputType.Shoot).Equals(GameMain.Config.KeyBind(InputType.Use)))
|
||||
{
|
||||
keys[(int)InputType.Use].Reset();
|
||||
}
|
||||
wasFiring = false;
|
||||
}
|
||||
|
||||
float targetOffsetAmount = 0.0f;
|
||||
if (moveCam)
|
||||
|
||||
@@ -276,9 +276,6 @@ namespace Barotrauma
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
characterInfos.Add(characterInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the character from the crew (and crew menus).
|
||||
/// </summary>
|
||||
|
||||
@@ -8,7 +8,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Repairable : ItemComponent
|
||||
partial class Repairable : ItemComponent, IDrawableComponent
|
||||
{
|
||||
private GUIButton repairButton;
|
||||
private GUIProgressBar progressBar;
|
||||
@@ -25,7 +25,13 @@ namespace Barotrauma.Items.Components
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public Vector2 DrawSize
|
||||
{
|
||||
//use the extents of the item as the draw size
|
||||
get { return Vector2.Zero; }
|
||||
}
|
||||
|
||||
public override bool ShouldDrawHUD(Character character)
|
||||
{
|
||||
if (!HasRequiredItems(character, false) || character.SelectedConstruction != item) return false;
|
||||
@@ -98,7 +104,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
IsActive = true;
|
||||
@@ -137,5 +143,28 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
//no need to write anything, just letting the server know we started repairing
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (GameMain.DebugDraw && Character.Controlled?.FocusedItem == item)
|
||||
{
|
||||
bool paused = !ShouldDeteriorate();
|
||||
if (deteriorationTimer > 0.0f)
|
||||
{
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y), "Deterioration delay " + ((int)deteriorationTimer) + (paused ? " [PAUSED]" : ""),
|
||||
paused ? Color.Cyan : Color.Lime, Color.Black * 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y), "Deteriorating at " + (int)(DeteriorationSpeed * 60.0f) + " units/min" + (paused ? " [PAUSED]" : ""),
|
||||
paused ? Color.Cyan : Color.Red, Color.Black * 0.5f);
|
||||
}
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(item.WorldPosition.X, -item.WorldPosition.Y + 20), "Condition: " + (int)item.Condition + "/" + (int)item.MaxCondition,
|
||||
Color.Orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1272,17 +1272,17 @@ namespace Barotrauma
|
||||
};
|
||||
|
||||
var innerFrame = new GUIFrame(new RectTransform(new Vector2(0.2f, 0.36f), loadFrame.RectTransform, Anchor.Center) { MinSize = new Point(350, 500) });
|
||||
GUIFrame paddedLoadFrame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
var subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.9f), paddedLoadFrame.RectTransform))
|
||||
var paddedLoadFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.9f), innerFrame.RectTransform, Anchor.Center)) { Stretch = true, RelativeSpacing = 0.05f };
|
||||
|
||||
var deleteButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedLoadFrame.RectTransform, Anchor.Center));
|
||||
|
||||
var subList = new GUIListBox(new RectTransform(new Vector2(1.0f, 1.0f), paddedLoadFrame.RectTransform))
|
||||
{
|
||||
ScrollBarVisible = true,
|
||||
OnSelected = (GUIComponent selected, object userData) =>
|
||||
{
|
||||
Submarine sub = userData as Submarine;
|
||||
if (paddedLoadFrame.FindChild("delete") is GUIButton deleteBtn)
|
||||
{
|
||||
deleteBtn.Enabled = !sub.IsVanillaSubmarine();
|
||||
}
|
||||
if (deleteButtonHolder.FindChild("delete") is GUIButton deleteBtn) deleteBtn.Enabled = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -1307,17 +1307,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.05f), paddedLoadFrame.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("Cancel"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = (GUIButton btn, object userdata) =>
|
||||
{
|
||||
loadFrame = null;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var deleteButton = new GUIButton(new RectTransform(new Vector2(0.3f, 0.05f), paddedLoadFrame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.31f, 0.0f) },
|
||||
var deleteButton = new GUIButton(new RectTransform(new Vector2(1.0f, 1.0f), deleteButtonHolder.RectTransform, Anchor.TopCenter),
|
||||
TextManager.Get("Delete"), style: "GUIButtonLarge")
|
||||
{
|
||||
Enabled = false,
|
||||
@@ -1335,7 +1325,19 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 0.05f), paddedLoadFrame.RectTransform, Anchor.BottomRight),
|
||||
var controlBtnHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedLoadFrame.RectTransform), isHorizontal: true) { RelativeSpacing = 0.2f, Stretch = true };
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), controlBtnHolder.RectTransform, Anchor.BottomLeft),
|
||||
TextManager.Get("Cancel"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = (GUIButton btn, object userdata) =>
|
||||
{
|
||||
loadFrame = null;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.5f, 1.0f), controlBtnHolder.RectTransform, Anchor.BottomRight),
|
||||
TextManager.Get("Load"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = LoadSub
|
||||
|
||||
@@ -800,40 +800,7 @@ namespace Barotrauma
|
||||
Collider.LinearVelocity.Y > 0.0f ? Collider.LinearVelocity.Y * 0.5f : Collider.LinearVelocity.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClimbOverObstacles()
|
||||
{
|
||||
if (Collider.FarseerBody.ContactList == null || Math.Abs(movement.X) < 0.01f) return;
|
||||
|
||||
//check if the collider is touching a suitable obstacle to climb over
|
||||
Vector2? handle = null;
|
||||
FarseerPhysics.Dynamics.Contacts.ContactEdge ce = Collider.FarseerBody.ContactList;
|
||||
while (ce != null && ce.Contact != null)
|
||||
{
|
||||
if (ce.Contact.Enabled && ce.Contact.IsTouching && ce.Contact.FixtureA.CollisionCategories.HasFlag(Physics.CollisionWall))
|
||||
{
|
||||
Vector2 contactNormal;
|
||||
FarseerPhysics.Common.FixedArray2<Vector2> contactPos;
|
||||
ce.Contact.GetWorldManifold(out contactNormal, out contactPos);
|
||||
|
||||
//only climb if moving towards the obstacle
|
||||
if (Math.Sign(contactPos[0].X - Collider.SimPosition.X) == Math.Sign(movement.X) &&
|
||||
(handle == null || contactPos[0].Y > ((Vector2)handle).Y))
|
||||
{
|
||||
handle = contactPos[0];
|
||||
}
|
||||
}
|
||||
|
||||
ce = ce.Next;
|
||||
}
|
||||
else if (onGround && (!character.IsRemotePlayer || (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)))
|
||||
{
|
||||
Collider.LinearVelocity = new Vector2(
|
||||
movement.X,
|
||||
Collider.LinearVelocity.Y > 0.0f ? Collider.LinearVelocity.Y * 0.5f : Collider.LinearVelocity.Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private float handCyclePos;
|
||||
private float legCyclePos;
|
||||
void UpdateSwimming()
|
||||
|
||||
@@ -66,6 +66,14 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
//if enabled, the deterioration timer will always run regardless if the item is being used or not
|
||||
[Serialize(false, false)]
|
||||
public bool DeteriorateAlways
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private Character currentFixer;
|
||||
public Character CurrentFixer
|
||||
{
|
||||
@@ -190,38 +198,43 @@ namespace Barotrauma.Items.Components
|
||||
if (LastActiveTime > Timing.TotalTime) { return true; }
|
||||
foreach (ItemComponent ic in item.Components)
|
||||
{
|
||||
if (ic is PowerTransfer pt)
|
||||
if (ic is Fabricator || ic is Deconstructor)
|
||||
{
|
||||
//fabricators and deconstructors rely on LastActiveTime
|
||||
return false;
|
||||
}
|
||||
else if (ic is PowerTransfer pt)
|
||||
{
|
||||
//power transfer items (junction boxes, relays) don't deteriorate if they're no carrying any power
|
||||
if (Math.Abs(pt.CurrPowerConsumption) < 0.1f) { return false; }
|
||||
if (Math.Abs(pt.CurrPowerConsumption) > 0.1f) { return true; }
|
||||
}
|
||||
else if (ic is Engine engine)
|
||||
{
|
||||
//engines don't deteriorate if they're not running
|
||||
if (Math.Abs(engine.Force) < 1.0f) { return false; }
|
||||
if (Math.Abs(engine.Force) > 1.0f) { return true; }
|
||||
}
|
||||
else if (ic is Pump pump)
|
||||
{
|
||||
//pumps don't deteriorate if they're not running
|
||||
if (Math.Abs(pump.FlowPercentage) < 1.0f) { return false; }
|
||||
if (Math.Abs(pump.FlowPercentage) > 1.0f) { return true; }
|
||||
}
|
||||
else if (ic is Reactor reactor)
|
||||
{
|
||||
//reactors don't deteriorate if they're not powered up
|
||||
if (reactor.Temperature < 0.1f) { return false; }
|
||||
if (reactor.Temperature > 0.1f) { return true; }
|
||||
}
|
||||
else if (ic is OxygenGenerator oxyGenerator)
|
||||
{
|
||||
//oxygen generators don't deteriorate if they're not running
|
||||
if (oxyGenerator.CurrFlow < 0.1f) { return false; }
|
||||
if (oxyGenerator.CurrFlow > 0.1f) { return true; }
|
||||
}
|
||||
else if (ic is Powered powered)
|
||||
{
|
||||
if (powered.Voltage < powered.MinVoltage) { return false; }
|
||||
if (powered.Voltage >= powered.MinVoltage) { return true; }
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return DeteriorateAlways;
|
||||
}
|
||||
|
||||
private void UpdateFixAnimation(Character character)
|
||||
|
||||
@@ -86,6 +86,25 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is KeyOrMouse keyOrMouse )
|
||||
{
|
||||
if (MouseButton.HasValue)
|
||||
{
|
||||
return keyOrMouse.MouseButton.HasValue && keyOrMouse.MouseButton.Value == MouseButton.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return keyOrMouse.Key.Equals(Key);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
switch (MouseButton)
|
||||
{
|
||||
@@ -133,7 +152,6 @@ namespace Barotrauma
|
||||
{
|
||||
get { return binding; }
|
||||
}
|
||||
#endif
|
||||
|
||||
public void SetState()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user