Build 0.20.8.0
This commit is contained in:
@@ -315,6 +315,7 @@ namespace Barotrauma.Items.Components
|
||||
if (f2.Body.UserData is Limb targetLimb)
|
||||
{
|
||||
if (targetLimb.IsSevered || targetLimb.character == null || targetLimb.character == User) { return false; }
|
||||
if (targetLimb.character.IgnoreMeleeWeapons) { return false; }
|
||||
var targetCharacter = targetLimb.character;
|
||||
if (targetCharacter == picker) { return false; }
|
||||
if (AllowHitMultiple)
|
||||
@@ -330,6 +331,7 @@ namespace Barotrauma.Items.Components
|
||||
else if (f2.Body.UserData is Character targetCharacter)
|
||||
{
|
||||
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 (AllowHitMultiple)
|
||||
{
|
||||
|
||||
@@ -816,7 +816,14 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
hasRequiredItems = itemList.Any(Predicate);
|
||||
if (itemList.Any(Predicate))
|
||||
{
|
||||
hasRequiredItems = !relatedItem.RequireEmpty;
|
||||
}
|
||||
else
|
||||
{
|
||||
hasRequiredItems = relatedItem.MatchOnEmpty || relatedItem.RequireEmpty;
|
||||
}
|
||||
if (!hasRequiredItems)
|
||||
{
|
||||
shouldBreak = true;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Barotrauma.Items.Components
|
||||
[Serialize(100, IsPropertySaveable.No, description: "How many items are placed in a row before starting a new row.")]
|
||||
public int ItemsPerRow { get; set; }
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No, description: "Should the inventory of this item be visible when the item is selected.")]
|
||||
[Serialize(true, IsPropertySaveable.No, description: "Should the contents in the item's inventory be visible? Disabled on items like magazines that spawn the contents as needed.")]
|
||||
public bool DrawInventory
|
||||
{
|
||||
get;
|
||||
@@ -135,9 +135,6 @@ namespace Barotrauma.Items.Components
|
||||
set;
|
||||
}
|
||||
|
||||
[Serialize(true, IsPropertySaveable.No)]
|
||||
public bool AllowAccess { get; set; }
|
||||
|
||||
[Serialize(false, IsPropertySaveable.No)]
|
||||
public bool AccessOnlyWhenBroken { get; set; }
|
||||
|
||||
@@ -530,12 +527,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool HasRequiredItems(Character character, bool addMessage, LocalizedString msg = null)
|
||||
{
|
||||
return AllowAccess && (!AccessOnlyWhenBroken || Item.Condition <= 0) && base.HasRequiredItems(character, addMessage, msg);
|
||||
return DrawInventory && (!AccessOnlyWhenBroken || Item.Condition <= 0) && base.HasRequiredItems(character, addMessage, msg);
|
||||
}
|
||||
|
||||
public override bool Select(Character character)
|
||||
{
|
||||
if (!AllowAccess) { return false; }
|
||||
if (!DrawInventory) { return false; }
|
||||
if (item.Container != null) { return false; }
|
||||
if (AccessOnlyWhenBroken)
|
||||
{
|
||||
@@ -571,7 +568,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
{
|
||||
if (!AllowAccess) { return false; }
|
||||
if (!DrawInventory) { return false; }
|
||||
if (AccessOnlyWhenBroken)
|
||||
{
|
||||
if (item.Condition > 0)
|
||||
|
||||
@@ -539,7 +539,7 @@ namespace Barotrauma.Items.Components
|
||||
var prevUser = user;
|
||||
CancelFabricating();
|
||||
|
||||
amountRemaining--;
|
||||
amountRemaining--;
|
||||
if (amountRemaining > 0 && CanBeFabricated(prevFabricatedItem, availableIngredients, prevUser))
|
||||
{
|
||||
//keep fabricating if we can fabricate more
|
||||
@@ -745,7 +745,7 @@ namespace Barotrauma.Items.Components
|
||||
itemList.AddRange(container.Inventory.AllItems);
|
||||
}
|
||||
}
|
||||
if (user?.Inventory != null)
|
||||
if (user?.Inventory != null && user.SelectedItem == item)
|
||||
{
|
||||
itemList.AddRange(user.Inventory.AllItems);
|
||||
linkedInventories.Add(user.Inventory);
|
||||
|
||||
@@ -65,14 +65,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
get
|
||||
{
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
return (float)(Timing.TotalTime - GameMain.GameSession.RoundStartTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
return GameMain.GameSession?.RoundDuration ?? 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -639,7 +639,13 @@ namespace Barotrauma.Items.Components
|
||||
ItemContainer projectileContainer = projectiles.First().Item.Container?.GetComponent<ItemContainer>();
|
||||
if (projectileContainer != null && projectileContainer.Item != item)
|
||||
{
|
||||
projectileContainer?.Item.Use(deltaTime, null);
|
||||
projectileContainer.Item.Use(deltaTime, null);
|
||||
//Use root container (e.g. loader) too in case it needs to react to firing somehow
|
||||
var rootContainer = projectileContainer.Item.GetRootContainer();
|
||||
if (rootContainer != projectileContainer.Item)
|
||||
{
|
||||
rootContainer.Use(deltaTime, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -649,7 +655,7 @@ namespace Barotrauma.Items.Components
|
||||
var e = item.linkedTo[(j + currentLoaderIndex) % item.linkedTo.Count];
|
||||
//use linked projectile containers in case they have to react to the turret being launched somehow
|
||||
//(play a sound, spawn more projectiles)
|
||||
if (!(e is Item linkedItem)) { continue; }
|
||||
if (e is not Item linkedItem) { continue; }
|
||||
if (!item.Prefab.IsLinkAllowed(e.Prefab)) { continue; }
|
||||
if (linkedItem.Condition <= 0.0f)
|
||||
{
|
||||
@@ -692,7 +698,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (MapEntity e in item.linkedTo)
|
||||
{
|
||||
if (!(e is Item linkedItem)) { continue; }
|
||||
if (e is not Item linkedItem) { continue; }
|
||||
if (!((MapEntity)item).Prefab.IsLinkAllowed(e.Prefab)) { continue; }
|
||||
if (linkedItem.GetComponent<Repairable>() is Repairable repairable && repairable.IsTinkering && linkedItem.HasTag("turretammosource"))
|
||||
{
|
||||
@@ -872,7 +878,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void LaunchProjSpecific();
|
||||
|
||||
private void ShiftItemsInProjectileContainer(ItemContainer container)
|
||||
private static void ShiftItemsInProjectileContainer(ItemContainer container)
|
||||
{
|
||||
if (container == null) { return; }
|
||||
bool moved;
|
||||
@@ -1063,8 +1069,8 @@ namespace Barotrauma.Items.Components
|
||||
character.AIController.SelectTarget(null);
|
||||
}
|
||||
|
||||
bool canShoot = true;
|
||||
if (!HasPowerToShoot())
|
||||
bool canShoot = HasPowerToShoot();
|
||||
if (!canShoot)
|
||||
{
|
||||
List<PowerContainer> batteries = GetDirectlyConnectedBatteries();
|
||||
float lowestCharge = 0.0f;
|
||||
@@ -1089,7 +1095,6 @@ namespace Barotrauma.Items.Components
|
||||
character.Speak(TextManager.Get("DialogSupercapacitorIsBroken").Value,
|
||||
identifier: "supercapacitorisbroken".ToIdentifier(),
|
||||
minDurationBetweenSimilar: 30.0f);
|
||||
canShoot = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1104,7 +1109,6 @@ namespace Barotrauma.Items.Components
|
||||
character.Speak(TextManager.Get("DialogTurretHasNoPower").Value,
|
||||
identifier: "turrethasnopower".ToIdentifier(),
|
||||
minDurationBetweenSimilar: 30.0f);
|
||||
canShoot = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1283,7 +1287,7 @@ namespace Barotrauma.Items.Components
|
||||
closestDistance = shootDistance;
|
||||
foreach (var wall in Level.Loaded.ExtraWalls)
|
||||
{
|
||||
if (!(wall is DestructibleLevelWall destructibleWall) || destructibleWall.Destroyed) { continue; }
|
||||
if (wall is not DestructibleLevelWall destructibleWall || destructibleWall.Destroyed) { continue; }
|
||||
foreach (var cell in wall.Cells)
|
||||
{
|
||||
if (cell.DoesDamage)
|
||||
@@ -1405,19 +1409,18 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 end = ConvertUnits.ToSimUnits(targetPos.Value);
|
||||
// Check that there's not other entities that shouldn't be targeted (like a friendly sub) between us and the target.
|
||||
Body worldTarget = CheckLineOfSight(start, end);
|
||||
bool shoot;
|
||||
if (closestEnemy != null && closestEnemy.Submarine != null)
|
||||
{
|
||||
start -= closestEnemy.Submarine.SimPosition;
|
||||
end -= closestEnemy.Submarine.SimPosition;
|
||||
Body transformedTarget = CheckLineOfSight(start, end);
|
||||
shoot = CanShoot(transformedTarget, character) && (worldTarget == null || CanShoot(worldTarget, character));
|
||||
canShoot = CanShoot(transformedTarget, character) && (worldTarget == null || CanShoot(worldTarget, character));
|
||||
}
|
||||
else
|
||||
{
|
||||
shoot = CanShoot(worldTarget, character);
|
||||
canShoot = CanShoot(worldTarget, character);
|
||||
}
|
||||
if (!shoot) { return false; }
|
||||
if (!canShoot) { return false; }
|
||||
if (character.IsOnPlayerTeam)
|
||||
{
|
||||
character.Speak(TextManager.Get("DialogFireTurret").Value,
|
||||
@@ -1471,6 +1474,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (targetBody.UserData is ISpatialEntity e)
|
||||
{
|
||||
if (e is Structure s && s.Indestructible) { return false; }
|
||||
Submarine sub = e.Submarine ?? e as Submarine;
|
||||
if (!targetSubmarines && e is Submarine) { return false; }
|
||||
if (sub == null) { return false; }
|
||||
@@ -1559,7 +1563,7 @@ namespace Barotrauma.Items.Components
|
||||
return projectiles;
|
||||
}
|
||||
|
||||
private void CheckProjectileContainer(Item projectileContainer, List<Projectile> projectiles, out bool stopSearching)
|
||||
private static void CheckProjectileContainer(Item projectileContainer, List<Projectile> projectiles, out bool stopSearching)
|
||||
{
|
||||
stopSearching = false;
|
||||
if (projectileContainer.Condition <= 0.0f) { return; }
|
||||
|
||||
Reference in New Issue
Block a user