public void CollisionCheck_ignores_hurtboxes_on_inactive_gameobjects() { var hitbox = CreateHitbox().WithRadius(1.5f).Build(); CreateHurtbox().WithPosition(-0.5f * Vector3.up).WithRadius(0.5f); CreateHurtbox().WithPosition(0.5f * Vector3.up).WithRadius(0.5f).WithActive(false); CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.right; Assert.AreEqual(1, HitboxUtil.CollisionCheck(hitbox, new Hurtbox[10])); }
public void CollisionCheck_ignores_disabled_hurtboxes() { var hitbox = CreateHitbox().WithOffset(Vector3.one).WithRadius(1.5f).Build(); CreateHurtbox().WithPosition(-0.5f * Vector3.up).WithRadius(0.5f).WithEnabled(false); CreateHurtbox().WithPosition(0.5f * Vector3.up).WithRadius(0.5f); CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.right; Assert.AreEqual(1, HitboxUtil.CollisionCheck(hitbox, new Hurtbox[10])); }
public void CollisionCheck_returns_zero_if_colliders_has_no_hurtboxes() { var hitbox = CreateHitbox().WithOffset(Vector3.one).WithRadius(0.5f).Build(); CreateObject <SphereCollider>().transform.position = -0.5f * Vector3.up; CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.up; CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.right; Assert.AreEqual(0, HitboxUtil.CollisionCheck(hitbox, new Hurtbox[10])); }
public void CollisionCheck_returns_number_of_collided_hurtboxes() { var hitbox = CreateHitbox().WithRadius(1.5f).Build(); var h1 = CreateHurtbox().WithPosition(-0.5f * Vector3.up).WithRadius(0.5f).Build(); var h2 = CreateHurtbox().WithPosition(0.5f * Vector3.up).WithRadius(0.5f).Build(); CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.right; var hurtboxes = new Hurtbox[10]; Assert.AreEqual(2, HitboxUtil.CollisionCheck(hitbox, hurtboxes)); CollectionAssert.AreEquivalent(new[] { h1, h2 }, hurtboxes.Take(2)); }
public void CollisionCheck_returns_non_null_hurtboxes() { var hitbox = CreateHitbox().WithRadius(1.5f).Build(); CreateHurtbox().WithPosition(-0.5f * Vector3.up).WithRadius(0.5f); CreateHurtbox().WithPosition(0.5f * Vector3.up).WithRadius(0.5f); CreateObject <SphereCollider>().transform.position = 0.5f * Vector3.right; var hurtboxes = new Hurtbox[10]; var count = HitboxUtil.CollisionCheck(hitbox, hurtboxes); Assert.AreEqual(2, count); Assert.That(hurtboxes.Take(count), Is.Not.Null); }
public void CreateCollisions() { var hurtboxes = ArrayPool <Hurtbox> .Shared.Rent(256); foreach (var hitbox in ActiveHitboxes) { var hurtboxCount = HitboxUtil.CollisionCheck(hitbox, hurtboxes); for (var i = 0; i < hurtboxCount; i++) { if (!ActiveHurtboxes.Contains(hurtboxes[i])) { continue; } var collision = new HitboxCollision { Source = hitbox, Destination = hurtboxes[i] }; CollisionManager.Add(collision); } } ArrayPool <Hurtbox> .Shared.Return(hurtboxes); }
public void CollisionCheck_returns_zero_if_no_nearby_colliders() { var hitbox = CreateHitbox().WithOffset(Vector3.one).WithRadius(0.5f).Build(); Assert.AreEqual(0, HitboxUtil.CollisionCheck(hitbox, new Hurtbox[10])); }