(f36b3a111) Merge branch 'dev' of https://github.com/Regalis11/Barotrauma-development into dev
This commit is contained in:
@@ -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