public void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag(Tags.Hitbox)) { if (_context.OwnershipService.Contains(collision.gameObject)) { IThrowableObject throwableObject = collision.GetComponent <IThrowableObject>(); if (throwableObject.CanPick) { PickUpObject(collision.gameObject); } } } }
public void UseObject(Vector3 direction) { if (counter > 0) { counter--; Transform obj = _poolSystem.Spawn(_throwableObjectPoolStats, _context.Transform.position + _context.Transform.right, Quaternion.identity); _context.OwnershipService.Add(obj.gameObject); IThrowableObject throwableObject = obj.GetComponent <IThrowableObject>(); if (_context.isPowerupActive) { throwableObject.PrepareForPowerup(); } throwableObject.Throw(_throwingForce, direction.normalized); } _messageBus.RaiseEvent(new OnAttackToggled(_context.CharacterId, _context.PlayerId, false)); }