made weapon into a dependant and used new forgeneitty node as a node3d
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
// Copyright © Gamesmiths Guild.
|
||||
|
||||
using System;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Gamesmiths.Forge.Core;
|
||||
@@ -12,14 +11,13 @@ 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 partial class ForgeEntityNode : Node3D, IForgeEntity
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ public class ExplodingSwordBehavior(PackedScene explosion, float radius) : IAbil
|
||||
return;
|
||||
}
|
||||
explo.Radius = radius;
|
||||
|
||||
|
||||
GD.Print("explosion");
|
||||
owner.GetTree().GetRoot().CallDeferred(Node.MethodName.AddChild, explo);
|
||||
explo.CallDeferred(Node3D.MethodName.SetGlobalPosition, owner.GlobalPosition);
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ public partial class Enemy : CharacterBody3D,
|
||||
|
||||
#endregion
|
||||
|
||||
// Private stuff
|
||||
[Node("DamageBox")] public required Area3D DamageBox { get; set;}
|
||||
[Node("CTarget")] public required Node3D TargetComponent { get; set;}
|
||||
[Node("CHealthBar")] public required CHealthbar HealthBarWrapper { get; set;}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://bctpe34ddamg5" path="res://scenes/components/knockback/CKnockback.tscn" id="10_dejyg"]
|
||||
[ext_resource type="Resource" uid="uid://dt7a1io5o0b8s" path="res://scenes/enemies/flying_enemy/flying_enemy_knockback.tres" id="11_mpa2u"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vfi88"]
|
||||
[sub_resource type="Resource" id="Resource_46wn3"]
|
||||
script = ExtResource("8_oj1ws")
|
||||
ContainerTags = Array[String](["character.enemy"])
|
||||
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
|
||||
@@ -85,9 +85,9 @@ RDamage = ExtResource("2_on7rt")
|
||||
RKnockback = ExtResource("11_mpa2u")
|
||||
RMovement = ExtResource("4_dejyg")
|
||||
|
||||
[node name="ForgeEntityNode" type="Node" parent="." unique_id=22374325]
|
||||
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1255429192]
|
||||
script = ExtResource("7_46wn3")
|
||||
BaseTags = SubResource("Resource_vfi88")
|
||||
BaseTags = SubResource("Resource_46wn3")
|
||||
metadata/_custom_type_script = "uid://rpcbb54q4atx"
|
||||
|
||||
[node name="ForgeAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=1840910245]
|
||||
|
||||
@@ -35,7 +35,7 @@ Default = 1
|
||||
Min = 1
|
||||
Max = 100
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_4jf2q"]
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_ub34u"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qj0ob"]
|
||||
@@ -85,7 +85,7 @@ RDamage = ExtResource("2_bn56u")
|
||||
RKnockback = ExtResource("11_8k3xb")
|
||||
RMovement = ExtResource("4_na24f")
|
||||
|
||||
[node name="ForgeEntityNode" type="Node" parent="." unique_id=136254637]
|
||||
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=289553407]
|
||||
script = ExtResource("7_f22p3")
|
||||
BaseTags = SubResource("Resource_4jf2q")
|
||||
metadata/_custom_type_script = "uid://rpcbb54q4atx"
|
||||
@@ -108,7 +108,7 @@ metadata/_custom_type_script = "uid://bjwrpv3jpsc1e"
|
||||
|
||||
[node name="CHealthBar" parent="." unique_id=1278247727 instance=ExtResource("7_18xwy")]
|
||||
transform = Transform3D(0.4, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0)
|
||||
texture = SubResource("ViewportTexture_4jf2q")
|
||||
texture = SubResource("ViewportTexture_ub34u")
|
||||
|
||||
[node name="CDamageable" type="Node" parent="." unique_id=1601518000]
|
||||
script = ExtResource("7_1tw73")
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Gamesmiths.Forge.Abilities;
|
||||
using Gamesmiths.Forge.Attributes;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Cues;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Effects.Calculator;
|
||||
using Gamesmiths.Forge.Effects.Components;
|
||||
@@ -26,9 +29,20 @@ using Node = Godot.Node;
|
||||
namespace Movementtests.systems;
|
||||
|
||||
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_sword.png")]
|
||||
[GlobalClass, Icon("res://assets/ui/IconGodotNode/node_3D/icon_sword.png"), Meta(typeof(IAutoNode))]
|
||||
public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
#region Dependencies
|
||||
|
||||
[Dependency]
|
||||
public TagsManager TagsManager => this.DependOn<TagsManager>();
|
||||
[Dependency]
|
||||
public CuesManager CuesManager => this.DependOn<CuesManager>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Enums
|
||||
|
||||
public enum WeaponEvent
|
||||
@@ -76,10 +90,7 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
#endregion
|
||||
|
||||
#region Inspector
|
||||
|
||||
[Export]
|
||||
public ForgeTagContainer BaseTags { get; set; }
|
||||
[Export] public ForgeAbilityData FlyingTickAbility { get; set; }
|
||||
[Export] public ForgeAbilityData? FlyingTickAbility { get; set; }
|
||||
|
||||
[Export]
|
||||
public RDamage RDamage { get; set; }
|
||||
@@ -88,32 +99,60 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
[Export(PropertyHint.Range, "0,0.2,0.01,or_greater")]
|
||||
public float StraightThrowDuration { get; set; } = 0.1f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region IForgeEntity
|
||||
|
||||
// Perfectly forward the IForgeEntity interface to the ForgeEntity component
|
||||
public EntityAttributes Attributes
|
||||
{
|
||||
get => ForgeEntity.Attributes;
|
||||
set => ForgeEntity.Attributes = value;
|
||||
}
|
||||
public EntityTags Tags
|
||||
{
|
||||
get => ForgeEntity.Tags;
|
||||
set => ForgeEntity.Tags = value;
|
||||
}
|
||||
public EffectsManager EffectsManager
|
||||
{
|
||||
get => ForgeEntity.EffectsManager;
|
||||
set => ForgeEntity.EffectsManager = value;
|
||||
}
|
||||
public EntityAbilities Abilities
|
||||
{
|
||||
get => ForgeEntity.Abilities;
|
||||
set => ForgeEntity.Abilities = value;
|
||||
}
|
||||
public EventManager Events
|
||||
{
|
||||
get => ForgeEntity.Events;
|
||||
set => ForgeEntity.Events = value;
|
||||
}
|
||||
|
||||
public Variables SharedVariables
|
||||
{
|
||||
get => ForgeEntity.SharedVariables;
|
||||
set => ForgeEntity.SharedVariables = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Publics
|
||||
|
||||
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 StateChartState InHandState = null!;
|
||||
public StateChartState FlyingState = null!;
|
||||
public StateChartState PlantedState = null!;
|
||||
|
||||
public Timer WeaponFlyingTick = null!;
|
||||
|
||||
public Vector3 PlantLocation { get; set; }
|
||||
public Vector3 PlantNormal { get; set; }
|
||||
public Node? PlantObject { get; set; }
|
||||
|
||||
public MeshInstance3D WeaponLocationIndicator { get; set; } = null!;
|
||||
public StandardMaterial3D WeaponLocationIndicatorMaterial { get; set; } = null!;
|
||||
public MeshInstance3D WeaponMesh { get; set; } = null!;
|
||||
|
||||
|
||||
[Node("ForgeEntityNode")] public required ForgeEntityNode ForgeEntity { get; set;}
|
||||
[Node("Weapon")] public required MeshInstance3D WeaponMesh { get; set; }
|
||||
[Node("WeaponLocationIndicator")] public required MeshInstance3D WeaponLocationIndicator { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Privates
|
||||
@@ -133,9 +172,11 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
private Vector3 _throwDirection;
|
||||
|
||||
#endregion
|
||||
|
||||
public void Init()
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
#region StateManagement
|
||||
|
||||
_weaponState = StateChart.Of(GetNode("StateChart"));
|
||||
InHandState = StateChartState.Of(GetNode("StateChart/Root/InHand"));
|
||||
FlyingState = StateChartState.Of(GetNode("StateChart/Root/Flying"));
|
||||
@@ -145,49 +186,41 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
_plantedToHand = Transition.Of(GetNode("StateChart/Root/Planted/ToHand"));
|
||||
_plantedToFlying = Transition.Of(GetNode("StateChart/Root/Planted/ToFlying"));
|
||||
_toPlanted = Transition.Of(GetNode("StateChart/Root/ToPlanted"));
|
||||
|
||||
WeaponLocationIndicator = GetNode<MeshInstance3D>("WeaponLocationIndicator");
|
||||
WeaponLocationIndicator.Visible = false;
|
||||
WeaponLocationIndicatorMaterial = (WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D)!;
|
||||
|
||||
WeaponFlyingTick = GetNode<Timer>("WeaponFlyingTick");
|
||||
|
||||
WeaponMesh = GetNode<MeshInstance3D>("Weapon");
|
||||
#endregion
|
||||
|
||||
// Initial setup
|
||||
_startMeshRotation = WeaponMesh.Rotation;
|
||||
|
||||
_startTransform = Transform;
|
||||
Freeze = true;
|
||||
Visible = false;
|
||||
|
||||
WeaponLocationIndicator.Visible = false;
|
||||
WeaponLocationIndicatorMaterial = (WeaponLocationIndicator.GetActiveMaterial(0) as StandardMaterial3D)!;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
// Forge
|
||||
var tagsManager = ForgeManagers.Instance.TagsManager;
|
||||
var cuesManager = ForgeManagers.Instance.CuesManager;
|
||||
WeaponFlyingTickEventTag = Tag.RequestTag(TagsManager, "events.weapon.flyingTick");
|
||||
WeaponStartedFlyingEventTag = Tag.RequestTag(TagsManager, "events.weapon.startedFlying");
|
||||
WeaponStoppedFlyingEventTag = Tag.RequestTag(TagsManager, "events.weapon.stoppedFlying");
|
||||
WeaponHandToFlyingEventTag = Tag.RequestTag(TagsManager, "events.weapon.handToFlying");
|
||||
WeaponFlyingToHandEventTag = Tag.RequestTag(TagsManager, "events.weapon.flyingToHand");
|
||||
WeaponPlantedToHandEventTag = Tag.RequestTag(TagsManager, "events.weapon.plantedToHand");
|
||||
WeaponPlantedToFlyingEventTag = Tag.RequestTag(TagsManager, "events.weapon.plantedToFlying");
|
||||
WeaponPlantedEventTag = Tag.RequestTag(TagsManager, "events.weapon.planted");
|
||||
|
||||
WeaponFlyingTickEventTag = Tag.RequestTag(tagsManager, "events.weapon.flyingTick");
|
||||
WeaponStartedFlyingEventTag = Tag.RequestTag(tagsManager, "events.weapon.startedFlying");
|
||||
WeaponStoppedFlyingEventTag = Tag.RequestTag(tagsManager, "events.weapon.stoppedFlying");
|
||||
WeaponHandToFlyingEventTag = Tag.RequestTag(tagsManager, "events.weapon.handToFlying");
|
||||
WeaponFlyingToHandEventTag = Tag.RequestTag(tagsManager, "events.weapon.flyingToHand");
|
||||
WeaponPlantedToHandEventTag = Tag.RequestTag(tagsManager, "events.weapon.plantedToHand");
|
||||
WeaponPlantedToFlyingEventTag = Tag.RequestTag(tagsManager, "events.weapon.plantedToFlying");
|
||||
WeaponPlantedEventTag = Tag.RequestTag(tagsManager, "events.weapon.planted");
|
||||
|
||||
// WeaponInHandStatusTag = Tag.RequestTag(tagsManager, "status.weapon.inHand");
|
||||
// WeaponFlyingStatusTag = Tag.RequestTag(tagsManager, "status.weapon.flying");
|
||||
// WeaponPlantedStatusTag = Tag.RequestTag(tagsManager, "status.weapon.planted");
|
||||
|
||||
WeaponFlyingAbilityTag = Tag.RequestTag(tagsManager,"abilities.weapon.flying");
|
||||
|
||||
Attributes = new EntityAttributes([.. ForgeUtils.CollectAttributeList(this)]);
|
||||
Tags = new(BaseTags.GetTagContainer());
|
||||
EffectsManager = new EffectsManager(this, cuesManager);
|
||||
Abilities = new(this);
|
||||
Events = new();
|
||||
// WeaponInHandStatusTag = Tag.RequestTag(TagsManager, "status.weapon.inHand");
|
||||
// WeaponFlyingStatusTag = Tag.RequestTag(TagsManager, "status.weapon.flying");
|
||||
// WeaponPlantedStatusTag = Tag.RequestTag(TagsManager, "status.weapon.planted");
|
||||
|
||||
// Manage weapon flying tick raising ability
|
||||
WeaponFlyingAbilityTag = Tag.RequestTag(TagsManager,"abilities.weapon.flying");
|
||||
_weaponFlyingAbility = Abilities.GrantAbilityPermanently(FlyingTickAbility.GetAbilityData(), 1, LevelComparison.None, this);
|
||||
|
||||
Events.Subscribe(WeaponStoppedFlyingEventTag, _ => { _weaponFlyingAbility.Cancel(); });
|
||||
|
||||
BodyEntered += OnThrownWeaponReachesGround;
|
||||
|
||||
InHandState.StateExited += WeaponLeft;
|
||||
InHandState.StateEntered += WeaponBack;
|
||||
|
||||
@@ -260,10 +293,8 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
||||
Events.Subscribe(WeaponStoppedFlyingEventTag, _ => { _weaponFlyingAbility.Cancel(); });
|
||||
}
|
||||
|
||||
|
||||
public void GrantNewAbilityForEvent(WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var relevantMap = GetGrantedAbilities(forEvent);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
[ext_resource type="Resource" uid="uid://btnnpqann3ktp" path="res://forge/resources/ability_datas/weapon_flying_tick_ability.tres" id="4_7bruw"]
|
||||
[ext_resource type="Script" uid="uid://ccovd5i0wr3kk" path="res://addons/forge/editor/attributes/AttributeValues.cs" id="4_q6xv7"]
|
||||
[ext_resource type="Script" uid="uid://jk2jm1g6q853" path="res://addons/godot_state_charts/compound_state.gd" id="4_svc06"]
|
||||
[ext_resource type="Script" uid="uid://rpcbb54q4atx" path="res://forge/ForgeEntityNode.cs" id="5_7bruw"]
|
||||
[ext_resource type="Script" uid="uid://cytafq8i1y8qm" path="res://addons/godot_state_charts/atomic_state.gd" id="5_m0v1h"]
|
||||
[ext_resource type="Script" uid="uid://cf1nsco3w0mf6" path="res://addons/godot_state_charts/transition.gd" id="6_jpdh0"]
|
||||
|
||||
@@ -22,6 +23,11 @@ script = ExtResource("2_m0v1h")
|
||||
DamageDealt = 2.0
|
||||
metadata/_custom_type_script = "uid://jitubgv6judn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7bruw"]
|
||||
script = ExtResource("2_l1xlx")
|
||||
ContainerTags = Array[String](["weapon"])
|
||||
metadata/_custom_type_script = "uid://cw525n4mjqgw0"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pgbtr"]
|
||||
script = ExtResource("4_q6xv7")
|
||||
Default = 1
|
||||
@@ -67,7 +73,12 @@ BaseTags = SubResource("Resource_06gln")
|
||||
FlyingTickAbility = ExtResource("4_7bruw")
|
||||
RDamage = SubResource("Resource_jpdh0")
|
||||
|
||||
[node name="WeaponAttributeSet" type="Node" parent="." unique_id=14845649]
|
||||
[node name="ForgeEntityNode" type="Node3D" parent="." unique_id=1798885192]
|
||||
script = ExtResource("5_7bruw")
|
||||
BaseTags = SubResource("Resource_7bruw")
|
||||
metadata/_custom_type_script = "uid://rpcbb54q4atx"
|
||||
|
||||
[node name="WeaponAttributeSet" type="Node" parent="ForgeEntityNode" unique_id=14845649]
|
||||
script = ExtResource("3_3xjpi")
|
||||
AttributeSetClass = "WeaponAttributeSet"
|
||||
InitialAttributeValues = Dictionary[String, ExtResource("4_q6xv7")]({
|
||||
|
||||
@@ -576,7 +576,6 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
|
||||
MantleSystem.Init();
|
||||
StairsSystem.Init(stairsBelowRayCast3D, stairsAheadRayCast3D, cameraSmooth);
|
||||
DashSystem.Init(HeadSystem, Camera);
|
||||
WeaponSystem.Init();
|
||||
WallHugSystem.Init();
|
||||
|
||||
// if (!TutorialDone)
|
||||
|
||||
Reference in New Issue
Block a user