mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:05:34 +00:00
51 lines
No EOL
1.8 KiB
C#
51 lines
No EOL
1.8 KiB
C#
using Cirno.Scripts.Components.FSM;
|
|
using Cirno.Scripts.Components.FSM.Player;
|
|
using Cirno.Scripts.Controllers;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Resources.ItemEffects;
|
|
|
|
[GlobalClass]
|
|
[Tool]
|
|
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()
|
|
{
|
|
|
|
var bullet = PoolingManager.Instance.SpawnBullet<Bullet>(item.WeaponData.BulletData);
|
|
bullet.GlobalPosition = parent.Machine.MainObject.GlobalPosition;
|
|
|
|
//var bullet = parent.CreateChildOf<Bullet>(GameManager.Instance.BulletsContainer, item.WeaponData.BulletData.BulletScene, parent.GlobalPosition);
|
|
|
|
var bulletData = item.WeaponData.MakeBullet(parent.Machine.MainObject.GlobalPosition);
|
|
|
|
bullet.Initialize(bulletData);
|
|
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;
|
|
}
|
|
}
|
|
} |