Added Unity project files
This commit is contained in:
@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Event Dispatcher is how ClientSim implements the Observer Pattern.
|
||||
/// Systems can subscribe to specific event types, and other systems can then send the event.
|
||||
/// </summary>
|
||||
public class ClientSimEventDispatcher : IClientSimEventDispatcher, IDisposable
|
||||
{
|
||||
private readonly Dictionary<Type, Delegate> _eventSubscribers;
|
||||
|
||||
public ClientSimEventDispatcher()
|
||||
{
|
||||
_eventSubscribers = new Dictionary<Type, Delegate>();
|
||||
}
|
||||
|
||||
public void Subscribe<T>(Action<T> eventHandler) where T : IClientSimEvent
|
||||
{
|
||||
Type t = typeof(T);
|
||||
if (_eventSubscribers.TryGetValue(t, out Delegate eventDelegate))
|
||||
{
|
||||
_eventSubscribers[t] = Delegate.Combine(eventDelegate, eventHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventSubscribers.Add(t, eventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unsubscribe<T>(Action<T> eventHandler) where T : IClientSimEvent
|
||||
{
|
||||
Type t = typeof(T);
|
||||
if (_eventSubscribers.TryGetValue(t, out Delegate eventDelegate))
|
||||
{
|
||||
Delegate remainingDelegate = Delegate.Remove(eventDelegate, eventHandler);
|
||||
|
||||
if (remainingDelegate == null)
|
||||
{
|
||||
_eventSubscribers.Remove(t);
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventSubscribers[t] = remainingDelegate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the event to subscribed receivers
|
||||
/// </summary>
|
||||
/// <param name="clientSimEvent"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public void SendEvent<T>(T clientSimEvent) where T : IClientSimEvent
|
||||
{
|
||||
// TODO log warning if trying to send events while another is still being processed.
|
||||
|
||||
if (_eventSubscribers.TryGetValue(typeof(T), out Delegate eventDelegate)
|
||||
&& eventDelegate is Action<T> action)
|
||||
{
|
||||
action.Invoke(clientSimEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_eventSubscribers.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 039d8e7360df43b2a1b0b5f387761dce
|
||||
timeCreated: 1638918329
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1d43bb9f467463cb77ef60d29a6178a
|
||||
timeCreated: 1640236379
|
||||
@ -0,0 +1,10 @@
|
||||
using VRC.SDKBase;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimPlayerDeathStatusChangedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public bool isDead;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d6d64ca05845d34bb6753f2cc018bfd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,9 @@
|
||||
using VRC.Udon.Common;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimCurrentHandEvent : IClientSimEvent
|
||||
{
|
||||
public HandType currentUsedHand;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23f6deb432924c9f898f7f83f000045b
|
||||
timeCreated: 1641101850
|
||||
@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using VRC.Udon.Common;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimInteractEvent : IClientSimEvent
|
||||
{
|
||||
public HandType handType;
|
||||
public GameObject interactObject;
|
||||
public float interactDistance;
|
||||
public List<IClientSimInteractable> interacts;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d4f50777a7b4f5ba8f64f4fe7cb04c4
|
||||
timeCreated: 1640814847
|
||||
@ -0,0 +1,11 @@
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimMenuStateChangedEvent : IClientSimEvent
|
||||
{
|
||||
public bool isMenuOpen;
|
||||
}
|
||||
|
||||
public class ClientSimMenuRespawnClickedEvent : IClientSimEvent { }
|
||||
|
||||
public class ClientSimStackedCameraReadyEvent : IClientSimEvent { }
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 334e4be0c4ea3a34d86e69054d5adc66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,7 @@
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimMouseReleasedEvent : IClientSimEvent
|
||||
{
|
||||
public bool isReleased;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efb979a4880368e4997d8efe6882a914
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,113 @@
|
||||
using System.Collections.Generic;
|
||||
using VRC.SDKBase;
|
||||
|
||||
#if VRC_ENABLE_PLAYER_PERSISTENCE
|
||||
using VRC.SDK3.ClientSim.Interfaces;
|
||||
using VRC.SDK3.ClientSim.Persistence;
|
||||
#endif
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimOnPlayerJoinedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerLeftEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerRespawnEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerTeleportedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerMovedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerEnteredStationEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public IClientSimStation station;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerExitedStationEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public IClientSimStation station;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerHeightUpdateEvent : IClientSimEvent
|
||||
{
|
||||
public float playerHeight;
|
||||
public bool exceedsManualScalingMaximum;
|
||||
public bool exceedsManualScalingMinimum;
|
||||
}
|
||||
|
||||
public class ClientSimOnTrackingScaleUpdateEvent : IClientSimEvent
|
||||
{
|
||||
public float trackingScale;
|
||||
}
|
||||
|
||||
public class ClientSimOnNewMasterEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi oldMasterPlayer;
|
||||
public VRCPlayerApi newMasterPlayer;
|
||||
}
|
||||
|
||||
#if VRC_ENABLE_PLAYER_PERSISTENCE
|
||||
public class ClientSimOnPlayerDataDecodedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerObjectsDecodedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerRestoredEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerDataUpdatedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public Dictionary<string, ClientSimPlayerDataPair> playerData;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerDataClearedEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerObjectUpdatedEvent : IClientSimEvent
|
||||
{
|
||||
public IClientSimNetworkSerializer Data;
|
||||
}
|
||||
|
||||
public class ClientSimOnPlayerObjectUpdateEndedEvent : IClientSimEvent
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
public class ClientSimOnToggleManualScalingEvent : IClientSimEvent
|
||||
{
|
||||
public bool manualScalingAllowed;
|
||||
}
|
||||
|
||||
public class ClientSimOnVRCPlusMassGift : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi gifter;
|
||||
public int numGifts;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c994dd199309cb84c843fe843584cdbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,33 @@
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon.Common;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimOnPickupEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public HandType handType;
|
||||
public IClientSimPickupable pickup;
|
||||
}
|
||||
|
||||
public class ClientSimOnPickupDropEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public HandType handType;
|
||||
public IClientSimPickupable pickup;
|
||||
}
|
||||
|
||||
public class ClientSimOnPickupUseDownEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public HandType handType;
|
||||
public IClientSimPickupable pickup;
|
||||
}
|
||||
|
||||
public class ClientSimOnPickupUseUpEvent : IClientSimEvent
|
||||
{
|
||||
public VRCPlayerApi player;
|
||||
public HandType handType;
|
||||
public IClientSimPickupable pickup;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: daf6e253eca84774b6643ef83c0594e7
|
||||
timeCreated: 1640732560
|
||||
@ -0,0 +1,9 @@
|
||||
using VRC.SDK3.Platform;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimScreenUpdateEvent : IClientSimEvent
|
||||
{
|
||||
public ScreenUpdateData data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 228a1330ea1c47babdd3a40d81194d1d
|
||||
timeCreated: 1698364360
|
||||
@ -0,0 +1,10 @@
|
||||
using VRC.Udon.Common;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimRaycastHitResultsEvent : IClientSimEvent
|
||||
{
|
||||
public HandType handType;
|
||||
public ClientSimRaycastResults raycastResults;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 609324b47ca7465991701242bb8a9e0d
|
||||
timeCreated: 1640274005
|
||||
@ -0,0 +1,7 @@
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public class ClientSimReadyEvent : IClientSimEvent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09530bd2269622c4385b1db5178aa0a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 982b72f64cba3cc42a0918c3fec1ce5e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,4 @@
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public interface IClientSimEvent { }
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91bfef23cc10ff640880e382bf79c390
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace VRC.SDK3.ClientSim
|
||||
{
|
||||
public interface IClientSimEventDispatcher
|
||||
{
|
||||
void Subscribe<T>(Action<T> eventHandler) where T : IClientSimEvent;
|
||||
void Unsubscribe<T>(Action<T> eventHandler) where T : IClientSimEvent;
|
||||
void SendEvent<T>(T clientSimEvent) where T : IClientSimEvent;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6db79d31b2023245b6131565300da0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user