new forge entity node to benefit from autoinject
This commit is contained in:
74
forge/ForgeEntityNode.cs
Normal file
74
forge/ForgeEntityNode.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright © Gamesmiths Guild.
|
||||
|
||||
using System;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Events;
|
||||
using Gamesmiths.Forge.Godot.Core;
|
||||
using Gamesmiths.Forge.Godot.Resources;
|
||||
using Gamesmiths.Forge.Statescript;
|
||||
using Gamesmiths.Forge.Tags;
|
||||
using Godot;
|
||||
using Node = Godot.Node;
|
||||
|
||||
namespace Movementtests.tools;
|
||||
|
||||
[GlobalClass]
|
||||
[Icon("uid://cu6ncpuumjo20")]
|
||||
[Meta(typeof(IAutoNode))]
|
||||
public partial class ForgeEntityNode : Node, IForgeEntity
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
[Dependency]
|
||||
public TagsManager TagsManager => this.DependOn<TagsManager>();
|
||||
[Dependency]
|
||||
public CuesManager CuesManager => this.DependOn<CuesManager>();
|
||||
|
||||
[Export]
|
||||
public ForgeTagContainer? BaseTags { get; set; }
|
||||
[Export]
|
||||
public ForgeSharedVariableSet? SharedVariableDefinitions { get; set; }
|
||||
|
||||
public required EntityAttributes Attributes { get; set; }
|
||||
|
||||
public required EntityTags Tags { get; set; }
|
||||
|
||||
public required EffectsManager EffectsManager { get; set; }
|
||||
|
||||
public required EntityAbilities Abilities { get; set; }
|
||||
|
||||
public required EventManager Events { get; set; }
|
||||
|
||||
public required Variables SharedVariables { get; set; }
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
BaseTags ??= new ForgeTagContainer();
|
||||
Tags = new EntityTags(BaseTags.GetTagContainer());
|
||||
Attributes = new EntityAttributes([.. ForgeUtils.CollectAttributeList(this)]);
|
||||
Abilities = new EntityAbilities(this);
|
||||
Events = new EventManager();
|
||||
|
||||
SharedVariables = new Variables();
|
||||
SharedVariableDefinitions?.PopulateVariables(SharedVariables);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
EffectsManager = new EffectsManager(this, CuesManager);
|
||||
var effectApplier = new EffectApplier(this);
|
||||
effectApplier.ApplyEffects(this, this, this);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
base._Process(delta);
|
||||
|
||||
EffectsManager.UpdateEffects(delta);
|
||||
Abilities.UpdateAbilities(delta);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user