Skip to content

Commit

Permalink
add entity on head when head detached
Browse files Browse the repository at this point in the history
  • Loading branch information
stilnat committed Aug 21, 2023
1 parent 035b6a5 commit 78424b4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 31 deletions.
42 changes: 21 additions & 21 deletions Assets/Content/WorldObjects/Entities/Humanoids/Human/Human.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5564,8 +5564,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 444995378988440430}
- component: {fileID: 5151850602389077742}
- component: {fileID: 270151793522417329}
- component: {fileID: 3338140507791060534}
m_Layer: 12
m_Name: HumanHead
m_TagString: Untagged
Expand Down Expand Up @@ -5593,25 +5593,6 @@ Transform:
m_Father: {fileID: 498654123859477456}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &5151850602389077742
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4586892454499637632}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d25aaf3a871b3d1438c1a27c2c6b57c6, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 24
_addedNetworkObject: {fileID: 2930813178971533500}
_networkObjectCache: {fileID: 2930813178971533500}
_parentBodyPart: {fileID: 5839020956740199093}
_skinnedMeshRenderer: {fileID: 270151793522417329}
_bodyPartItem: {fileID: 5774385816057912484, guid: 9ac7c2cd12db800479e566335ff7440b, type: 3}
_bodyCollider: {fileID: 4933536203666300704}
--- !u!137 &270151793522417329
SkinnedMeshRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5715,6 +5696,25 @@ SkinnedMeshRenderer:
m_Center: {x: 0.0000001937151, y: 0.598488, z: -0.025634572}
m_Extent: {x: 0.10535494, y: 0.15681435, z: 0.13710809}
m_DirtyAABB: 0
--- !u!114 &3338140507791060534
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4586892454499637632}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: de75930610499f24788224d6b0e10d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 255
_addedNetworkObject: {fileID: 2930813178971533500}
_networkObjectCache: {fileID: 0}
_parentBodyPart: {fileID: 5839020956740199093}
_skinnedMeshRenderer: {fileID: 270151793522417329}
_bodyPartItem: {fileID: 5774385816057912484, guid: 9ac7c2cd12db800479e566335ff7440b, type: 3}
_bodyCollider: {fileID: 4933536203666300704}
--- !u!1 &4806492444777318490
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -7415,7 +7415,7 @@ MonoBehaviour:
- {fileID: 300689357194200928}
- {fileID: 7110782222688458070}
- {fileID: 677427367997810169}
- {fileID: 5151850602389077742}
- {fileID: 0}
- {fileID: 5839020956740199093}
- {fileID: 465916857022110443}
- {fileID: 1082974716090020341}
Expand Down
29 changes: 23 additions & 6 deletions Assets/Content/WorldObjects/Items/BodyParts/HumanHeadItem.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ GameObject:
- component: {fileID: 6576413314991157836}
- component: {fileID: 8532088199163376958}
- component: {fileID: 103478066480505861}
- component: {fileID: 7435336742737043067}
- component: {fileID: 8461581488634887098}
- component: {fileID: 7232113870036127856}
m_Layer: 10
m_Name: HumanHeadItem
m_TagString: Untagged
Expand Down Expand Up @@ -658,13 +659,13 @@ MonoBehaviour:
_networkBehaviours:
- {fileID: 6576413314991157836}
- {fileID: 103478066480505861}
- {fileID: 7435336742737043067}
- {fileID: 8461581488634887098}
<ParentNetworkObject>k__BackingField: {fileID: 0}
<ChildNetworkObjects>k__BackingField: []
SerializedTransformProperties:
Position: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 0}
LocalScale: {x: 0, y: 0, z: 0}
Rotation: {x: 0, y: 0, z: 0, w: 1}
LocalScale: {x: 1, y: 1, z: 1}
_isNetworked: 1
_isGlobal: 0
_initializeOrder: 0
Expand Down Expand Up @@ -697,7 +698,7 @@ MonoBehaviour:
_rigidbody: {fileID: 3362323121630547519}
AttachmentPoint: {fileID: 8087437400747043343}
AttachmentPointAlt: {fileID: 0}
--- !u!114 &7435336742737043067
--- !u!114 &8461581488634887098
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
Expand All @@ -706,7 +707,7 @@ MonoBehaviour:
m_GameObject: {fileID: 5774385816057912484}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d25aaf3a871b3d1438c1a27c2c6b57c6, type: 3}
m_Script: {fileID: 11500000, guid: de75930610499f24788224d6b0e10d6b, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 2
Expand All @@ -716,6 +717,22 @@ MonoBehaviour:
_skinnedMeshRenderer: {fileID: 0}
_bodyPartItem: {fileID: 0}
_bodyCollider: {fileID: 0}
--- !u!114 &7232113870036127856
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5774385816057912484}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67a464fdf1254e188dcb2729033a7718, type: 3}
m_Name:
m_EditorClassIdentifier:
_componentIndexCache: 255
_addedNetworkObject: {fileID: 8532088199163376958}
_networkObjectCache: {fileID: 0}
_mind: {fileID: 0}
--- !u!1 &6053338017641552129
GameObject:
m_ObjectHideFlags: 0
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/SS3D/Systems/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public void SyncMind(Mind oldMind, Mind newMind, bool asServer)
[Server]
public void SetMind(Mind mind)
{
this._mind = mind;

this._mind = mind;
if(mind == null) return;
GiveOwnership(mind.Owner);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/SS3D/Systems/Entities/MindSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void CmdSwapMinds(Entity origin, Entity target, NetworkConnection network
/// <param name="origin"></param>
/// <param name="target"></param>
[Server]
private void SwapMinds(Entity origin, Entity target)
public void SwapMinds(Entity origin, Entity target)
{
Mind originMind = origin.Mind;
Mind targetMind = target.Mind;
Expand Down
16 changes: 15 additions & 1 deletion Assets/Scripts/SS3D/Systems/Health/HeadBodyPart.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections;
using FishNet;
using SS3D.Core;
using SS3D.Systems.Entities;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

Expand All @@ -15,5 +18,16 @@ protected override void AddInitialLayers()
TryAddBodyLayer(new BoneLayer(this));
TryAddBodyLayer(new CirculatoryLayer(this));
TryAddBodyLayer(new NerveLayer(this));
TryAddBodyLayer(new OrganLayer(this));
}

protected override void DetachBodyPart()
{
GameObject go = Instantiate(_bodyPartItem, Position, Rotation);
InstanceFinder.ServerManager.Spawn(go, null);
MindSystem entitySystem = Subsystems.Get<MindSystem>();
entitySystem.SwapMinds(GetComponentInParent<Entity>(), go.GetComponent<Entity>());

Dispose();
}
}

0 comments on commit 78424b4

Please sign in to comment.