Skip to content
smartargs
VantageDocumentation

Resource nodes reference

The resource node component and the asset that sets its yield, tool and skill gates, respawn time and visuals. For how to use it, see Resource nodes.

VtResourceNode

Component. Add it with Add Component → Vantage → Resources → VtResourceNode.

Resource node — tree, ore vein, fishing spot. Specialized harvest-feel behavior on top of the existing combat / item / skill systems.

Inspector fields

Field Type Default Description
Definition (definition) VtResourceNodeDefinition None Behavior config. Required — node silently no-ops if null.

Scripting API

Member Description
bool IsDepleted { get; } True while the node is in the depleted state (chopped) and waiting for its respawn timer.
float RespawnRemainingSeconds { get; } Seconds remaining on the respawn timer when IsDepleted is true. 0 when alive.
event Action<VtUnit, VtResourceNodeFailureReason> OnHarvestFailed Fires when an incoming hit was refused. Args: (attacker, reason). Attacker may be null when the refusal happened before the killer was resolved (e.g. VtResourceNodeFailureReason.Depleted). Subscribe for “Need an axe!” floating text or audio.
event Action<VtUnit, IReadOnlyList<VtLootDrop>> OnHarvested Fires after a successful harvest hit (the damage applied AND the entry roll produced at least one drop). Args: (attacker, drops). Drops have already been credited to the attacker’s inventory and list only what fit, so a roll of 5 into room for 2 reports 2; the event is informational so consumers can render “+5 Wood” combat text or play harvest audio.
event Action OnDepleted Fires when the node transitions to depleted (HP hit 0).
event Action OnRespawned Fires when the node respawns (HP restored, visual swapped back, accepting hits again).
bool CanBeAttackedOnCommand(VtFaction attacker) Every attacker may harvest the node on command while it is not depleted.
void Initialize() Find the sibling unit and stats, listen to their damage events and spawn the visuals. Safe to call any number of times.
void SetRandom(IVtRandom newRng) Replace the random source used for harvest rolls, for deterministic yields. Null restores Unity’s random.
void Tick(float deltaTime) Advance the respawn timer of a depleted node by deltaTime seconds and Respawn when it drains. Authority-only; other copies only count the timer down for UI.
void Respawn() Force the node back to alive state — restores HP, swaps visuals, fires OnRespawned. Authority-gated. Idempotent (no-op when already alive). Public so admin / scripted-event flows can force respawn ahead of the timer.
void ApplyDepletedFromNet(bool isDepleted, float respawnSeconds) Mirror the authority’s depleted state: swap the visuals and raise OnDepleted or OnRespawned when it changes, and count respawnSeconds down for UI. HP arrives through pool replication. Used by replication on clients; refused on the authority.

VtResourceNodeDefinition

Asset. Create it with Create → Vantage → Resources → Resource Node Definition.

Authored resource-node behavior — the per-hit yield, tool / skill / damage-type gating, respawn cadence, and visual swap for trees, ore veins, fishing spots, and any other “harvest by damaging it” world entity.

Inspector fields

General

Field Type Default Range Description
Id (id) string Empty Stable string identifier for DB / network payloads. Convention: ‘node.tree.oak’, ‘node.ore.iron’. Required.
Display Name (displayName) string Empty UI display name. E.g. ‘Oak Tree’, ‘Iron Vein’, ‘Berry Bush’.
Description (description) string Empty Designer-facing description.

Yield

Field Type Default Range Description
Harvest Entries (harvestEntries) VtLootDropEntry[] Empty Weighted pool rolled on every successful hit. Each entry’s (item, count) is added directly to the attacker’s VtUnitInventory (no world-item spawn). Null-item entries are ‘no drop’ weight buckets, same shape as the loot system. Per-kill tables should use the standard VtLootDropper instead.
Rolls Per Hit (rollsPerHit) int 1 ≥ 1 Number of independent picks against harvestEntries per hit. 1 = standard ‘one item per chop’ feel; > 1 lets boss-tier nodes drop bundles per swing.

Tool Gate

Field Type Default Range Description
Required Item Tag (requiredItemTag) VtItemTagDefinition None Optional. When set, the attacker must have an item with this tag equipped in any slot. Pair with VtItemTagDefinition assets like ‘Axe’ / ‘Pickaxe’ / ‘FishingRod’. Null = no tool gate.

