diff --git a/Assets/Scripts/SS3D/Systems/Health/Bodypart.cs b/Assets/Scripts/SS3D/Systems/Health/Bodypart.cs index 546c4b3504..8c82dd9a74 100644 --- a/Assets/Scripts/SS3D/Systems/Health/Bodypart.cs +++ b/Assets/Scripts/SS3D/Systems/Health/Bodypart.cs @@ -13,6 +13,7 @@ using SS3D.Systems.Health; using System.Linq; using System.Collections.ObjectModel; +using FishNet; /// /// Class to handle all networking stuff related to a body part, there should be only one on a given game object. @@ -27,13 +28,19 @@ public abstract class BodyPart : InteractionTargetNetworkBehaviour [SerializeField] private SkinnedMeshRenderer _skinnedMeshRenderer; + [SerializeField] + protected GameObject _bodyPartItem; - private readonly List _childBodyParts = new List(); + + private readonly List _childBodyParts = new List(); public readonly List _bodyLayers = new List(); public string Name; + + + public ReadOnlyCollection BodyLayers { get { return _bodyLayers.AsReadOnly(); } @@ -112,22 +119,23 @@ public virtual void Init(BodyPart parentBodyPart, List childBodyParts, /// /// The body part is not destroyed, it's simply detached from the entity. /// - public void DetachBodyPart() + protected virtual void DetachBodyPart() { - //Spawn a detached body part from the entity, and destroy this one with all childs. - // Maybe better in body part controller. - //throw new NotImplementedException(); - _parentBodyPart.DetachBodyPart(); - Despawn(); - } + //Spawn a detached body part from the entity, and destroy this one with all childs. + // Maybe better in body part controller. + //throw new NotImplementedException(); - /// - /// The body part took so much damages that it's simply destroyed. - /// Think complete crushing, burning to dust kind of stuff. - /// All child body parts are detached. - /// - /// - public void DestroyBodyPart() + GameObject go = Instantiate(_bodyPartItem); + InstanceFinder.ServerManager.Spawn(go, null); + } + + /// + /// The body part took so much damages that it's simply destroyed. + /// Think complete crushing, burning to dust kind of stuff. + /// All child body parts are detached. + /// + /// + public void DestroyBodyPart() { // destroy this body part with all childs on the entity, detach all childs. // Maybe better in body part controller. @@ -283,6 +291,7 @@ private void RemoveBodyPart() protected virtual void RemoveSingleBodyPart() { HideSeveredBodyPart(); + DetachBodyPart(); } private void HideSeveredBodyPart()