# h2v9696/unitygas architecture

> Architecture diagram of the GitHub repository h2v9696/unitygas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/h2v9696/unitygas
- Repository: https://github.com/h2v9696/unitygas

## Overview

##### Project Type and Purpose
- This is a Unity Package implementing a Gameplay Ability System (GAS) architecture (inspired by Unreal’s GAS) for Unity.
- It provides runtime subsystems for abilities, attributes, effects, and tags, plus editor tooling and test suites.
- It is an open-source, data-driven plugin/library to be consumed by Unity projects.

##### File Structure Analysis
- Top-level folders
- Editor – Unity Editor extensions (custom inspectors, tree views for tags).
- Runtime – Core subsystems broken into four domains: AbilitySystem, AttributeSystem, EffectSystem, TagSystem, plus Helpers.
- Tests – EditorMode and PlayMode tests verifying behavior of each subsystem.
- Each Runtime subsystem follows the same pattern:
- Components folder – MonoBehaviour entry points (e.g., AbilitySystemBehaviour).
- ScriptableObjects folder – definitions (SO classes such as AbilitySO, AttributeSO, GameplayEffectSO).
- Domain logic files (e.g., AbilityContext, ModifierData, policy implementations).
- Configuration files and assembly definitions (.asmdef) partition Editor vs Runtime vs Test code.
- External package dependencies: UnityExtensionsCore, Unity SerializeReferenceExtensions.

##### README Insights
- Confirms data-driven, SO-based architecture.
- Mentions intended features (gameplay cues, multiplayer).

