Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5e47e9f5e | |||
| 99ed6375a2 | |||
| 6888499b78 | |||
| 2a98137653 | |||
| b0fe2549ea | |||
| 667d6b2588 |
@@ -10,5 +10,9 @@ namespace Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
[Icon("uid://bcx7anhepqfmd")]
|
||||
public abstract partial class ForgeAbilityBehavior : Resource
|
||||
{
|
||||
[Export] public string? Name { get; set; }
|
||||
[Export] public string? Description { get; set; }
|
||||
[Export] public Texture2D? Icon { get; set; }
|
||||
|
||||
public abstract IAbilityBehavior GetBehavior();
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func _input(event : InputEvent) -> void:
|
||||
if event.is_action_released("ui_cancel"):
|
||||
if sub_menu:
|
||||
_close_sub_menu()
|
||||
else:
|
||||
get_tree().quit()
|
||||
# else:
|
||||
# get_tree().quit()
|
||||
if event.is_action_released("ui_accept") and get_viewport().gui_get_focus_owner() == null:
|
||||
%MenuButtonsBoxContainer.focus_first()
|
||||
|
||||
|
||||
58
managers/InventoryManager.cs
Normal file
58
managers/InventoryManager.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Collections.Generic;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
namespace Movementtests.managers;
|
||||
|
||||
public partial class WeaponEventAbilityData(WeaponSystem.WeaponEvent forEvent, Resource ability)
|
||||
: RefCounted
|
||||
{
|
||||
public WeaponSystem.WeaponEvent ForEvent { get; private set; } = forEvent;
|
||||
public Resource Ability { get; private set; } = ability;
|
||||
}
|
||||
|
||||
public partial class InventoryManager : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void InventoryChangedEventHandler();
|
||||
|
||||
[Signal]
|
||||
public delegate void WeaponEventInventoryChangedEventHandler();
|
||||
[Signal]
|
||||
public delegate void WeaponEventAbilityAddedEventHandler(WeaponEventAbilityData data);
|
||||
[Signal]
|
||||
public delegate void WeaponEventAbilityRemovedEventHandler(WeaponEventAbilityData data);
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, HashSet<Resource>> WeaponEventsInventory { get; } = [];
|
||||
|
||||
public static InventoryManager Instance { get; private set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick] = new HashSet<Resource>();
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying] = new HashSet<Resource>();
|
||||
WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying] = new HashSet<Resource>();
|
||||
}
|
||||
|
||||
public void AddAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var inventoryForEvent = WeaponEventsInventory[forEvent];
|
||||
var addedAbilityToInventory = inventoryForEvent.Add(abilityBehavior);
|
||||
if (!addedAbilityToInventory) return;
|
||||
|
||||
EmitSignalWeaponEventInventoryChanged();
|
||||
EmitSignalWeaponEventAbilityAdded(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
||||
}
|
||||
|
||||
public void RemoveAbilityForWeaponEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var inventoryForEvent = WeaponEventsInventory[forEvent];
|
||||
var removedFromInventory = inventoryForEvent.Remove(abilityBehavior);
|
||||
if (!removedFromInventory) return;
|
||||
|
||||
EmitSignalWeaponEventInventoryChanged();
|
||||
EmitSignalWeaponEventAbilityRemoved(new WeaponEventAbilityData(forEvent, abilityBehavior));
|
||||
}
|
||||
}
|
||||
1
managers/InventoryManager.cs.uid
Normal file
1
managers/InventoryManager.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cgwhrwfqsiing
|
||||
67
maps/_templates/MainSceneTemplate.cs
Normal file
67
maps/_templates/MainSceneTemplate.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.interfaces;
|
||||
using Movementtests.systems;
|
||||
|
||||
public partial class MainSceneTemplate : Node3D
|
||||
{
|
||||
private Marker3D? _playerRespawnMarker;
|
||||
private AnimationPlayer? _animationPlayer;
|
||||
private Node3D? _respawnabble;
|
||||
|
||||
private Area3D? _playerFellPlane;
|
||||
private Area3D? _deathPlane;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_playerRespawnMarker = GetNode<Marker3D>("PlayerFellRespawn");
|
||||
_animationPlayer = GetNode<AnimationPlayer>("AnimationPlayer");
|
||||
|
||||
_playerFellPlane = GetNode<Area3D>("PlayerFellTP");
|
||||
_deathPlane = GetNode<Area3D>("DeathPlane");
|
||||
|
||||
if (_playerRespawnMarker == null) throw new Exception("Player respawn marker is null");
|
||||
if (_animationPlayer == null) throw new Exception("Animation player is null");
|
||||
if (_playerFellPlane == null) throw new Exception("Player reset plane is null");
|
||||
if (_deathPlane == null) throw new Exception("Enemy death plane is null");
|
||||
|
||||
_playerFellPlane.BodyEntered += StartResetPlayerAnimation;
|
||||
_deathPlane.BodyEntered += KillEnemy;
|
||||
|
||||
}
|
||||
|
||||
public void ResetPlayerPosition()
|
||||
{
|
||||
if (_respawnabble == null || _playerRespawnMarker == null) throw new Exception("Player or respawn marker is null");
|
||||
_respawnabble.GlobalPosition = _playerRespawnMarker.GlobalPosition;
|
||||
}
|
||||
|
||||
public void StartResetPlayerAnimation(Node3D body)
|
||||
{
|
||||
if (body is WeaponSystem weapon)
|
||||
{
|
||||
if (_playerRespawnMarker == null) throw new Exception("Respawn marker is null");
|
||||
weapon.GlobalPosition = _playerRespawnMarker.GlobalPosition;
|
||||
weapon.SetLinearVelocity(Vector3.Down);
|
||||
return;
|
||||
}
|
||||
_respawnabble = body as PlayerController;
|
||||
if (_respawnabble == null || _animationPlayer == null) throw new Exception("Player or anim player is null");
|
||||
_animationPlayer.Play("player_fell");
|
||||
}
|
||||
|
||||
public void KillEnemy(Node3D body)
|
||||
{
|
||||
if (body is not IKillable killable)
|
||||
{
|
||||
body.QueueFree();
|
||||
return;
|
||||
}
|
||||
if (killable is not IHealthable healthable)
|
||||
{
|
||||
body.QueueFree();
|
||||
return;
|
||||
}
|
||||
killable.Kill(healthable);
|
||||
}
|
||||
}
|
||||
1
maps/_templates/MainSceneTemplate.cs.uid
Normal file
1
maps/_templates/MainSceneTemplate.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://br0f18u1iou2d
|
||||
@@ -1,21 +0,0 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
@onready var player_fell_respawn: Marker3D = $PlayerFellRespawn
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var _player: Node3D
|
||||
|
||||
func _on_player_fell_tp_body_entered(body: Node3D) -> void:
|
||||
_player = body
|
||||
animation_player.play("player_fell")
|
||||
|
||||
|
||||
func reset_player_position() -> void:
|
||||
if _player == null:
|
||||
return
|
||||
_player.position = player_fell_respawn.position
|
||||
|
||||
|
||||
func _on_death_plane_body_entered(body: Node3D) -> void:
|
||||
body.queue_free()
|
||||
@@ -1 +0,0 @@
|
||||
uid://beof168aw2acj
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene format=3 uid="uid://55wehh6xombr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://beof168aw2acj" path="res://maps/_templates/main_scene_template.gd" id="1_5g5a0"]
|
||||
[ext_resource type="Script" uid="uid://br0f18u1iou2d" path="res://maps/_templates/MainSceneTemplate.cs" id="1_5g5a0"]
|
||||
[ext_resource type="PackedScene" uid="uid://bkcsjsk2ciff" path="res://addons/maaacks_game_template/base/scenes/music_players/background_music_player.tscn" id="2_roiv2"]
|
||||
[ext_resource type="AudioStream" uid="uid://f8cvr5s041ej" path="res://assets/audio/ambiance/637083__nox_sound__ambiance_nature_night_cricket_calm_loop_stereo.wav" id="3_boadi"]
|
||||
[ext_resource type="Script" uid="uid://cupqhe3qv7ero" path="res://tools/general_manager.gd" id="3_k6got"]
|
||||
@@ -237,7 +237,7 @@ tracks/6/keys = {
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"values": [{
|
||||
"args": [],
|
||||
"method": &"reset_player_position"
|
||||
"method": &"ResetPlayerPosition"
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -300,6 +300,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 300, 0)
|
||||
[node name="PlayerFellTP" type="Area3D" parent="." unique_id=1277888169]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -200, 0)
|
||||
collision_layer = 0
|
||||
collision_mask = 65537
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="PlayerFellTP" unique_id=1866249040]
|
||||
|
||||
@@ -41,7 +41,7 @@ size = Vector3(6.75, 8.25, 7.25)
|
||||
|
||||
[node name="Main" unique_id=955321579 instance=ExtResource("1_jyq54")]
|
||||
|
||||
[node name="DirectionalLight3D" parent="." index="5" unique_id=1357990191]
|
||||
[node name="DirectionalLight3D" parent="." index="6" unique_id=1357990191]
|
||||
transform = Transform3D(-0.1772511, 0.44628847, 0.87715954, 0.49540228, -0.72966087, 0.4713508, 0.85038733, 0.51809436, -0.09175911, 0, 0, 0)
|
||||
|
||||
[node name="Greybox" type="CSGCombiner3D" parent="." index="7" unique_id=2082385716]
|
||||
@@ -907,9 +907,9 @@ light_energy = 8.571
|
||||
omni_range = 7.0
|
||||
|
||||
[node name="OmniLight3D29" type="OmniLight3D" parent="Lights" index="24" unique_id=2143811783]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 25.5, -16.5)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 16.75, -18.75)
|
||||
light_energy = 4.004
|
||||
omni_range = 7.0
|
||||
omni_range = 9.25
|
||||
|
||||
[node name="OmniLight3D20" type="OmniLight3D" parent="Lights" index="25" unique_id=1665621589]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -37, 24.5, -35.25)
|
||||
@@ -934,14 +934,19 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -33.5, 24.5, -47)
|
||||
light_energy = 2.725
|
||||
omni_range = 10.0
|
||||
|
||||
[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="30" unique_id=727558952]
|
||||
[node name="OmniLight3D34" type="OmniLight3D" parent="Lights" index="30" unique_id=2065211844]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -36.25, 13.75, -45.5)
|
||||
light_energy = 2.725
|
||||
omni_range = 10.0
|
||||
|
||||
[node name="OmniLight3D25" type="OmniLight3D" parent="Lights" index="31" unique_id=727558952]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -28, 24.5, -51)
|
||||
|
||||
[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="31" unique_id=1646376304]
|
||||
[node name="OmniLight3D26" type="OmniLight3D" parent="Lights" index="32" unique_id=1646376304]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5)
|
||||
omni_range = 7.0
|
||||
|
||||
[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="32" unique_id=1849438050]
|
||||
[node name="OmniLight3D27" type="OmniLight3D" parent="Lights" index="33" unique_id=1849438050]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 24.5, -51.5)
|
||||
omni_range = 4.5
|
||||
|
||||
@@ -1047,10 +1052,10 @@ tuto_text = "Select next level when ready"
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.875, 1.125, -4.625)
|
||||
shape = SubResource("BoxShape3D_7hd1j")
|
||||
|
||||
[node name="Player" parent="." index="11" unique_id=1309399929]
|
||||
[node name="Player" parent="." index="12" unique_id=1309399929]
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, -0.5, 0.4102497, 0.5415039)
|
||||
HasSword = false
|
||||
HasParry = false
|
||||
|
||||
[node name="PlayerFellRespawn" parent="." index="12" unique_id=479136076]
|
||||
[node name="PlayerFellRespawn" parent="." index="13" unique_id=479136076]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.25, -1.25)
|
||||
|
||||
@@ -343,7 +343,7 @@ transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, -7.25, 20.5, -27.5)
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 1.3647223, 23.75, -13.75)
|
||||
|
||||
[node name="Enemy28" parent="Tutorial" index="2" unique_id=1765389924 node_paths=PackedStringArray("Target") instance=ExtResource("7_egib5")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -5, 22, 16.5)
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -5, 22, 15.5)
|
||||
Target = NodePath("../../Player")
|
||||
RHealth = SubResource("Resource_invhv")
|
||||
RDamage = SubResource("Resource_cgfmf")
|
||||
@@ -520,15 +520,15 @@ size = Vector3(1, 1, 4.75)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="CSGBox3D137" type="CSGBox3D" parent="Tutorial/DashWithMantle" index="10" unique_id=1930091014]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 22.5, 58)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6, 22.5, 57.5)
|
||||
use_collision = true
|
||||
size = Vector3(1, 1, 11)
|
||||
size = Vector3(1, 1, 12)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="CSGBox3D138" type="CSGBox3D" parent="Tutorial/DashWithMantle" index="11" unique_id=1299444131]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 22.5, 58)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 22.5, 57.5)
|
||||
use_collision = true
|
||||
size = Vector3(1, 1, 11)
|
||||
size = Vector3(1, 1, 12)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="CSGBox3D139" type="CSGBox3D" parent="Tutorial/DashWithMantle" index="12" unique_id=1708119368]
|
||||
@@ -628,9 +628,9 @@ size = Vector3(9.5, 5, 11.75)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="CSGBox3D133" type="CSGBox3D" parent="Tutorial/DashWithMantle" index="28" unique_id=672467040]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 21.487345, 58)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 21.487345, 57.5)
|
||||
use_collision = true
|
||||
size = Vector3(5, 1, 11)
|
||||
size = Vector3(5, 1, 12)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="CSGBox3D141" type="CSGBox3D" parent="Tutorial/DashWithMantle" index="29" unique_id=1207463075]
|
||||
@@ -765,10 +765,10 @@ use_collision = true
|
||||
size = Vector3(2, 3.25, 1)
|
||||
material = ExtResource("3_4m8g1")
|
||||
|
||||
[node name="Player" parent="." index="9" unique_id=1309399929]
|
||||
[node name="Player" parent="." index="10" unique_id=1309399929]
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, -0.5, 0, 0)
|
||||
|
||||
[node name="PlayerFellRespawn" parent="." index="10" unique_id=479136076]
|
||||
[node name="PlayerFellRespawn" parent="." index="11" unique_id=479136076]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 1.5, 0)
|
||||
|
||||
[node name="OmniLight3D" type="OmniLight3D" parent="." index="13" unique_id=702421172]
|
||||
|
||||
@@ -112,5 +112,5 @@ tuto_text = "Try to survive!"
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0.625, -1.875)
|
||||
shape = SubResource("BoxShape3D_lthgu")
|
||||
|
||||
[node name="Player" parent="." index="15" unique_id=1309399929]
|
||||
[node name="Player" parent="." index="16" unique_id=1309399929]
|
||||
transform = Transform3D(0.99999994, 0, 0, 0, 1, 0, 0, 0, 0.99999994, 3, 0, 0)
|
||||
|
||||
@@ -1,55 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
[Tool, GlobalClass]
|
||||
public partial class AbilitySelection : Control
|
||||
{
|
||||
[Signal] public delegate void AbilityAddedEventHandler(WeaponSystem.WeaponEvent forEvent, string abilityName);
|
||||
[Signal] public delegate void AbilityAddedEventHandler(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior behavior);
|
||||
[Signal] public delegate void AbilityRemovedEventHandler(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior behavior);
|
||||
|
||||
[Export] public WeaponSystem.WeaponEvent ForEvent { get; set; } = WeaponSystem.WeaponEvent.StartedFlying;
|
||||
|
||||
private string _title = string.Empty;
|
||||
[Export] public string Title {
|
||||
get => _title;
|
||||
set
|
||||
{
|
||||
_title = value;
|
||||
TitleChanged();
|
||||
}
|
||||
}
|
||||
[Export] public string Title { get; set; } = string.Empty;
|
||||
|
||||
[Export] public PackedScene AbilitySelectionItem { get; set; }
|
||||
[Export] public PackedScene AbilitySelectedItem { get; set; }
|
||||
|
||||
[Export] public ForgeAbilityBehavior[] AbilityBehaviors { get; set; }
|
||||
|
||||
private VBoxContainer _abilities;
|
||||
private VBoxContainer _selectedAbilities;
|
||||
private MenuButton _addAbility;
|
||||
private PopupMenu _addAbilityMenu;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_abilities = GetNode<VBoxContainer>("%SelectedAbilities");
|
||||
var titleLabel = GetNode<Label>("%TitleLabel");
|
||||
titleLabel.Text = Title;
|
||||
|
||||
_selectedAbilities = GetNode<VBoxContainer>("%SelectedAbilities");
|
||||
_addAbility = GetNode<MenuButton>("%AddAbility");
|
||||
_addAbilityMenu = _addAbility.GetPopup();
|
||||
|
||||
_addAbilityMenu.IdPressed += AddAbilityMenuOnIdPressed;
|
||||
if (Engine.IsEditorHint()) return;
|
||||
|
||||
var i = 0;
|
||||
foreach (var behavior in AbilityBehaviors)
|
||||
{
|
||||
_addAbilityMenu.AddIconItem(behavior.Icon, behavior.Name);
|
||||
_addAbilityMenu.SetItemMetadata(i, behavior);
|
||||
i += 1;
|
||||
}
|
||||
|
||||
_addAbilityMenu.IndexPressed += AddAbilityMenuOnIndexPressed;
|
||||
}
|
||||
|
||||
public void Initialize(IEnumerable<Resource> equippedAbilities)
|
||||
{
|
||||
foreach (var equippedAbility in equippedAbilities)
|
||||
{
|
||||
if (equippedAbility is not ForgeAbilityBehavior ability) continue;
|
||||
AddSelectedAbility(ability);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddAbilityMenuOnIndexPressed(long index)
|
||||
{
|
||||
var indexInt = Convert.ToInt32(index);
|
||||
var metadata = _addAbilityMenu.GetItemMetadata(indexInt);
|
||||
var name = _addAbilityMenu.GetItemText(indexInt);
|
||||
EmitSignalAbilityAdded(ForEvent, name);
|
||||
var metadata = (ForgeAbilityBehavior) _addAbilityMenu.GetItemMetadata(indexInt);
|
||||
EmitSignalAbilityAdded(ForEvent, metadata);
|
||||
}
|
||||
|
||||
private void AddAbilityMenuOnIdPressed(long id)
|
||||
public void AddSelectedAbility(ForgeAbilityBehavior behavior)
|
||||
{
|
||||
var newSelectedAbilityItem = AbilitySelectedItem.Instantiate() as SelectedAbility;
|
||||
if (newSelectedAbilityItem == null) return;
|
||||
|
||||
newSelectedAbilityItem.SetAbility(behavior);
|
||||
newSelectedAbilityItem.AbilityRemoved += ability => EmitSignalAbilityRemoved(ForEvent, ability);
|
||||
_selectedAbilities.AddChild(newSelectedAbilityItem);
|
||||
}
|
||||
|
||||
public void TitleChanged()
|
||||
|
||||
public void RemoveSelectedAbility(ForgeAbilityBehavior behavior)
|
||||
{
|
||||
var titleLabel = GetNode<Label>("%TitleLabel");
|
||||
titleLabel.Text = Title;
|
||||
foreach (var child in _selectedAbilities.GetChildren())
|
||||
{
|
||||
if (child is not SelectedAbility selectedAbility || selectedAbility.Ability != behavior) continue;
|
||||
_selectedAbilities.RemoveChild(selectedAbility);
|
||||
_addAbility.GrabFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
56
menus/scenes/components/SelectedAbility.cs
Normal file
56
menus/scenes/components/SelectedAbility.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
|
||||
[Tool, GlobalClass]
|
||||
public partial class SelectedAbility : Control
|
||||
{
|
||||
[Signal] public delegate void AbilityRemovedEventHandler(ForgeAbilityBehavior ability);
|
||||
|
||||
private ForgeAbilityBehavior? _ability;
|
||||
[Export]
|
||||
public ForgeAbilityBehavior? Ability
|
||||
{
|
||||
get => _ability;
|
||||
set
|
||||
{
|
||||
_ability = value;
|
||||
if (_ability == null || !Engine.IsEditorHint()) return;
|
||||
AbilityUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
private TextureRect? _icon;
|
||||
private Label? _title;
|
||||
private Button? _remove;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_icon = GetNode<TextureRect>("%Icon");
|
||||
_title = GetNode<Label>("%Title");
|
||||
_remove = GetNode<Button>("%Remove");
|
||||
|
||||
_remove.Pressed += () => EmitSignalAbilityRemoved(Ability);
|
||||
}
|
||||
|
||||
public void SetAbility(ForgeAbilityBehavior ability)
|
||||
{
|
||||
_ability = ability;
|
||||
AbilityUpdated();
|
||||
}
|
||||
|
||||
public void AbilityUpdated()
|
||||
{
|
||||
var icon = _icon ?? GetNode<TextureRect>("%Icon");
|
||||
var title = _title ?? GetNode<Label>("%Title");
|
||||
if (icon == null || title == null) return;
|
||||
if (_ability == null)
|
||||
{
|
||||
icon.Texture = null;
|
||||
title.Text = "";
|
||||
return;
|
||||
}
|
||||
icon.Texture = _ability.Icon;
|
||||
title.Text = _ability.Name;
|
||||
}
|
||||
}
|
||||
1
menus/scenes/components/SelectedAbility.cs.uid
Normal file
1
menus/scenes/components/SelectedAbility.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://duest06l5answ
|
||||
@@ -1,8 +1,9 @@
|
||||
[gd_scene format=3 uid="uid://dmv685sskgh3l"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://5emed8iegtui" path="res://menus/scenes/components/AbilitySelection.cs" id="1_fcxyu"]
|
||||
[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://scenes/player_controller/resources/forge/exploding_sword.tres" id="2_j1yif"]
|
||||
[ext_resource type="Texture2D" uid="uid://by5v33lu8v1fm" path="res://assets/ui/input-prompts/Flairs/Vector/flair_plus.svg" id="2_uf3m5"]
|
||||
[ext_resource type="Texture2D" uid="uid://c2akxlg7tdb67" path="res://assets/ui/IconGodotNode/node/icon_projectile.png" id="3_41pdy"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjnimmo2jyvx7" path="res://menus/scenes/components/selected_ability.tscn" id="3_cndde"]
|
||||
|
||||
[node name="AbilitySelection" type="MarginContainer" unique_id=1373426933]
|
||||
size_flags_horizontal = 3
|
||||
@@ -11,6 +12,9 @@ theme_override_constants/margin_top = 4
|
||||
theme_override_constants/margin_right = 4
|
||||
theme_override_constants/margin_bottom = 4
|
||||
script = ExtResource("1_fcxyu")
|
||||
Title = "Test"
|
||||
AbilitySelectedItem = ExtResource("3_cndde")
|
||||
AbilityBehaviors = [ExtResource("2_j1yif")]
|
||||
|
||||
[node name="HBoxContainer" type="VBoxContainer" parent="." unique_id=364343452]
|
||||
layout_mode = 2
|
||||
@@ -18,6 +22,7 @@ layout_mode = 2
|
||||
[node name="TitleLabel" type="Label" parent="HBoxContainer" unique_id=8350369]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Test"
|
||||
|
||||
[node name="SelectedAbilities" type="VBoxContainer" parent="HBoxContainer" unique_id=1173689490]
|
||||
unique_name_in_owner = true
|
||||
@@ -39,7 +44,3 @@ layout_mode = 2
|
||||
focus_mode = 2
|
||||
text = "Add ability"
|
||||
icon = ExtResource("2_uf3m5")
|
||||
item_count = 1
|
||||
popup/item_0/text = "Weapon explosion"
|
||||
popup/item_0/icon = ExtResource("3_41pdy")
|
||||
popup/item_0/id = 0
|
||||
|
||||
30
menus/scenes/components/selected_ability.tscn
Normal file
30
menus/scenes/components/selected_ability.tscn
Normal file
@@ -0,0 +1,30 @@
|
||||
[gd_scene format=3 uid="uid://cjnimmo2jyvx7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://duest06l5answ" path="res://menus/scenes/components/SelectedAbility.cs" id="1_dc51o"]
|
||||
[ext_resource type="Resource" uid="uid://ifeavnlps7hy" path="res://scenes/player_controller/resources/forge/exploding_sword.tres" id="2_um64s"]
|
||||
[ext_resource type="Texture2D" uid="uid://b3403ry3yxw1t" path="res://assets/ui/input-prompts/Flairs/Vector/flair_cross.svg" id="4_x7nho"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_2nvj1"]
|
||||
atlas = ExtResource("4_x7nho")
|
||||
region = Rect2(20, 20, 24, 24)
|
||||
|
||||
[node name="SelectedAbility" type="PanelContainer" unique_id=931414010]
|
||||
script = ExtResource("1_dc51o")
|
||||
Ability = ExtResource("2_um64s")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=489712453]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Icon" type="TextureRect" parent="HBoxContainer" unique_id=1615158957]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="Title" type="Label" parent="HBoxContainer" unique_id=809638027]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Remove" type="Button" parent="HBoxContainer" unique_id=1761723956]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
icon = SubResource("AtlasTexture_2nvj1")
|
||||
@@ -37,6 +37,7 @@ option_name = "Joystick Sensitivity"
|
||||
option_section = 1
|
||||
key = "LookSensitivity"
|
||||
section = "InputSettings"
|
||||
default_value = 1.1
|
||||
|
||||
[node name="OptionLabel" parent="VBoxContainer/MarginContainer/VBoxContainer/LookSensitivityControl" index="0" unique_id=1789907427]
|
||||
text = "Joystick Sensitivity :"
|
||||
@@ -44,8 +45,8 @@ text = "Joystick Sensitivity :"
|
||||
[node name="HSlider" parent="VBoxContainer/MarginContainer/VBoxContainer/LookSensitivityControl" index="1" unique_id=494926010]
|
||||
min_value = 0.2
|
||||
max_value = 2.0
|
||||
step = 0.2
|
||||
value = 0.6000000000000001
|
||||
step = 0.1
|
||||
value = 1.1
|
||||
tick_count = 10
|
||||
|
||||
[node name="MouseSensitivityControl" parent="VBoxContainer/MarginContainer/VBoxContainer" unique_id=1444662884 instance=ExtResource("2_iyvrj")]
|
||||
@@ -54,16 +55,17 @@ option_name = "Mouse Sensitivity"
|
||||
option_section = 1
|
||||
key = "MouseSensitivity"
|
||||
section = "InputSettings"
|
||||
default_value = 25.0
|
||||
|
||||
[node name="OptionLabel" parent="VBoxContainer/MarginContainer/VBoxContainer/MouseSensitivityControl" index="0" unique_id=1789907427]
|
||||
text = "Mouse Sensitivity :"
|
||||
|
||||
[node name="HSlider" parent="VBoxContainer/MarginContainer/VBoxContainer/MouseSensitivityControl" index="1" unique_id=494926010]
|
||||
min_value = 1.0
|
||||
max_value = 20.0
|
||||
max_value = 50.0
|
||||
step = 1.0
|
||||
value = 8.0
|
||||
tick_count = 20
|
||||
value = 25.0
|
||||
tick_count = 10
|
||||
|
||||
[node name="HeadBobbingControl" parent="VBoxContainer/MarginContainer/VBoxContainer" unique_id=1905029466 instance=ExtResource("2_iyvrj")]
|
||||
layout_mode = 2
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
using Godot;
|
||||
using Movementtests.systems;
|
||||
|
||||
[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png")]
|
||||
public partial class Inventory : Control
|
||||
{
|
||||
public PlayerController? Player { get; set; }
|
||||
|
||||
private AbilitySelection _startedFlyingSelection;
|
||||
private AbilitySelection _whileFlyingSelection;
|
||||
private AbilitySelection _stoppedFlyingSelection;
|
||||
public override void _Ready()
|
||||
{
|
||||
_startedFlyingSelection = GetNode<AbilitySelection>("%StartedFlying");
|
||||
_whileFlyingSelection = GetNode<AbilitySelection>("%WhileFlying");
|
||||
_stoppedFlyingSelection = GetNode<AbilitySelection>("%StoppedFlying");
|
||||
|
||||
_startedFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
_whileFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
_stoppedFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
}
|
||||
|
||||
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, string abilityName)
|
||||
{
|
||||
if (Player is null) return;
|
||||
Player.GrantWeaponExplosionAbilityForEvent(forEvent, abilityName);
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://7yil0fiftvaf
|
||||
81
menus/scenes/overlaid_menus/InventoryUi.cs
Normal file
81
menus/scenes/overlaid_menus/InventoryUi.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using System.Collections.Generic;
|
||||
using Gamesmiths.Forge.Effects;
|
||||
using Gamesmiths.Forge.Godot.Resources.Abilities;
|
||||
using Godot;
|
||||
using Movementtests.managers;
|
||||
using Movementtests.systems;
|
||||
|
||||
[Tool, GlobalClass, Icon("res://assets/ui/IconGodotNode/control/icon_crate.png")]
|
||||
public partial class InventoryUi : Control
|
||||
{
|
||||
private AbilitySelection _startedFlyingSelection;
|
||||
private AbilitySelection _whileFlyingSelection;
|
||||
private AbilitySelection _stoppedFlyingSelection;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_startedFlyingSelection = GetNode<AbilitySelection>("%StartedFlying");
|
||||
_whileFlyingSelection = GetNode<AbilitySelection>("%WhileFlying");
|
||||
_stoppedFlyingSelection = GetNode<AbilitySelection>("%StoppedFlying");
|
||||
|
||||
_startedFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying]);
|
||||
_whileFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
|
||||
_stoppedFlyingSelection.Initialize(InventoryManager.Instance.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
|
||||
|
||||
_startedFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
_whileFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
_stoppedFlyingSelection.AbilityAdded += AddAbilityForEvent;
|
||||
|
||||
_startedFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
|
||||
_whileFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
|
||||
_stoppedFlyingSelection.AbilityRemoved += RemoveAbilityForEvent;
|
||||
|
||||
InventoryManager.Instance.WeaponEventAbilityAdded += OnWeaponEventInventoryAdded;
|
||||
InventoryManager.Instance.WeaponEventAbilityRemoved += OnWeaponEventInventoryRemoved;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
InventoryManager.Instance.WeaponEventAbilityAdded -= OnWeaponEventInventoryAdded;
|
||||
InventoryManager.Instance.WeaponEventAbilityRemoved -= OnWeaponEventInventoryRemoved;
|
||||
base._ExitTree();
|
||||
}
|
||||
|
||||
public void AddAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
InventoryManager.Instance.AddAbilityForWeaponEvent(forEvent, abilityBehavior);
|
||||
}
|
||||
|
||||
public void RemoveAbilityForEvent(WeaponSystem.WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
InventoryManager.Instance.RemoveAbilityForWeaponEvent(forEvent, abilityBehavior);
|
||||
}
|
||||
|
||||
public void OnWeaponEventInventoryAdded(WeaponEventAbilityData data)
|
||||
{
|
||||
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
|
||||
|
||||
var selection = GetAbilitySelection(data.ForEvent);
|
||||
selection.AddSelectedAbility(abilityBehavior);
|
||||
}
|
||||
|
||||
public void OnWeaponEventInventoryRemoved(WeaponEventAbilityData data)
|
||||
{
|
||||
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
|
||||
|
||||
var selection = GetAbilitySelection(data.ForEvent);
|
||||
selection.RemoveSelectedAbility(abilityBehavior);
|
||||
}
|
||||
|
||||
public AbilitySelection GetAbilitySelection(WeaponSystem.WeaponEvent forEvent)
|
||||
{
|
||||
var abilitiesSelectionsMap = new Dictionary<WeaponSystem.WeaponEvent, AbilitySelection>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, _startedFlyingSelection },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, _stoppedFlyingSelection },
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, _whileFlyingSelection },
|
||||
};
|
||||
|
||||
return abilitiesSelectionsMap[forEvent];
|
||||
}
|
||||
}
|
||||
1
menus/scenes/overlaid_menus/InventoryUi.cs.uid
Normal file
1
menus/scenes/overlaid_menus/InventoryUi.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvwiftuay8jep
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://vu5kh5amnta" path="res://menus/scenes/overlaid_menus/inventory_wrapper.gd" id="1_yst23"]
|
||||
[ext_resource type="Script" uid="uid://1nf36h0gms3q" path="res://addons/maaacks_game_template/base/scripts/capture_focus.gd" id="2_ijoei"]
|
||||
[ext_resource type="Script" uid="uid://7yil0fiftvaf" path="res://menus/scenes/overlaid_menus/Inventory.cs" id="2_sb1gh"]
|
||||
[ext_resource type="Script" uid="uid://cvwiftuay8jep" path="res://menus/scenes/overlaid_menus/InventoryUi.cs" id="2_sb1gh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dmv685sskgh3l" path="res://menus/scenes/components/ability_selection.tscn" id="3_ijoei"]
|
||||
|
||||
[node name="InventoryWrapper" type="Control" unique_id=1853168495]
|
||||
|
||||
@@ -3,13 +3,10 @@
|
||||
class_name InventoryWrapper
|
||||
extends OverlaidMenu
|
||||
|
||||
@export var player: PlayerController
|
||||
|
||||
@onready var inventory: Control = %Inventory
|
||||
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint(): return
|
||||
inventory.Player = player
|
||||
|
||||
func _on_close_button_pressed() -> void:
|
||||
close()
|
||||
|
||||
@@ -30,6 +30,7 @@ Shaker="*uid://c7flmumgr5w3u"
|
||||
CsgToolkitAutoload="*uid://w8ad8q4lneis"
|
||||
"Forge Bootstrap"="*uid://ba8fquhtwu5mu"
|
||||
GlobalHelpers="*uid://dqcm83o8e66a2"
|
||||
InventoryManager="*uid://cgwhrwfqsiing"
|
||||
|
||||
[display]
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ metadata/_custom_type_script = "uid://jitubgv6judn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_abfq8"]
|
||||
script = ExtResource("3_cb2lu")
|
||||
Modifier = 20.0
|
||||
Modifier = 5.0
|
||||
metadata/_custom_type_script = "uid://b44cse62qru7j"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ue7xq"]
|
||||
|
||||
@@ -240,9 +240,9 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
Events.Subscribe(WeaponStoppedFlyingEventTag, _ => { _weaponFlyingAbility.Cancel(); });
|
||||
}
|
||||
|
||||
private List<ActiveEffectHandle> _grantedWeaponStartedFlyingAbilities = new List<ActiveEffectHandle>();
|
||||
private List<ActiveEffectHandle> _grantedWeaponStoppedFlyingAbilities = new List<ActiveEffectHandle>();
|
||||
private List<ActiveEffectHandle> _grantedWeaponFlyingTickAbilities = new List<ActiveEffectHandle>();
|
||||
private Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> _grantedWeaponStartedFlyingAbilities = new ();
|
||||
private Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> _grantedWeaponStoppedFlyingAbilities = new ();
|
||||
private Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> _grantedWeaponFlyingTickAbilities = new ();
|
||||
|
||||
public enum WeaponEvent
|
||||
{
|
||||
@@ -253,12 +253,9 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
|
||||
public void GrantNewAbilityForEvent(WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var abilitiesMap = new Dictionary<WeaponEvent, List<ActiveEffectHandle>>
|
||||
{
|
||||
{ WeaponEvent.StartedFlying, _grantedWeaponStartedFlyingAbilities },
|
||||
{ WeaponEvent.StoppedFlying, _grantedWeaponStoppedFlyingAbilities },
|
||||
{ WeaponEvent.FlyingTick, _grantedWeaponFlyingTickAbilities },
|
||||
};
|
||||
var relevantMap = GetGrantedAbilities(forEvent);
|
||||
GD.Print($"Granted {abilityBehavior} for {forEvent}");
|
||||
if (relevantMap.ContainsKey(abilityBehavior)) return;
|
||||
|
||||
var eventTagsMap = new Dictionary<WeaponEvent, Tag>
|
||||
{
|
||||
@@ -288,10 +285,28 @@ public partial class WeaponSystem : RigidBody3D, IDamageDealer, IForgeEntity
|
||||
effectComponents: [leftGrantComponent]);
|
||||
var effectHandle = EffectsManager.ApplyEffect(new Effect(leftGrantEffect, new EffectOwnership(this, this)));
|
||||
if (effectHandle == null) return;
|
||||
|
||||
abilitiesMap[forEvent].Add(effectHandle);
|
||||
relevantMap[abilityBehavior] = effectHandle;
|
||||
}
|
||||
|
||||
public void RemoveAbilityForEvent(WeaponEvent forEvent, ForgeAbilityBehavior abilityBehavior)
|
||||
{
|
||||
var relevantMap = GetGrantedAbilities(forEvent);
|
||||
if (!relevantMap.TryGetValue(abilityBehavior, out var effectHandle)) return;
|
||||
EffectsManager.RemoveEffect(effectHandle);
|
||||
relevantMap.Remove(abilityBehavior);
|
||||
}
|
||||
|
||||
public Dictionary<ForgeAbilityBehavior, ActiveEffectHandle> GetGrantedAbilities(WeaponEvent forEvent)
|
||||
{
|
||||
var abilitiesMap = new Dictionary<WeaponEvent, Dictionary<ForgeAbilityBehavior, ActiveEffectHandle>>
|
||||
{
|
||||
{ WeaponEvent.StartedFlying, _grantedWeaponStartedFlyingAbilities },
|
||||
{ WeaponEvent.StoppedFlying, _grantedWeaponStoppedFlyingAbilities },
|
||||
{ WeaponEvent.FlyingTick, _grantedWeaponFlyingTickAbilities },
|
||||
};
|
||||
|
||||
return abilitiesMap[forEvent];
|
||||
}
|
||||
|
||||
|
||||
public void WeaponLeft()
|
||||
{
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://duju3atqgltkg" path="res://scenes/explosion/explosion.tscn" id="1_mnals"]
|
||||
[ext_resource type="Script" uid="uid://bnee6amtc2bhj" path="res://forge/abilities/ForgeExplodingSwordBehavior.cs" id="1_ot53g"]
|
||||
[ext_resource type="Texture2D" uid="uid://c2akxlg7tdb67" path="res://assets/ui/IconGodotNode/node/icon_projectile.png" id="2_l3coe"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ot53g")
|
||||
Explosion = ExtResource("1_mnals")
|
||||
Name = "Exploding Sword"
|
||||
Description = "Make the sword explode"
|
||||
Icon = ExtResource("2_l3coe")
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
[resource]
|
||||
script = ExtResource("2_f5qgs")
|
||||
EffectData = ExtResource("1_hlq5f")
|
||||
Name = "Flying tick application"
|
||||
metadata/_custom_type_script = "uid://cl5hudinl1rex"
|
||||
|
||||
@@ -28,6 +28,7 @@ using Movementtests.player_controller.Scripts;
|
||||
using Movementtests.scenes.player_controller.scripts;
|
||||
using Movementtests.tools;
|
||||
using Movementtests.forge.abilities;
|
||||
using Movementtests.managers;
|
||||
using Movementtests.tools.calculators;
|
||||
using RustyOptions;
|
||||
using Node = Godot.Node;
|
||||
@@ -715,6 +716,10 @@ public partial class PlayerController : CharacterBody3D,
|
||||
_parryStandard.StateEntered += OnStandardParryStarted;
|
||||
_parryDash.StateEntered += OnDashParryStarted;
|
||||
|
||||
// Inventory Management
|
||||
InventoryManager.Instance.WeaponEventAbilityAdded += OnWeaponEventAbilityAdded;
|
||||
InventoryManager.Instance.WeaponEventAbilityRemoved += OnWeaponEventAbilityRemoved;
|
||||
|
||||
// Forge events
|
||||
var weaponLeftToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStartedFlyingEventTag, OnWeaponLeft);
|
||||
var weaponLandedToken = WeaponSystem.Events.Subscribe(WeaponSystem.WeaponStoppedFlyingEventTag, OnWeaponLanded);
|
||||
@@ -747,9 +752,18 @@ public partial class PlayerController : CharacterBody3D,
|
||||
out var failures);
|
||||
}
|
||||
|
||||
public void GrantWeaponExplosionAbilityForEvent(WeaponSystem.WeaponEvent forEvent, string abilityName)
|
||||
public void OnWeaponEventAbilityAdded(WeaponEventAbilityData data)
|
||||
{
|
||||
WeaponSystem.GrantNewAbilityForEvent(forEvent, WeaponExplosionBehavior);
|
||||
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
|
||||
|
||||
WeaponSystem.GrantNewAbilityForEvent(data.ForEvent, abilityBehavior);
|
||||
}
|
||||
|
||||
public void OnWeaponEventAbilityRemoved(WeaponEventAbilityData data)
|
||||
{
|
||||
if (data.Ability is not ForgeAbilityBehavior abilityBehavior) return;
|
||||
|
||||
WeaponSystem.RemoveAbilityForEvent(data.ForEvent, abilityBehavior);
|
||||
}
|
||||
|
||||
///////////////////////////
|
||||
@@ -1158,7 +1172,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
var tween = GetTree().CreateTween();
|
||||
tween.SetParallel();
|
||||
tween.SetTrans(Tween.TransitionType.Cubic);
|
||||
tween.SetEase(Tween.EaseType.InOut);
|
||||
tween.SetEase(Tween.EaseType.In);
|
||||
tween.TweenProperty(this, "global_position", targetLocation, tweenTime);
|
||||
|
||||
return tween;
|
||||
@@ -1919,6 +1933,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
///////////////////////////
|
||||
// Slam Management ///////
|
||||
///////////////////////////
|
||||
|
||||
private Vector3 _slamStartPosition = Vector3.Zero;
|
||||
public void OnInputSlamPressed()
|
||||
{
|
||||
_playerState.SendEvent("slam");
|
||||
@@ -1926,6 +1942,7 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
public void SlamStarted()
|
||||
{
|
||||
_slamStartPosition = GlobalPosition;
|
||||
SetHorizontalVelocity(Vector2.Zero);
|
||||
SetVerticalVelocity(-SlamSpeed);
|
||||
_audioStream.SwitchToClipByName("dash");
|
||||
@@ -1936,11 +1953,16 @@ public partial class PlayerController : CharacterBody3D,
|
||||
}
|
||||
public void SlamEnded()
|
||||
{
|
||||
var distanceTraveled = GlobalPosition.DistanceTo(_slamStartPosition);
|
||||
HeadSystem.OnGetHit();
|
||||
_audioStream.SwitchToClipByName("slam");
|
||||
|
||||
if (Explosion.Instantiate() is not Explosion explosion) return;
|
||||
explosion.Radius = 10f;
|
||||
|
||||
// Basic distance traveled explosion manipulation
|
||||
explosion.Radius = distanceTraveled;
|
||||
explosion.RDamage.DamageDealt = distanceTraveled;
|
||||
|
||||
GetTree().GetRoot().AddChild(explosion);
|
||||
explosion.GlobalPosition = GlobalPosition;
|
||||
}
|
||||
@@ -2020,8 +2042,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
|
||||
public void OnAimingEntered()
|
||||
{
|
||||
if (!CanPerformEmpoweredAction())
|
||||
return;
|
||||
// if (!CanPerformEmpoweredAction())
|
||||
// return;
|
||||
|
||||
// DashIndicatorMesh.Visible = true;
|
||||
if (!isOnFloorCustom())
|
||||
@@ -2035,8 +2057,8 @@ public partial class PlayerController : CharacterBody3D,
|
||||
// DashIndicatorMeshCylinder.Height = DashSystem.PlannedLocation.DistanceTo(GlobalPosition);
|
||||
// DashIndicatorNode.LookAt(DashSystem.PlannedLocation);
|
||||
|
||||
if (CanPerformEmpoweredAction())
|
||||
DashSystem.PrepareDash();
|
||||
// if (CanPerformEmpoweredAction())
|
||||
DashSystem.PrepareDash();
|
||||
}
|
||||
public void OnAimingExited()
|
||||
{
|
||||
@@ -2296,13 +2318,13 @@ public partial class PlayerController : CharacterBody3D,
|
||||
// Manage gameplay systems
|
||||
MantleSystem.ProcessMantle(_grounded.Active);
|
||||
HandleEnemyTargeting();
|
||||
// Manage head and camera movement
|
||||
LookAround(delta);
|
||||
}
|
||||
|
||||
// private float _oldMana = 100;
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
// Manage head and camera movement
|
||||
LookAround(delta);
|
||||
EffectsManager.UpdateEffects(delta);
|
||||
}
|
||||
|
||||
@@ -2486,22 +2508,23 @@ public partial class PlayerController : CharacterBody3D,
|
||||
if (!HasSword) return;
|
||||
|
||||
if (_onWallHanging.Active) return;
|
||||
|
||||
if (_aiming.Active && WeaponSystem.InHandState.Active && CanPerformEmpoweredAction())
|
||||
|
||||
if (_aiming.Active && WeaponSystem.InHandState.Active)
|
||||
{
|
||||
ThrowWeapon();
|
||||
return;
|
||||
}
|
||||
if (WeaponSystem.FlyingState.Active)
|
||||
if (WeaponSystem.FlyingState.Active && CanPerformEmpoweredAction())
|
||||
{
|
||||
DashToFlyingWeapon();
|
||||
return;
|
||||
}
|
||||
if (WeaponSystem.PlantedState.Active)
|
||||
if (WeaponSystem.PlantedState.Active && CanPerformEmpoweredAction())
|
||||
{
|
||||
DashToPlantedWeapon();
|
||||
return;
|
||||
}
|
||||
if (!WeaponSystem.InHandState.Active) return;
|
||||
|
||||
var attackToDo = _isEnemyInDashAttackRange ? "dash_attack" : "standard_attack";
|
||||
_playerState.SendEvent(attackToDo);
|
||||
|
||||
@@ -38,7 +38,7 @@ func open_toolbox() -> void:
|
||||
|
||||
func open_inventory() -> void:
|
||||
var inventory: Control = open_overlaid_menu(inventory_scene)
|
||||
inventory.player = player
|
||||
# inventory.player = player
|
||||
inventory_layer.call_deferred("add_child", inventory)
|
||||
|
||||
func on_player_died() -> void:
|
||||
|
||||
Reference in New Issue
Block a user