Skip to content
cccskills
FreePublished on GitHub

godot-resource-data-patterns

Expert blueprint for data-oriented design using Resource/RefCounted classes (item databases, character stats, reusable data structures). Covers typed arrays, serialization, nested resources, and resource caching. Use when implementing data systems OR inventory/stats/dialogue databases. Keywords Resource, RefCounted, ItemData, CharacterStats, database, serialization, @export, typed arrays.

The English summary is being prepared. Showing the original description.

See how to install

Files included (16)

  • SKILL.md10.0 KB
  • references/migration-notes.md2.9 KB
  • references/resource-patterns-deep.md3.7 KB
  • scripts/character_stats_resource.gd1.3 KB
  • scripts/custom_data_resource.gd1.4 KB
  • scripts/data_factory_resource.gd2.5 KB
  • scripts/dynamic_resource_generation.gd1.3 KB
  • scripts/flyweight_enemy_config.gd1.3 KB
  • scripts/nested_resource_serialization.gd1.3 KB
  • scripts/resource_based_inventory.gd1.2 KB
  • scripts/resource_flyweight_caching.gd1.3 KB
  • scripts/resource_local_to_scene.gd1.3 KB
  • scripts/resource_pool.gd2.0 KB
  • scripts/resource_preloading_strategy.gd1.3 KB
  • scripts/resource_save_system.gd1.5 KB
  • scripts/resource_validator.gd2.9 KB

SKILL.md (original)

Review the instructions the agent will receive before you install.

NEVER Do in Resource Design

  • NEVER modify resource instances directly — Without .duplicate(), changing a value (like HP) modifies the shared .tres for everyone.
  • NEVER use untyped arrays in Resources — @export var items: Array allows logic errors. Always use Array[ResourceClass] for type safety.
  • NEVER store Node references in Resources — Objects that only exist in a specific SceneTree cannot be serialized. Store NodePath or UID.
  • NEVER perform heavy calculations in Resource getters/setters — Resources should be data containers. Offload logic to Nodes or specialized RefCounted classes.
  • NEVER skip ResourceSaver.save() error checks — Saving can fail due to permissions, disk space, or path issues. Always check the return code.
  • NEVER use Resources for high-frequency runtime data — If a value changes 60 times a second (like velocity), a standard variable is faster than a Resource property.
  • NEVER allow circular Resource references — If A.tres references B.tres and B.tres references A.tres, the engine may crash on load.
  • NEVER forget the _init defaults — Resources created via new() or in the Inspector need default values in their constructor to be editable.
  • NEVER share a Resource between entities if they need unique state — Use resource_local_to_scene = true or duplicate() for components.
  • NEVER use .tres for massive datasets — If you have 10,000 items, a JSON or custom binary format might be more efficient than individualized Resource files.

Decision Tree: Resource vs RefCounted vs Node

TypeUse whenDisk / Inspector
ResourceShared definitions, saveable data, @export authoring.tres/.res, Inspector ✅
RefCountedTemporary runtime calcs, non-persistent helpersNo disk / weak Inspector
NodeScene entities with process/signals in the treeScene files

Use Resources for: item defs, stats templates, abilities, dialogue tables, enemy configs. Use RefCounted for: damage calc scratchpads, ephemeral state machines, non-saved utilities.

Available Scripts — MANDATORY by Scenario

ScenarioMANDATORY read
Per-instance mutable stats (HP) sharing a base .tresresource_local_to_scene.gd
Nested Item → Weapon → StatusEffect trees / save whole graphnested_resource_serialization.gd
Many entities sharing one config (flyweight)resource_flyweight_caching.gd / flyweight_enemy_config.gd
Custom @export data containerscustom_data_resource.gd
Reactive stats with signalscharacter_stats_resource.gd
Inventory arrays of Resourcesresource_based_inventory.gd
Save Resource trees to diskresource_save_system.gd — check Error
Preload / O(1) cache before playresource_preloading_strategy.gd
Runtime Resource.new() lootdynamic_resource_generation.gd
Validate / pool / factoryresource_validator.gd / resource_pool.gd / data_factory_resource.gd

Expert WHY (critical)

CAUTION: Runtime HP/mana on a shared .tres without duplicate(true) or resource_local_to_scene mutates the asset on disk — the "damaging one damages all" bug.

  • .res vs .tres: binary .res in production; .tres for design diffs; nested trees save with parent via ResourceSaver.
  • Cache: ResourceLoader.CACHE_MODE_REPLACE after external edits bypass stale cache.
  • Local-to-scene / duplicate: mandatory for per-instance components — resource_local_to_scene.gd.
  • 10k+ rows: individualized .tres files lose to JSON/binary — see Official Docs binary serialization.

