Skip to main content

PlayerControllerMultiLockModel

A class in Root.Township, the global namespace.

Tracks objects that lock the local player's controls (such as a screen fade) and syncs the locked state to the server. While locked, PlayerHealth ignores damage.

Constructors​

MemberWhat it is
PlayerControllerMultiLockModel()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

3 private and internal fields
MemberWhat it is
private HashSet<object> locksObjects currently holding a lock.
private PlayerController playerControllerThe player controller being locked.
private MethodSync syncLockStateNetwork message sent to chunks when the state changes.

Properties​

MemberWhat it is
bool IsLocked { get; private set; }True while any lock is held. The server takes it from the owning player's message.

Events​

1 private and internal event
MemberWhat it is
private event Action<bool> onLockStateChangedEvent raised with the new state when the lock changes.

Methods​

MemberWhat it is
void AddLock(object lockerObject)Local player only: adds a lock object; the first lock sets IsLocked and syncs it.
override void Initialize()Sets up the network message for the lock state.
void RemoveLock(object lockerObject)Local player only: removes a lock object; removing the last one clears IsLocked and syncs it.
1 private and internal method
MemberWhat it is
private void SyncLockState(IPlayer player, Stream stream)Serializes the lock state; the server only accepts it from the player who owns this controller.