Compare commits

..

5 Commits

Author SHA1 Message Date
69a0a752be Successful sync test 2026-01-01 20:44:34 +01:00
97fe8cd69f Trying to get stuff to work 2025-12-29 21:02:05 +01:00
8d5362eff6 Fixed stuff 2025-12-28 19:55:54 +01:00
e3f93c69c5 Removing more networking things 2025-12-28 19:40:10 +01:00
74223c8139 Added NetworkManager 2025-12-28 19:35:18 +01:00
38 changed files with 5681 additions and 2052 deletions

6
.vsconfig Normal file
View File

@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

View File

@@ -5,7 +5,7 @@ TextureImporter:
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0

View File

@@ -5,7 +5,7 @@ TextureImporter:
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0

View File

@@ -5,7 +5,7 @@ TextureImporter:
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 0
linearTexture: 0

View File

@@ -5,7 +5,7 @@ TextureImporter:
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0

View File

@@ -5,7 +5,7 @@ TextureImporter:
externalObjects: {}
serializedVersion: 12
mipmaps:
mipMapMode: 0
mipMapMode: 1
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0

File diff suppressed because it is too large Load Diff

View File

@@ -1,120 +1,120 @@
namespace Marro.PacManUdon
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Animations;
using UnityEditor;
//namespace Marro.PacManUdon
//{
// using System.Collections;
// using System.Collections.Generic;
// using UnityEngine;
// using UnityEditor.Animations;
// using UnityEditor;
public class AnimationRecorder : MonoBehaviour
{
[SerializeField] AnimationClip clip;
[SerializeField] GameObject root;
[SerializeField] GameObject[] gameObjectsToAnimate;
private GameObjectRecorder recorder;
// public class AnimationRecorder : MonoBehaviour
// {
// [SerializeField] AnimationClip clip;
// [SerializeField] GameObject root;
// [SerializeField] GameObject[] gameObjectsToAnimate;
// private GameObjectRecorder recorder;
void Start()
{
recorder = new GameObjectRecorder(root);
// void Start()
// {
// recorder = new GameObjectRecorder(root);
foreach (GameObject gameObject in gameObjectsToAnimate)
{
// if(gameObject.GetComponent<PacMan>() || gameObject.GetComponent<Ghost>())
// {
// recorder.BindComponentsOfType<Transform>(gameObject, true);
// }
// recorder.BindComponentsOfType<Renderer>(gameObject, true);
// foreach (GameObject gameObject in gameObjectsToAnimate)
// {
// // if(gameObject.GetComponent<PacMan>() || gameObject.GetComponent<Ghost>())
// // {
// // recorder.BindComponentsOfType<Transform>(gameObject, true);
// // }
// // recorder.BindComponentsOfType<Renderer>(gameObject, true);
string path = AnimationUtility.CalculateTransformPath(gameObject.transform, root.transform);
// string path = AnimationUtility.CalculateTransformPath(gameObject.transform, root.transform);
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(GameObject), "m_IsActive"));
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(GameObject), "m_IsActive"));
Pellet pellet = gameObject.GetComponent<Pellet>();
if (pellet)
{
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(SpriteRenderer), "m_Enabled"));
if (pellet.isPowerPellet)
{
recorder.Bind(EditorCurveBinding.PPtrCurve(path, typeof(SpriteRenderer), "m_Sprite"));
}
continue;
}
// Pellet pellet = gameObject.GetComponent<Pellet>();
// if (pellet)
// {
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(SpriteRenderer), "m_Enabled"));
// if (pellet.isPowerPellet)
// {
// recorder.Bind(EditorCurveBinding.PPtrCurve(path, typeof(SpriteRenderer), "m_Sprite"));
// }
// continue;
// }
if (gameObject.GetComponent<SpriteRenderer>())
{
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(SpriteRenderer), "m_Enabled"));
recorder.Bind(EditorCurveBinding.PPtrCurve(path, typeof(SpriteRenderer), "m_Sprite"));
}
else if (gameObject.GetComponent<MeshRenderer>())
{
recorder.Bind(EditorCurveBinding.DiscreteCurve(path, typeof(MeshRenderer), "m_Enabled"));
}
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.x"));
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.y"));
recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.z"));
}
// if (gameObject.GetComponent<SpriteRenderer>())
// {
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(SpriteRenderer), "m_Enabled"));
// recorder.Bind(EditorCurveBinding.PPtrCurve(path, typeof(SpriteRenderer), "m_Sprite"));
// }
// else if (gameObject.GetComponent<MeshRenderer>())
// {
// recorder.Bind(EditorCurveBinding.DiscreteCurve(path, typeof(MeshRenderer), "m_Enabled"));
// }
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.x"));
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.y"));
// recorder.Bind(EditorCurveBinding.FloatCurve(path, typeof(Transform), "m_LocalPosition.z"));
// }
EditorCurveBinding[] bindings = recorder.GetBindings();
foreach (EditorCurveBinding binding in bindings)
{
Debug.Log($"{binding.path}, {binding.propertyName}, {binding.type}");
}
}
// EditorCurveBinding[] bindings = recorder.GetBindings();
// foreach (EditorCurveBinding binding in bindings)
// {
// Debug.Log($"{binding.path}, {binding.propertyName}, {binding.type}");
// }
// }
private static string GetGameObjectPathToObject(GameObject obj, Transform target)
{
string path = "/" + obj.name;
while (!obj.transform.parent.Equals(target))
{
obj = obj.transform.parent.gameObject;
path = "/" + obj.name + path;
}
Debug.Log($"GetGameObjectPathToTransform from {obj} to {target.gameObject} gives {path}");
return path;
}
// private static string GetGameObjectPathToObject(GameObject obj, Transform target)
// {
// string path = "/" + obj.name;
// while (!obj.transform.parent.Equals(target))
// {
// obj = obj.transform.parent.gameObject;
// path = "/" + obj.name + path;
// }
// Debug.Log($"GetGameObjectPathToTransform from {obj} to {target.gameObject} gives {path}");
// return path;
// }
void LateUpdate()
{
if (clip == null)
return;
// void LateUpdate()
// {
// if (clip == null)
// return;
recorder.TakeSnapshot(Time.deltaTime);
}
// recorder.TakeSnapshot(Time.deltaTime);
// }
void OnDisable()
{
if (clip == null)
return;
// void OnDisable()
// {
// if (clip == null)
// return;
if (recorder.isRecording)
{
recorder.SaveToClip(clip);
RemoveUnneededCurves(clip);
}
}
// if (recorder.isRecording)
// {
// recorder.SaveToClip(clip);
// RemoveUnneededCurves(clip);
// }
// }
private static void RemoveUnneededCurves(AnimationClip clip)
{
// Collect curves to process
EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(clip);
List<EditorCurveBinding> unneededCurves = new List<EditorCurveBinding>();
// private static void RemoveUnneededCurves(AnimationClip clip)
// {
// // Collect curves to process
// EditorCurveBinding[] bindings = AnimationUtility.GetCurveBindings(clip);
// List<EditorCurveBinding> unneededCurves = new List<EditorCurveBinding>();
foreach (var binding in bindings)
{
AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);
// foreach (var binding in bindings)
// {
// AnimationCurve curve = AnimationUtility.GetEditorCurve(clip, binding);
if (curve == null || curve.keys.Length <= 2)
{
unneededCurves.Add(binding);
}
}
// if (curve == null || curve.keys.Length <= 2)
// {
// unneededCurves.Add(binding);
// }
// }
// Remove unchanged curves
foreach (var binding in unneededCurves)
{
AnimationUtility.SetEditorCurve(clip, binding, null);
Debug.Log($"Removed unchanged curve for property: {binding.propertyName}");
}
}
}
}
// // Remove unchanged curves
// foreach (var binding in unneededCurves)
// {
// AnimationUtility.SetEditorCurve(clip, binding, null);
// Debug.Log($"Removed unchanged curve for property: {binding.propertyName}");
// }
// }
// }
//}