Deep dive (load on demand)

Pattern 1–7 walkthroughs (ItemData, databases, RefCounted calcs, directory scan, O(1) cache) — references/resource-patterns-deep.md. Implement nested weapons from nested_resource_serialization.gd, not memory.

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing to a peer domain — do not preload the whole lattice.

Official Documentation

  • Resources — Custom Resource scripts, .tres/.res, sharing vs duplicate(), and resource_local_to_scene for per-instance state.
  • Data preferences — When to store data in Resources vs dictionaries, ConfigFile, or plain scripts for inspector and serialization needs.
  • Resource — duplicate, emit_changed, resource_path, and local-to-scene flags used by every data container pattern here.
  • ResourceLoader — Cached load / threaded requests that power flyweight sharing and preload caches.
  • ResourceSaver — Persist custom Resources to user:// or res:// and always check the returned Error.
  • RefCounted — Lightweight runtime objects when you need refcounting without disk serialization or Inspector exports.
  • Saving games — Broader save strategies that pair with ResourceSaver for slot-based .tres state.
  • Background loading — Threaded ResourceLoader polling so databases and VFX packs do not hitch the main thread.
  • GDScript exports — Typed @export / Array[T] so item and quest Resources stay Inspector-safe.
  • Binary serialization API — Compact FileAccess packing when thousands of rows outgrow individualized .tres files.
  • Scene organization — Why shared Resources live outside scene trees and how component scenes compose exported data.

Related Skills

Prerequisites

  • godot-project-foundations — Project layout, import, and res:// hygiene before authoring shared .tres databases.
  • godot-gdscript-mastery — class_name, typed arrays, setters, and @tool discipline every custom Resource script depends on.

Complements

  • godot-signal-architecture — Ownership and fan-out for Resource changed / custom signals that drive reactive UI and stats.
  • godot-save-load-systems — Slot versioning, migration, and secure paths that wrap ResourceSaver/ResourceLoader save flows.
  • godot-scene-management — Packed scenes and threaded loads that consume preloaded Resource caches without hitch spikes.
  • godot-ability-system — Ability/buff definitions are Resource data; this skill owns the container and serialization patterns.
  • godot-dialogue-system — Dialogue graphs and line tables are nested Resources that reuse typed-array and save patterns here.
  • godot-performance-optimization — Flyweight sharing, pooling RefCounted payloads, and when .res beats text .tres at scale.

Downstream / consumers

  • godot-inventory-system — Item stacks, equipment, and bags consume ItemData / inventory Resource arrays defined here.
  • godot-procedural-generation — Generators that instantiate loot, quests, and configs via Resource.new() at runtime.
  • godot-monte-carlo-balancer — .tres stats and economy tables are the preferred extract source — build the data layer before regex farms.

Master

  • godot-master — Library router and mirrored module entry for cross-skill discovery.

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Bevy ECS skill for 2D sprite animation. Keywords: Bevy, sprite, animation, AnimationPlayer, AnimationClip, 2D.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

Spawn and tune Bevy 0.20 directional, point, and spot lights, cascade shadows, distance fog, and a nearest-light shadow budget. Use when a 3D scene needs a sun, local lights, or fog on the camera. Keywords: DirectionalLight, PointLight, SpotLight, CascadeShadowConfig, DistanceFog, bevy_light.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

Bevy ECS skill for PBR materials. Keywords: Bevy, StandardMaterial, PBR, material, ExtendedMaterial.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

Bevy ECS skill for 3D level assembly. Keywords: Bevy, level, scene, mesh, world, ECS.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

Bevy ECS skill for abilities. Keywords: Bevy, ability, cooldown, ECS, gameplay.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

Rewrite Bevy 2D actors and cameras into 3D meshes and Camera3d while keeping gameplay components. Use when a Bevy 2D game should gain a perspective camera, mesh draw, and a planar velocity lifted onto XZ. Keywords: Camera2d, Camera3d, Sprite, Mesh3d, StandardMaterial, WishVelocity.

The English summary is being prepared. Showing the original description.

thedivergentai/Game-Dev-Agentic-Skills877Updated Oct 17, 2026

See all skills by thedivergentai

Report a problem with this skill