The Access Handler is used to funnel some of ORK’s functionality through overridable functions.
This allows you to interject custom functionality, like creating a combatant, adding an item to an inventory or using an action. A custom access handler can e.g. be used to collect analytics data, use client/server communication or redirect ORK’s functionality to custom systems.
You can create custom handlers by extending the AccessHandler classes and overriding the functions you want to replace. The available functions are divided into different sub-handlers for actions, battles, combatants, groups and inventories. Each sub-handler contains the overridable functions for their thematic topic, e.g. the inventory access handler manages inventory changes like adding or removing an item.
The access handler mainly handles functionality that is caused by the player and will be extended in future updates. If there’s a functionality you need to be funneled through the access handler, be sure to let me know, e.g. in the support forum.
You can download a custom access handler for you to build upon, details about the different classes and their use below:
Download Custom Access Handler
Access Handler
The AccessHandler class holds the sub-handlers for actions, combatants, groups and inventories. To add a custom access handler, create a new class extending the AccessHandler class.
The constructor needs to create instances of the sub-handlers, either using the default handlers or your custom handlers. The sub-handlers contain the overridable functions.
The ORKEditorSettingInfo attribute added to the class is used to have the access handler available in the Access Type setting in Game > Game Settings and allows you to change to this access handler. Define the (unique) name and (optional) help text of your custom access handler.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // Defines the name and help text of this access handler. [ORKEditorSettingInfo("Custom", "This is a custom access handler.", "")] // The access handler holds the sub-handlers with their overridable functions. // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_access_handler.html public class CustomAccessHandler : AccessHandler { // The constructor needs to create the instances of the sub-handlers for actions, combatants, groups and inventory. public CustomAccessHandler() { this.actionAccess = new CustomActionAccessHandler(); this.battleAccess = new CustomBattleAccessHandler(); this.combatantAccess = new CustomCombatantAccessHandler(); this.groupAccess = new CustomGroupAccessHandler(); this.inventoryAccess = new CustomInventoryAccessHandler(); } } }
This example is included in the download above.
Action Access Handler
The ActionAccessHandler class is responsible for using actions and shortcuts, as well as spending experience (e.g. on abilities). To add a custom action access handler, create a new class extending the ActionAccessHandler class.
Check the API to see all functions that can be overridden and what they’re used for.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // The action access handler is responsible for using actions and shortcuts, as well as spending experience (e.g. on abilities). // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_action_access_handler.html public class CustomActionAccessHandler : ActionAccessHandler { public CustomActionAccessHandler() { } public override void AddActionToCombatant(Combatant user, BaseAction action, bool newTurn) { base.AddActionToCombatant(user, action, newTurn); } } }
This example is included in the download above.
Battle Access Handler
The BattleAccessHandler class is responsible for battle loot and flying texts. To add a custom battle access handler, create a new class extending the BattleAccessHandler class.
Check the API to see all functions that can be overridden and what they’re used for.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // The battle access handler is responsible for battle loot and flying texts. // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_battle_access_handler.html public class CustomBattleAccessHandler : BattleAccessHandler { public CustomBattleAccessHandler() { } public override void AddLoot(IShortcut item) { base.AddLoot(item); } } }
This example is included in the download above.
Combatant Access Handler
The CombatantAccessHandler class is responsible for everything combatant related, e.g. changing status values, adding status effects, learning abilities or changing equipment. To add a combatant access handler, create a new class extending the CombatantAccessHandler class.
Check the API to see all functions that can be overridden and what they’re used for.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // The combatant access handler is responsible for everything combatant related, from status changes to learning abilities or changing equipment. // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_combatant_access_handler.html public class CustomCombatantAccessHandler : CombatantAccessHandler { public CustomCombatantAccessHandler() { } public override Combatant CreateInstance(int index, Group group, bool showNotification, bool showConsole) { return base.CreateInstance(index, group, showNotification, showConsole); } } }
This example is included in the download above.
Group Access Handler
The GroupAccessHandler class is responsible for changes in combatant groups, e.g. joining or leaving a group. To add a custom group access handler, create a new class extending the GroupAccessHandler class.
Check the API to see all functions that can be overridden and what they’re used for.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // The group access handler is responsible for changes in combatant groups, e.g. joining or leaving a group. // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_group_access_handler.html public class CustomGroupAccessHandler : GroupAccessHandler { public CustomGroupAccessHandler() { } public override void Join(Group group, Combatant combatant, bool showNotification, bool showConsole) { base.Join(group, combatant, showNotification, showConsole); } } }
This example is included in the download above.
Inventory Access Handler
The InventoryAccessHandler class is responsible for inventory changes, e.g. adding or removing an item. To add a custom inventory access handler, create a new class extending the InventoryAccessHandler class.
Check the API to see all functions that can be overridden and what they’re used for.
using UnityEngine; using System.Collections.Generic; namespace ORKFramework { // The inventory access handler is responsible for inventory changes, e.g. adding or removing an item. // See the API for details: http://api.orkframework.com/class_o_r_k_framework_1_1_inventory_access_handler.html public class CustomInventoryAccessHandler : InventoryAccessHandler { public CustomInventoryAccessHandler() { } public override void UseCraftingRecipe(Combatant combatant, int recipeID, NotifyBool notify) { base.UseCraftingRecipe(combatant, recipeID, notify); } } }
This example is included in the download above.