View File

@@ -43,7 +43,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 36
Data: 37
- Name:
Entry: 7
Data:
@@ -103,13 +103,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: waitingForTimeSequenceFinish
Data: waitingForTimeSequenceFinalize
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: waitingForTimeSequenceFinish
Data: waitingForTimeSequenceFinalize
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
@@ -1150,19 +1150,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: recorder
Data: networkManager
- Name: $v
Entry: 7
Data: 71|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: recorder
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 9
Data: 53
Entry: 7
Data: 72|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 53
Data: 30
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1177,13 +1183,13 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 73|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 73|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 74|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -1204,19 +1210,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: startingExtraLives
Data: recorder
- Name: $v
Entry: 7
Data: 74|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startingExtraLives
Data: recorder
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
Data: 53
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 53
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1231,19 +1237,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 75|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 76|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 76|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Game settings
- Name:
Entry: 8
Data:
Data: 1
- Name:
Entry: 7
Data: 77|UnityEngine.SerializeField, UnityEngine.CoreModule
@@ -1267,13 +1264,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: scoreToExtraLife
Data: startingExtraLives
- Name: $v
Entry: 7
Data: 78|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: scoreToExtraLife
Data: startingExtraLives
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
@@ -1297,10 +1294,19 @@ MonoBehaviour:
Data: 79|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
Data: 2
- Name:
Entry: 7
Data: 80|UnityEngine.SerializeField, UnityEngine.CoreModule
Data: 80|UnityEngine.HeaderAttribute, UnityEngine.CoreModule
- Name: header
Entry: 1
Data: Game settings
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 81|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -1321,13 +1327,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletCountOverride
Data: scoreToExtraLife
- Name: $v
Entry: 7
Data: 81|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 82|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountOverride
Data: scoreToExtraLife
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
@@ -1348,19 +1354,10 @@ MonoBehaviour:
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 82|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 83|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 83|UnityEngine.TooltipAttribute, UnityEngine.CoreModule
- Name: tooltip
Entry: 1
Data: Override amount of pellets needed to clear stage, set to -1 to disable.
- Name:
Entry: 8
Data:
Data: 1
- Name:
Entry: 7
Data: 84|UnityEngine.SerializeField, UnityEngine.CoreModule
@@ -1384,16 +1381,79 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: maze
Data: pelletCountOverride
- Name: $v
Entry: 7
Data: 85|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountOverride
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 86|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 87|UnityEngine.TooltipAttribute, UnityEngine.CoreModule
- Name: tooltip
Entry: 1
Data: Override amount of pellets needed to clear stage, set to -1 to disable.
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 88|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: maze
- Name: $v
Entry: 7
Data: 89|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: maze
- Name: <UserType>k__BackingField
Entry: 7
Data: 86|System.RuntimeType, mscorlib
Data: 90|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Maze, Assembly-CSharp
@@ -1417,7 +1477,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 87|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 91|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -1441,13 +1501,13 @@ MonoBehaviour:
Data: pelletPool
- Name: $v
Entry: 7
Data: 88|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 92|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletPool
- Name: <UserType>k__BackingField
Entry: 7
Data: 89|System.RuntimeType, mscorlib
Data: 93|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCObjectPool, VRCSDK3
@@ -1456,7 +1516,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 89
Data: 93
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1471,7 +1531,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 90|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 94|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -1495,13 +1555,13 @@ MonoBehaviour:
Data: intermission2Pole
- Name: $v
Entry: 7
Data: 91|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 95|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: intermission2Pole
- Name: <UserType>k__BackingField
Entry: 7
Data: 92|System.RuntimeType, mscorlib
Data: 96|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.Intermission2Pole, Assembly-CSharp
@@ -1523,102 +1583,6 @@ MonoBehaviour:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 93|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: mazeSpriteAnimator
- Name: $v
Entry: 7
Data: 94|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: mazeSpriteAnimator
- Name: <UserType>k__BackingField
Entry: 9
Data: 64
- Name: <SystemType>k__BackingField
Entry: 9
Data: 64
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 95|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pelletCountTotal
- Name: $v
Entry: 7
Data: 96|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountTotal
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 97|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
@@ -1642,19 +1606,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletCountRemaining
Data: mazeSpriteAnimator
- Name: $v
Entry: 7
Data: 98|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountRemaining
Data: mazeSpriteAnimator
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
Data: 64
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
Data: 64
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1690,16 +1654,114 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: attractScreenElements
Data: pelletCountTotal
- Name: $v
Entry: 7
Data: 100|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountTotal
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 101|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: pelletCountRemaining
- Name: $v
Entry: 7
Data: 102|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletCountRemaining
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 103|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: attractScreenElements
- Name: $v
Entry: 7
Data: 104|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: attractScreenElements
- Name: <UserType>k__BackingField
Entry: 7
Data: 101|System.RuntimeType, mscorlib
Data: 105|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.GameObject[], UnityEngine.CoreModule
@@ -1708,7 +1770,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 101
Data: 105
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1723,7 +1785,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 102|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
Data: 106|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
@@ -1748,16 +1810,16 @@ MonoBehaviour:
Data: intermissionScreenElements
- Name: $v
Entry: 7
Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 107|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: intermissionScreenElements
- Name: <UserType>k__BackingField
Entry: 9
Data: 101
Data: 105
- Name: <SystemType>k__BackingField
Entry: 9
Data: 101
Data: 105
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -1772,7 +1834,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 104|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
Data: 108|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
@@ -1797,13 +1859,13 @@ MonoBehaviour:
Data: gameState
- Name: $v
Entry: 7
Data: 105|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 109|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: gameState
- Name: <UserType>k__BackingField
Entry: 7
Data: 106|System.RuntimeType, mscorlib
Data: 110|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PacManGameState, Assembly-CSharp
@@ -1817,69 +1879,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Entry: 6
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 107|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 108|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 109|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: score
- Name: $v
Entry: 7
Data: 110|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: score
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
@@ -1892,16 +1893,65 @@ MonoBehaviour:
mscorlib
- Name:
Entry: 12
Data: 2
Data: 0
- Name:
Entry: 7
Data: 112|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 113|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data:
- Name: $k
Entry: 1
Data: score
- Name: $v
Entry: 7
Data: 112|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: score
- Name: <UserType>k__BackingField
Entry: 9
Data: 11
- Name: <SystemType>k__BackingField
Entry: 9
Data: 11
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 113|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 114|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 115|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -1925,7 +1975,7 @@ MonoBehaviour:
Data: level
- Name: $v
Entry: 7
Data: 114|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 116|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: level
@@ -1949,20 +1999,20 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 115|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
Data: 117|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 116|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 118|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 117|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 119|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -1986,7 +2036,7 @@ MonoBehaviour:
Data: highScore
- Name: $v
Entry: 7
Data: 118|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 120|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: highScore
@@ -2010,20 +2060,20 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 119|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
Data: 121|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 120|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 122|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 121|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 123|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -2047,7 +2097,7 @@ MonoBehaviour:
Data: extraLives
- Name: $v
Entry: 7
Data: 122|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 124|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: extraLives
@@ -2071,20 +2121,20 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 123|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
Data: 125|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 124|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 126|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 125|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 127|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:

View File

@@ -5,13 +5,10 @@ namespace Marro.PacManUdon
using System;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
using VRC.SDK3.Components;
using VRC.Udon.Common.Interfaces;
using VRC.SDK3.Data;
using VRC.SDKBase;
public partial class GameManager : UdonSharpBehaviour
public partial class GameManager : SyncedObject
{
[Header("Static game components")]
[SerializeField] private Maze[] mazes;
@@ -26,6 +23,7 @@ namespace Marro.PacManUdon
[SerializeField] private PlayerInput playerInput;
[SerializeField] private Animator demo;
[SerializeField] private SoundManager soundManager;
[SerializeField] private NetworkManager networkManager;
[SerializeField] private GameObject recorder;
@@ -46,7 +44,7 @@ namespace Marro.PacManUdon
private GameObject[] attractScreenElements;
private GameObject[] intermissionScreenElements;
[UdonSynced, FieldChangeCallback(nameof(GameState))] private PacManGameState gameState;
private PacManGameState gameState;
[UdonSynced, FieldChangeCallback(nameof(Score))] private int score;
[UdonSynced, FieldChangeCallback(nameof(Level))] private int level;
[UdonSynced, FieldChangeCallback(nameof(HighScore))] private int highScore;
@@ -79,6 +77,7 @@ namespace Marro.PacManUdon
playerInput.Initialize(this);
soundManager.Initialize();
intermission2Pole.Initialize(this, ghostManager.Ghosts[0]);
networkManager.Initialize();
HideEverything();
@@ -119,35 +118,16 @@ namespace Marro.PacManUdon
StartTimeSequence(PacManTimeSequence.StartNewGame);
}
public void SkipLevelButtonPressed()
{
if (Networking.IsOwner(gameObject))
{
Debug.Log($"{gameObject} Skip level button pressed!");
StartTimeSequence(PacManTimeSequence.BoardClear);
TimeSequenceSkipToNextStep();
}
}
public void StartDemoButtonPressed()
{
if (Networking.IsOwner(gameObject))
{
Debug.Log($"{gameObject} Start demo button pressed!");
StartTimeSequence(PacManTimeSequence.Intermission1);
}
}
private void StartAttractMode()
{
// #if RECORDING_DEMO
// #if RECORDING_DEMO
// recorder.gameObject.SetActive(true);
StartTimeSequence(PacManTimeSequence.AttractScreenIntroduction);
// #else
// SetGameState(PacManGameState.AttractMode);
// HideEverything();
// demo.gameObject.SetActive(true);
// #endif
// #else
// SetGameState(PacManGameState.AttractMode);
// HideEverything();
// demo.gameObject.SetActive(true);
// #endif
}
private void InitializeNewGame()
@@ -162,19 +142,16 @@ namespace Marro.PacManUdon
{
Debug.Log($"{gameObject} New level started!");
if (Networking.IsOwner(gameObject))
pelletCountTotal = pelletPool.Pool.Length;
pelletCountRemaining = pelletCountTotal;
ghostManager.SetPelletsRemaining(pelletCountRemaining);
ghostManager.NewLevel();
pelletManager.RestoreAllPellets();
if (pelletCountOverride > 0)
{
pelletCountTotal = pelletPool.Pool.Length;
pelletCountRemaining = pelletCountTotal;
ghostManager.SetPelletsRemaining(pelletCountRemaining);
ghostManager.NewLevel();
pelletManager.RestoreAllPellets();
if (pelletCountOverride > 0)
{
pelletCountRemaining = pelletCountOverride;
}
pelletCountRemaining = pelletCountOverride;
}
mazeSpriteAnimator.SetBool("Blinking", false);
}
@@ -287,7 +264,7 @@ namespace Marro.PacManUdon
mazeSpriteAnimator.SetBool("Blinking", true);
}
private void HideEverything()
{
SetPelletsActive(false);
@@ -445,6 +422,32 @@ namespace Marro.PacManUdon
ghostManager.SetOwner(Networking.LocalPlayer);
}
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
{
data[offset++] = new byte[] { Int32ToByte((int)gameState) };
data[offset++] = BitConverter.GetBytes(currentlyInTimeSequence);
data[offset++] = new byte[] { Int32ToByte((int)currentTimeSequence) };
data[offset++] = BitConverter.GetBytes(timeSequenceProgress);
}
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType, uint eventTime)
{
SetGameState((PacManGameState)data[offset++]);
var currentlyInTimeSequence = BitConverter.ToBoolean(data, offset++);
var currentTimeSequence = (PacManTimeSequence)data[offset++];
var timeSequenceProgress = BitConverter.ToSingle(data, offset);
offset += 4;
TimeSequenceSyncWithRemote(currentlyInTimeSequence, currentTimeSequence, timeSequenceProgress);
return true;
}
public override void SyncedToNewTime(uint oldTime, uint newTime)
{
}
public int ExtraLives
{
set
@@ -498,5 +501,9 @@ namespace Marro.PacManUdon
}
get => level;
}
public static byte Int32ToByte(int value) =>
(byte)value;
//byte.Parse(value.ToString()); // This is the only way I could find to cast an int to byte in Udon, a regular cast crashes in runtime...
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -72,21 +72,20 @@ namespace Marro.PacManUdon
private Vector2[] predefinedPath;
private int predefinedPathIndex;
[UdonSynced] int rngState;
[UdonSynced] private Vector2 syncedPosition;
[UdonSynced] private float speed;
[UdonSynced] private Vector2 direction;
[UdonSynced] private Vector2 target;
[UdonSynced] private bool offGrid;
[UdonSynced] private bool inTunnel;
[UdonSynced] private PacManGhostState ghostState;
[UdonSynced] private bool isScared;
[UdonSynced] private bool scattering;
[UdonSynced] private PacManGhostFrozenState frozenState;
[UdonSynced] private bool hideUntilUnfrozen;
[UdonSynced] private int housePelletCounter;
[UdonSynced] private bool housePelletCounterActive;
[UdonSynced] private bool turnAroundSoon;
int rngState;
private Vector2 syncedPosition;
private float speed;
private Vector2 target;
private bool offGrid;
private bool inTunnel;
private PacManGhostState ghostState;
private bool isScared;
private bool scattering;
private PacManGhostFrozenState frozenState;
private bool hideUntilUnfrozen;
private int housePelletCounter;
private bool housePelletCounterActive;
private bool turnAroundSoon;
public void Initialize(PacMan pacMan, Ghost blinky, Vector2 homePosition, Vector2 idlePosition1, Vector2 idlePosition2, Vector2 cornerPosition)
{
@@ -478,7 +477,7 @@ namespace Marro.PacManUdon
}
}
private void UpdateAnimator()
protected override void UpdateAnimator()
{
if (!gameObject.activeInHierarchy)
return;
@@ -639,10 +638,6 @@ namespace Marro.PacManUdon
ghostState = state;
UpdateAnimator();
UpdateSpeed();
if (Networking.IsOwner(gameObject))
{
RequestSerialization();
}
}
private void SetScared(bool scared)
@@ -655,11 +650,6 @@ namespace Marro.PacManUdon
{
SetWhite(false);
}
if (Networking.IsOwner(gameObject))
{
RequestSerialization();
}
}
public void SetScattering(bool scattering, bool reverseDirection = true)
@@ -783,43 +773,15 @@ namespace Marro.PacManUdon
public bool IsScared => isScared;
public override Vector2 GetPosition()
{
return (Vector2)transform.localPosition;
}
public override void SetPosition(Vector2 position)
{
GridMoverTools.SetPosition(position, transform);
}
public override Vector2 GetDirection()
{
return direction;
}
public void SetDirection(Vector2 direction)
{
this.direction = direction;
UpdateAnimator();
RequestSerialization();
}
public void SetSpeed(float speed)
{
this.speed = speed;
UpdateAnimator();
}
public override void OnPreSerialization()
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
{
syncedPosition = GetPosition();
}
public override void OnDeserialization()
{
SetPosition(syncedPosition);
UpdateAnimator();
base.AppendSyncedData(data, ref offset, eventType, eventTime);
}
void OnTriggerEnter(Collider other)

View File

@@ -3,24 +3,58 @@ namespace Marro.PacManUdon
using System;
using UdonSharp;
using UnityEngine;
using VRC.Udon.Serialization.OdinSerializer;
public abstract class GridMover : UdonSharpBehaviour
public abstract class GridMover : SyncedObject
{
protected Vector2 direction;
public virtual Vector2 GetPosition()
{
Debug.LogError($"{gameObject} does not implement GetPosition");
return Vector2.zero;
return (Vector2)transform.localPosition;
}
public virtual void SetPosition(Vector2 position)
{
Debug.LogError($"{gameObject} does not implement SetPosition");
transform.localPosition = new Vector3(position.x, position.y, transform.localPosition.z);
}
public virtual Vector2 GetDirection()
{
Debug.LogError($"{gameObject} does not implement GetDirection");
return Vector2.zero;
return direction;
}
public void SetDirection(Vector2 direction)
{
this.direction = direction;
UpdateAnimator();
}
protected abstract void UpdateAnimator();
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType, uint eventTime)
{
var position = GetPosition();
data[offset++] = BitConverter.GetBytes(position.x);
data[offset++] = BitConverter.GetBytes(position.y);
var direction = GetDirection();
data[offset++] = BitConverter.GetBytes(direction.x);
data[offset++] = BitConverter.GetBytes(direction.y);
}
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType, uint eventTime)
{
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 2)));
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 4), BitConverter.ToSingle(data, offset + 6)));
offset += 8;
return true;
}
public override void SyncedToNewTime(uint oldTime, uint newTime)
{
}
}
}

View File

@@ -10,12 +10,6 @@ namespace Marro.PacManUdon
return currentPosition + direction * speed * Time.deltaTime;
}
public static void SetPosition(Vector2 position, Transform transform)
{
transform.localPosition = new Vector3(position.x, position.y, transform.localPosition.z);
}
public static Vector2 PositionToGrid(Vector2 position)
{
return new Vector2((float)Math.Round(position.x), (float)Math.Round(position.y));

View File

@@ -0,0 +1,598 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: NetworkManager
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 37b60ab207700554ba5c119f63c3c7bd, type: 2}
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: ac984c07ae3e9674a850c3916be56ca3, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 0
hasInteractEvent: 0
scriptID: -3442137929426346155
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes:
- Name: fieldDefinitions
Entry: 7
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
UdonSharp.Editor]], mscorlib
- Name: comparer
Entry: 7
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
mscorlib]], mscorlib
- Name:
Entry: 8
Data:
- Name:
Entry: 12
Data: 10
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: syncedObjects
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedObjects
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.SyncedObject[], Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Component[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: DebugImageToIndicateOwner
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: DebugImageToIndicateOwner
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: isOwner
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: isOwner
- Name: <UserType>k__BackingField
Entry: 7
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 12
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: isSynced
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: isSynced
- Name: <UserType>k__BackingField
Entry: 9
Data: 12
- Name: <SystemType>k__BackingField
Entry: 9
Data: 12
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: startTimeTicks
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startTimeTicks
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int64, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: nextEventTime
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: nextEventTime
- Name: <UserType>k__BackingField
Entry: 7
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.UInt32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 20
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 21|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: retriesWithoutSuccess
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: retriesWithoutSuccess
- Name: <UserType>k__BackingField
Entry: 7
Data: 23|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 23
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: buffer
- Name: $v
Entry: 7
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: buffer
- Name: <UserType>k__BackingField
Entry: 7
Data: 26|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Byte[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 26
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 27|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: index
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: index
- Name: <UserType>k__BackingField
Entry: 9
Data: 23
- Name: <SystemType>k__BackingField
Entry: 9
Data: 23
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: networkedData
- Name: $v
Entry: 7
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: networkedData
- Name: <UserType>k__BackingField
Entry: 9
Data: 26
- Name: <SystemType>k__BackingField
Entry: 9
Data: 26
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 32|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a327a0e472dbf694a8e2b23bf0ce90d0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,506 @@
using System;
using System.Drawing;
using System.Text;
using UdonSharp;
using UnityEngine;
using VRC.SDK3.UdonNetworkCalling;
using VRC.SDKBase;
using VRC.Udon.ClientBindings.Interfaces;
using VRC.Udon.Common;
namespace Marro.PacManUdon
{
public enum NetworkEventType
{
FullSync = 0,
PacManTurn = 1,
}
public class NetworkManager : UdonSharpBehaviour
{
// The network manager works by serializing event and state data into a byte array, including a timestamp for each event.
// If user is owner, this data is created and stored in a buffer which is cleared upon transmission.
// If user is not owner, this data is read into the same buffer and replayed based on the included timestamp.
// Data replay is delayed with an offset on the timestamp to hide inconsistency in latency.
// The timestamp is transferred in ms as a 32 bit uint, which gives a maximum time of about 49 days.
// The maximum allowed age of a VRChat instance is 7 days, so this should not cause issues.
// A byte array is used as a DataList or DataDictionary can only be transmitted as JSON which is much less efficient.
// As Udon does not support instantiating objects, I have not created classes to represent the data being sent.
// Correct parsing is dependend upon everything being read out identially to how it was created.
// An event has the following structure:
// [0-1]: (ushort) Size of event.
// [2-5]: (uint) Time in seconds at which event occured.
// [6]: (byte) Type of event. 0 = Full Sync, which is used to sync up from an undefinted state.
// [7+]: Event-specific data
private const int BufferMaxSizeBytes = 10000;
private const int BufferIncrementSizeBytes = 1000;
[SerializeField] private SyncedObject[] syncedObjects;
[SerializeField] private Animator DebugImageToIndicateOwner;
private bool isOwner;
private bool isSynced;
private long startTimeTicks = DateTime.UtcNow.Ticks; // Initialize to prevent errors
private uint nextEventTime;
private int retriesWithoutSuccess;
// Main buffer of events
private byte[] buffer;
private int index;
private const ushort HeaderEventSizeIndex = 0;
private const ushort HeaderTimestampIndex = 2;
private const ushort HeaderEventTypeIndex = 6;
private const ushort HeaderLength = 7;
private const int Delay = 250;
[UdonSynced] private byte[] networkedData = new byte[0];
public void Initialize()
{
if (!BitConverter.IsLittleEndian)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
var zero = 0;
Debug.Log(1 / zero); // Intentionally crash
return;
}
buffer = new byte[BufferIncrementSizeBytes];
index = 0;
startTimeTicks = DateTime.UtcNow.Ticks;
isSynced = false;
retriesWithoutSuccess = 0;
SetOwner(Networking.IsOwner(gameObject));
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized, startTimeTicks: {startTimeTicks}");
}
public void Update()
{
if (!isOwner)
{
ProgressReplayTime();
}
}
public void SendEvent(NetworkEventType eventType)
{
if (!isOwner)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(SendEvent)} while not the owner!");
return;
}
var eventTime = CurrentTime;
InitializeEvent(eventType, eventTime, BufferMaxSizeBytes, out byte[][] data, out var index);
foreach (var obj in syncedObjects)
{
obj.AppendSyncedData(data, ref index, eventType, eventTime);
}
// Get event size, skipping over the event size which is not yet included
ushort eventSize = 0;
for (int i = 0; i < index; i++)
{
eventSize += (ushort)data[i].Length;
}
if (!EnsureSpaceToStoreEvent(eventSize))
{
return;
}
data[0] = BitConverter.GetBytes(eventSize);
var oldIndex = this.index;
FlattenAndCopy(data, index, buffer, ref this.index);
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event with {eventSize} bytes and timestamp {eventTime} for serialization, index went from {oldIndex} to {this.index}");
RequestSerialization();
retriesWithoutSuccess = 0; // We had success!
}
public void RequestEvent(NetworkEventType eventType)
{
if (isOwner)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEvent)} while we are the owner!");
return;
}
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
}
[NetworkCallable]
public void RequestEventReceived(NetworkEventType eventType)
{
if (!isOwner)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Attempted {nameof(RequestEventReceived)} while we are not the owner!");
return;
}
SendEvent(eventType);
}
private void ProcessIncomingData()
{
if (networkedData.Length == 0)
{
return; // Nothing to process
}
var length = networkedData.Length;
int index = 0;
while (index < length)
{
if (length - index < HeaderLength)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(ProcessIncomingData)}: Remaining data in networkedData is not long enough to form a complete event!");
HandleError();
return;
}
var eventSize = networkedData[index + HeaderEventSizeIndex];
var eventType = (NetworkEventType)networkedData[index + HeaderEventTypeIndex];
if (eventType == NetworkEventType.FullSync)
{
ProcessIncomingFullSync(index, eventSize); // Immediately process full sync
index += eventSize;
continue;
}
if (!isSynced)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received event of type {eventType} while we are not yet synced to the remote time, ignoring event.");
index += eventSize;
continue;
}
AppendEventToBuffer(index, eventSize);
index += eventSize;
}
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{BytesToString(networkedData)}");
}
private void ProcessIncomingFullSync(int index, int size)
{
// Intentionally not doing a buffer size check here, since this is not appending to the buffer
// (and there is no good way to continue if event is too large)
// Clear buffer and copy the full sync into it
buffer = new byte[size];
Array.Copy(networkedData, index, buffer, 0, size);
this.index = size;
// Sync up to the time in the full sync
var time = BitConverter.ToUInt32(networkedData, index + HeaderTimestampIndex);
SyncToTime(time);
// Immediately apply the full sync
nextEventTime = time;
isSynced = true;
}
private void AppendEventToBuffer(int index, int size)
{
if (!EnsureSpaceToStoreEvent(size))
{
return;
}
Array.Copy(networkedData, index, buffer, this.index, size);
this.index += size;
UpdateNextEventTime();
}
private void ProgressReplayTime()
{
var currentTime = CurrentTime;
while (index != 0 && nextEventTime <= currentTime)
{
ProcessIncomingEvent();
UpdateNextEventTime();
}
}
private void UpdateNextEventTime()
{
if (index == 0)
{
return;
}
var nextEventTime = BitConverter.ToUInt32(buffer, HeaderTimestampIndex);
if (nextEventTime >= this.nextEventTime)
{
this.nextEventTime = nextEventTime;
}
else
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event is earlier than previous event!");
HandleError();
return;
}
}
private void ProcessIncomingEvent()
{
var eventTime = BitConverter.ToUInt32(buffer, HeaderTimestampIndex);
var eventType = (NetworkEventType)buffer[HeaderEventTypeIndex];
var index = (int)HeaderLength; // Skip header
if (false) // TODO: check event type
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Invalid event type for incoming data! Buffer will be cleared.");
HandleError();
return;
}
foreach (var obj in syncedObjects)
{
var success = obj.SetSyncedData(buffer, ref index, eventType, eventTime);
if (!success)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Malformed data reported by {obj.name} during event type {eventType}! Resetting state.");
HandleError();
return;
}
if (index > this.index)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer overflow during SetSyncedData for {obj.name} in event type {eventType}! Resetting state.");
HandleError();
return;
}
}
var eventSize = BitConverter.ToUInt16(buffer, HeaderEventSizeIndex);
if (index != eventSize)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Amount of data read does not match event size! Expected {eventSize}, read {index}.");
HandleError();
return;
}
RemoveProcessedDataFromBuffer(index);
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Processed incoming event! Total {index} bytes.");
retriesWithoutSuccess = 0; // We had success!
}
private void SyncToTime(uint newTime)
{
var timeToSyncTo = newTime - Delay;
startTimeTicks = DateTime.UtcNow.Ticks - timeToSyncTo * TimeSpan.TicksPerMillisecond;
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to time {newTime}, startTimeTicks is now {startTimeTicks}");
}
private bool EnsureSpaceToStoreEvent(int eventSize)
{
if (index + eventSize <= buffer.Length)
{
return true; // Enough space!
}
var newBufferSize = ((index + eventSize) / BufferIncrementSizeBytes + 1) * BufferIncrementSizeBytes;
var success = IncreaseBufferSize(newBufferSize);
if (success)
{
return true;
}
if (index == 0)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Buffer is not large enough to store event!");
}
else
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Too much data in buffer to store event!");
}
HandleError(); // We can store event now that we cleared the buffer.
return false;
}
private bool IncreaseBufferSize(int newSize)
{
if (newSize < buffer.Length)
{
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Cannot decrease the size of the buffer!");
return false;
}
if (newSize > BufferMaxSizeBytes)
{
return false;
}
var oldBuffer = buffer;
buffer = new byte[newSize];
oldBuffer.CopyTo(buffer, 0);
return true;
}
private void InitializeEvent(NetworkEventType eventType, uint eventTime, int maxSize, out byte[][] data, out int index)
{
data = new byte[maxSize][];
index = 3;
data[0] = new byte[2]; // Placeholder for event size
data[1] = BitConverter.GetBytes(eventTime);
data[2] = new byte[] { GameManager.Int32ToByte((int)eventType) };
}
private void FlattenAndCopy(byte[][] data, int length, byte[] target, ref int index)
{
for (int i = 0; i < length; i++)
{
var values = data[i];
Array.Copy(values, 0, target, index, values.Length);
index += values.Length;
}
}
private void RemoveProcessedDataFromBuffer(int amountProcessed)
{
var oldBuffer = buffer;
index -= amountProcessed;
buffer = new byte[BufferMaxSizeBytes];
Array.Copy(oldBuffer, amountProcessed, buffer, 0, index);
}
private void ClearBuffer()
{
buffer = new byte[BufferMaxSizeBytes];
index = 0;
}
private void HandleError()
{
retriesWithoutSuccess++;
if (retriesWithoutSuccess > 3)
{
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: Retried 3 times without success.");
var zero = 0;
Debug.Log(1 / zero); // Intentionally crash
return;
}
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Encountered data error, attempting to recover via full sync.");
ClearBuffer();
if (!isOwner)
{
RequestEvent(NetworkEventType.FullSync);
}
else
{
SendEvent(NetworkEventType.FullSync);
}
}
private void SetOwner(bool isOwner)
{
this.isOwner = isOwner;
if (DebugImageToIndicateOwner != null)
{
DebugImageToIndicateOwner.SetFloat("Color", isOwner ? 1 : 0);
}
}
public override void OnOwnershipTransferred(VRCPlayerApi newOwner)
{
SetOwner(newOwner == Networking.LocalPlayer);
if(isOwner)
{
HandleError();
}
}
public override void OnPreSerialization()
{
if (isOwner)
{
networkedData = new byte[index];
Array.Copy(buffer, networkedData, index);
}
else
{
networkedData = new byte[0]; // Prevent exception loop in VRChat SDK
}
}
public override void OnPostSerialization(SerializationResult result)
{
if (!result.success)
{
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialization failed! Tried to send {result.byteCount} bytes.");
return;
}
if (!isOwner || networkedData.Length == 0)
{
return;
}
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Serialized with {networkedData.Length} bytes!\nBytes sent:\n{BytesToString(networkedData)}");
// Remove all transferred data from the buffer, leaving data that came in after serialization
RemoveProcessedDataFromBuffer(networkedData.Length);
networkedData = null;
}
public override void OnDeserialization()
{
if (!isOwner)
{
ProcessIncomingData();
}
}
public float GetDtInSeconds(uint currentTime, uint lastUpdate)
{
return (CurrentTime - lastUpdate) / 1000f;
}
public uint CurrentTime => (uint)((DateTime.UtcNow.Ticks - startTimeTicks) / TimeSpan.TicksPerMillisecond);
public bool IsOwner => isOwner;
public string BytesToString(byte[] bytes)
{
var sb = new StringBuilder("new byte[] { ");
foreach (var b in bytes)
{
sb.Append(b + ", ");
}
sb.Append("}");
return sb.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac984c07ae3e9674a850c3916be56ca3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -49,31 +49,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: gameController
Data: direction
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: gameController
Data: direction
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
Data: UnityEngine.Vector2, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
Entry: 9
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -88,7 +82,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 4|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -109,25 +103,31 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: input
Data: gameController
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: input
Data: gameController
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
Data: 6|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.PlayerInput, Assembly-CSharp
Data: Marro.PacManUdon.GameManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -163,25 +163,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: defaultSpeed
Data: input
- Name: $v
Entry: 7
Data: 9|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: defaultSpeed
Data: input
- Name: <UserType>k__BackingField
Entry: 7
Data: 10|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
Data: Marro.PacManUdon.PlayerInput, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 10
Data: 7
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -217,19 +217,73 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: powerPelletSpeed
Data: defaultSpeed
- Name: $v
Entry: 7
Data: 12|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: defaultSpeed
- Name: <UserType>k__BackingField
Entry: 7
Data: 13|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 14|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: powerPelletSpeed
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: powerPelletSpeed
- Name: <UserType>k__BackingField
Entry: 9
Data: 10
Data: 13
- Name: <SystemType>k__BackingField
Entry: 9
Data: 10
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -244,7 +298,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -268,70 +322,16 @@ MonoBehaviour:
Data: speed
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: speed
- Name: <UserType>k__BackingField
Entry: 9
Data: 10
Data: 13
- Name: <SystemType>k__BackingField
Entry: 9
Data: 10
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 15|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: startPosition
- Name: $v
Entry: 7
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector3, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -367,19 +367,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: startRotation
Data: startPosition
- Name: $v
Entry: 7
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startRotation
Data: startPosition
- Name: <UserType>k__BackingField
Entry: 7
Data: 20|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Quaternion, UnityEngine.CoreModule
Data: UnityEngine.Vector3, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -421,19 +421,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: startScale
Data: startRotation
- Name: $v
Entry: 7
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: startScale
Data: startRotation
- Name: <UserType>k__BackingField
Entry: 9
Data: 17
Entry: 7
Data: 23|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Quaternion, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 17
Data: 23
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -448,7 +454,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 23|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -469,25 +475,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: animator
Data: startScale
- Name: $v
Entry: 7
Data: 24|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 25|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: animator
Data: startScale
- Name: <UserType>k__BackingField
Entry: 7
Data: 25|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
Entry: 9
Data: 20
- Name: <SystemType>k__BackingField
Entry: 9
Data: 25
Data: 20
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -523,19 +523,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: renderer
Data: animator
- Name: $v
Entry: 7
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: renderer
Data: animator
- Name: <UserType>k__BackingField
Entry: 7
Data: 28|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Renderer, UnityEngine.CoreModule
Data: UnityEngine.Animator, UnityEngine.AnimationModule
- Name:
Entry: 8
Data:
@@ -577,19 +577,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: pelletPool
Data: renderer
- Name: $v
Entry: 7
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: pelletPool
Data: renderer
- Name: <UserType>k__BackingField
Entry: 7
Data: 31|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCObjectPool, VRCSDK3
Data: UnityEngine.Renderer, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -631,19 +631,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: hideUntilUnfrozen
Data: pelletPool
- Name: $v
Entry: 7
Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: hideUntilUnfrozen
Data: pelletPool
- Name: <UserType>k__BackingField
Entry: 7
Data: 34|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
Data: VRC.SDK3.Components.VRCObjectPool, VRCSDK3
- Name:
Entry: 8
Data:
@@ -685,19 +685,73 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: dead
Data: hideUntilUnfrozen
- Name: $v
Entry: 7
Data: 36|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: hideUntilUnfrozen
- Name: <UserType>k__BackingField
Entry: 7
Data: 37|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 38|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: dead
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: dead
- Name: <UserType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -712,7 +766,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 40|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -736,16 +790,16 @@ MonoBehaviour:
Data: kinematic
- Name: $v
Entry: 7
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: kinematic
- Name: <UserType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -760,7 +814,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -784,70 +838,16 @@ MonoBehaviour:
Data: followingPredefinedPath
- Name: $v
Entry: 7
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: followingPredefinedPath
- Name: <UserType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 41|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: predefinedPath
- Name: $v
Entry: 7
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPath
- Name: <UserType>k__BackingField
Entry: 7
Data: 43|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector2[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 43
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -883,19 +883,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: predefinedPathIndex
Data: predefinedPath
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: predefinedPathIndex
Data: predefinedPath
- Name: <UserType>k__BackingField
Entry: 7
Data: 46|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
Data: UnityEngine.Vector2[], UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -937,19 +937,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: syncedPosition
Data: predefinedPathIndex
- Name: $v
Entry: 7
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: syncedPosition
Data: predefinedPathIndex
- Name: <UserType>k__BackingField
Entry: 7
Data: 49|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Vector2, UnityEngine.CoreModule
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
@@ -960,8 +960,8 @@ MonoBehaviour:
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
Entry: 6
Data:
- Name:
Entry: 8
Data:
@@ -973,13 +973,7 @@ MonoBehaviour:
Data: 50|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 51|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -997,25 +991,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: targetDirection
Data: syncedPosition
- Name: $v
Entry: 7
Data: 52|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: targetDirection
Data: syncedPosition
- Name: <UserType>k__BackingField
Entry: 9
Data: 49
Data: 3
- Name: <SystemType>k__BackingField
Entry: 9
Data: 49
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
Entry: 6
Data:
- Name:
Entry: 8
Data:
@@ -1024,16 +1018,10 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 53|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 52|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 54|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -1051,25 +1039,73 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: direction
Data: targetDirection
- Name: $v
Entry: 7
Data: 53|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: targetDirection
- Name: <UserType>k__BackingField
Entry: 9
Data: 3
- Name: <SystemType>k__BackingField
Entry: 9
Data: 3
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 54|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: freezeSeconds
- Name: $v
Entry: 7
Data: 55|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: direction
Data: freezeSeconds
- Name: <UserType>k__BackingField
Entry: 9
Data: 49
Data: 13
- Name: <SystemType>k__BackingField
Entry: 9
Data: 49
Data: 13
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
Entry: 6
Data:
- Name:
Entry: 8
Data:
@@ -1081,67 +1117,7 @@ MonoBehaviour:
Data: 56|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 57|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: freezeSeconds
- Name: $v
Entry: 7
Data: 58|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: freezeSeconds
- Name: <UserType>k__BackingField
Entry: 9
Data: 10
- Name: <SystemType>k__BackingField
Entry: 9
Data: 10
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 59|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 60|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:
@@ -1162,22 +1138,22 @@ MonoBehaviour:
Data: frozen
- Name: $v
Entry: 7
Data: 61|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 57|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: frozen
- Name: <UserType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SystemType>k__BackingField
Entry: 9
Data: 34
Data: 37
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
Entry: 6
Data:
- Name:
Entry: 8
Data:
@@ -1186,16 +1162,10 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 62|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 58|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 63|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
Data: 0
- Name:
Entry: 13
Data:

View File

@@ -28,11 +28,10 @@
private Vector2[] predefinedPath;
private int predefinedPathIndex;
[UdonSynced] private Vector2 syncedPosition;
[UdonSynced] private Vector2 targetDirection;
[UdonSynced] private Vector2 direction;
[UdonSynced] private float freezeSeconds;
[UdonSynced] private bool frozen;
private Vector2 syncedPosition;
private Vector2 targetDirection;
private float freezeSeconds;
private bool frozen;
#region Animator constants
private const string AnimatorKeyDead = "Dead";
@@ -207,7 +206,7 @@
return nextPosition;
}
private void UpdateAnimator()
protected override void UpdateAnimator()
{
// Debug.Log($"{gameObject} UpdateAnimator with direction {direction}, dead {dead}, frozen {frozen}");
if (!gameObject.activeInHierarchy)
@@ -316,45 +315,12 @@
renderer.enabled = visible;
}
public override Vector2 GetPosition()
{
return (Vector2)transform.localPosition;
}
public override void SetPosition(Vector2 position)
{
GridMoverTools.SetPosition(position, transform);
}
public override Vector2 GetDirection()
{
return direction;
}
public void SetDirection(Vector2 direction)
{
this.direction = direction;
RequestSerialization();
UpdateAnimator();
}
public void SetTargetDirection(Vector2 targetDirection)
{
this.targetDirection = targetDirection;
UpdateAnimator();
}
public override void OnPreSerialization()
{
syncedPosition = GetPosition();
}
public override void OnDeserialization()
{
SetPosition(syncedPosition);
UpdateAnimator();
}
void OnTriggerEnter(Collider other)
{
Pellet pellet = other.gameObject.GetComponent<Pellet>();
@@ -372,16 +338,14 @@
if (pellet.isPowerPellet)
{
if (Networking.IsOwner(gameObject)) gameController.GotPowerPellet();
gameController.GotPowerPellet();
freezeSeconds = 0.05f;
}
else
{
if (Networking.IsOwner(gameObject)) gameController.GotPellet();
gameController.GotPellet();
freezeSeconds = 0.0166666666666667f;
}
if (Networking.IsOwner(gameObject)) RequestSerialization();
return;
}
else if (Networking.IsOwner(gameObject) && other.gameObject.GetComponent<BonusFruit>())

View File

@@ -103,13 +103,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: gameController
Data: gameManager
- Name: $v
Entry: 7
Data: 5|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: gameController
Data: gameManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 6|System.RuntimeType, mscorlib

View File

@@ -10,7 +10,7 @@
public class PlayerInput : UdonSharpBehaviour
{
public bool active;
private GameManager gameController;
private GameManager gameManager;
Vector2 inputHorizontal;
Vector2 inputVertical;
float horizontalValue;
@@ -18,9 +18,9 @@
bool horizontalPriority;
VRCPlayerApi player;
public void Initialize(GameManager gameController)
public void Initialize(GameManager gameManager)
{
this.gameController = gameController;
this.gameManager = gameManager;
inputHorizontal = Vector2.zero;
inputVertical = Vector2.zero;
horizontalPriority = false;
@@ -35,7 +35,7 @@
player.SetRunSpeed(0);
player.SetStrafeSpeed(0);
gameController.JoystickGrabbed();
gameManager.JoystickGrabbed();
}
public void Deactivate()
@@ -46,7 +46,7 @@
player.SetStrafeSpeed(2);
active = false;
gameController.JoystickReleased();
gameManager.JoystickReleased();
}
public override void InputJump(bool pressed, UdonInputEventArgs args)
@@ -128,6 +128,7 @@
// horizontalPriority = true;
SetPriority(true);
}
// Debug.Log("Vertical Input Event: " + value + " | Direction: " + direction + " | lastDirection : " + lastDirection);
}

