DIFF

class CodeLockComponent

CodeLockComponent › Managed

Constructors 1

Constants 5

const int MIN_LOCK_PIN_LENGTH = 4

min amount of digits the combination needs to contain

const int MAX_LOCK_PIN_LENGTH = 6

max amount of digits the combination can contain

private const float DEFAULT_BRUTEFORCE_TIME = 30.0
Referenced by CodeLockComponent()
private const float DEFAULT_BRUTEFORCE_RESET_TIME = 3600.0
Referenced by CodeLockComponent()
const float CODELOCK_MAX_CODE_DISTANCE_SQ = Math.SqrFloat(5.0)

Max distance from the lock a player may submit code requests, also used by the code lock UI to close the menu

Members 17

protected int m_MinLockPinLength
protected string m_InputPIN

combination that is dialed on lock

protected string m_LockPIN

actual combination of the lock

protected bool m_IsLocked

lock state

protected int m_DoorIndex = -1

code lock door index for parent building if code lock belongs to a door

protected bool m_HasPIN

code state

protected float m_BruteForceProtectionTime
protected float m_BruteForceResetTime
protected ref Timer m_BruteForceUpdateTimer
protected ref Timer m_BruteForceResetTimer
protected bool m_HandleBruteForceProtection
protected CodeLockUIAction m_UIAction
protected PluginAdminLog m_AdmingLog

Methods 45

void SetMinimalPinCodeLength(int length)
bool SetInputCode(string pin, bool force = true)
protected bool ValidatePIN(string pin, bool enforceMinLength = true)
Referenced by SetLockCode()
void ResetPIN(bool sync = true)
References SetStage(), SyncAndMarkDirty(), m_HasPIN
Show 1 more, m_LockPIN
protected void HandleHierarchyRootLock(bool state)
Referenced by SetLockState()
void OnStoreSave(ParamsWriteContext ctx)
References Serializer.Write(), m_DoorIndex, m_IsLocked
Show 1 more, m_LockPIN
protected void CheckUIActionServer(CodeLockUIAction uiAction)

Derive from a stored PIN only - the minimum length is a mutable setting, coupling to it let a lock load as "no PIN" (and be claimed) after a config change

Referenced by OnRPC()
protected void ResetUIActionServer()
private PlayerBase ResolveCodeRequestPlayer(PlayerIdentity identity)

Resolves the RPC sender identity to the matching player entity on the server

Referenced by CheckCodeRequest(), and OnRPC()
private bool ValidateCodeRequest(PlayerBase player)

Server-side trust boundary for code requests: the sender must be a living, acting player standing in range on the keypad side of a powered lock

Referenced by CheckCodeRequest(), and OnRPC()
private bool IsDigitsOnly(string pin)

Player keypad input is digits only, reject anything else before it can be stored as a PIN

Referenced by CheckCodeRequest()
private void LogExploitAttempt(PlayerIdentity identity, string reason)
Referenced by CheckCodeRequest()
private void SendCodeResponse(PlayerIdentity identity, bool success)

Sends the code response back to the requesting client (or handles single player)

Referenced by CheckCodeRequest()
protected void HandleBruteForceProtectionServer()

Reject non-digit PINs that could never be dialed back on the keypad (owner lockout)

Referenced by CheckCodeRequest()
protected void CheckBruteForceState()
void OnParentDetached(bool sync = true)
protected void UpdateParentVisuals()

Only accept UI actions from a valid in-range sender, prevents remote sound spam

EntityAI GetParent()
References m_Parent
void SetDoorIndex(int index)
References m_DoorIndex
int GetDoorIndex()
References m_DoorIndex
vector GetPosition()

ToDo: Door parent position handling?!

string GetInputPIN()
References m_InputPIN
string GetLockPIN()
References m_LockPIN
bool HasParent()
References m_DoorIndex, and m_Parent
int GetWrongCodeCount()
References m_WrongCodeCount
int GetMinLockPINLength()