v0.14.6.0
This commit is contained in:
@@ -319,6 +319,25 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Equip(Character character)
|
||||
{
|
||||
//if the item has multiple Pickable components (e.g. Holdable and Wearable, check that we don't equip it in hands when the item is worn or vice versa)
|
||||
if (item.GetComponents<Pickable>().Count() > 0)
|
||||
{
|
||||
bool inSuitableSlot = false;
|
||||
for (int i = 0; i < character.Inventory.Capacity; i++)
|
||||
{
|
||||
if (character.Inventory.GetItemsAt(i).Contains(item))
|
||||
{
|
||||
if (character.Inventory.SlotTypes[i] != InvSlotType.Any &&
|
||||
allowedSlots.Any(a => a.HasFlag(character.Inventory.SlotTypes[i])))
|
||||
{
|
||||
inSuitableSlot = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!inSuitableSlot) { return; }
|
||||
}
|
||||
|
||||
picker = character;
|
||||
|
||||
if (item.Removed)
|
||||
@@ -327,6 +346,13 @@ namespace Barotrauma.Items.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var wearable = item.GetComponent<Wearable>();
|
||||
if (wearable != null)
|
||||
{
|
||||
//cannot hold and wear an item at the same time
|
||||
wearable.Unequip(character);
|
||||
}
|
||||
|
||||
if (character != null) { item.Submarine = character.Submarine; }
|
||||
if (item.body == null)
|
||||
{
|
||||
@@ -414,7 +440,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (item.CurrentHull == null)
|
||||
{
|
||||
return attachTargetCell != null && Structure.GetAttachTarget(item.WorldPosition) != null;
|
||||
return attachTargetCell != null || Structure.GetAttachTarget(item.WorldPosition) != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -75,6 +75,14 @@ namespace Barotrauma.Items.Components
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
{
|
||||
if (trigger != null && amount.LengthSquared() > 0.00001f)
|
||||
{
|
||||
trigger.SetTransform(item.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (holdable != null && !holdable.Attached)
|
||||
|
||||
@@ -132,7 +132,12 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
return characterUsable || character == null;
|
||||
}
|
||||
|
||||
public override void Drop(Character dropper)
|
||||
{
|
||||
base.Drop(dropper);
|
||||
|
||||
@@ -90,6 +90,24 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public virtual bool OnPicked(Character picker)
|
||||
{
|
||||
//if the item has multiple Pickable components (e.g. Holdable and Wearable, check that we don't equip it in hands when the item is worn or vice versa)
|
||||
if (item.GetComponents<Pickable>().Count() > 0)
|
||||
{
|
||||
bool alreadyEquipped = false;
|
||||
for (int i = 0; i < picker.Inventory.Capacity; i++)
|
||||
{
|
||||
if (picker.Inventory.GetItemsAt(i).Contains(item))
|
||||
{
|
||||
if (picker.Inventory.SlotTypes[i] != InvSlotType.Any &&
|
||||
!allowedSlots.Any(a => a.HasFlag(picker.Inventory.SlotTypes[i])))
|
||||
{
|
||||
alreadyEquipped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (alreadyEquipped) { return false; }
|
||||
}
|
||||
if (picker.Inventory.TryPutItemWithAutoEquipCheck(item, picker, allowedSlots))
|
||||
{
|
||||
if (!picker.HeldItems.Contains(item) && item.body != null) { item.body.Enabled = false; }
|
||||
|
||||
@@ -69,6 +69,7 @@ namespace Barotrauma.Items.Components
|
||||
item.IsShootable = true;
|
||||
// TODO: should define this in xml if we have ranged weapons that don't require aim to use
|
||||
item.RequireAimToUse = true;
|
||||
characterUsable = true;
|
||||
InitProjSpecific(element);
|
||||
}
|
||||
|
||||
@@ -151,6 +152,11 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool SecondaryUse(float deltaTime, Character character = null)
|
||||
{
|
||||
return characterUsable || character == null;
|
||||
}
|
||||
|
||||
public Projectile FindProjectile(bool triggerOnUseOnContainers = false)
|
||||
{
|
||||
var containedItems = item.OwnInventory?.AllItemsMod;
|
||||
|
||||
@@ -548,6 +548,11 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (targetBody.UserData is LevelObject levelObject && levelObject.Prefab.TakeLevelWallDamage)
|
||||
{
|
||||
levelObject.AddDamage(-LevelWallFixAmount, deltaTime, item);
|
||||
return true;
|
||||
}
|
||||
else if (targetBody.UserData is Character targetCharacter)
|
||||
{
|
||||
if (targetCharacter.Removed) { return false; }
|
||||
|
||||
Reference in New Issue
Block a user