Build 0.18.13.0

This commit is contained in:
Markus Isberg
2022-07-01 12:16:36 +09:00
parent 8e6c601162
commit 497045de7e
79 changed files with 717 additions and 361 deletions
@@ -193,6 +193,9 @@ namespace Barotrauma.Items.Components
private Vector2 prevContainedItemPositions;
private float autoInjectCooldown = 1.0f;
const float AutoInjectInterval = 1.0f;
public bool ShouldBeContained(string[] identifiersOrTags, out bool isRestrictionsDefined)
{
@@ -412,7 +415,15 @@ namespace Barotrauma.Items.Components
if (AutoInject)
{
if (ownerInventory?.Owner is Character ownerCharacter &&
//normally autoinjection should delete the (medical) item, so it only gets applied once
//but in multiplayer clients aren't allowed to remove items themselves, so they may be able to trigger this dozens of times
//before the server notifies them of the item being removed, leading to a sharp lag spike.
//this can also happen with mods, if there's a way to autoinject something that doesn't get removed On Use.
//so let's ensure the item is only applied once per second at most.
autoInjectCooldown -= deltaTime;
if (autoInjectCooldown <= 0.0f &&
ownerInventory?.Owner is Character ownerCharacter &&
ownerCharacter.HealthPercentage / 100f <= AutoInjectThreshold &&
ownerCharacter.HasEquippedItem(item))
{
@@ -420,6 +431,7 @@ namespace Barotrauma.Items.Components
{
item.ApplyStatusEffects(ActionType.OnUse, 1.0f, ownerCharacter);
item.GetComponent<GeneticMaterial>()?.Equip(ownerCharacter);
autoInjectCooldown = AutoInjectInterval;
}
}
}
@@ -338,9 +338,7 @@ namespace Barotrauma.Items.Components
if (user == null) { return; }
if (GameMain.GameSession?.GameMode is MultiPlayerCampaign mpCampaign)
{
#if CLIENT
mpCampaign.TryPurchase(null, fabricatedItem.RequiredMoney);
#elif SERVER
#if SERVER
if (GetUsingClient() is { } client)
{
mpCampaign.TryPurchase(client, fabricatedItem.RequiredMoney);
@@ -142,9 +142,8 @@ namespace Barotrauma.Items.Components
//less effective when in a bad condition
currFlow *= MathHelper.Lerp(0.5f, 1.0f, item.Condition / item.MaxCondition);
item.CurrentHull.WaterVolume += currFlow * deltaTime * Timing.FixedUpdateRate;
item.CurrentHull.WaterVolume += currFlow * deltaTime * Timing.FixedUpdateRate;
if (item.CurrentHull.WaterVolume > item.CurrentHull.Volume) { item.CurrentHull.Pressure += 30.0f * deltaTime; }
}
public void InfectBallast(Identifier identifier, bool allowMultiplePerShip = false)
@@ -789,6 +789,11 @@ namespace Barotrauma.Items.Components
private bool ShouldIgnoreSubmarineCollision(ref Fixture target, Contact contact)
{
//not in the projectile category: the projectile has not been launched (e.g. just dropped from an inventory)
if (item.body.CollisionCategories != Physics.CollisionProjectile)
{
return false;
}
if (target.Body.UserData is Submarine sub)
{
Vector2 dir = item.body.LinearVelocity.LengthSquared() < 0.001f ?