##### Detailed Capture of Architectural Elements
- Interfaces and policies on the connectors.
- Don’t shy away from splitting each subsystem into its Behaviour, Data, and Policy sub-components for completeness.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Editor Layer
    subgraph "Editor Layer"
        direction TB
        TagBrowser["Tag Browser"]:::editor
        TagTreeView["Tag TreeView"]:::editor
        EditorAsmdef["H2V.GameplayAbilitySystem.Editor.asmdef"]:::editor
    end

    %% Runtime Layer
    subgraph "Runtime Layer"
        direction TB

        subgraph "Ability System" 
            direction TB
            ASB["AbilitySystemBehaviour: manages ability activation"]:::runtime
            AC["AbilityContext"]:::runtime
            ASpec["AbilitySpec"]:::runtime
        end

        subgraph "Effect System"
            direction TB
            ESB["EffectSystemBehaviour: applies effects"]:::runtime
            GESpec["GameplayEffectSpec"]:::runtime
            policyGroup["IGameplayEffectPolicy implementations"]:::runtime
            Instant["InstantPolicy"]:::runtime
            Durational["DurationalPolicy"]:::runtime
            Periodic["PeriodicPolicy"]:::runtime
            Counter["CounterPolicy"]:::runtime
            Stack["StackPolicy"]:::runtime
            Cond["IEffectCondition"]:::runtime
        end

        subgraph "Attribute System"
            direction TB
            ATB["AttributeSystemBehaviour: updates stats"]:::runtime
            AVC["AttributeValueCalculator"]:::runtime
            StatsProv["StatsProvider"]:::runtime
            AV["AttributeValue"]:::runtime
        end

        subgraph "Tag System"
            direction TB
            TSB["TagSystemBehaviour: provides tag queries"]:::runtime
        end

        RuntimeAsmdef["H2V.GameplayAbilitySystem.asmdef"]:::runtime
    end

    %% Data Layer (ScriptableObjects)
    subgraph "Data Layer"
        direction TB
        ASO["AbilitySO (SO)"]:::data
        GESO["GameplayEffectSO (SO)"]:::data
        ModCompSO["ModifierComputationSO (SO)"]:::data
        AttrSO["AttributeSO (SO)"]:::data
        InitStatsSO["InitializeStatsSO (SO)"]:::data
        TagSO["TagSO (SO)"]:::data
        CommonTags["CommonTags (SO)"]:::data
    end

    %% External Dependencies
    subgraph "External"
        direction TB
        UECore["UnityExtensionsCore"]:::external
        SRExt["SerializeReferenceExtensions"]:::external
    end

    %% Runtime Flow
    GameObject["GameObject"]:::runtime
    GameObject -->|"adds"| ASB
    ASB -->|"creates"| AC
    AC -->|"looks up"| ASpec
    ASpec -->|"generates"| GESpec
    GESpec -->|"sent to"| ESB
    ESB -->|"uses policies"| policyGroup
    policyGroup --> Instant
    policyGroup --> Durational
    policyGroup --> Periodic
    policyGroup --> Counter
    policyGroup --> Stack
    ESB -->|"checks conditions"| Cond
    ESB -->|"calculates modifiers via"| AVC
    AVC --> AV
    AV --> ATB
    ATB --> StatsProv
    StatsProv --> GameObject

    %% Tag System Flow
    GameObject -->|"queries"| TSB

    %% Data Config Injection (dashed)
    ASO -.-> ASB
    GESO -.-> ESB
    ModCompSO -.-> ESB
    AttrSO -.-> ATB
    InitStatsSO -.-> ATB
    TagSO -.-> TSB
    CommonTags -.-> TSB

    TagBrowser -.-> TagSO
    TagTreeView -.-> TagSO

    %% External linkage
    UECore --> ASB
    UECore --> ATB
    UECore --> ESB
    UECore --> TSB
    SRExt --> AC
    SRExt --> AVC

    %% Click events
    click ASB "https://github.com/h2v9696/unitygas/blob/main/Runtime/AbilitySystem/Components/AbilitySystemBehaviour.cs"
    click AC "https://github.com/h2v9696/unitygas/blob/main/Runtime/AbilitySystem/AbilityContext.cs"
    click ASpec "https://github.com/h2v9696/unitygas/blob/main/Runtime/AbilitySystem/AbilitySpec.cs"
    click ASO "https://github.com/h2v9696/unitygas/blob/main/Runtime/AbilitySystem/ScriptableObjects/AbilitySO.cs"
    click ATB "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/Components/AttributeSystemBehaviour.cs"
    click AV "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/AttributeValue.cs"
    click AVC "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/AttributeValueCalculator.cs"
    click StatsProv "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/StatsProvider.cs"
    click AttrSO "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/ScriptableObjects/AttributeSO.cs"
    click InitStatsSO "https://github.com/h2v9696/unitygas/blob/main/Runtime/AttributeSystem/ScriptableObjects/InitializeStatsSO.cs"
    click ESB "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/Components/EffectSystemBehaviour.cs"
    click GESpec "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GameplayEffectSpec.cs"
    click policyGroup "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/IGameplayEffectPolicy.cs"
    click Instant "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/InstantPolicy.cs"
    click Durational "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/DurationalPolicy.cs"
    click Periodic "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/PeriodicPolicy.cs"
    click Counter "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/CounterPolicy.cs"
    click Stack "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/GamplayEffectPolicies/StackPolicy.cs"
    click Cond "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/EffectConditions/IEffectCondition.cs"
    click GESO "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/ScriptableObjects/GameplayEffectSO.cs"
    click ModCompSO "https://github.com/h2v9696/unitygas/blob/main/Runtime/EffectSystem/ScriptableObjects/ModifierComputationSO.cs"
    click TSB "https://github.com/h2v9696/unitygas/blob/main/Runtime/TagSystem/TagSystemBehaviour.cs"
    click TagSO "https://github.com/h2v9696/unitygas/blob/main/Runtime/TagSystem/ScriptableObjects/TagSO.cs"
    click CommonTags "https://github.com/h2v9696/unitygas/blob/main/Runtime/TagSystem/ScriptableObjects/CommonTags.cs"
    click TagBrowser "https://github.com/h2v9696/unitygas/blob/main/Editor/TagSystem/TagsBrowser.cs"
    click TagTreeView "https://github.com/h2v9696/unitygas/blob/main/Editor/TagSystem/TagsTreeView.cs"
    click EditorAsmdef "https://github.com/h2v9696/unitygas/blob/main/Editor/H2V.GameplayAbilitySystem.Editor.asmdef"
    click RuntimeAsmdef "https://github.com/h2v9696/unitygas/blob/main/Runtime/H2V.GameplayAbilitySystem.asmdef"

    %% Styles
    classDef editor fill:#BBDEFB,stroke:#000,stroke-width:1px
    classDef runtime fill:#C8E6C9,stroke:#000,stroke-width:1px
    classDef data fill:#FFF9C4,stroke:#000,stroke-width:1px
    classDef external fill:#FFE0B2,stroke:#000,stroke-width:1px
```
