mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 22:05:55 +00:00
Bullets pooling
This commit is contained in:
parent
37bcf8b2d0
commit
fa3805ecfe
18 changed files with 280 additions and 69 deletions
|
|
@ -8,6 +8,7 @@ using Cirno.Scripts.Components.Actors;
|
|||
using Cirno.Scripts.Resources;
|
||||
using Godot.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Controllers;
|
||||
|
||||
public partial class PlayerMovement : CharacterBody2D, IDestructible
|
||||
{
|
||||
|
|
@ -229,10 +230,14 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
_inventoryManager.RemoveItem(item.ItemKey, 1);
|
||||
// emit projectile
|
||||
var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, item.WeaponData.BulletData.BulletScene, this.GlobalPosition);
|
||||
|
||||
var bulletData = item.WeaponData.MakeBullet(this.GlobalPosition);
|
||||
|
||||
var bullet = PoolingManager.Instance.SpawnBullet(bulletData.OriginalBulletResource);
|
||||
|
||||
bullet.GlobalPosition = this.GlobalPosition;
|
||||
|
||||
//var bullet = this.CreateChildOf<Bullet>(_gameManager.BulletsContainer, item.WeaponData.BulletData.BulletScene, this.GlobalPosition);
|
||||
|
||||
bullet.Initialize(bulletData, _gameManager);
|
||||
|
||||
//bullet.SetDirection(ShootDirection);
|
||||
|
|
@ -572,6 +577,7 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
if (!_canMove) return;
|
||||
if (area is Bullet bullet && bullet.BulletOwner != BulletGroup)
|
||||
{
|
||||
if (!bullet.Enabled) return;
|
||||
this.Hit(bullet.Damage, bullet.DamageType);
|
||||
bullet.RequestCollisionDestruction();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue