Compare commits
8 Commits
b688b4739b
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 42f9e2ee9d | |||
| 8255eb8b99 | |||
| 2f18464e71 | |||
| ad605bcab3 | |||
| 3be8d2f6a6 | |||
| 875d0ad5f0 | |||
| 378d6bc7a7 | |||
| 540cfe16ab |
+175
-10
@@ -459,7 +459,8 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1470248941}
|
||||
- {fileID: 962437701}
|
||||
- {fileID: 1772674898}
|
||||
m_Father: {fileID: 1886023632}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &107806787
|
||||
@@ -1323,7 +1324,8 @@ Transform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 685148375}
|
||||
m_Father: {fileID: 1886023632}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &310045873 stripped
|
||||
@@ -3171,6 +3173,37 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 712073434}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &571802606
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 571802607}
|
||||
m_Layer: 0
|
||||
m_Name: High score persistance
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &571802607
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 571802606}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 851913432}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &573616886 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 184438965336248073, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
@@ -3655,6 +3688,37 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 9086668275070771076, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
m_PrefabInstance: {fileID: 7528894854307259292}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &685148374
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 685148375}
|
||||
m_Layer: 0
|
||||
m_Name: Make networkmanager visible
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &685148375
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 685148374}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 297676220}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &689152543
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4129,7 +4193,7 @@ MonoBehaviour:
|
||||
networkManagers:
|
||||
- {fileID: 811840793}
|
||||
- {fileID: 65516626}
|
||||
interval: 0
|
||||
interval: 0.3
|
||||
ownerIndex: 0
|
||||
--- !u!114 &805005474
|
||||
MonoBehaviour:
|
||||
@@ -4138,7 +4202,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 805005470}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 45115577ef41a5b4ca741ed302693907, type: 3}
|
||||
m_Name:
|
||||
@@ -4163,7 +4227,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 805005470}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: cbbf384cde136444d9f640ff9f3445cf, type: 3}
|
||||
m_Name:
|
||||
@@ -4190,6 +4254,37 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1928664601999823222, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
m_PrefabInstance: {fileID: 7528894854307259292}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &806335367
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 806335368}
|
||||
m_Layer: 0
|
||||
m_Name: Instance high score
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &806335368
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 806335367}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 851913432}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &806693070 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4795217970421011192, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
@@ -4405,7 +4500,9 @@ Transform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Children:
|
||||
- {fileID: 571802607}
|
||||
- {fileID: 806335368}
|
||||
m_Father: {fileID: 1886023632}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &859475370 stripped
|
||||
@@ -4550,6 +4647,37 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8648916981024671211, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
m_PrefabInstance: {fileID: 1210508488}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &962437700
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 962437701}
|
||||
m_Layer: 0
|
||||
m_Name: Repair demo
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &962437701
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 962437700}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 106401850}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &962831748 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4432432907462793590, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
@@ -6129,7 +6257,8 @@ MonoBehaviour:
|
||||
root: {fileID: 0}
|
||||
delay: 50
|
||||
maxEventSendTries: 3
|
||||
pingDelay: 15
|
||||
sendingPingDelay: 15
|
||||
syncingPingDelay: 300
|
||||
tickDelta: 0.016666668
|
||||
debugOutput: {fileID: 0}
|
||||
DebugImageToIndicateOwner: {fileID: 1745114900}
|
||||
@@ -6382,7 +6511,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 776794315963647603, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
- target: {fileID: 795751881681854794, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
propertyPath: delay
|
||||
value: 1
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 795751881681854794, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
propertyPath: debugOutput
|
||||
@@ -8211,6 +8340,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1470248941}
|
||||
- {fileID: 991830906}
|
||||
- {fileID: 791132292}
|
||||
- {fileID: 2130594149}
|
||||
@@ -8463,12 +8593,12 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1470248940}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 106401850}
|
||||
m_Father: {fileID: 1438618203}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1472000832 stripped
|
||||
GameObject:
|
||||
@@ -12087,6 +12217,37 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 8413102315728467232, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
m_PrefabInstance: {fileID: 1210508488}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1772674897
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1772674898}
|
||||
m_Layer: 0
|
||||
m_Name: Repair other cutscenes
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1772674898
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1772674897}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 106401850}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1773753006 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7955628641985366373, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
@@ -14139,6 +14300,10 @@ PrefabInstance:
|
||||
propertyPath: serializationData.Prefab
|
||||
value:
|
||||
objectReference: {fileID: 776794315963647603, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
- target: {fileID: 795751881681854794, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
propertyPath: delay
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 795751881681854794, guid: 15ac0ed4c56c7784ea3ae9000fc2af1f, type: 3}
|
||||
propertyPath: serializationData.Prefab
|
||||
value:
|
||||
|
||||
@@ -217,7 +217,7 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
var active = (syncedPelletsCollected[i/8] & (byte)(1 << i%8)) == 0;
|
||||
pellets[i].gameObject.SetActive(active);
|
||||
pelletMap[pelletIndices[i]] = i;
|
||||
pelletMap[pelletIndices[i]] = active ? i : (byte)PacManConsumableType.None;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
+850
-906
File diff suppressed because it is too large
Load Diff
@@ -106,7 +106,7 @@ namespace Marro.PacManUdon
|
||||
Debug.Log($"{gameObject} Start Game Button was pressed!");
|
||||
if (networkManager.IsOwner)
|
||||
{
|
||||
networkManager.SendEventNow(NetworkEventType.StartGameButtonPressed);
|
||||
networkManager.SendEventSoon(NetworkEventType.StartGameButtonPressed, false);
|
||||
}
|
||||
StartTimeSequence(PacManTimeSequence.StartNewGame);
|
||||
}
|
||||
|
||||
+140
-91
@@ -43,7 +43,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 44
|
||||
Data: 45
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -1525,13 +1525,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: scattering
|
||||
Data: whiteScared
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 80|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: scattering
|
||||
Data: whiteScared
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
@@ -1573,25 +1573,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: frozenState
|
||||
Data: scattering
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 82|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: frozenState
|
||||
Data: scattering
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 83|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: Marro.PacManUdon.PacManGhostFrozenState, Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
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
|
||||
@@ -1606,7 +1600,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 84|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 83|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -1627,19 +1621,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: offGrid
|
||||
Data: frozenState
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 85|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 84|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: offGrid
|
||||
Data: frozenState
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Entry: 7
|
||||
Data: 85|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: Marro.PacManUdon.PacManGhostFrozenState, Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Data: 11
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -1675,19 +1675,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: housePelletCounter
|
||||
Data: offGrid
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 87|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: housePelletCounter
|
||||
Data: offGrid
|
||||
- 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
|
||||
@@ -1723,19 +1723,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: housePelletCounterActive
|
||||
Data: housePelletCounter
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 89|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: housePelletCounterActive
|
||||
Data: housePelletCounter
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Data: 11
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Data: 11
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -1771,19 +1771,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: housePelletCounterLimit
|
||||
Data: housePelletCounterActive
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 91|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: housePelletCounterLimit
|
||||
Data: housePelletCounterActive
|
||||
- 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
|
||||
@@ -1819,19 +1819,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: kinematic
|
||||
Data: housePelletCounterLimit
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 93|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: kinematic
|
||||
Data: housePelletCounterLimit
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Data: 11
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
Data: 11
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -1867,13 +1867,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: specialLook
|
||||
Data: kinematic
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 95|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: specialLook
|
||||
Data: kinematic
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
@@ -1915,13 +1915,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: followingPredefinedPath
|
||||
Data: specialLook
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 97|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: followingPredefinedPath
|
||||
Data: specialLook
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 64
|
||||
@@ -1963,31 +1963,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: predefinedPath
|
||||
Data: followingPredefinedPath
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 99|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: predefinedPath
|
||||
Data: followingPredefinedPath
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 100|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: Marro.PacManUdon.Direction[], Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
Data: 64
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 101|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
Data: 64
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -2002,7 +1990,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 102|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
|
||||
Data: 100|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
|
||||
mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
@@ -2024,19 +2012,31 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: predefinedPathIndex
|
||||
Data: predefinedPath
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 103|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 101|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: predefinedPathIndex
|
||||
Data: predefinedPath
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 11
|
||||
Entry: 7
|
||||
Data: 102|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: Marro.PacManUdon.Direction[], Assembly-CSharp
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 11
|
||||
Entry: 7
|
||||
Data: 103|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Int32[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -2073,13 +2073,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: <Index>k__BackingField
|
||||
Data: predefinedPathIndex
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 105|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: <Index>k__BackingField
|
||||
Data: predefinedPathIndex
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 11
|
||||
@@ -2122,13 +2122,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: animatorKeyDirection
|
||||
Data: <Index>k__BackingField
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 107|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: animatorKeyDirection
|
||||
Data: <Index>k__BackingField
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 11
|
||||
@@ -2171,13 +2171,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: animatorKeyGhostType
|
||||
Data: animatorKeyDirection
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 109|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: animatorKeyGhostType
|
||||
Data: animatorKeyDirection
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 11
|
||||
@@ -2220,25 +2220,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: isSingleBitSet
|
||||
Data: animatorKeyGhostType
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 111|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: isSingleBitSet
|
||||
Data: animatorKeyGhostType
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 112|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Boolean[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
Entry: 9
|
||||
Data: 11
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 112
|
||||
Data: 11
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -2253,7 +2247,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 113|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
|
||||
Data: 112|System.Collections.Generic.List`1[[System.Attribute, mscorlib]],
|
||||
mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
@@ -2275,19 +2269,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: cardinalDirections
|
||||
Data: isSingleBitSet
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 114|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 113|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: cardinalDirections
|
||||
Data: isSingleBitSet
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 100
|
||||
Entry: 7
|
||||
Data: 114|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Boolean[], mscorlib
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 101
|
||||
Data: 114
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -2319,6 +2319,55 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: cardinalDirections
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 116|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: cardinalDirections
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 102
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 103
|
||||
- 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: 117|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:
|
||||
|
||||
+647
-447
File diff suppressed because it is too large
Load Diff
+212
-111
@@ -13,9 +13,8 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
public enum NetworkEventType
|
||||
{
|
||||
FullSyncForced = 0,
|
||||
FullSync = 1,
|
||||
PacManTurn = 2,
|
||||
InputChange = 2,
|
||||
StartGameButtonPressed = 3,
|
||||
Pause = 7,
|
||||
Resume = 8,
|
||||
@@ -53,19 +52,23 @@ namespace Marro.PacManUdon
|
||||
/// <summary>
|
||||
/// The delay in ticks at which the receiving side replays events.
|
||||
/// </summary>
|
||||
[SerializeField] private int delay = 50;
|
||||
[SerializeField] private int delay = 1;
|
||||
/// <summary>
|
||||
/// The maximum amount of times a message is sent.
|
||||
/// </summary>
|
||||
[SerializeField] private int maxEventSendTries = 3;
|
||||
/// <summary>
|
||||
/// How long to wait since last message to send next ping.
|
||||
/// How long to wait since last message to send next message.
|
||||
/// </summary>
|
||||
[SerializeField] private int pingDelay = 15;
|
||||
[SerializeField] private int sendingPingDelay = 15;
|
||||
/// <summary>
|
||||
/// How long to wait since last attempt to request sync.
|
||||
/// </summary>
|
||||
[SerializeField] private int syncingPingDelay = 300;
|
||||
/// <summary>
|
||||
/// The time delta at which updates occur.
|
||||
/// </summary>
|
||||
[SerializeField] private float tickDelta = 0.0166666667f;
|
||||
[SerializeField] private float tickDelta = 0.0165f;
|
||||
#endregion
|
||||
|
||||
#region Constants
|
||||
@@ -98,6 +101,15 @@ namespace Marro.PacManUdon
|
||||
/// The total length of the header of an event, in bytes.
|
||||
/// </summary>
|
||||
private const ushort HeaderLength = 8;
|
||||
|
||||
/// <summary>
|
||||
/// The size of a GUID as used in the Reset event, in bytes.
|
||||
/// </summary>
|
||||
private const ushort GuidSize = 16;
|
||||
/// <summary>
|
||||
/// The total size of the Reset event.
|
||||
/// </summary>
|
||||
private const ushort ResetEventSize = HeaderTimestampIndex + GuidSize;
|
||||
#endregion
|
||||
|
||||
#region Private attributes
|
||||
@@ -151,6 +163,11 @@ namespace Marro.PacManUdon
|
||||
/// </summary>
|
||||
private int retriesWithoutSuccess;
|
||||
|
||||
/// <summary>
|
||||
/// The data of the last aknowledged Reset event.
|
||||
/// </summary>
|
||||
private byte[] lastResetEventData;
|
||||
|
||||
/// <summary>
|
||||
/// For receiver: True if there's a full sync in the queue and we are not synced, otherwise false.
|
||||
/// For transmitter: True if there's a full sync in the queue which has not yet been transmitted, otherwise false.
|
||||
@@ -162,13 +179,21 @@ namespace Marro.PacManUdon
|
||||
private bool serializationRequested;
|
||||
|
||||
/// <summary>
|
||||
/// Events to send at the end of SyncedUpdate cycle
|
||||
/// Events to send at the end of SyncedUpdate cycle.
|
||||
/// </summary>
|
||||
private NetworkEventType[] eventsToSend;
|
||||
private NetworkEventType[] eventsToSendEarly;
|
||||
/// <summary>
|
||||
/// Index for <see cref="eventsToSend"/>
|
||||
/// Index for <see cref="eventsToSendEarly"/>.
|
||||
/// </summary>
|
||||
private int eventsToSendIndex;
|
||||
private int eventsToSendEarlyIndex;
|
||||
/// <summary>
|
||||
/// Events to send at the end of SyncedUpdate cycle, delayed by a tick.
|
||||
/// </summary>
|
||||
private NetworkEventType[] eventsToSendLate;
|
||||
/// <summary>
|
||||
/// Index for <see cref="eventsToSendLate"/>.
|
||||
/// </summary>
|
||||
private int eventsToSendLateIndex;
|
||||
|
||||
/// <summary>
|
||||
/// Queue of events to be transmitted or processed.
|
||||
@@ -192,7 +217,7 @@ namespace Marro.PacManUdon
|
||||
/// </summary>
|
||||
private int eventTransmissionHistoryIndex;
|
||||
/// <summary>
|
||||
/// Time of last event transmission, in ticks.
|
||||
/// Time of last event transmission sent, requested or received, in ticks.
|
||||
/// </summary>
|
||||
private int lastEventTransmissionTime;
|
||||
|
||||
@@ -202,7 +227,6 @@ namespace Marro.PacManUdon
|
||||
/// </summary>
|
||||
private byte lastEventId;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Data which is currently available on the network.
|
||||
/// </summary>
|
||||
@@ -287,26 +311,17 @@ namespace Marro.PacManUdon
|
||||
|
||||
#region General
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="NetworkManager"/>. Call <see cref="Reset"/> afterwards to activate networking.
|
||||
/// Initializes the <see cref="NetworkManager"/>.
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Tried to call {nameof(Initialize)} when already initialized!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (root == null)
|
||||
{
|
||||
root = transform.parent.gameObject;
|
||||
}
|
||||
root = transform.parent.gameObject;
|
||||
|
||||
InitializeSubscribers();
|
||||
|
||||
@@ -330,6 +345,8 @@ namespace Marro.PacManUdon
|
||||
|
||||
networkEventSubscribers = new SyncedObject[eventTypeCount][];
|
||||
networkEventSubscribersIndices = new int[eventTypeCount];
|
||||
|
||||
lastResetEventData = new byte[ResetEventSize];
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -351,9 +368,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
ClearBuffer();
|
||||
|
||||
Synced = IsOwner; // Owner is always synced
|
||||
retriesWithoutSuccess = 0;
|
||||
hasFullSyncReady = false;
|
||||
|
||||
targetTicks = 0;
|
||||
startTime = Time.fixedTime;
|
||||
@@ -363,13 +378,14 @@ namespace Marro.PacManUdon
|
||||
Ready = true;
|
||||
|
||||
// Sync up
|
||||
if (IsOwner)
|
||||
if (!IsOwner)
|
||||
{
|
||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
||||
SetSynced(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
RequestEvent(NetworkEventType.FullSync);
|
||||
Synced = true; // Owner is always synced
|
||||
SendReset();
|
||||
}
|
||||
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Initialized");
|
||||
@@ -401,14 +417,18 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
if (Ready)
|
||||
{
|
||||
if (IsOwner)
|
||||
if (isOwner)
|
||||
{
|
||||
ProcessEventsToSend(); // Prepare events from last cycle
|
||||
ProgressPingTime(); // See if we need to send a ping
|
||||
ProgressSendingPingTime(); // See if we need to send a ping
|
||||
}
|
||||
else if (Synced || hasFullSyncReady)
|
||||
{
|
||||
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplyReceivedEvents(); // See if there's events after last update that need to be replayed
|
||||
ProgressSyncingPingTime(); // See if we should request syncing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,15 +469,13 @@ namespace Marro.PacManUdon
|
||||
ClearBuffer();
|
||||
}
|
||||
|
||||
Synced = false;
|
||||
|
||||
if (!IsOwner)
|
||||
{
|
||||
RequestEvent(NetworkEventType.FullSync);
|
||||
SetSynced(false);
|
||||
}
|
||||
else
|
||||
else if (clearBuffer)
|
||||
{
|
||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
||||
SendReset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,7 +507,7 @@ namespace Marro.PacManUdon
|
||||
#endregion
|
||||
|
||||
#region Sender
|
||||
public void SendEventSoon(NetworkEventType eventType)
|
||||
public void SendEventSoon(NetworkEventType eventType, bool early = false)
|
||||
{
|
||||
if (!Ready)
|
||||
{
|
||||
@@ -502,27 +520,53 @@ namespace Marro.PacManUdon
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventsQueueIndex > eventsToSend.Length)
|
||||
if (early)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSend)} overflow!");
|
||||
HandleError(false);
|
||||
return;
|
||||
if (eventsToSendEarlyIndex >= eventsToSendEarly.Length)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSendEarly)} overflow!");
|
||||
HandleError(true);
|
||||
return;
|
||||
}
|
||||
|
||||
eventsToSendEarly[eventsToSendEarlyIndex++] = eventType;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (eventsToSendLateIndex >= eventsToSendLate.Length)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(eventsToSendLate)} overflow!");
|
||||
HandleError(true);
|
||||
return;
|
||||
}
|
||||
|
||||
eventsToSendLate[eventsToSendLateIndex++] = eventType;
|
||||
}
|
||||
|
||||
eventsToSend[eventsToSendIndex++] = eventType;
|
||||
if (eventType == NetworkEventType.FullSync)
|
||||
{
|
||||
hasFullSyncReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessEventsToSend()
|
||||
{
|
||||
for (int i = 0; i < eventsToSendIndex; i++)
|
||||
for (int i = 0; i < eventsToSendEarlyIndex; i++)
|
||||
{
|
||||
SendEventNow(eventsToSend[0]);
|
||||
SendEventNow(eventsToSendEarly[i], true);
|
||||
}
|
||||
|
||||
eventsToSendIndex = 0;
|
||||
eventsToSendEarlyIndex = 0;
|
||||
|
||||
for (int i = 0; i < eventsToSendLateIndex; i++)
|
||||
{
|
||||
SendEventNow(eventsToSendLate[i], false);
|
||||
}
|
||||
|
||||
eventsToSendLateIndex = 0;
|
||||
}
|
||||
|
||||
public void SendEventNow(NetworkEventType eventType)
|
||||
public void SendEventNow(NetworkEventType eventType, bool early)
|
||||
{
|
||||
if (!Ready)
|
||||
{
|
||||
@@ -537,19 +581,22 @@ namespace Marro.PacManUdon
|
||||
|
||||
var timestamp = SyncedTimeTicks;
|
||||
|
||||
if (early)
|
||||
{
|
||||
timestamp--;
|
||||
}
|
||||
|
||||
var eventId = GetNextEventId(lastEventId);
|
||||
|
||||
InitializeEvent(eventType, timestamp, eventId, out byte[] data, out var index);
|
||||
|
||||
var effectiveEventType = eventType == NetworkEventType.FullSyncForced ? NetworkEventType.FullSync : eventType;
|
||||
|
||||
var subscibers = GetEventSubscribers(effectiveEventType);
|
||||
var subscibers = GetEventSubscribers(eventType);
|
||||
|
||||
if (subscibers != null)
|
||||
{
|
||||
foreach (var obj in subscibers)
|
||||
{
|
||||
obj.CollectSyncedData(data, ref index, effectiveEventType);
|
||||
obj.CollectSyncedData(data, ref index, eventType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,16 +604,11 @@ namespace Marro.PacManUdon
|
||||
var eventSizeBytes = BitConverter.GetBytes((ushort)index);
|
||||
Array.Copy(eventSizeBytes, 0, data, HeaderEventSizeIndex, eventSizeBytes.Length);
|
||||
|
||||
if (IsFullSync(eventType))
|
||||
{
|
||||
hasFullSyncReady = true;
|
||||
}
|
||||
|
||||
data = GetArrayPart(data, 0, index);
|
||||
|
||||
QueueEventInBuffer(data);
|
||||
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event of type {eventType} with {data.Length} bytes, timestamp {timestamp} and id {eventId} for serialization.");
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Prepared event of type {eventType} with {data.Length} bytes, timestamp {timestamp} and id {eventId} for serialization.");
|
||||
|
||||
RequestSerializationForEvents();
|
||||
|
||||
@@ -587,6 +629,19 @@ namespace Marro.PacManUdon
|
||||
index = HeaderLength;
|
||||
}
|
||||
|
||||
private void SendReset()
|
||||
{
|
||||
var data = new byte[ResetEventSize];
|
||||
|
||||
var guid = Guid.NewGuid().ToByteArray();
|
||||
Array.Copy(guid, 0, data, HeaderTimestampIndex, GuidSize);
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Sent Reset event!");
|
||||
|
||||
QueueEventInBuffer(data);
|
||||
RequestSerializationForEvents();
|
||||
}
|
||||
|
||||
private void RequestSerializationForEvents()
|
||||
{
|
||||
RequestSerialization();
|
||||
@@ -605,29 +660,32 @@ namespace Marro.PacManUdon
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFullSync(eventType) && hasFullSyncReady)
|
||||
if (eventType == NetworkEventType.FullSync && hasFullSyncReady)
|
||||
{
|
||||
//Debug.Log($"Rejected event request because already have full sync ready");
|
||||
return; // Don't send another full sync if we're already preparing to send one
|
||||
}
|
||||
|
||||
if (eventType == NetworkEventType.FullSyncForced)
|
||||
{
|
||||
SendEventSoon(NetworkEventType.FullSync); // Remote is not allowed to request a forced full sync
|
||||
return;
|
||||
}
|
||||
|
||||
SendEventSoon(eventType);
|
||||
}
|
||||
|
||||
private void ProgressPingTime()
|
||||
private void ProgressSendingPingTime()
|
||||
{
|
||||
if (eventsQueueIndex > 0 && !serializationRequested
|
||||
&& targetTicks - lastEventTransmissionTime >= pingDelay)
|
||||
&& targetTicks - lastEventTransmissionTime >= sendingPingDelay)
|
||||
{
|
||||
RequestSerializationForEvents();
|
||||
}
|
||||
}
|
||||
|
||||
private void ProgressSyncingPingTime()
|
||||
{
|
||||
if (targetTicks - lastEventTransmissionTime >= syncingPingDelay)
|
||||
{
|
||||
RequestEvent(NetworkEventType.FullSync);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnPreSerialization()
|
||||
{
|
||||
if (!Ready || !IsOwner || !serializationRequested || eventsQueue == null || eventsQueueIndex == 0)
|
||||
@@ -654,6 +712,9 @@ namespace Marro.PacManUdon
|
||||
// Version of OnPostSerialization which does not require instantiating SerializationResult, so that it can be called for debugging purposes.
|
||||
public void OnPostSerializationInternal(bool success, int byteCount)
|
||||
{
|
||||
// If there was a full sync in the queue, it should now have been transmitted at least once
|
||||
hasFullSyncReady = false;
|
||||
|
||||
if (!Ready || !IsOwner || networkedData.Length == 0)
|
||||
{
|
||||
return;
|
||||
@@ -674,9 +735,6 @@ namespace Marro.PacManUdon
|
||||
|
||||
networkedData = new byte[0];
|
||||
|
||||
// If there was a full sync in the queue, it has now been transmitted at least once
|
||||
hasFullSyncReady = false;
|
||||
|
||||
lastEventTransmissionTime = targetTicks;
|
||||
}
|
||||
#endregion
|
||||
@@ -696,6 +754,7 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
|
||||
SendCustomNetworkEvent(VRC.Udon.Common.Interfaces.NetworkEventTarget.Owner, "RequestEventReceived", eventType);
|
||||
lastEventTransmissionTime = SyncedTimeTicks;
|
||||
|
||||
if (tester != null)
|
||||
{
|
||||
@@ -710,14 +769,14 @@ namespace Marro.PacManUdon
|
||||
return; // Nothing to store
|
||||
}
|
||||
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{ArrayToString(networkedData)}");
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Received {networkedData.Length} bytes!\nBytes received:\n{ArrayToString(networkedData)}");
|
||||
|
||||
var length = networkedData.Length;
|
||||
int index = 0;
|
||||
int eventSize = 0; // Store event size here so we can increment the index no matter how we increment the loop
|
||||
while ((index += eventSize) < length)
|
||||
{
|
||||
if (length - index < HeaderLength)
|
||||
if (length - index < HeaderLength) // Check package is at least as long as the minimum length possible. Reset package is also larger than HeaderLength.
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) {nameof(StoreIncomingData)}: Remaining data in networkedData is not long enough to form a complete event! remaining: {length - index}.");
|
||||
HandleError(false);
|
||||
@@ -725,6 +784,12 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
|
||||
eventSize = GetEventSizeFromHeader(networkedData, index);
|
||||
bool isReset = eventSize == 0;
|
||||
|
||||
if (isReset)
|
||||
{
|
||||
eventSize = ResetEventSize;
|
||||
}
|
||||
|
||||
if (length - index < eventSize)
|
||||
{
|
||||
@@ -742,11 +807,16 @@ namespace Marro.PacManUdon
|
||||
|
||||
var @event = GetArrayPart(networkedData, index, eventSize);
|
||||
|
||||
if (isReset && TryApplyReset(@event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var timestamp = GetTimestampFromHeader(@event);
|
||||
var eventId = GetEventIdFromHeader(@event);
|
||||
var eventType = GetEventTypeFromHeader(@event);
|
||||
|
||||
if (eventType != NetworkEventType.FullSyncForced && (Synced || hasFullSyncReady))
|
||||
if (Synced || hasFullSyncReady)
|
||||
{
|
||||
// Check if event id is sequential
|
||||
if (eventId != GetNextEventId(lastEventId))
|
||||
@@ -764,25 +834,29 @@ namespace Marro.PacManUdon
|
||||
continue;
|
||||
}
|
||||
|
||||
QueueEventInBuffer(@event);
|
||||
if (!QueueEventInBuffer(@event))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventsQueueIndex == 1) // If this is the next upcoming event, update the next event time
|
||||
{
|
||||
UpdateNextEventTime();
|
||||
}
|
||||
|
||||
//Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)} Queued event with id {eventId}");
|
||||
}
|
||||
else if (eventType == NetworkEventType.FullSync) // If we're not yet synced, we only care about full sync events.
|
||||
{
|
||||
QueueFullSyncForReplay(@event); // Immediately process full sync
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we're not yet synced, we only care about full sync events.
|
||||
if (IsFullSync(eventType))
|
||||
{
|
||||
QueueFullSyncForReplay(@event); // Immediately process full sync
|
||||
}
|
||||
continue; // Event is currently not relevant
|
||||
}
|
||||
|
||||
lastEventId = eventId;
|
||||
}
|
||||
|
||||
if (Synced)
|
||||
{
|
||||
UpdateNextEventTime();
|
||||
lastEventTransmissionTime = SyncedTimeTicks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -797,7 +871,47 @@ namespace Marro.PacManUdon
|
||||
|
||||
hasFullSyncReady = true;
|
||||
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Queued full sync in buffer, should execute at {nextEventTime}.");
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Queued full sync in buffer, current time is {SyncedTimeTicks}, should execute at {nextEventTime}.");
|
||||
}
|
||||
|
||||
private bool TryApplyReset(byte[] @event)
|
||||
{
|
||||
// Compare the guid to the one in the previous reset event
|
||||
if (IsDuplicateResetEvent(@event))
|
||||
{
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Rejected Reset event as it was a duplicate.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Applied Reset event!");
|
||||
|
||||
lastResetEventData = @event;
|
||||
Reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsDuplicateResetEvent(byte[] @event)
|
||||
{
|
||||
for (int i = HeaderTimestampIndex; i < ResetEventSize; i++)
|
||||
{
|
||||
if (@event[i] != lastResetEventData[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SetSynced(bool synced)
|
||||
{
|
||||
Synced = synced;
|
||||
|
||||
if (!Synced)
|
||||
{
|
||||
Synced = false;
|
||||
RequestEvent(NetworkEventType.FullSync);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyReceivedEvents()
|
||||
@@ -823,11 +937,11 @@ namespace Marro.PacManUdon
|
||||
var timestamp = GetTimestampFromHeader(@event);
|
||||
var eventType = GetEventTypeFromHeader(@event);
|
||||
|
||||
var isFullSync = IsFullSync(eventType);
|
||||
|
||||
if (!Synced || eventType == NetworkEventType.FullSyncForced)
|
||||
if (!Synced)
|
||||
{
|
||||
SyncToTimestamp(timestamp);
|
||||
hasFullSyncReady = false;
|
||||
SetSynced(true);
|
||||
}
|
||||
else if (timestamp < SyncedTimeTicks)
|
||||
{
|
||||
@@ -837,11 +951,6 @@ namespace Marro.PacManUdon
|
||||
return false;
|
||||
}
|
||||
|
||||
if (eventType == NetworkEventType.FullSyncForced)
|
||||
{
|
||||
eventType = NetworkEventType.FullSync;
|
||||
}
|
||||
|
||||
var index = (int)HeaderLength; // Skip header
|
||||
|
||||
var subscribers = GetEventSubscribers(eventType);
|
||||
@@ -850,11 +959,6 @@ namespace Marro.PacManUdon
|
||||
|
||||
if (subscribers != null)
|
||||
{
|
||||
foreach (var obj in subscribers)
|
||||
{
|
||||
obj.SyncedUpdate();
|
||||
}
|
||||
|
||||
foreach (var obj in subscribers)
|
||||
{
|
||||
var success = obj.WriteSyncedData(@event, ref index, eventType);
|
||||
@@ -876,13 +980,7 @@ namespace Marro.PacManUdon
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Synced && isFullSync)
|
||||
{
|
||||
hasFullSyncReady = false;
|
||||
Synced = true;
|
||||
}
|
||||
|
||||
//Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Performed incoming event of type {eventType}! Total {index} bytes.");
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Performed incoming event of type {eventType}! Total {index} bytes.");
|
||||
|
||||
retriesWithoutSuccess = 0; // We had success!
|
||||
|
||||
@@ -907,12 +1005,16 @@ namespace Marro.PacManUdon
|
||||
eventsQueueIndex = 0;
|
||||
lastEventId = 0;
|
||||
hasFullSyncReady = false;
|
||||
lastEventTransmissionTime = SyncedTimeTicks;
|
||||
|
||||
eventTransmissionHistory = new int[maxEventSendTries];
|
||||
eventTransmissionHistoryIndex = 0;
|
||||
eventsQueueIndexAtLastTransmission = 0;
|
||||
eventsToSend = new NetworkEventType[BufferMaxTotalEvents];
|
||||
eventsToSendIndex = 0;
|
||||
|
||||
eventsToSendEarly = new NetworkEventType[BufferMaxTotalEvents];
|
||||
eventsToSendEarlyIndex = 0;
|
||||
eventsToSendLate = new NetworkEventType[BufferMaxTotalEvents];
|
||||
eventsToSendLateIndex = 0;
|
||||
}
|
||||
|
||||
private void DequeueEventsFromBuffer(int eventCount)
|
||||
@@ -995,7 +1097,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
if (nextEventTime < SyncedTimeTicks)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event timestamp is earlier than our current synced time by {SyncedTime - nextEventTime} seconds! nextEventTime: {nextEventTime} SyncedTime: {SyncedTime}, internalTime: {targetTicks}");
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) New event timestamp is earlier than our current synced time by {SyncedTimeTicks - nextEventTime}! nextEventTime: {nextEventTime} SyncedTime: {SyncedTimeTicks}, targetTicks: {targetTicks}");
|
||||
HandleError(true);
|
||||
return;
|
||||
}
|
||||
@@ -1017,9 +1119,6 @@ namespace Marro.PacManUdon
|
||||
return currentEventId;
|
||||
}
|
||||
|
||||
private static bool IsFullSync(NetworkEventType eventType)
|
||||
=> eventType == NetworkEventType.FullSync || eventType == NetworkEventType.FullSyncForced;
|
||||
|
||||
private static ushort GetEventSizeFromHeader(byte[] @event, int eventIndex = 0)
|
||||
=> BitConverter.ToUInt16(@event, eventIndex + HeaderEventSizeIndex);
|
||||
|
||||
@@ -1046,7 +1145,8 @@ namespace Marro.PacManUdon
|
||||
|
||||
if (newOwnerIsLocalPlayer)
|
||||
{
|
||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
||||
ClearBuffer();
|
||||
SendReset();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -1179,6 +1279,7 @@ namespace Marro.PacManUdon
|
||||
[SerializeField] private Animator DebugImageToIndicateReady;
|
||||
|
||||
private NetworkManagerTester tester;
|
||||
|
||||
public void SetNetworkManagerTester(NetworkManagerTester tester)
|
||||
{
|
||||
this.tester = tester;
|
||||
@@ -1196,7 +1297,7 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void DoFullSync()
|
||||
{
|
||||
SendEventSoon(NetworkEventType.FullSyncForced);
|
||||
SendEventSoon(NetworkEventType.FullSync);
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
|
||||
+34
-26
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Marro.PacManUdon
|
||||
{
|
||||
@@ -9,7 +8,7 @@ namespace Marro.PacManUdon
|
||||
Moving,
|
||||
Stopped,
|
||||
Big,
|
||||
Dead,
|
||||
Dead,
|
||||
}
|
||||
|
||||
enum PacManState
|
||||
@@ -82,27 +81,7 @@ namespace Marro.PacManUdon
|
||||
return;
|
||||
}
|
||||
|
||||
float speed = this.speed;
|
||||
if (freezeSeconds > 0)
|
||||
{
|
||||
float freezePart = freezeSeconds / networkManager.SyncedDeltaTime;
|
||||
if (freezePart >= 1)
|
||||
{
|
||||
freezeSeconds -= networkManager.SyncedDeltaTime;
|
||||
animator.speed = 0;
|
||||
speed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed *= 1 - freezePart;
|
||||
animator.speed = 1 - freezePart;
|
||||
freezeSeconds = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.speed = 1;
|
||||
}
|
||||
float speed = GetNextSpeed();
|
||||
|
||||
Vector2 position = GetPosition();
|
||||
Vector2 nextPosition = GetNextPosition(position, directionVectors[(int)direction], speed, networkManager.SyncedDeltaTime); // The position pacman will move to, assuming it doens't get changed
|
||||
@@ -127,6 +106,33 @@ namespace Marro.PacManUdon
|
||||
SetPosition(nextPosition);
|
||||
}
|
||||
|
||||
private float GetNextSpeed()
|
||||
{
|
||||
float speed = this.speed;
|
||||
if (freezeSeconds > 0)
|
||||
{
|
||||
float freezePart = freezeSeconds / networkManager.SyncedDeltaTime;
|
||||
if (freezePart >= 1)
|
||||
{
|
||||
freezeSeconds -= networkManager.SyncedDeltaTime;
|
||||
animator.speed = 0;
|
||||
speed = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
speed *= 1 - freezePart;
|
||||
animator.speed = 1 - freezePart;
|
||||
freezeSeconds = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.speed = 1;
|
||||
}
|
||||
|
||||
return speed;
|
||||
}
|
||||
|
||||
private Vector2 ProcessNextPosition(Vector2 position, Vector2 nextPosition)
|
||||
{
|
||||
if (CrossesTileCenter(position, nextPosition, Direction.Left) // If pacman is moving horizontally, check if he may cross the center of a tile in that axis
|
||||
@@ -210,11 +216,11 @@ namespace Marro.PacManUdon
|
||||
|
||||
if (eatResult == EatResult.Pellet)
|
||||
{
|
||||
freezeSeconds = 0.0166666666666667f;
|
||||
freezeSeconds = 0.0165f;
|
||||
}
|
||||
else if (eatResult == EatResult.PowerPellet)
|
||||
{
|
||||
freezeSeconds = 0.05f;
|
||||
freezeSeconds = 0.0495f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,6 +289,7 @@ namespace Marro.PacManUdon
|
||||
// Debug.Log($"{gameObject} SetLevel {level}");
|
||||
defaultSpeed = PacManConstants.GetPacManDefaultSpeedForLevel(level);
|
||||
powerPelletSpeed = PacManConstants.GetPacManPowerPelletSpeedForLevel(level);
|
||||
UpdateSpeed();
|
||||
}
|
||||
|
||||
public void SetPowerPellet(bool powerPellet)
|
||||
@@ -350,6 +357,7 @@ namespace Marro.PacManUdon
|
||||
state = (PacManState)data.ReadByte(ref index);
|
||||
freezeSeconds = data.ReadFloat(ref index);
|
||||
frozen = data.ReadBool(ref index);
|
||||
|
||||
UpdateSpeed();
|
||||
|
||||
return base.WriteSyncedData(data, ref index, eventType);
|
||||
|
||||
@@ -43,7 +43,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 11
|
||||
Data: 10
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -385,19 +385,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: inputHorizontal
|
||||
Data: analogInput
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 22|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: inputHorizontal
|
||||
Data: analogInput
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 20
|
||||
Entry: 7
|
||||
Data: 23|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: UnityEngine.Vector2, 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
|
||||
@@ -412,7 +418,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
|
||||
@@ -433,19 +439,19 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: inputVertical
|
||||
Data: dirty
|
||||
- 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: inputVertical
|
||||
Data: dirty
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 20
|
||||
Data: 7
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 17
|
||||
Data: 7
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -460,7 +466,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 25|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 26|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -481,25 +487,25 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: horizontalValue
|
||||
Data: lastUsedHand
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 26|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 27|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: horizontalValue
|
||||
Data: lastUsedHand
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 27|System.RuntimeType, mscorlib
|
||||
Data: 28|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: System.Single, mscorlib
|
||||
Data: VRC.Udon.Common.HandType, VRC.Udon.Common
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 27
|
||||
Data: 28
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -514,55 +520,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 28|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: verticalValue
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 29|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: verticalValue
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 27
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 27
|
||||
- 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: 30|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 29|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
@@ -586,7 +544,7 @@ MonoBehaviour:
|
||||
Data: horizontalPriority
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
Data: 30|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: horizontalPriority
|
||||
@@ -610,7 +568,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 31|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
+117
-87
@@ -21,22 +21,24 @@
|
||||
private InputMethod inputMethod;
|
||||
|
||||
private Direction resultInput;
|
||||
private Direction inputHorizontal;
|
||||
private Direction inputVertical;
|
||||
private float horizontalValue;
|
||||
private float verticalValue;
|
||||
private Vector2 analogInput;
|
||||
private bool dirty;
|
||||
private HandType lastUsedHand;
|
||||
private bool horizontalPriority;
|
||||
|
||||
public void Initialize(GameManager gameManager)
|
||||
{
|
||||
this.gameManager = gameManager;
|
||||
resultInput = Direction.Zero;
|
||||
inputHorizontal = Direction.Zero;
|
||||
inputVertical = Direction.Zero;
|
||||
horizontalPriority = false;
|
||||
|
||||
player = Networking.LocalPlayer;
|
||||
inputMethod = InputMethod.KeyboardMouse;
|
||||
|
||||
SubscribeToEvent(NetworkEventType.PacManTurn);
|
||||
resultInput = Direction.Zero;
|
||||
analogInput = Vector2.zero;
|
||||
dirty = false;
|
||||
horizontalPriority = false;
|
||||
|
||||
SubscribeToEvent(NetworkEventType.InputChange);
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -67,6 +69,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
public override void SyncedUpdate()
|
||||
{
|
||||
if (dirty) // Update now to ensure input feedback is performed timely
|
||||
{
|
||||
UpdateResultInput();
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Debug.Log($"{gameObject} got activated, {player} was immobilized");
|
||||
@@ -109,36 +119,9 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var previousInputHorizontal = inputHorizontal;
|
||||
|
||||
horizontalValue = Math.Abs(value);
|
||||
if (value < -0.5)
|
||||
{
|
||||
inputHorizontal = Direction.Left;
|
||||
if (horizontalValue >= verticalValue)
|
||||
{
|
||||
SetPriority(true);
|
||||
}
|
||||
}
|
||||
else if (value > 0.5)
|
||||
{
|
||||
inputHorizontal = Direction.Right;
|
||||
if (horizontalValue >= verticalValue)
|
||||
{
|
||||
SetPriority(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inputHorizontal = Direction.Zero;
|
||||
SetPriority(false);
|
||||
}
|
||||
|
||||
if (previousInputHorizontal != inputHorizontal)
|
||||
{
|
||||
UpdateResultInput();
|
||||
}
|
||||
// Debug.Log("Horizontal Input Event: " + value + " | Direction: " + direction + " | lastDirection: " + lastDirection + " | Left: " + left + " | Right: " + right);
|
||||
analogInput.x = value;
|
||||
lastUsedHand = args.handType;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public override void InputMoveVertical(float value, UdonInputEventArgs args)
|
||||
@@ -148,37 +131,9 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var previousInputVertical = inputVertical;
|
||||
|
||||
verticalValue = Math.Abs(value);
|
||||
if (value > 0.5)
|
||||
{
|
||||
inputVertical = Direction.Up;
|
||||
if (verticalValue >= horizontalValue)
|
||||
{
|
||||
SetPriority(false);
|
||||
}
|
||||
}
|
||||
else if (value < -0.5)
|
||||
{
|
||||
inputVertical = Direction.Down;
|
||||
if (verticalValue >= horizontalValue)
|
||||
{
|
||||
SetPriority(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inputVertical = Direction.Zero;
|
||||
SetPriority(true);
|
||||
}
|
||||
|
||||
if (previousInputVertical != inputVertical)
|
||||
{
|
||||
UpdateResultInput();
|
||||
}
|
||||
|
||||
// Debug.Log("Vertical Input Event: " + value + " | Direction: " + direction + " | lastDirection : " + lastDirection);
|
||||
analogInput.y = value;
|
||||
lastUsedHand = args.handType;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
public override void OnInputMethodChanged(VRCInputMethod inputMethod)
|
||||
@@ -195,33 +150,108 @@
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPriority(bool horizontalPriority)
|
||||
{
|
||||
if (this.horizontalPriority != horizontalPriority)
|
||||
{
|
||||
if (inputMethod != InputMethod.KeyboardMouse)
|
||||
{
|
||||
player.PlayHapticEventInHand(VRC_Pickup.PickupHand.Left, 0.1f, 0.15f, 75);
|
||||
}
|
||||
|
||||
this.horizontalPriority = horizontalPriority;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateResultInput()
|
||||
{
|
||||
resultInput = horizontalPriority ? inputHorizontal : inputVertical;
|
||||
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
|
||||
dirty = false;
|
||||
var newResult = GetResultInput(analogInput);
|
||||
|
||||
if (newResult == resultInput)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Debug.Log($"Switched to input direction {newResult} from analogInput {analogInput} with HorizontalPriority {horizontalPriority}");
|
||||
|
||||
resultInput = newResult;
|
||||
networkManager.SendEventSoon(NetworkEventType.InputChange, true);
|
||||
PlayHaptics();
|
||||
}
|
||||
|
||||
private void PlayHaptics()
|
||||
{
|
||||
if (inputMethod == InputMethod.KeyboardMouse)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
VRC_Pickup.PickupHand hand;
|
||||
switch (lastUsedHand)
|
||||
{
|
||||
case HandType.LEFT:
|
||||
hand = VRC_Pickup.PickupHand.Left;
|
||||
break;
|
||||
case HandType.RIGHT:
|
||||
hand = VRC_Pickup.PickupHand.Right;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
player.PlayHapticEventInHand(hand, 0.1f, 0.15f, 75);
|
||||
}
|
||||
|
||||
private Direction GetResultInput(Vector2 analogInput)
|
||||
{
|
||||
if (analogInput.magnitude < 0.8)
|
||||
{
|
||||
return Direction.Zero;
|
||||
}
|
||||
|
||||
var normalized = analogInput.normalized;
|
||||
|
||||
//Debug.Log($"Checking analogInput {analogInput} with HorizontalPriority {horizontalPriority}, normalized {normalized}");
|
||||
|
||||
const float directionDivider = 0.72f;
|
||||
if (normalized.x > directionDivider)
|
||||
{
|
||||
horizontalPriority = false;
|
||||
return Direction.Right;
|
||||
}
|
||||
else if (normalized.x < -directionDivider)
|
||||
{
|
||||
horizontalPriority = false;
|
||||
return Direction.Left;
|
||||
}
|
||||
else if (normalized.y > directionDivider)
|
||||
{
|
||||
horizontalPriority = true;
|
||||
return Direction.Up;
|
||||
}
|
||||
else if (normalized.y < -directionDivider)
|
||||
{
|
||||
horizontalPriority = true;
|
||||
return Direction.Down;
|
||||
}
|
||||
|
||||
if (horizontalPriority)
|
||||
{
|
||||
if (normalized.x > 0)
|
||||
{
|
||||
return Direction.Right;
|
||||
}
|
||||
return Direction.Left;
|
||||
}
|
||||
|
||||
if (normalized.y > 0)
|
||||
{
|
||||
return Direction.Up;
|
||||
}
|
||||
return Direction.Down;
|
||||
}
|
||||
|
||||
public Direction GetDirection()
|
||||
{
|
||||
if (dirty) // Update now to reduce input delay
|
||||
{
|
||||
UpdateResultInput();
|
||||
}
|
||||
|
||||
return resultInput;
|
||||
}
|
||||
|
||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType != NetworkEventType.PacManTurn)
|
||||
if (eventType != NetworkEventType.InputChange)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -231,7 +261,7 @@
|
||||
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType != NetworkEventType.PacManTurn)
|
||||
if (eventType != NetworkEventType.InputChange)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
||||
[SerializeField] GridMover[] gridMovers1;
|
||||
[SerializeField] NetworkManager networkManager2;
|
||||
[SerializeField] GridMover[] gridMovers2;
|
||||
|
||||
[SerializeField] Animator debugImageToIndicateSynced;
|
||||
|
||||
private int[] captureTimes = new int[1000];
|
||||
@@ -68,6 +69,10 @@ public class NetworkManagerSyncTester : UdonSharpBehaviour
|
||||
var equal = true;
|
||||
|
||||
var positions1 = positionCaptures[index];
|
||||
if (positions1 == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var positions2 = GetPositions(gridMovers2);
|
||||
for (int i = 0; i < positions1.Length; i++)
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
public class NetworkManagerTester : UdonSharpBehaviour
|
||||
{
|
||||
[SerializeField] private NetworkManager[] networkManagers;
|
||||
[SerializeField] private float interval = 0.1f;
|
||||
[SerializeField] private float interval = 0.01f;
|
||||
[SerializeField] private int ownerIndex = 0;
|
||||
|
||||
private float countdown = 0;
|
||||
@@ -62,7 +62,7 @@ public class NetworkManagerTester : UdonSharpBehaviour
|
||||
{
|
||||
networkManager.OnPreSerialization();
|
||||
var data = networkManager.NetworkedData;
|
||||
networkManager.OnPostSerializationInternal(true, data.Length) ;
|
||||
networkManager.OnPostSerializationInternal(true, data.Length);
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -86,12 +86,12 @@ public class NetworkManagerTester : UdonSharpBehaviour
|
||||
{
|
||||
foreach (var target in networkManagers)
|
||||
{
|
||||
if (!target.IsOwner || !target.SerializationRequested)
|
||||
if (!target.IsOwner)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Debug.Log($"{nameof(NetworkManagerTester)} Requested event with type {eventType}.");
|
||||
Debug.Log($"{nameof(NetworkManagerTester)} Requested event with type {eventType}.");
|
||||
|
||||
target.RequestEventReceived(eventType);
|
||||
}
|
||||
|
||||
@@ -130,8 +130,7 @@ public class TestBall : SyncedObject
|
||||
|
||||
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType == NetworkEventType.FullSync
|
||||
|| eventType == NetworkEventType.FullSyncForced)
|
||||
if (eventType == NetworkEventType.FullSync)
|
||||
{
|
||||
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
|
||||
data.Append(amountUp, ref index);
|
||||
@@ -141,8 +140,7 @@ public class TestBall : SyncedObject
|
||||
|
||||
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
|
||||
{
|
||||
if (eventType == NetworkEventType.FullSync
|
||||
|| eventType == NetworkEventType.FullSyncForced)
|
||||
if (eventType == NetworkEventType.FullSync)
|
||||
{
|
||||
amountUp = data.ReadFloat(ref index);
|
||||
SetProgress(data.ReadFloat(ref index));
|
||||
|
||||
@@ -50,7 +50,7 @@ public class TestBallManager : UdonSharpBehaviour
|
||||
testBall.UpButtonPressed();
|
||||
}
|
||||
|
||||
networkManager.SendEventSoon(NetworkEventType.PacManTurn);
|
||||
networkManager.SendEventSoon(NetworkEventType.InputChange);
|
||||
}
|
||||
|
||||
public void SyncButtonPressed()
|
||||
|
||||
Reference in New Issue
Block a user