Clean up events, add weapon tag for weaker on swing
This commit is contained in:
@@ -17,6 +17,8 @@ public interface IEquipmentComponent : IEntityComponent
|
||||
|
||||
public bool IsItemEquipped(InventoryItem item);
|
||||
|
||||
public void UpdateEquipment(EquipableItem equipable);
|
||||
|
||||
public int BonusAttack { get; }
|
||||
|
||||
public int BonusDefense { get; }
|
||||
|
||||
@@ -9,5 +9,6 @@ public enum WeaponTag
|
||||
Knockback,
|
||||
InverseHPAttackPower,
|
||||
RustChanceSelfAndEnemy,
|
||||
Instakill
|
||||
Instakill,
|
||||
DegradeOnSwing
|
||||
}
|
||||
|
||||
@@ -76,4 +76,6 @@ public class EquipmentComponent : IEquipmentComponent
|
||||
|
||||
return item == _equippedWeapon.Value || item == _equippedArmor.Value || item == _equippedAccessory.Value;
|
||||
}
|
||||
|
||||
public void UpdateEquipment(EquipableItem equipable) => EquipmentChanged?.Invoke(equipable);
|
||||
}
|
||||
|
||||
@@ -261,6 +261,13 @@ public partial class App : Node, IApp
|
||||
|
||||
MainMenu.StartGame -= OnStartGame;
|
||||
MainMenu.EnemyViewer -= OnEnemyViewer;
|
||||
MainMenu.Gallery -= OnGallery;
|
||||
MainMenu.Options -= OnOptions;
|
||||
MainMenu.Quit -= OnQuit;
|
||||
|
||||
GalleryMenu.GalleryExited -= GalleryExited;
|
||||
|
||||
OptionsMenu.OptionsMenuExited -= OptionsMenu_OptionsMenuExited;
|
||||
OptionsMenu.DeleteSaveData -= DeleteSaveData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,16 @@ public partial class DataViewer : Control, IDataViewer
|
||||
DisplayEnemy();
|
||||
}
|
||||
|
||||
public void OnEnterTree() => GetTree().Paused = false;
|
||||
public void OnEnterTree()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
}
|
||||
|
||||
public void OnExitTree() => GetTree().Paused = false;
|
||||
public void OnExitTree()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
BackButton.Pressed -= BackButton_Pressed;
|
||||
}
|
||||
|
||||
private void BackButton_Pressed() => AppRepo.OnDataViewerExited();
|
||||
|
||||
|
||||
@@ -39,4 +39,10 @@ public partial class BossAModelView : EnemyModelView3D, INode3D
|
||||
ExplodingModel.Show();
|
||||
DeathAnimation.Play("Animation");
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
DeathAnimation.AnimationFinished -= DeathAnimation_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,5 +180,6 @@ public partial class BossTypeA : Enemy, IHaveEngagePlayerBehavior, IHaveFollowBe
|
||||
EngagePlayerBehavior.TakeAction -= PerformAction;
|
||||
PlayerDetector.BodyEntered -= PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
(EnemyModelView as BossAModelView).OnDeathAnimationCompleted -= EnemyModelView3D_OnDeathAnimationCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,4 +69,10 @@ public abstract partial class Enemy2D : Enemy
|
||||
if (body is IPlayer)
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Alert());
|
||||
}
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
LineOfSight.BodyEntered -= LineOfSight_BodyEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,5 +129,6 @@ public abstract partial class EnemyModelView : Node3D, IEnemyModelView
|
||||
{
|
||||
if (AnimationTree != null)
|
||||
AnimationTree.Get(_parametersPlayback).As<AnimationNodeStateMachinePlayback>().Stop();
|
||||
AnimationTree.AnimationFinished -= AnimationTree_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,16 @@ public partial class Michael : Enemy2D, IHavePatrolBehavior, IHaveEngagePlayerBe
|
||||
_enemyLogic.Input(new EnemyLogic.Input.Patrol());
|
||||
}
|
||||
|
||||
|
||||
public override void Move() => EnemyModelView.PlayIdleAnimation();
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
PatrolBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
FollowBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
EngagePlayerBehavior.TakeAction -= EngagePlayerBehavior_TakeAction;
|
||||
EngagePlayerBehavior.AcquireTarget -= EngagePlayerBehavior_AcquireTarget;
|
||||
PlayerDetector.BodyEntered -= PlayerDetector_BodyEntered;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,12 @@ public partial class GoldSproingy : Enemy2D, IHavePatrolBehavior, IHaveFleeBehav
|
||||
}
|
||||
|
||||
public override void Move() => EnemyModelView.PlayIdleAnimation();
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
PatrolBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
PlayerDetector.BodyExited -= PlayerDetector_BodyExited;
|
||||
FleeBehavior.OnVelocityComputed -= OnVelocityComputed;
|
||||
PlayerDetector.BodyEntered -= GoldSproingyFlee;
|
||||
}
|
||||
}
|
||||
@@ -52,4 +52,9 @@ public partial class DemonWall : Enemy3D
|
||||
{
|
||||
EnemyModelView.Attack(_maximumWallMoveAmount);
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_attackTimer.Timeout -= AttackTimer_Timeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,9 @@ public partial class DemonWallArm : EnemyModelView
|
||||
if (target is IPlayer player)
|
||||
base.OnPlayerHit(new AttackEventArgs(AttackData));
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,13 +608,21 @@ public partial class Game : Node3D, IGame
|
||||
LoadNextLevel.Exit -= FloorClearMenu_Exit;
|
||||
LoadNextLevel.TransitionCompleted -= FloorClearMenu_TransitionCompleted;
|
||||
|
||||
_player.Inventory.BroadcastMessage -= BroadcastMessage;
|
||||
OnLoadLevelRequest -= LoadLevel;
|
||||
|
||||
GameRepo.RestorativePickedUp -= GameEventDepot_RestorativePickedUp;
|
||||
GameRepo.CloseInventoryEvent -= ExitInventoryAction;
|
||||
|
||||
_player.Inventory.BroadcastMessage -= BroadcastMessage;
|
||||
|
||||
_map.FloorLoaded -= OnFloorLoadFinished;
|
||||
|
||||
_player.PlayerDied -= GameOver;
|
||||
GameOverMenu.NewGame -= OnNewGame;
|
||||
GameOverMenu.QuitGame -= OnQuit;
|
||||
|
||||
PauseMenu.ExitGamePressed -= OnQuit;
|
||||
|
||||
GameRepo.IsPaused.Sync -= IsPaused_Sync;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,9 @@ public partial class ItemRescue : Area3D
|
||||
|
||||
BodyEntered -= OnItemRescueEntered;
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
BodyEntered -= OnItemRescueEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,4 +54,10 @@ public partial class SetItem : RigidBody3D
|
||||
{
|
||||
_stateMachine.Travel("timer");
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
ExplosionArea.AreaEntered -= ExplosionArea_AreaEntered;
|
||||
AnimationTree.AnimationFinished -= AnimationTree_AnimationFinished;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,4 +127,10 @@ public partial class ThrownItem : RigidBody3D, IThrownItem
|
||||
enemy.HealthComponent.Damage(damageDealt);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
BodyEntered -= ThrownItem_BodyEntered;
|
||||
Collision.AreaEntered -= Collision_AreaEntered;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,9 @@ public partial class Weapon : EquipableItem
|
||||
public void OnReady()
|
||||
{
|
||||
_sprite.Texture = Stats.Texture;
|
||||
_bonusDamage = Stats.BonusAttack;
|
||||
_bonusDefense = Stats.BonusDefense;
|
||||
_bonusLuck = Stats.BonusLuck;
|
||||
}
|
||||
|
||||
public override string ItemName => Stats.Name;
|
||||
@@ -51,11 +54,11 @@ public partial class Weapon : EquipableItem
|
||||
|
||||
public void SetWeaponDefense(int newBonus) => _bonusDefense = newBonus;
|
||||
|
||||
public override int BonusAttack { get => Stats.BonusAttack + _bonusDamage; }
|
||||
public override int BonusAttack { get => _bonusDamage; }
|
||||
|
||||
public override int BonusDefense { get => Stats.BonusDefense + _bonusDefense; }
|
||||
public override int BonusDefense { get => _bonusDefense; }
|
||||
|
||||
public override int BonusLuck { get => Stats.BonusLuck + _bonusLuck; }
|
||||
public override int BonusLuck { get => _bonusLuck; }
|
||||
|
||||
[Save("weapon_bonus_damage")]
|
||||
private int _bonusDamage { get; set; } = 0;
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
script = ExtResource("2_vrork")
|
||||
AttackSpeed = 0.75
|
||||
WeaponElement = 0
|
||||
WeaponTag = 0
|
||||
WeaponTag = 8
|
||||
SelfDamage = 0
|
||||
SoundEffect = 23
|
||||
Name = "Shining Halberd"
|
||||
Description = "Weapon that gradually becomes weaker."
|
||||
SpawnRate = 0.3
|
||||
BonusAttack = 8
|
||||
BonusDefense = 0
|
||||
BonusLuck = 0.05
|
||||
BonusLuck = 5
|
||||
BonusHP = 0
|
||||
BonusVT = 0
|
||||
AeolicResistance = 0
|
||||
|
||||
@@ -20,4 +20,9 @@ public partial class UnlockableDoor : Node3D, IDoor
|
||||
foreach (var child in children)
|
||||
child.QueueFree();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
UnlockArea.AreaEntered -= UnlockArea_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,4 +61,10 @@ public partial class Altar : SpecialFloor, IDungeonFloor
|
||||
}
|
||||
|
||||
public void ExitReached() => Game.FloorExitReached();
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
NoExitArea.AreaEntered -= NoExitArea_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,4 +72,12 @@ public partial class BossRoomA : SpecialFloor, IBossRoom, IDungeonFloor
|
||||
}
|
||||
|
||||
public override (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (PlayerSpawn.Rotation, new Vector3(PlayerSpawn.GlobalPosition.X, -2.5f, PlayerSpawn.GlobalPosition.Z)); }
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
ActivateTrap.BodyEntered -= ActivateTrap_BodyEntered;
|
||||
_exit.AreaEntered -= Exit_AreaEntered;
|
||||
OxFace.HealthComponent.HealthReachedZero -= CheckForBossFightEnd;
|
||||
HorseHead.HealthComponent.HealthReachedZero -= CheckForBossFightEnd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Collections.Immutable;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
@@ -47,4 +46,10 @@ public partial class BossRoomB : SpecialFloor, IBossRoom, IDungeonFloor
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
ActivateTrap.BodyEntered -= ActivateTrap_AreaEntered;
|
||||
_exit.AreaEntered -= Exit_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,9 @@ public partial class CorridorRoom : Node3D
|
||||
if (!Game.CurrentFloor.FloorIsLoaded)
|
||||
return;
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_room.BodyEntered -= Room_BodyEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,10 @@ public partial class ExitRoom : DungeonRoom
|
||||
if (area.GetOwner() is IPlayer)
|
||||
ExitReached();
|
||||
}
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
_exit.AreaEntered -= Exit_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
@@ -24,4 +25,9 @@ public partial class FinalFloor : SpecialFloor
|
||||
{
|
||||
_player.Die();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,10 @@ public partial class JumpScareRoom : DungeonRoom
|
||||
DialogueController.ShowDialogue(Dialogue, "general");
|
||||
JumpScare.SetMonitoring(false);
|
||||
}
|
||||
|
||||
public new void OnExitTree()
|
||||
{
|
||||
base.OnExitTree();
|
||||
JumpScare.AreaEntered -= JumpScare_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,4 +85,12 @@ public partial class Overworld : SpecialFloor, IDungeonFloor
|
||||
|
||||
public override (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() { return (PlayerSpawnPoint.Rotation, new Vector3(PlayerSpawnPoint.GlobalPosition.X, 2.4f, PlayerSpawnPoint.GlobalPosition.Z)); }
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Exit.AreaEntered -= Exit_AreaEntered;
|
||||
RestoreArea.AreaEntered -= RestoreArea_AreaEntered;
|
||||
RestoreArea.AreaExited -= RestoreArea_AreaExited;
|
||||
RestoreTimer.Timeout -= RestoreTimer_Timeout;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,9 @@ public partial class MapRevealerCube : Node3D
|
||||
}
|
||||
|
||||
private void Area3D_AreaEntered(Area3D area) => MeshInstance3D.Hide();
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
Area3D.AreaEntered -= Area3D_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,9 @@ public partial class Minimap : Control
|
||||
{
|
||||
LayerNumberText.Text = $"{obj:D2}";
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
_map.CurrentFloorNumber.Sync -= CurrentFloorNumber_Sync;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,14 +71,11 @@ public partial class Npc : Node3D
|
||||
}
|
||||
}
|
||||
|
||||
public partial class Gesthemii : Npc
|
||||
public void OnExitTree()
|
||||
{
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
if (@event.IsActionPressed(GameInputs.Interact) && _isInDialogueZone)
|
||||
{
|
||||
DialogueController.ShowDialogue(Dialogue, "general");
|
||||
}
|
||||
}
|
||||
DialogueZone.BodyEntered -= DialogueZone_BodyEntered;
|
||||
DialogueZone.BodyExited -= DialogueZone_BodyExited;
|
||||
DialogueExitZone.BodyExited -= DialogueExitZone_BodyExited;
|
||||
Hitbox.AreaEntered -= Hitbox_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,6 +323,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
AnimationPlayer.Play("hit_wall");
|
||||
else if (!AnimationPlayer.IsPlaying())
|
||||
PlayAttackAnimation();
|
||||
else
|
||||
return;
|
||||
|
||||
var weapon = EquipmentComponent.EquippedWeapon.Value as Weapon;
|
||||
if (weapon.WeaponTag == WeaponTag.DegradeOnSwing)
|
||||
_playerEffectService.Degrade();
|
||||
}
|
||||
|
||||
private void ThrowItem()
|
||||
@@ -367,6 +373,10 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
CollisionDetector.AreaEntered -= CollisionDetector_AreaEntered;
|
||||
HealthComponent.HealthReachedZero -= Die;
|
||||
HealthTimer.Timeout -= OnHealthTimerTimeout;
|
||||
HealthComponent.CurrentHP.Changed -= InverseHPToAttackPowerSync;
|
||||
HealthComponent.HealthReachedZero -= Die;
|
||||
ExperiencePointsComponent.PlayerLevelUp -= OnLevelUp;
|
||||
PlayerFXAnimations.AnimationFinished -= PlayerFXAnimations_AnimationFinished;
|
||||
}
|
||||
|
||||
private void Move(float delta)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Godot;
|
||||
using Zennysoft.Game.Ma;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
using Zennysoft.Ma.Adapter.Entity;
|
||||
|
||||
@@ -23,4 +24,12 @@ internal class PlayerEffectService
|
||||
if (rand <= _player.TotalLuck)
|
||||
enemy.Die();
|
||||
}
|
||||
|
||||
public void Degrade()
|
||||
{
|
||||
var weapon = _player.EquipmentComponent.EquippedWeapon.Value as Weapon;
|
||||
var newAttack = Mathf.Max(weapon.BonusAttack - 1, 0);
|
||||
weapon.SetWeaponAttack(newAttack);
|
||||
_player.EquipmentComponent.UpdateEquipment(weapon);
|
||||
}
|
||||
}
|
||||
@@ -22,4 +22,9 @@ public partial class QuestTest : Area3D
|
||||
Game.QuestData.QuestMarker1 = true;
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
{
|
||||
AreaEntered -= QuestTest_AreaEntered;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user