Skill Gate

Field Type Default Range Description
Required Skill (requiredSkill) VtCraftingSkillDefinition None Optional crafting skill the attacker is leveled in. Null = no skill gate (and no XP grant).
Required Skill Level (requiredSkillLevel) int 0 ≥ 0 Minimum level in requiredSkill to accept hits. 0 = any level passes. Ignored when requiredSkill is null.
Xp Grant Per Hit (xpGrantPerHit) int 1 ≥ 0 XP credited to requiredSkill per successful hit (NOT per kill — harvesters get steady XP through the chop). Ignored when requiredSkill is null. Set to 0 to skip the XP grant.

Damage-Type Filter

Field Type Default Range Description
Accepted Damage Types (acceptedDamageTypes) VtDamageType[] Empty Damage types the node accepts. Empty = accepts every type. Non-empty = hits whose VtDamageType isn’t in this list are cancelled before applying (e.g. ore takes Physical only — a Fire spell does nothing).

Respawn

Field Type Default Range Description
Respawn Seconds (respawnSeconds) float 60 ≥ 0 Seconds after depletion before the node restores HP and becomes harvestable again. 0 = no respawn (one-shot node — killable like any normal unit, doesn’t come back).

Visuals (optional)

Field Type Default Range Description
Alive Visual (aliveVisual) GameObject None Visual shown while the node is alive (tree mesh). Spawned as a child of the node GameObject at Initialize time, active until depletion. Null = no visual swap.
Depleted Visual (depletedVisual) GameObject None Visual shown while the node is depleted (stump). Toggled active when the node is chopped, inactive on respawn. Null = node simply disappears visually until respawn (consumer can still rely on collision / interaction).

Enums

VtResourceNodeFailureReason

Why a hit on a VtResourceNode was rejected (damage cancelled before it landed). Surfaced via VtResourceNode.OnHarvestFailed so the consumer’s UI can render precise feedback like “Need an axe!” or “Mining 50 required.”

Value Description
None The hit was accepted — the node took damage and harvested.
Depleted The node is currently depleted (already chopped) and is waiting for its respawn timer to elapse.
WrongTool The attacker doesn’t have an item with the required tool tag equipped (e.g. no axe in any equipment slot when chopping a tree).
SkillTooLow The attacker’s level in the required VtCraftingSkillDefinition is below the node’s threshold.
WrongDamageType The damage type (VtDamageType) isn’t in the node’s VtResourceNodeDefinition.acceptedDamageTypes list. E.g. ore takes Blunt only — a Slash sword bounces off.
InventoryFull The attacker’s inventory has no room for even one of anything the node yields, so the hit is refused and the node keeps its HP.

VtFaction

Team or allegiance of a VtUnit. Units of different factions fight each other unless either is Neutral; AI targeting, splash damage and projectiles all respect it.

Value Description
Neutral Unaffiliated or ambient — not targeted, not hostile.
Player The local player and their summons / pets.
Enemy Scripted hostile units (waves, bosses).
Wildlife Passive NPCs (deer, rabbits) — flee when attacked, don’t aggro.

VtDamageType

The element of an attack — routed through the corresponding resistX stat on VtCoreStats in VtUnitStats.TakeDamage.

Value Description
Physical Weapons, claws and falling rocks. Reduced by armor; resisted by stat.resist_physical.
Fire Fire and burning. Resisted by stat.resist_fire.
Cold Frost and ice. Resisted by stat.resist_cold.
Poison Poison and venom, often dealt over time. Resisted by stat.resist_poison.
True Bypasses all mitigation (resistance, armor, matrix). Use sparingly.
Lightning Electricity / chain-lightning / EMP-flavor. Resisted by stat.resist_lightning.
Holy Paladin / priest school. Strong vs undead in many genres. Resisted by stat.resist_holy.
Shadow Warlock / necromancer school — corruption, agony, void. Resisted by stat.resist_shadow. Often paired oppositionally with Holy.
Arcane Mage’s “raw magic” school — distinct from elemental. Magic missile, polymorph. Resisted by stat.resist_arcane. Conventionally hardest to resist.
Nature Druid / shaman school — earth, plant, weather, wildlife. Resisted by stat.resist_nature.