(476b2ba9b) Don't allow deattaching items when another component of the item is selected (e.g. wiring interface), interrupt picking if the item is removed or moved to an inventory

This commit is contained in:
Joonas Rikkonen
2019-04-10 13:24:53 +03:00
parent fa4d1caeed
commit ca5e11e859

View File

@@ -122,7 +122,14 @@ namespace Barotrauma.Items.Components
pickTimer = 0.0f;
while (pickTimer < requiredTime && Screen.Selected != GameMain.SubEditorScreen)
{
if (picker.IsKeyDown(InputType.Aim) || !picker.CanInteractWith(item))
//cancel if the item is currently selected
//attempting to pick does not select the item, so if it is selected at this point, another ItemComponent
//must have been selected and we should not keep deattaching (happens when for example interacting with
//an electrical component while holding both a screwdriver and a wrench).
if (picker.SelectedConstruction == item ||
picker.IsKeyDown(InputType.Aim) ||
!picker.CanInteractWith(item) ||
item.Removed || item.ParentInventory != null)
{
StopPicking(picker);
yield return CoroutineStatus.Success;
@@ -135,9 +142,8 @@ namespace Barotrauma.Items.Components
pickTimer / requiredTime,
Color.Red, Color.Green);
#endif
picker.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((pickTimer / 10.0f) % 0.1f));
picker.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((pickTimer / 10.0f) % 0.1f));
pickTimer += CoroutineManager.DeltaTime;
yield return CoroutineStatus.Running;