Skip to main content

SkillOrb

A class in Root.Township, the global namespace.

One orb at a skill shrine standing for a skill slot. Players grab it to practise the skill and pull it away to buy or sell. Spawned by SkillShrine on the server and not saved.

Constructors​

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

Fields​

29 private and internal fields
MemberWhat it is
private readonly int _MainTexShader property id for _MainTex, used to put the slot icon on the inner model.
private float accelerationAcceleration of the return flight.
private Color[] connectionLineColorBacking field for ConnectionLineColor, one colour per skill status.
private FauxRigidbody fauxRigidBodyFaux rigidbody used to move the orb on its return flight.
private Coroutine heldDurationCheckThe running CheckDistanceToReplace coroutine.
private float holdDurationSerialized hold time (3 seconds). Not read in this build.
private MaterialPropertyBlock internalModelBlockProperty block that puts the slot icon texture on the inner model.
private Renderer internalModelRendererRenderer of the inner model that shows the slot icon.
private bool isCompleteOperationReset on each grab. When true at release, the orb doesn't fly back.
private bool isInInteractionCooldownTrue during the short cooldown after a grab starts.
private static Logger loggerNLog logger for this class.
private float maxDistanceFromTargetSquaredSquared distance from its spot the held orb can move before the replace check fires.
private SkillOrbMovement movementBacking field for Movement, which moves the orb to its target spot.
private float moveSpeedTop speed of the return flight.
private TransformEvent OnAcquiredEffectEffect event played when a slot is unlocked through the orb.
private TransformEvent OnSoldEffectEffect event played when a skill is locked again (sold back).
private TransformEvent OnStartTestEffectEffect event played when testing a skill starts.
private Pickup pickupBacking field for Pickup.
private Transform renderersTransformBacking field for RenderersTransform.
private SkillOrbReplacer replacerThe replacer orb spawned while the player tests a skill, or null.
private NetworkPrefab replacerPrefabPrefab spawned as the replacer when the orb is pulled from its spot.
private Coroutine returningToTargetCoroutineThe running ReturnSelectionOrb coroutine.
private float rotationLerpSpeedHow fast the rotation levels out on the return flight. Faster when closer.
private Renderer shellRendererBacking field for ShellRenderer, whose material shows the status.
private Material[] statusMaterialsShell materials, one per skill status.
private MethodSync syncAllowedMethod sync made in Initialize for SyncAllowed.
private MethodSyncStruct<bool> syncEffectMethod sync made in Initialize for SyncEffect.
private MethodSync syncFullMethod sync made in Initialize for SyncFull, sent to players on connect.
private MethodSyncStruct<bool> syncModelEnabledMethod sync made in Initialize for SyncModelEnabled.

Properties​

MemberWhat it is
Color[] ConnectionLineColor { get; }Colour of the tree line for each SkillStatus.
Transform InternalModelTransform { get; }Transform of the icon model inside the orb.
bool IsInteractable { get; private set; }False while a replacer orb is out being pulled; only interactable orbs can be grabbed.
SkillOrbMovement Movement { get; }Moves the orb to its place in the tree.
Pickup Pickup { get; }The orb's Pickup.
Transform RenderersTransform { get; }Parent transform of the orb's renderers.
Renderer ShellRenderer { get; }Outer shell renderer; its material shows the status.
SkillShrine Shrine { get; private set; }The shrine that spawned the orb.
ProfessionSkill Skill { get; private set; }The ProfessionSkill the slot grants.
ProgressionSlot Slot { get; private set; }The progression slot this orb stands for.
SkillStatus Status { get; private set; }The shrine user's SkillStatus for this slot. Other players see OtherPlayer.
1 private and internal property
MemberWhat it is
private Material ISkillOrb.ShellMaterial { get; }The shell renderer's shared material.

Events​

MemberWhat it is
event SkillOrbStatusUpdateDelegate AlowedUpdatedRaised when the orb's Status changes.

Methods​

MemberWhat it is
override void Initialize()Sets up the orb's synced messages.
override void InitializeAsServer(SpawnData spawnData)Server: makes the orb's pickup unsaved.
void InitializeSlot(ProgressionSlot slot, SkillShrine callingShrine, SkillStatus status)Sets the slot, shrine and status, shows the slot icon and, on the server, syncs the orb.
override void OnConnected(Player player)Server: sends the orb's slot, status and position to a new player.
void Operate(bool isComplete)Server: complete buys or sells by status; not complete starts practising the slot. Ignored for orbs not allowed.
void UpdateAllowed()Server: rechecks the slot's status for the shrine's player and syncs it if it changed.
17 private and internal methods
MemberWhat it is
private void Awake()Hooks the pickup's interaction start, end and filter, and the destroy effect on clients.
private IEnumerator CheckDistanceToReplace(Interactable interactable, Interactor interactor) (iterator)Server coroutine: once the held orb leaves its spot, drops it if it can't be tested, else swaps in a replacer.
private void DestroyEffect(NetworkEntity entity, bool isUnload)Client: plays the progression settings' orb destroy effect unless the orb is only unloading.
private void EndInteraction(Interactable arg1, Interactor arg2)On release, the server practises the slot if no replacer took over. The orb then flies back to its spot.
private void FilterInteraction(Interactor interactor, Interactable interactable, ref bool result)Blocks grabbing until the orb has arrived, is off cooldown and allowed. Server also requires the shrine's current player.
private void InitializeSkill(ProfessionSkill skill, SkillStatus status)Sets the skill, puts the slot icon on the inner model, applies the status material and, on the server, sends a full sync.
private void LoseReplacer(NetworkEntity entity, bool isUnload)When the replacer is destroyed, makes the orb grabbable and visible again and practises the slot.
private void OnDisable()Removes the orb from the shrine's list and destroys any replacer.
private IEnumerator ReturnSelectionOrb() (iterator)Coroutine that flies the released orb back to its target spot with a faux rigidbody and levels its rotation.
private IEnumerator RunCooldown() (iterator)Blocks grabbing for 0.5 seconds after a grab starts.
private void SpawnReplacer(Interactor interactor)Server: spawns the replacer orb in the same place, hides this one's model and swaps the player's grab to it.
private void StartInteraction(Interactable interactable, Interactor interactor)On grab, stops the return flight, starts the grab cooldown and, on the server, starts CheckDistanceToReplace.
private void SyncAllowed(IPlayer player, Stream stream)Method sync for the orb's status. Clients that aren't the shrine's player see it as not allowed.
private void SyncEffect(IPlayer player, Stream stream, bool isComplete)Method sync that plays the acquired, start test or sold effect on clients.
private void SyncFull(IPlayer player, Stream stream)Method sync for the slot hash, status, shrine id, chunk and movement. Clients wait for the shrine, then set up the slot.
private void SyncModelEnabled(IPlayer player, Stream stream, bool isEnabled)Method sync that shows or hides the inner model and sets whether the orb can be grabbed.
private bool UpdateAllowed(SkillStatus status, bool isForced = false)Server: rechecks the slot's status for the shrine's player and syncs it if it changed.

Used in​

Members of other types that take, return or hold a SkillOrb: