From 9cfbbb44ed615afb47c484f159ea253a2f311081 Mon Sep 17 00:00:00 2001 From: Regalis Date: Fri, 19 Feb 2016 15:58:43 +0200 Subject: [PATCH] Fixed a bunch of sprites not being removed --- Subsurface/Source/Characters/Character.cs | 4 +++ Subsurface/Source/Characters/CharacterInfo.cs | 5 ++++ Subsurface/Source/Characters/Limb.cs | 3 +- Subsurface/Source/Items/Components/Door.cs | 6 ++-- .../Source/Items/Components/ItemComponent.cs | 11 ++++++-- .../Source/Items/Components/ItemContainer.cs | 4 +-- .../Source/Items/Components/Machines/Radar.cs | 7 +++++ .../Components/Signal/ConnectionPanel.cs | 7 +---- .../Items/Components/Signal/LightComponent.cs | 4 +-- .../Items/Components/Signal/WifiComponent.cs | 4 +-- .../Source/Items/Components/Signal/Wire.cs | 4 +-- Subsurface/Source/Items/Components/Turret.cs | 4 +-- .../Source/Items/Components/Wearable.cs | 26 ++++++++++++------ Subsurface/Source/Map/Lights/LightSource.cs | 2 ++ Subsurface/Source/Sprite.cs | 7 +++++ Subsurface_Solution.v12.suo | Bin 819712 -> 819712 bytes 16 files changed, 68 insertions(+), 30 deletions(-) diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index cde80ccc1..0cdb390bb 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -124,6 +124,8 @@ namespace Barotrauma } set { + if (info != null && info != value) info.Remove(); + info = value; if (info != null) info.Character = this; } @@ -1685,6 +1687,8 @@ namespace Barotrauma { base.Remove(); + if (info != null) info.Remove(); + CharacterList.Remove(this); if (controlled == this) controlled = null; diff --git a/Subsurface/Source/Characters/CharacterInfo.cs b/Subsurface/Source/Characters/CharacterInfo.cs index ab8e073b8..0b49799f5 100644 --- a/Subsurface/Source/Characters/CharacterInfo.cs +++ b/Subsurface/Source/Characters/CharacterInfo.cs @@ -325,5 +325,10 @@ namespace Barotrauma parentElement.Add(charElement); return charElement; } + + public void Remove() + { + if (headSprite != null) headSprite.Remove(); + } } } diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index af8be0cdc..4463aa0b7 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -286,7 +286,6 @@ namespace Barotrauma damagedSpritePath = damagedSpritePath.Replace("[HEADID]", character.Info.HeadSpriteId.ToString()); } - damagedSprite = new Sprite(subElement, "", damagedSpritePath); break; case "attack": @@ -546,6 +545,8 @@ namespace Barotrauma public void Remove() { sprite.Remove(); + if (damagedSprite != null) damagedSprite.Remove(); + body.Remove(); if (bodyShapeTexture != null) diff --git a/Subsurface/Source/Items/Components/Door.cs b/Subsurface/Source/Items/Components/Door.cs index 3eaeed503..8c485b99d 100644 --- a/Subsurface/Source/Items/Components/Door.cs +++ b/Subsurface/Source/Items/Components/Door.cs @@ -349,16 +349,16 @@ namespace Barotrauma.Items.Components UpdateConvexHulls(); } - public override void Remove() + protected override void RemoveComponentSpecific() { - base.Remove(); + base.RemoveComponentSpecific(); GameMain.World.RemoveBody(body.FarseerBody); if (linkedGap!=null) linkedGap.Remove(); doorSprite.Remove(); - weldedSprite.Remove(); + if (weldedSprite != null) weldedSprite.Remove(); if (convexHull!=null) convexHull.Remove(); if (convexHull2 != null) convexHull2.Remove(); diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index 18cf9fcc5..d39882f6c 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -470,12 +470,19 @@ namespace Barotrauma.Items.Components return false; } - public virtual void Remove() + public void Remove() { - if (loopingSound!=null) + if (loopingSound != null) { Sounds.SoundManager.Stop(loopingSoundIndex); } + + RemoveComponentSpecific(); + } + + protected virtual void RemoveComponentSpecific() + { + } public bool HasRequiredSkills(Character character) diff --git a/Subsurface/Source/Items/Components/ItemContainer.cs b/Subsurface/Source/Items/Components/ItemContainer.cs index 0f59ed56f..0f529c2d9 100644 --- a/Subsurface/Source/Items/Components/ItemContainer.cs +++ b/Subsurface/Source/Items/Components/ItemContainer.cs @@ -247,9 +247,9 @@ namespace Barotrauma.Items.Components itemIds = null; } - public override void Remove() + protected override void RemoveComponentSpecific() { - base.Remove(); + base.RemoveComponentSpecific(); foreach (Item item in Inventory.Items) { diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index a2fe024df..eee114b86 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -321,6 +321,13 @@ namespace Barotrauma.Items.Components new Vector2(markerPos.X + 10, markerPos.Y + 15), Color.LightGreen); } + protected override void RemoveComponentSpecific() + { + if (pingCircle!=null) pingCircle.Remove(); + if (screenOverlay != null) screenOverlay.Remove(); + + } + public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) { message.Write(IsActive); diff --git a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs index bc4cb8490..80f6070d6 100644 --- a/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Source/Items/Components/Signal/ConnectionPanel.cs @@ -118,12 +118,7 @@ namespace Barotrauma.Items.Components loadedConnections[i].wireId.CopyTo(Connections[i].wireId, 0); } } - - public override void Remove() - { - base.Remove(); - } - + public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) { foreach (Connection c in Connections) diff --git a/Subsurface/Source/Items/Components/Signal/LightComponent.cs b/Subsurface/Source/Items/Components/Signal/LightComponent.cs index 4075c8d8a..da087e47d 100644 --- a/Subsurface/Source/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/LightComponent.cs @@ -145,9 +145,9 @@ namespace Barotrauma.Items.Components //GUI.DrawLine(spriteBatch, center - Vector2.One * range, center + Vector2.One * range, lightColor); } - public override void Remove() + protected override void RemoveComponentSpecific() { - base.Remove(); + base.RemoveComponentSpecific(); light.Remove(); } diff --git a/Subsurface/Source/Items/Components/Signal/WifiComponent.cs b/Subsurface/Source/Items/Components/Signal/WifiComponent.cs index 870f3ddb3..067c6fcbd 100644 --- a/Subsurface/Source/Items/Components/Signal/WifiComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/WifiComponent.cs @@ -46,9 +46,9 @@ namespace Barotrauma.Items.Components } } - public override void Remove() + protected override void RemoveComponentSpecific() { - base.Remove(); + base.RemoveComponentSpecific(); list.Remove(this); } diff --git a/Subsurface/Source/Items/Components/Signal/Wire.cs b/Subsurface/Source/Items/Components/Signal/Wire.cs index 8f1821305..6e5831beb 100644 --- a/Subsurface/Source/Items/Components/Signal/Wire.cs +++ b/Subsurface/Source/Items/Components/Signal/Wire.cs @@ -461,11 +461,11 @@ namespace Barotrauma.Items.Components } - public override void Remove() + protected override void RemoveComponentSpecific() { ClearConnections(); - base.Remove(); + base.RemoveComponentSpecific(); } public override bool FillNetworkData(Networking.NetworkEventType type, Lidgren.Network.NetBuffer message) diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs index ed9118b46..8cf31b3d5 100644 --- a/Subsurface/Source/Items/Components/Turret.cs +++ b/Subsurface/Source/Items/Components/Turret.cs @@ -294,9 +294,9 @@ namespace Barotrauma.Items.Components return availablePower; } - public override void Remove() + protected override void RemoveComponentSpecific() { - base.Remove(); + base.RemoveComponentSpecific(); barrelSprite.Remove(); } diff --git a/Subsurface/Source/Items/Components/Wearable.cs b/Subsurface/Source/Items/Components/Wearable.cs index 7aba939e4..6f267bc20 100644 --- a/Subsurface/Source/Items/Components/Wearable.cs +++ b/Subsurface/Source/Items/Components/Wearable.cs @@ -23,7 +23,7 @@ namespace Barotrauma.Items.Components class Wearable : Pickable { - WearableSprite[] wearableSprite; + WearableSprite[] wearableSprites; LimbType[] limbType; Limb[] limb; @@ -62,7 +62,7 @@ namespace Barotrauma.Items.Components var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList(); int spriteCount = sprites.Count(); - wearableSprite = new WearableSprite[spriteCount]; + wearableSprites = new WearableSprite[spriteCount]; limbType = new LimbType[spriteCount]; limb = new Limb[spriteCount]; @@ -85,7 +85,7 @@ namespace Barotrauma.Items.Components spritePath = Path.GetDirectoryName( item.Prefab.ConfigFile)+"/"+spritePath; var sprite = new Sprite(subElement, "", spritePath); - wearableSprite[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false), + wearableSprites[i] = new WearableSprite(sprite, ToolBox.GetAttributeBool(subElement, "hidelimb", false), (LimbType)Enum.Parse(typeof(LimbType), ToolBox.GetAttributeString(subElement, "depthlimb", "None"), true)); @@ -99,7 +99,7 @@ namespace Barotrauma.Items.Components public override void Equip(Character character) { picker = character; - for (int i = 0; i < wearableSprite.Length; i++ ) + for (int i = 0; i < wearableSprites.Length; i++ ) { Limb equipLimb = character.AnimController.GetLimb(limbType[i]); if (equipLimb == null) continue; @@ -118,7 +118,7 @@ namespace Barotrauma.Items.Components limb[i] = equipLimb; equipLimb.WearingItem = this; - equipLimb.WearingItemSprite = wearableSprite[i]; + equipLimb.WearingItemSprite = wearableSprites[i]; } } @@ -135,7 +135,7 @@ namespace Barotrauma.Items.Components public override void Unequip(Character character) { if (picker == null) return; - for (int i = 0; i < wearableSprite.Length; i++) + for (int i = 0; i < wearableSprites.Length; i++) { Limb equipLimb = character.AnimController.GetLimb(limbType[i]); if (equipLimb == null) continue; @@ -162,18 +162,28 @@ namespace Barotrauma.Items.Components item.SetTransform(picker.SimPosition, 0.0f); Item[] containedItems = item.ContainedItems; - + ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker); PlaySound(ActionType.OnWearing, picker.WorldPosition); if (containedItems == null) return; - for (int j = 0; j?d`-3&7$$S9X0$7CFcD3*d}j8PF+jS@gYyuy0ot%<}jp5YSlfVj$I zr#)f>qc6Hic?9J}jRwycuhNad3k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