cirnogodot/Scripts/Resources/ItemEffects/SpiderbombEffectResource.cs

51 lines
1.8 KiB
C#
Raw Permalink Normal View History

using Cirno.Scripts.Components.FSM;
using Cirno.Scripts.Components.FSM.Player;
2025-06-08 16:33:38 +02:00
using Cirno.Scripts.Controllers;
2025-03-17 16:20:22 +01:00
using Godot;
namespace Cirno.Scripts.Resources.ItemEffects;
[GlobalClass]
[Tool]
2025-03-17 16:20:22 +01:00
public partial class SpiderbombEffectResource : ItemEffectResource
{
public override IITemEffectMachine Execute(PlayerFSMItemUseModule parent, LootItem item)
{
return new SpiderbombEffectmachine(this, parent, item).Execute();
}
public class SpiderbombEffectmachine(SpiderbombEffectResource resource, PlayerFSMItemUseModule parent, LootItem item) : IITemEffectMachine
{
public IITemEffectMachine Execute()
{
2025-06-08 16:33:38 +02:00
2025-06-17 11:57:59 +02:00
var bullet = PoolingManager.Instance.SpawnBullet<Bullet>(item.WeaponData.BulletData);
2025-06-10 16:33:43 +02:00
bullet.GlobalPosition = parent.Machine.MainObject.GlobalPosition;
2025-06-08 16:33:38 +02:00
//var bullet = parent.CreateChildOf<Bullet>(GameManager.Instance.BulletsContainer, item.WeaponData.BulletData.BulletScene, parent.GlobalPosition);
2025-03-17 16:20:22 +01:00
2025-06-10 16:33:43 +02:00
var bulletData = item.WeaponData.MakeBullet(parent.Machine.MainObject.GlobalPosition);
2025-03-17 16:20:22 +01:00
2025-06-19 17:55:23 +02:00
bullet.Initialize(bulletData);
2025-03-17 16:20:22 +01:00
bullet.SetDirection(parent.FacingDirection);
bullet.RotateSpriteDegrees(-90);
//bullet.SetDirection(_facingDirection);
bullet.Speed = item.WeaponData.BulletData.BulletSpeed;
parent.Machine.SetState(PlayerState.Controlling);
//RequestMovementDisable(true);
// set camera
GameManager.Instance.CameraTargetObject(bullet);
// set event destroy
bullet.OnDestroy += () =>
{
GameManager.Instance.CameraTargetPlayer();
parent.Machine.SetState(PlayerState.Active);
//RequestMovementDisable(false);
};
return this;
}
}
}