View File

@@ -12,7 +12,7 @@ namespace Marro.PacManUdon
// While I'm not a big fan of the partial class solution that I ended up doing (static classes would still be neater, or perhaps separate UdonSharpBehaviour instances),
// I'm not redoing this unless I get instantiatable classes before I wrap up this project.
bool currentlyInTimeSequence;
bool waitingForTimeSequenceFinish;
bool waitingForTimeSequenceFinalize;
bool jumpingToTimeSequence;
PacManTimeSequence currentTimeSequence;
[UdonSynced] float timeSequenceSecondsPassed;
@@ -42,6 +42,7 @@ namespace Marro.PacManUdon
{
jumpingToTimeSequence = true;
TimeSequenceProgressToTime(100000f);
TryFinalizeTimeSequence();
jumpingToTimeSequence = false;
}
@@ -98,7 +99,39 @@ namespace Marro.PacManUdon
}
else
{
waitingForTimeSequenceFinish = true;
waitingForTimeSequenceFinalize = true;
}
}
private void TryFinalizeTimeSequence()
{
if (!waitingForTimeSequenceFinalize)
{
return;
}
TimeSequenceExecuteFinalize(currentTimeSequence);
waitingForTimeSequenceFinalize = false;
}
private void TimeSequenceSyncWithRemote(bool currentlyInTimeSequence, PacManTimeSequence currentTimeSequence, float timeSequenceProgress)
{
// If the remote is in a time sequence but we're not, or we're in a different time sequence, jump to the remote's time sequence.
if (currentlyInTimeSequence && (!this.currentlyInTimeSequence || currentTimeSequence != this.currentTimeSequence))
{
StartTimeSequence(currentTimeSequence);
}
// If we're (now) in a time sequence, jump our progress to match the one on the remote
if (this.currentlyInTimeSequence)
{
TimeSequenceProgressToTime(timeSequenceProgress);
}
// If the remote has finished it's time sequence and we have one waiting to be finalized, we can do so now
if (!currentlyInTimeSequence)
{
TryFinalizeTimeSequence();
}
}

View File

@@ -0,0 +1,13 @@
using System.Collections;
using UdonSharp;
using UnityEngine;
namespace Marro.PacManUdon
{
public abstract class SyncedObject : UdonSharpBehaviour
{
public abstract void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType, uint eventTime);
public abstract bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType, uint eventTime);
public abstract void SyncedToNewTime(uint oldTime, uint newTime);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d09fe6fd5a83df9468f5ffcb43d73af3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Test stuff.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ab80220efbebb2489a3218f3ee9b00b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,109 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: ColoredTexture
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Color
m_Type: 1
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 2235177317997810699}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1107 &2235177317997810699
AnimatorStateMachine:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 6251436573727931732}
m_Position: {x: 384.82895, y: 133.70117, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions: []
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_EntryPosition: {x: 50, y: 120, z: 0}
m_ExitPosition: {x: 800, y: 120, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 6251436573727931732}
--- !u!1102 &6251436573727931732
AnimatorState:
serializedVersion: 6
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Speed: 1
m_CycleOffset: 0
m_Transitions: []
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7315205519034161812}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!206 &7315205519034161812
BlendTree:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Blend Tree
m_Childs:
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: f06a4450a22bb184bb3881fbc7ddc36f, type: 2}
m_Threshold: 0
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: Color
m_Mirror: 0
- serializedVersion: 2
m_Motion: {fileID: 7400000, guid: 152a2df117ac1c948b25f28a386ac289, type: 2}
m_Threshold: 1
m_Position: {x: 0, y: 0}
m_TimeScale: 1
m_CycleOffset: 0
m_DirectBlendParameter: Color
m_Mirror: 0
m_BlendParameter: Color
m_BlendParameterY: Blend
m_MinThreshold: 0
m_MaxThreshold: 1
m_UseAutomaticThresholds: 0
m_NormalizedBlendValues: 0
m_BlendType: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 72593807222e776478e455c600f7ccf9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,206 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: GreenTexture
serializedVersion: 7
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
m_PPtrCurves: []
m_SampleRate: 1
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 2526845255
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 0
attribute: 4215373228
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 0
attribute: 2334886179
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 152a2df117ac1c948b25f28a386ac289
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,206 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!74 &7400000
AnimationClip:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: RedTexture
serializedVersion: 7
m_Legacy: 0
m_Compressed: 0
m_UseHighQualityCurve: 1
m_RotationCurves: []
m_CompressedRotationCurves: []
m_EulerCurves: []
m_PositionCurves: []
m_ScaleCurves: []
m_FloatCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
m_PPtrCurves: []
m_SampleRate: 1
m_WrapMode: 0
m_Bounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
m_ClipBindingConstant:
genericBindings:
- serializedVersion: 2
path: 0
attribute: 2526845255
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 0
attribute: 4215373228
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
- serializedVersion: 2
path: 0
attribute: 2334886179
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
typeID: 114
customType: 0
isPPtrCurve: 0
isIntCurve: 0
isSerializeReferenceCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
m_AdditiveReferencePoseClip: {fileID: 0}
m_AdditiveReferencePoseTime: 0
m_StartTime: 0
m_StopTime: 0
m_OrientationOffsetY: 0
m_Level: 0
m_CycleOffset: 0
m_HasAdditiveReferencePose: 0
m_LoopTime: 0
m_LoopBlend: 0
m_LoopBlendOrientation: 0
m_LoopBlendPositionY: 0
m_LoopBlendPositionXZ: 0
m_KeepOriginalOrientation: 0
m_KeepOriginalPositionY: 1
m_KeepOriginalPositionXZ: 0
m_HeightFromFeet: 0
m_Mirror: 0
m_EditorCurves:
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.r
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.g
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
- serializedVersion: 2
curve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 136
weightedMode: 0
inWeight: 0
outWeight: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
attribute: m_Color.b
path:
classID: 114
script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
flags: 0
m_EulerEditorCurves: []
m_HasGenericRootTransform: 0
m_HasMotionFloatCurves: 0
m_Events: []

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f06a4450a22bb184bb3881fbc7ddc36f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 7400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,394 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: TestBall
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: 8968388b0e4fe434fb8da62328c108a0, type: 2}
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 0980d82a15346eb45b49fd33db0ffee9, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 0
hasInteractEvent: 0
scriptID: -3035274785675086507
serializationData:
SerializedFormat: 2
SerializedBytes:
ReferencedUnityObjects: []
SerializedBytesString:
Prefab: {fileID: 0}
PrefabModificationsReferencedUnityObjects: []
PrefabModifications: []
SerializationNodes:
- Name: fieldDefinitions
Entry: 7
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[UdonSharp.Compiler.FieldDefinition,
UdonSharp.Editor]], mscorlib
- Name: comparer
Entry: 7
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
mscorlib]], mscorlib
- Name:
Entry: 8
Data:
- Name:
Entry: 12
Data: 6
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: networkManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: networkManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: Marro.PacManUdon.NetworkManager, Assembly-CSharp
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 7
Data: 4|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.Udon.UdonBehaviour, VRC.Udon
- Name:
Entry: 8
Data:
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 5|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 6|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: start
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: start
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Transform, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 9|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 10|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: end
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: end
- Name: <UserType>k__BackingField
Entry: 9
Data: 8
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: true
- Name: _fieldAttributes
Entry: 7
Data: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 13|UnityEngine.SerializeField, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: amountUp
- Name: $v
Entry: 7
Data: 14|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: amountUp
- Name: <UserType>k__BackingField
Entry: 7
Data: 15|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 15
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 16|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: loopOffset
- Name: $v
Entry: 7
Data: 17|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: loopOffset
- Name: <UserType>k__BackingField
Entry: 7
Data: 18|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 18
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 19|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: lastUpdate
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: lastUpdate
- Name: <UserType>k__BackingField
Entry: 7
Data: 21|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.UInt32, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 21
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1845851c6c8f8254baa6b40646c66d59
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,107 @@
using librsync.net;
using Marro.PacManUdon;
using System;
using System.Drawing.Text;
using UnityEngine;
public class TestBall : SyncedObject
{
[SerializeField] private NetworkManager networkManager;
[SerializeField] private Transform start;
[SerializeField] private Transform end;
private const int LoopTimeMs = 1000;
private const float MaxUp = 0.7f;
private const float UpPerPress = 0.4f;
private const float DownPerSecond = 1;
private float amountUp = 0;
private int loopOffset = 0;
private uint lastUpdate;
private void Start()
{
networkManager.Initialize();
lastUpdate = networkManager.CurrentTime;
}
public void FixedUpdate()
{
var currentTime = networkManager.CurrentTime;
float dt = networkManager.GetDtInSeconds(currentTime, lastUpdate);
DeltaUp(-DownPerSecond * dt);
float progress = GetProgress(currentTime);
transform.position = Vector3.Lerp(start.position, end.position, progress) + amountUp * MaxUp * Vector3.up;
lastUpdate = currentTime;
}
private void DeltaUp(float delta)
{
amountUp = Mathf.Clamp(amountUp + delta, 0, 1);
//Debug.Log($"delta: {delta}, amountUp: {amountUp}");
}
private void SetProgress(float progress, uint currentTime)
{
//loopOffset = (int)(progress * LoopTimeMs % (LoopTimeMs + currentTime));
loopOffset = (int)(currentTime - progress * LoopTimeMs);
//loopOffset = (int)currentTime % LoopTimeMs + (int)(progress * LoopTimeMs);
}
private float GetProgress(uint currentTime)
{
return ((int)currentTime - loopOffset) % LoopTimeMs / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
//return loopOffset - ((int)currentTime % LoopTimeMs) / (float)LoopTimeMs; // "uint % int" is not exposed, I love working in Udon
}
public void UpButtonPressed()
{
DeltaUp(UpPerPress);
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress(networkManager.CurrentTime)} to {amountUp}.");
networkManager.SendEvent((NetworkEventType)1);
}
public void SyncButtonPressed()
{
networkManager.SendEvent((NetworkEventType)0);
Debug.Log($"({nameof(TestBall)}) Sync button pressed, synced at progress {GetProgress(networkManager.CurrentTime)} and amountUp {amountUp}.");
}
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType, uint eventTime)
{
var currentTime = networkManager.CurrentTime;
if (eventType == 0)
{
data[index++] = BitConverter.GetBytes(amountUp);
data[index++] = BitConverter.GetBytes(GetProgress(currentTime));
}
}
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType, uint eventTime)
{
var currentTime = networkManager.CurrentTime;
if (eventType == 0)
{
amountUp = BitConverter.ToSingle(data, index);
SetProgress(BitConverter.ToSingle(data, index + 4), currentTime);
Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress(currentTime)} and amountUp {amountUp}.");
index += 8;
}
else
{
DeltaUp(UpPerPress);
Debug.Log($"({nameof(TestBall)}) Received up event, jumped up at {GetProgress(networkManager.CurrentTime)} to {amountUp}.");
}
return true;
}
public override void SyncedToNewTime(uint oldTime, uint newTime)
{
lastUpdate += newTime - oldTime;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0980d82a15346eb45b49fd33db0ffee9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -18,7 +18,7 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: dfaff7ffdfaff7ffdfaff7ffffffffffdfaff7ffc800c0ffffffffffffffffffdfaff7ffdf09f4ffdf09f4ffdfaff7ffc800c0ffdfe9c3ffc820c0ffdfa9f7ffdfa9f7ffdfa9f7ffdf8ff7ffc800c0ffdf8ff7ffdf8ff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_LayerCollisionMatrix: d7aff7ffd7aff7ffd7aff7ff0800c0ffd7aff7ffc000c0fff7fffffff7ffffffd7aff7ffd709f4ffd709f4ffd7aff7ffc000c0ffd7e9c3ffc020c0ffd7a9f7ffd7a9f7ffd7a9f7ffd78ff7ffc000c0ffd78ff7ffd78ff7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
m_SimulationMode: 0
m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1

View File

@@ -8,7 +8,7 @@ TagManager:
- Default
- TransparentFX
- Ignore Raycast
- reserved3
- Item
- Water
- UI
- reserved6
@@ -29,7 +29,7 @@ TagManager:
- reserved4
- MazeWalls
- GhostStations
-
- reserved3
-
-
-