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.
- Listed in Global namespace: S
- Inherits or implements
NetworkEntityBehaviour,ISkillOrb
Constructors
| Member | What it is |
|---|---|
SkillOrb() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
29 private and internal fields
| Member | What it is |
|---|---|
private readonly int _MainTex | Shader property id for _MainTex, used to put the slot icon on the inner model. |
private float acceleration | Acceleration of the return flight. |
private Color[] connectionLineColor | Backing field for ConnectionLineColor, one colour per skill status. |
private FauxRigidbody fauxRigidBody | Faux rigidbody used to move the orb on its return flight. |
private Coroutine heldDurationCheck | The running CheckDistanceToReplace coroutine. |
private float holdDuration | Serialized hold time (3 seconds). Not read in this build. |
private MaterialPropertyBlock internalModelBlock | Property block that puts the slot icon texture on the inner model. |
private Renderer internalModelRenderer | Renderer of the inner model that shows the slot icon. |
private bool isCompleteOperation | Reset on each grab. When true at release, the orb doesn't fly back. |
private bool isInInteractionCooldown | True during the short cooldown after a grab starts. |
private static Logger logger | NLog logger for this class. |
private float maxDistanceFromTargetSquared | Squared distance from its spot the held orb can move before the replace check fires. |
private SkillOrbMovement movement | Backing field for Movement, which moves the orb to its target spot. |
private float moveSpeed | Top speed of the return flight. |
private TransformEvent OnAcquiredEffect | Effect event played when a slot is unlocked through the orb. |
private TransformEvent OnSoldEffect | Effect event played when a skill is locked again (sold back). |
private TransformEvent OnStartTestEffect | Effect event played when testing a skill starts. |
private Pickup pickup | Backing field for Pickup. |
private Transform renderersTransform | Backing field for RenderersTransform. |
private SkillOrbReplacer replacer | The replacer orb spawned while the player tests a skill, or null. |
private NetworkPrefab replacerPrefab | Prefab spawned as the replacer when the orb is pulled from its spot. |
private Coroutine returningToTargetCoroutine | The running ReturnSelectionOrb coroutine. |
private float rotationLerpSpeed | How fast the rotation levels out on the return flight. Faster when closer. |
private Renderer shellRenderer | Backing field for ShellRenderer, whose material shows the status. |
private Material[] statusMaterials | Shell materials, one per skill status. |
private MethodSync syncAllowed | Method sync made in Initialize for SyncAllowed. |
private MethodSyncStruct<bool> syncEffect | Method sync made in Initialize for SyncEffect. |
private MethodSync syncFull | Method sync made in Initialize for SyncFull, sent to players on connect. |
private MethodSyncStruct<bool> syncModelEnabled | Method sync made in Initialize for SyncModelEnabled. |
Properties
| Member | What 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
Events
| Member | What it is |
|---|---|
event SkillOrbStatusUpdateDelegate AlowedUpdated | Raised when the orb's Status changes. |
Methods
| Member | What 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
| Member | What 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:
PlayerProgressionManager.PracticeSlot, PlayerProgressionManager.PracticingOrb, SkillOrbConnectionline.UpdateColor, SkillOrbDelegate.BeginInvoke, SkillOrbDelegate.Invoke, SkillOrbReplacer.InitializeOrb, SkillOrbReplacer.targetOrb, SkillOrbStatusUpdateDelegate.BeginInvoke, SkillOrbStatusUpdateDelegate.Invoke, SkillShrine.SpawnedOrbs, SkillShrine.UpdatePracticing, SkillShrine.ApliedSlotTuple.ApliedSlotTuple, SkillShrine.ApliedSlotTuple.Orb, SkillShrineTestingArea.Open, SkillShrineTestingArea.openSkillOrb.