(663910402) Unequip weapons when not in combat mode and all items when idling.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:20:11 +03:00
parent 3b313976c5
commit 7b6c2f1fa8
9 changed files with 324 additions and 46 deletions
@@ -4,6 +4,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Barotrauma.Extensions;
using Barotrauma.Items.Components;
namespace Barotrauma
{
@@ -197,6 +198,30 @@ namespace Barotrauma
extinguisherItem.Drop(Character);
}
}
foreach (var item in Character.Inventory.Items)
{
if (item == null) { continue; }
bool unequip = false;
if (ObjectiveManager.CurrentObjective is AIObjectiveIdle)
{
unequip = item.AllowedSlots.Contains(InvSlotType.RightHand | InvSlotType.LeftHand);
}
else if (!(ObjectiveManager.CurrentObjective is AIObjectiveCombat))
{
unequip = item.GetComponent<RangedWeapon>() != null || item.GetComponent<MeleeWeapon>() != null;
}
if (unequip)
{
if (Character.HasEquippedItem(item))
{
// Try to put the weapon in an Any slot, and drop it if that fails
if (!item.AllowedSlots.Contains(InvSlotType.Any) || !Character.Inventory.TryPutItem(item, Character, new List<InvSlotType>() { InvSlotType.Any }))
{
item.Drop(Character);
}
}
}
}
if (Character.IsKeyDown(InputType.Aim))
{