Cheat buttons

This commit is contained in:
Marco 2025-03-12 16:31:53 +01:00
commit e637f69ce6
7 changed files with 98 additions and 16 deletions

View file

@ -1,4 +1,5 @@
using System;
using Cirno.Scripts.Components.Actors;
using Cirno.Scripts.Resources;
using Godot;
@ -6,6 +7,12 @@ namespace Cirno.Scripts.Components.FSM.Player;
public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterBody2D>
{
[Export]
public ActorResourceProvider Health { get; set; }
[Export]
public ActorResourceProvider Shield { get; set; }
public bool Enabled { get; set; } = false;
public override void EnterState(PlayerState state)
@ -43,15 +50,18 @@ public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterB
case ItemTypes.Ammo:
break;
case ItemTypes.Medkit:
Heal(item);
break;
case ItemTypes.FrogBomb:
SpawnSpiderBomb(item);
break;
case ItemTypes.Bomb:
SpawnBomb(item);
break;
case ItemTypes.Mine:
break;
case ItemTypes.Battery:
RechargeShield(item);
break;
case ItemTypes.Weapon:
break;
@ -67,6 +77,21 @@ public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterB
}
private void SpawnBomb(LootItem item)
{
GD.Print("Spawned bomb");
}
private void Heal(LootItem item)
{
Health.CurrentResource += Mathf.CeilToInt(Health.MaxResource * 25 / 100);
}
private void RechargeShield(LootItem item)
{
Shield.CurrentResource += Mathf.CeilToInt(Health.MaxResource * 25 / 100);
}
private void SpawnSpiderBomb(LootItem item)
{
//var bullet = item.WeaponData.BulletData.BulletScene.Instantiate<Bullet>();