From 96cedd67f133e365f072c7c7d173f8fef1db9962 Mon Sep 17 00:00:00 2001 From: Regalis Date: Fri, 11 Nov 2016 17:34:21 +0200 Subject: [PATCH] ItemComponents that don't implement the IDrawableComponent interface can't be added to the list of drawable components, pickTimer is ignored when deattaching items from the walls in the editor --- .../Source/Items/Components/Holdable/Pickable.cs | 7 +------ .../Source/Items/Components/ItemComponent.cs | 15 ++++++++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Subsurface/Source/Items/Components/Holdable/Pickable.cs b/Subsurface/Source/Items/Components/Holdable/Pickable.cs index a4733defc..b14a2da64 100644 --- a/Subsurface/Source/Items/Components/Holdable/Pickable.cs +++ b/Subsurface/Source/Items/Components/Holdable/Pickable.cs @@ -112,10 +112,8 @@ namespace Barotrauma.Items.Components var leftHand = picker.AnimController.GetLimb(LimbType.LeftHand); var rightHand = picker.AnimController.GetLimb(LimbType.RightHand); - Drawable = true; - pickTimer = 0.0f; - while (pickTimer < requiredTime) + while (pickTimer < requiredTime && Screen.Selected != GameMain.EditMapScreen) { if (picker.IsKeyDown(InputType.Aim) || !item.IsInPickRange(picker.WorldPosition) || @@ -125,7 +123,6 @@ namespace Barotrauma.Items.Components yield return CoroutineStatus.Success; } - picker.UpdateHUDProgressBar( this, item.WorldPosition, @@ -158,8 +155,6 @@ namespace Barotrauma.Items.Components private void StopPicking(Character picker) { - Drawable = false; - picker.AnimController.Anim = AnimController.Animation.None; pickTimer = 0.0f; } diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index f8250618a..1a811bf91 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -117,17 +117,22 @@ namespace Barotrauma.Items.Components set { if (value == drawable) return; + if (!(this is IDrawableComponent)) + { + DebugConsole.ThrowError("Couldn't make ''"+this+"'' drawable (the component doesn't implement the IDrawableComponent interface)"); + return; + } + drawable = value; if (drawable) { - if (!item.drawableComponents.Contains(this as IDrawableComponent)) - item.drawableComponents.Add(this as IDrawableComponent); + if (!item.drawableComponents.Contains((IDrawableComponent)this)) + item.drawableComponents.Add((IDrawableComponent)this); } else { - item.drawableComponents.Remove(this as IDrawableComponent); - } - + item.drawableComponents.Remove((IDrawableComponent)this); + } } }