Scripting entry points¶
These are the entry points you will use most when extending the template. All game code lives in the
AiasTech.Runtime assembly. For full signatures and rules, read the ARCHITECTURE.md file of each system (see
Code architecture).
Where to extend¶
| You want to add | Start from | Read |
|---|---|---|
| An enemy AI state or action | EnemyStateSO / EnemyActionSO |
Enemy AI |
| Something that acts on enemy turns | ITurnActor (sample below) |
Assets/DungeonCrawler/Scripts/GridSystem/ARCHITECTURE.md |
| A new pickup type | BasePickUp |
Assets/DungeonCrawler/Scripts/PickUp/ARCHITECTURE.md |
| An interactable object or level trigger | GridInteractable / BaseLevelTrigger |
Assets/DungeonCrawler/Scripts/Level/ARCHITECTURE.md |
| Saved data | the save modules | Assets/DungeonCrawler/Scripts/SaveSystem/ARCHITECTURE.md |
Custom turn actor¶
using AiasTech.GridSystem;
using UnityEngine;
public sealed class GridPatrolActor : MonoBehaviour, ITurnActor
{
private GridMover mover;
private TurnManager turns;
public bool IsActive => isActiveAndEnabled;
public bool IsBusy => mover != null && mover.IsMoving;
public bool IsAttacking => false;
private void Awake() => mover = GetComponent<GridMover>();
private void OnEnable()
{
TurnManager.Changed += BindTurns;
BindTurns(TurnManager.Instance);
}
private void OnDisable()
{
TurnManager.Changed -= BindTurns;
BindTurns(null);
}
private void BindTurns(TurnManager manager)
{
if (turns != null) turns.UnregisterActor(this);
turns = manager;
if (turns != null) turns.RegisterActor(this);
}
public void BeginTurn() => mover.TryStep(Vector2Int.up);
}
BeginTurn starts at most one action and does not wait for animations; report the duration through IsBusy.
Actors added during the enemies' turn only act on the next round.
Events and services¶
// Player (AiasTech.Players): for your own UI, follow the current player
Player.Changed += player => { }; // then subscribe to player.Health.VitalsChanged
Player.Current.Health.RestoreHealth(25f);
// Damage (AiasTech.Shared.Data, AiasTech.Combat). Set SourcePosition for the hit indicator;
// do not reuse a Damage instance.
var damage = new Damage(30f, DamageType.Explosion, hitPosition);
DamageResolver.Apply(targetGameObject, damage); // enemy, player or destructible
RadialDamage.Detonate(origin, radiusInCells, damage, targetLayers);
// Grid and turns (AiasTech.GridSystem)
GridMap.Instance.IsWalkable(cell);
GridMap.Instance.InvalidateAfterMove(transform); // after moving or destroying geometry
TurnManager.Instance.TurnStarted += turn => { }; // start of each new player turn
// Level (AiasTech.Level)
LevelCore.Instance.CompleteLevel();
LevelCore.Instance.Keys.AddKey(KeyType.Blue);
door.OpenDoor(); secret.FindSecret();
// Weapons and items (AiasTech.Weapon, AiasTech.Equipment)
PlayerWeaponManager.Instance.AddAmmunition(AmmunitionType.Shell, 10);
EquipmentManager.AddPoints(100);
PlayerItemInventory.TryGrant(usableItem, 1);
// Game state, UI and scenes (AiasTech.Core.*)
GameStateEvents.PauseChanged += paused => { };
GameManagerUI.Instance?.ShowPickupToast("Text", icon);
LoadingScreen.Load("Scene");
// Save, localization and audio
SaveManager.Instance.RequestSave();
LocalizationManager.GetString(LocalizationCategory.UI, "Key", "fallback");
AudioManager.PlayClipAt(clip, position, AudioChannel.Effects);