Correct/incorrect events are now guaranteed to fire only from the marker owner.

This commit is contained in:
2025-07-20 20:45:15 -04:00
parent 999a0342d5
commit 83e08ed403
10 changed files with 3237 additions and 776 deletions
+20 -80
View File
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 6
Data: 5
- Name:
Entry: 7
Data:
@@ -110,19 +110,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _CurrentCountry
Data: _Activate
- Name: $v
Entry: 7
Data: 6|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CurrentCountry
Data: _Activate
- Name: <UserType>k__BackingField
Entry: 7
Data: 7|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
@@ -146,76 +146,16 @@ MonoBehaviour:
Data: 8|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
Data: 2
- Name:
Entry: 7
Data: 9|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: _Activate
- Name: $v
Entry: 7
Data: 10|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _Activate
- Name: <UserType>k__BackingField
Entry: 7
Data: 11|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
- 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: 12|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 13|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 14|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 10|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -239,13 +179,13 @@ MonoBehaviour:
Data: _RandomisedCountriesAndCities
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _RandomisedCountriesAndCities
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32[], mscorlib
@@ -254,7 +194,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
Data: 12
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -269,19 +209,19 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 17|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 13|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 2
- Name:
Entry: 7
Data: 18|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
Data: 14|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data: 19|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
Data: 15|UdonSharp.FieldChangeCallbackAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
@@ -305,13 +245,13 @@ MonoBehaviour:
Data: _ChosenCountries
- Name: $v
Entry: 7
Data: 20|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 16|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChosenCountries
- Name: <UserType>k__BackingField
Entry: 7
Data: 21|System.RuntimeType, mscorlib
Data: 17|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String[], mscorlib
@@ -320,7 +260,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 21
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -335,7 +275,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 22|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 18|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -359,16 +299,16 @@ MonoBehaviour:
Data: _ChosenCities
- Name: $v
Entry: 7
Data: 23|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 19|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ChosenCities
- Name: <UserType>k__BackingField
Entry: 9
Data: 21
Data: 17
- Name: <SystemType>k__BackingField
Entry: 9
Data: 21
Data: 17
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -383,7 +323,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 24|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 20|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
+5 -28
View File
@@ -11,14 +11,13 @@ public class FloorMap : UdonSharpBehaviour
{
public FloorMapCountry[] Countries;
[UdonSynced] private int _CurrentCountry = 0;
[UdonSynced, FieldChangeCallback(nameof(Activate))] private bool _Activate;
[UdonSynced, FieldChangeCallback(nameof(RandomisedCountriesAndCities))] private int[] _RandomisedCountriesAndCities;
private string[] _ChosenCountries = new string[MAX_SELECTED_COUNTRIES];
private string[] _ChosenCities = new string[MAX_SELECTED_COUNTRIES];
private const int MAX_SELECTED_COUNTRIES = 13;
public const int MAX_SELECTED_COUNTRIES = 13;
private const float DEACTIVATE_HEIGHT = -1000.0f;
@@ -88,8 +87,6 @@ public class FloorMap : UdonSharpBehaviour
{
DisableAllLocations();
_CurrentCountry = 0;
for (int i = 0; i < MAX_SELECTED_COUNTRIES; i++)
{
FloorMapCountry Country = Countries[NewCountrySelections[i]];
@@ -105,34 +102,14 @@ public class FloorMap : UdonSharpBehaviour
_RandomisedCountriesAndCities = NewCountrySelections;
}
public int NextCountry()
public string GetCountry(int CountryIndex)
{
_CurrentCountry++;
if (_CurrentCountry >= MAX_SELECTED_COUNTRIES)
{
// We ran out of countries. Just end the game here.
return -1;
}
RequestSerialization();
return _CurrentCountry;
return CountryIndex < _ChosenCountries.Length ? _ChosenCountries[CountryIndex] : "";
}
public int GetCurrentCountryIndex()
public string GetCity(int CityIndex)
{
return _CurrentCountry;
}
public string GetCurrentCountry()
{
return _ChosenCountries[_CurrentCountry];
}
public string GetCurrentCity()
{
return _ChosenCities[_CurrentCountry];
return CityIndex < _ChosenCities.Length ? _ChosenCities[CityIndex] : "";
}
+133 -187
View File
@@ -44,7 +44,7 @@ MonoBehaviour:
Data:
- Name:
Entry: 12
Data: 16
Data: 15
- Name:
Entry: 7
Data:
@@ -422,13 +422,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _LocationFindingEnabled
Data: _EnableCollisionChecks
- Name: $v
Entry: 7
Data: 28|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _LocationFindingEnabled
Data: _EnableCollisionChecks
- Name: <UserType>k__BackingField
Entry: 9
Data: 15
@@ -476,16 +476,70 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _FailureCounter
Data: _UsedUp
- Name: $v
Entry: 7
Data: 31|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FailureCounter
Data: _UsedUp
- Name: <UserType>k__BackingField
Entry: 9
Data: 15
- 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: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 32|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 33|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: _CollisionCheckCounter
- Name: $v
Entry: 7
Data: 34|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollisionCheckCounter
- Name: <UserType>k__BackingField
Entry: 7
Data: 32|System.RuntimeType, mscorlib
Data: 35|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Int32, mscorlib
@@ -494,115 +548,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
- 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: 33|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 34|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: _CheckingCollisions
- Name: $v
Entry: 7
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CheckingCollisions
- Name: <UserType>k__BackingField
Entry: 9
Data: 15
- 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: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 37|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: _CollisionCheckCounter
- Name: $v
Entry: 7
Data: 38|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollisionCheckCounter
- Name: <UserType>k__BackingField
Entry: 9
Data: 32
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
Data: 35
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -617,7 +563,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -641,16 +587,70 @@ MonoBehaviour:
Data: _NoCollisionCounter
- Name: $v
Entry: 7
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _NoCollisionCounter
- Name: <UserType>k__BackingField
Entry: 9
Data: 32
Data: 35
- Name: <SystemType>k__BackingField
Entry: 9
Data: 32
Data: 35
- 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: _CollidingLocations
- Name: $v
Entry: 7
Data: 39|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollidingLocations
- Name: <UserType>k__BackingField
Entry: 7
Data: 40|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataList, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 40
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -686,19 +686,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _CollidingLocations
Data: _RigidBodyComponent
- Name: $v
Entry: 7
Data: 42|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CollidingLocations
Data: _RigidBodyComponent
- Name: <UserType>k__BackingField
Entry: 7
Data: 43|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Data.DataList, VRCSDK3
Data: UnityEngine.Rigidbody, UnityEngine.PhysicsModule
- Name:
Entry: 8
Data:
@@ -740,25 +740,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _RigidBodyComponent
Data: _ObjectSync
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _RigidBodyComponent
Data: _ObjectSync
- Name: <UserType>k__BackingField
Entry: 7
Data: 46|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Rigidbody, UnityEngine.PhysicsModule
Data: MMMaellon.LightSync.LightSync, com.mmmaellon.lightsync
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 46
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -794,25 +794,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _ObjectSync
Data: _PickupComponent
- Name: $v
Entry: 7
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _ObjectSync
Data: _PickupComponent
- Name: <UserType>k__BackingField
Entry: 7
Data: 49|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: MMMaellon.LightSync.LightSync, com.mmmaellon.lightsync
Data: VRC.SDK3.Components.VRCPickup, VRCSDK3
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 4
Data: 49
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -848,19 +848,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _PickupComponent
Data: _MarkerMesh
- Name: $v
Entry: 7
Data: 51|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _PickupComponent
Data: _MarkerMesh
- Name: <UserType>k__BackingField
Entry: 7
Data: 52|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDK3.Components.VRCPickup, VRCSDK3
Data: UnityEngine.MeshRenderer, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
@@ -897,60 +897,6 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _MarkerMesh
- Name: $v
Entry: 7
Data: 54|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _MarkerMesh
- Name: <UserType>k__BackingField
Entry: 7
Data: 55|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.MeshRenderer, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 55
- 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: 56|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:
+60 -67
View File
@@ -20,10 +20,10 @@ public class FloorMapMarker : UdonSharpBehaviour
[UdonSynced, SerializeField, FieldChangeCallback(nameof(Active))] private bool _Active = false;
[UdonSynced, FieldChangeCallback(nameof(IsGrabbed))] private bool _IsGrabbed = false;
[UdonSynced, FieldChangeCallback(nameof(IsLit))] private bool _IsLit = false;
[UdonSynced] private bool _LocationFindingEnabled = false;
[UdonSynced] private int _FailureCounter = 0;
[UdonSynced] private bool _CheckingCollisions = false;
[UdonSynced] private bool _EnableCollisionChecks = false;
[UdonSynced] private bool _UsedUp = false;
private int _CollisionCheckCounter = 0;
private int _NoCollisionCounter = 0;
private DataList _CollidingLocations = new DataList();
@@ -33,7 +33,6 @@ public class FloorMapMarker : UdonSharpBehaviour
private VRCPickup _PickupComponent;
private MeshRenderer _MarkerMesh;
private const int MAX_FAILURE_COUNT = 2;
private const int MAX_REPEAT_COLLISION_CHECKS = 3;
private const int MAX_CHECKS_WITH_NO_COLLISIONS = 8;
private const float TIME_BETWEEN_REPEAT_COLLISION_CHECKS = 0.15f;
@@ -47,18 +46,21 @@ public class FloorMapMarker : UdonSharpBehaviour
_MarkerMesh = GetComponent<MeshRenderer>();
}
[NetworkCallable]
public void Initialise()
{
_RigidBodyComponent.constraints = RigidbodyConstraints.None;
_ObjectSync.TeleportToLocalSpace(Vector3.zero, Quaternion.identity, true);
SetPickupable(false);
Active = false;
IsGrabbed = false;
IsLit = false;
_LocationFindingEnabled = false;
_CheckingCollisions = false;
_FailureCounter = 0;
_EnableCollisionChecks = false;
_UsedUp = false;
_CollisionCheckCounter = 0;
_NoCollisionCounter = 0;
_CollidingLocations.Clear();
@@ -66,6 +68,7 @@ public class FloorMapMarker : UdonSharpBehaviour
RequestSerialization();
}
[NetworkCallable]
public void SetPickupable(bool Pickupable)
{
_PickupComponent.pickupable = Pickupable;
@@ -93,20 +96,14 @@ public class FloorMapMarker : UdonSharpBehaviour
public override void OnPickup()
{
if (Active)
{
IsGrabbed = true;
}
IsGrabbed = true;
base.OnPickup();
}
public override void OnDrop()
{
if (Active)
{
IsGrabbed = false;
}
IsGrabbed = false;
base.OnDrop();
}
@@ -124,13 +121,12 @@ public class FloorMapMarker : UdonSharpBehaviour
{
_RigidBodyComponent.constraints = RigidbodyConstraints.None;
_EnableCollisionChecks = true;
_NoCollisionCounter = 0;
_CollidingLocations.Clear();
}
else
{
_LocationFindingEnabled = true;
VRCPlayerApi Owner = Networking.GetOwner(gameObject);
if (!Owner.IsUserInVR())
{
@@ -138,62 +134,52 @@ public class FloorMapMarker : UdonSharpBehaviour
}
_NoCollisionCounter = 0;
if (!_CheckingCollisions) SendCustomNetworkEvent(NetworkEventTarget.Owner, nameof(CheckCollisions));
}
RequestSerialization();
}
[NetworkCallable]
public void CheckCollisions()
public void CheckCollisionsLoop()
{
if (!Active || !_LocationFindingEnabled || IsGrabbed) return;
_CheckingCollisions = true;
if (_CollidingLocations.Count > 0 && IsUpright())
if (Active)
{
_NoCollisionCounter = 0;
SendCustomEventDelayedSeconds(nameof(CheckCollisionsLoop), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
}
for (int i = 0; i < _CollidingLocations.Count; i++)
if (_EnableCollisionChecks && !IsGrabbed)
{
if (_CollidingLocations.Count > 0 && IsUpright())
{
FloorMapLocation Location = (FloorMapLocation)_CollidingLocations[i].Reference;
if (Location != null)
_NoCollisionCounter = 0;
for (int i = 0; i < _CollidingLocations.Count; i++)
{
bool FoundCorrectResponse = ConfirmChoice(Location.Country, Location.City);
if (FoundCorrectResponse)
FloorMapLocation Location = (FloorMapLocation)_CollidingLocations[i].Reference;
if (Location != null)
{
SendCorrectResponse(Location.transform.position);
return;
bool FoundCorrectResponse = ConfirmChoice(Location.Country, Location.City);
if (FoundCorrectResponse)
{
SendCorrectResponse(Location.transform.position);
return;
}
}
}
}
// We should make sure to only reach here if we don't get a correct
// response from the previous loop.
if (_CollisionCheckCounter < MAX_REPEAT_COLLISION_CHECKS)
{
SendCustomEventDelayedSeconds(nameof(CheckCollisions), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
_CollisionCheckCounter++;
if (_CollisionCheckCounter >= MAX_REPEAT_COLLISION_CHECKS)
{
SendIncorrectResponse();
}
}
else
{
SendIncorrectResponse();
}
_CollisionCheckCounter++;
}
else
{
_NoCollisionCounter++;
if (_NoCollisionCounter >= MAX_CHECKS_WITH_NO_COLLISIONS)
{
SendIncorrectResponse();
}
else
{
// If the marker isn't sitting mostly upright and is not grabbed,
// don't check collisions until later, in case it becomes upright.
SendCustomEventDelayedSeconds(nameof(CheckCollisions), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
_NoCollisionCounter++;
if (_NoCollisionCounter >= MAX_CHECKS_WITH_NO_COLLISIONS)
{
SendIncorrectResponse();
}
}
}
}
@@ -216,12 +202,15 @@ public class FloorMapMarker : UdonSharpBehaviour
IsLit = true;
Active = false;
_CheckingCollisions = false;
_EnableCollisionChecks = false;
_UsedUp = true;
RequestSerialization();
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "CorrectResponse");
_GameManager.PlayCorrectSound();
if (Networking.GetOwner(gameObject) == Networking.LocalPlayer)
{
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "CorrectResponse");
}
}
private void SendIncorrectResponse()
@@ -229,18 +218,15 @@ public class FloorMapMarker : UdonSharpBehaviour
DisableMovementCompletely();
_CollisionCheckCounter = 0;
_CheckingCollisions = false;
_CollidingLocations.Clear();
_FailureCounter++;
if (_FailureCounter >= MAX_FAILURE_COUNT)
_EnableCollisionChecks = false;
if (Networking.GetOwner(gameObject) == Networking.LocalPlayer)
{
Active = false;
_GameManager.SendCustomNetworkEvent(NetworkEventTarget.Owner, "IncorrectResponse");
}
_GameManager.PlayIncorrectSound();
RequestSerialization();
}
@@ -250,9 +236,17 @@ public class FloorMapMarker : UdonSharpBehaviour
Active = SetActive;
RequestSerialization();
}
private void ChangePickupable()
private void ReactToActivation()
{
_PickupComponent.pickupable = Active;
SendCustomEventDelayedSeconds(nameof(CheckCollisionsLoop), TIME_BETWEEN_REPEAT_COLLISION_CHECKS);
}
public bool IsUsedUp()
{
return _UsedUp;
}
@@ -266,7 +260,6 @@ public class FloorMapMarker : UdonSharpBehaviour
transform.position = CorrectLocation;
}
_LocationFindingEnabled = false;
RequestSerialization();
}
@@ -281,7 +274,7 @@ public class FloorMapMarker : UdonSharpBehaviour
set
{
_Active = value;
ChangePickupable();
ReactToActivation();
}
get => _Active;
}