Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2025-04-10 10:37:09 -03:00
296 changed files with 8420 additions and 2945 deletions
@@ -227,6 +227,13 @@ namespace Barotrauma.Items.Components
set;
}
[Editable, Serialize("", IsPropertySaveable.Yes, translationTextTag: "ItemMsg", description: "A text displayed next to the item when it's been dropped on the floor (not attached to a wall).")]
public string MsgWhenDropped
{
get;
set;
}
/// <summary>
/// For setting the handle positions using status effects
/// </summary>
@@ -733,7 +740,19 @@ namespace Barotrauma.Items.Components
#endif
//make the item pickable with the default pick key and with no specific tools/items when it's deattached
RequiredItems.Clear();
DisplayMsg = "";
if (MsgWhenDropped.IsNullOrEmpty())
{
DisplayMsg = "";
}
else
{
DisplayMsg = TextManager.Get(MsgWhenDropped);
DisplayMsg =
DisplayMsg.Loaded ?
TextManager.ParseInputTypes(DisplayMsg) :
MsgWhenDropped;
}
PickKey = InputType.Select;
#if CLIENT
item.DrawDepthOffset = SpriteDepthWhenDropped - item.SpriteDepth;
@@ -52,7 +52,11 @@ namespace Barotrauma.Items.Components
{
if (holdable.Attached)
{
GameAnalyticsManager.AddDesignEvent("ResourceCollected:" + (GameMain.GameSession?.GameMode?.Preset.Identifier.Value ?? "none") + ":" + item.Prefab.Identifier);
//we don't need info of every collected resource, we can get a good sample size just by logging a small sample
if (GameAnalyticsManager.ShouldLogRandomSample())
{
GameAnalyticsManager.AddDesignEvent("ResourceCollected:" + (GameMain.GameSession?.GameMode?.Preset.Identifier.Value ?? "none") + ":" + item.Prefab.Identifier);
}
holdable.DeattachFromWall();
}
trigger.Enabled = false;
@@ -334,6 +334,7 @@ namespace Barotrauma.Items.Components
if (targetLimb.character.IgnoreMeleeWeapons) { return false; }
var targetCharacter = targetLimb.character;
if (targetCharacter == picker) { return false; }
if (HitFriendlyTarget(targetCharacter)) { return false; }
if (AllowHitMultiple)
{
if (hitTargets.Contains(targetCharacter)) { return false; }
@@ -348,7 +349,7 @@ namespace Barotrauma.Items.Components
{
if (targetCharacter == picker || targetCharacter == User) { return false; }
if (targetCharacter.IgnoreMeleeWeapons) { return false; }
targetLimb = targetCharacter.AnimController.GetLimb(LimbType.Torso); //Otherwise armor can be bypassed in strange ways
if (HitFriendlyTarget(targetCharacter)) { return false; }
if (AllowHitMultiple)
{
if (hitTargets.Contains(targetCharacter)) { return false; }
@@ -395,10 +396,22 @@ namespace Barotrauma.Items.Components
{
return false;
}
impactQueue.Enqueue(f2);
return true;
// Prevent bots from hitting friendly targets.
bool HitFriendlyTarget(Character target)
{
if (User.IsPlayer) { return false; }
if (User.AIController is HumanAIController { Enabled: true } humanAI)
{
if (humanAI.ObjectiveManager.CurrentObjective is AIObjectiveCombat combat && combat.Enemy != target)
{
if (humanAI.IsFriendly(target, onlySameTeam: true)) { return true; }
}
}
return false;
}
}
private System.Text.StringBuilder serverLogger;
@@ -322,6 +322,7 @@ namespace Barotrauma.Items.Components
}
}
}
projectile.Item.body.Dir = Item.body.Dir;
projectile.Shoot(character, character.AnimController.AimSourceSimPos, barrelPos, rotation + spread, ignoredBodies: ignoredBodies.ToList(), createNetworkEvent: false, damageMultiplier, LaunchImpulse);
projectile.Item.GetComponent<Rope>()?.Attach(Item, projectile.Item);
if (projectile.Item.body != null)
@@ -248,7 +248,7 @@ namespace Barotrauma.Items.Components
var barrelHull = Hull.FindHull(ConvertUnits.ToDisplayUnits(rayStartWorld), item.CurrentHull, useWorldCoordinates: true);
if (barrelHull != null && barrelHull != item.CurrentHull)
{
if (MathUtils.GetLineRectangleIntersection(ConvertUnits.ToDisplayUnits(sourcePos), ConvertUnits.ToDisplayUnits(rayStart), item.CurrentHull.Rect, out Vector2 hullIntersection))
if (MathUtils.GetLineWorldRectangleIntersection(ConvertUnits.ToDisplayUnits(sourcePos), ConvertUnits.ToDisplayUnits(rayStart), item.CurrentHull.Rect, out Vector2 hullIntersection))
{
if (!item.CurrentHull.ConnectedGaps.Any(g => g.Open > 0.0f && Submarine.RectContains(g.Rect, hullIntersection)))
{