Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Added support for OnPlayerRespawn
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanLaser committed Mar 8, 2021
1 parent 959d978 commit e6fdb8b
Show file tree
Hide file tree
Showing 10 changed files with 647 additions and 11 deletions.
10 changes: 10 additions & 0 deletions CyanEmu/Scripts/CyanEmuMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,16 @@ private void OnPlayerLeft(VRCPlayerApi player)
sdkManager_.OnPlayerLeft(player);
}

public static void PlayerRespawned(VRCPlayerApi player)
{
instance_?.OnPlayerRespawn(player);
}

private void OnPlayerRespawn(VRCPlayerApi player)
{
sdkManager_.OnPlayerRespawn(player);
}

public static GameObject SpawnObject(GameObject prefab)
{
return SpawnObject(prefab, Vector3.zero, Quaternion.identity);
Expand Down
1 change: 1 addition & 0 deletions CyanEmu/Scripts/CyanEmuPlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ public void Respawn()
}
CloseMenu();
Teleport(descriptor_.spawns[0], false);
CyanEmuMain.PlayerRespawned(player_.player);
}

public void Teleport(Transform point, bool fromPlaySpace)
Expand Down
1 change: 1 addition & 0 deletions CyanEmu/Scripts/Interfaces/ICyanEmuSDKManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public interface ICyanEmuSDKManager
void OnNetworkReady();
void OnPlayerJoined(VRCPlayerApi player);
void OnPlayerLeft(VRCPlayerApi player);
void OnPlayerRespawn(VRCPlayerApi player);
void OnSpawnedObject(GameObject spawnedObject);
}
}
2 changes: 2 additions & 0 deletions CyanEmu/Scripts/VRCSDK2/CyanEmuTriggerExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public void OnPlayerLeft(VRCPlayerApi player)
FireTriggerTypeInternal(VRC_Trigger.TriggerType.OnPlayerLeft);
}

public void OnPlayerRespawn(VRCPlayerApi player) { } // SDK2 does not support this method

public void OnSpawnedObject(GameObject spawnedObject)
{
VRC_Trigger[] triggers = spawnedObject.GetComponentsInChildren<VRC_Trigger>();
Expand Down
8 changes: 8 additions & 0 deletions CyanEmu/Scripts/VRCSDK3/CyanEmuUdonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ public void OnPlayerLeft(VRCPlayerApi player)
}
}

public void OnPlayerRespawn(VRCPlayerApi player)
{
foreach (var udonBehavior in allUdonBehaviours_)
{
udonBehavior.RunEvent("_onPlayerRespawn", ("player", player));
}
}

public void OnSpawnedObject(GameObject spawnedObject)
{
UdonBehaviour[] udonBehaviours = spawnedObject.GetComponentsInChildren<UdonBehaviour>();
Expand Down
22 changes: 11 additions & 11 deletions CyanEmu/Tests/Scenes/VRCSDK2TestScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -38409,15 +38409,15 @@ PrefabInstance:
m_Modifications:
- target: {fileID: 416072, guid: 9cb1e183d39ba432db5c583c4548819c, type: 3}
propertyPath: m_LocalPosition.x
value: 1.98
value: -8.9
objectReference: {fileID: 0}
- target: {fileID: 416072, guid: 9cb1e183d39ba432db5c583c4548819c, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 416072, guid: 9cb1e183d39ba432db5c583c4548819c, type: 3}
propertyPath: m_LocalPosition.z
value: 6.45
value: -4.57
objectReference: {fileID: 0}
- target: {fileID: 416072, guid: 9cb1e183d39ba432db5c583c4548819c, type: 3}
propertyPath: m_LocalRotation.x
Expand Down Expand Up @@ -44354,17 +44354,17 @@ PrefabInstance:
type: 3}
propertyPath: DynamicMaterials.Array.data[3]
value:
objectReference: {fileID: 2100000, guid: 6025efa5103521d439261a278af62225, type: 2}
objectReference: {fileID: 2100000, guid: 3682f7747d485db4586750a832808b31, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[4]
value:
objectReference: {fileID: 2100000, guid: 7c48dd635ddae9d4bbd1847add58246a, type: 2}
objectReference: {fileID: 2100000, guid: 6025efa5103521d439261a278af62225, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[5]
value:
objectReference: {fileID: 2100000, guid: 9414e644b0d9d4c4cb1d863093f0284c, type: 2}
objectReference: {fileID: 2100000, guid: 7c48dd635ddae9d4bbd1847add58246a, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[6]
Expand All @@ -44374,22 +44374,22 @@ PrefabInstance:
type: 3}
propertyPath: DynamicMaterials.Array.data[7]
value:
objectReference: {fileID: 2100000, guid: 3682f7747d485db4586750a832808b31, type: 2}
objectReference: {fileID: 2100000, guid: bedcbcc4d577778478a5f01fe1415af1, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[8]
value:
objectReference: {fileID: 2100000, guid: bedcbcc4d577778478a5f01fe1415af1, type: 2}
objectReference: {fileID: 2100000, guid: 6021947067b9d6c4bac8d9e085a71558, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[9]
value:
objectReference: {fileID: 2100000, guid: 6021947067b9d6c4bac8d9e085a71558, type: 2}
objectReference: {fileID: 2100000, guid: 66cc0ea5b14665342802e7f17e512305, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[10]
value:
objectReference: {fileID: 2100000, guid: 66cc0ea5b14665342802e7f17e512305, type: 2}
objectReference: {fileID: 2100000, guid: 9414e644b0d9d4c4cb1d863093f0284c, type: 2}
- target: {fileID: 114409779611674446, guid: 9cb1e183d39ba432db5c583c4548819c,
type: 3}
propertyPath: DynamicMaterials.Array.data[11]
Expand Down Expand Up @@ -223958,7 +223958,7 @@ GameObject:
- component: {fileID: 1723337016}
- component: {fileID: 1723337015}
- component: {fileID: 1723337014}
m_Layer: 13
m_Layer: 0
m_Name: Pickup
m_TagString: Untagged
m_Icon: {fileID: 0}
Expand Down Expand Up @@ -224038,7 +224038,7 @@ Rigidbody:
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_IsKinematic: 1
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
Expand Down
Loading

0 comments on commit e6fdb8b

Please sign in to comment.