Release 1.10.5.0 - Autumn Update 2025

This commit is contained in:
Regalis11
2025-09-17 13:44:21 +03:00
parent d13836ce87
commit caa0326cf8
120 changed files with 2584 additions and 635 deletions
@@ -101,6 +101,7 @@ namespace Barotrauma
public static bool IsValidTarget(Item item, Character character, bool checkInventory, bool allowUnloading = true, bool requireValidContainer = true, bool ignoreItemsMarkedForDeconstruction = true)
{
if (item == null) { return false; }
if (item.GetComponents<Pickable>().None(c => c is not Door && c.CanBePicked)) { return false; }
if (item.DontCleanUp) { return false; }
if (item.Illegitimate == character.IsOnPlayerTeam) { return false; }
if (item.ParentInventory != null)
@@ -65,7 +65,7 @@ namespace Barotrauma
private readonly AIObjectiveFindSafety findSafety;
private readonly HashSet<ItemComponent> weapons = new HashSet<ItemComponent>();
private readonly HashSet<Item> ignoredWeapons = new HashSet<Item>();
private readonly HashSet<ItemComponent> ignoredWeapons = new HashSet<ItemComponent>();
private AIObjectiveContainItem seekAmmunitionObjective;
private AIObjectiveGoTo retreatObjective;
@@ -503,7 +503,8 @@ namespace Barotrauma
HashSet<ItemComponent> allWeapons = FindWeaponsFromInventory();
while (allWeapons.Any())
{
Weapon = GetWeapon(allWeapons, out _weaponComponent);
Weapon = GetWeapon(allWeapons, out ItemComponent newWeaponComponent);
_weaponComponent = newWeaponComponent;
if (Weapon == null)
{
// No weapons
@@ -512,7 +513,7 @@ namespace Barotrauma
if (!character.Inventory.Contains(Weapon) || WeaponComponent == null)
{
// Not in the inventory anymore or cannot find the weapon component
allWeapons.Remove(WeaponComponent);
allWeapons.RemoveWhere(weaponComponent => weaponComponent.Item == Weapon);
Weapon = null;
continue;
}
@@ -540,7 +541,7 @@ namespace Barotrauma
else
{
// No ammo and should not try to seek ammo.
allWeapons.Remove(WeaponComponent);
allWeapons.RemoveWhere(weaponComponent => weaponComponent.Item == Weapon);
Weapon = null;
}
}
@@ -980,7 +981,6 @@ namespace Barotrauma
weapons.Clear();
foreach (var item in character.Inventory.AllItems)
{
if (ignoredWeapons.Contains(item)) { continue; }
GetWeapons(item, weapons);
if (item.OwnInventory != null)
{
@@ -990,11 +990,12 @@ namespace Barotrauma
return weapons;
}
private static void GetWeapons(Item item, ICollection<ItemComponent> weaponList)
private void GetWeapons(Item item, ICollection<ItemComponent> weaponList)
{
if (item == null) { return; }
foreach (var component in item.Components)
{
if (ignoredWeapons.Contains(component)) { continue; }
if (component.CombatPriority > 0)
{
weaponList.Add(component);
@@ -1332,19 +1333,21 @@ namespace Barotrauma
{
SteeringManager.Reset();
RemoveSubObjective(ref seekAmmunitionObjective);
ignoredWeapons.Add(Weapon);
ignoredWeapons.Add(WeaponComponent);
Weapon = null;
});
}
/// <summary>
/// Reloads the ammunition found in the inventory.
/// If seekAmmo is true, tries to get find the ammo elsewhere.
/// </summary>
/// <returns>True if the weapon was reloaded successfully.</returns>
private bool Reload(bool seekAmmo)
{
if (WeaponComponent == null) { return false; }
if (Weapon.OwnInventory == null) { return true; }
if (!Weapon.IsInteractable(character)) { return false; }
HumanAIController.UnequipEmptyItems(Weapon, allowDestroying: !character.IsOnPlayerTeam);
ImmutableHashSet<Identifier> ammunitionIdentifiers = null;
if (WeaponComponent.RequiredItems.ContainsKey(RelatedItem.RelationType.Contained))
@@ -443,6 +443,10 @@ namespace Barotrauma
newCurrentObjective.Abandoned += () => DismissSelf(order);
CurrentOrders.Add(order.WithObjective(newCurrentObjective));
}
else if (!order.IsDismissal)
{
DebugConsole.ThrowError($"Failed to create an objective for the order: {order.Name}");
}
if (!HasOrders())
{
// Recreate objectives, because some of them may be removed, if impossible to complete (e.g. due to path finding)
@@ -458,6 +462,9 @@ namespace Barotrauma
}
}
/// <summary>
/// Creates an AI objective based on the order. Note that the method can return null in the case of e.g. Dismissal orders or orders that erroneously target something non-interactable.
/// </summary>
public AIObjective CreateObjective(Order order, float priorityModifier = 1)
{
if (order == null || order.IsDismissal) { return null; }