43 lines
987 B
C#
43 lines
987 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using Unity.Mathematics;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Scene
|
|
{
|
|
public class DestructibleCollider : MonoBehaviour,IDamagable,ISceneBlockArea
|
|
{
|
|
[SerializeField] private int health;
|
|
[SerializeField] private new Collider collider;
|
|
|
|
public IHealth Health => null;
|
|
public IUnityEntity UnityEntity => null;
|
|
public Rigidbody Rigidbody => null;
|
|
public void GiveDamage(DamageMessage message)
|
|
{
|
|
health -= message.Damage;
|
|
}
|
|
public bool IsBlocked=>health>0;
|
|
|
|
public bool InRange(float3 position)
|
|
{
|
|
return collider.bounds.Contains(position);
|
|
}
|
|
|
|
public bool InRange(float3 position, float3 direction)
|
|
{
|
|
var ray = new Ray(position, direction);
|
|
if (collider.Raycast(ray, out var hit, 1))
|
|
{
|
|
Debug.DrawLine(position,hit.point,Color.red,1);
|
|
return true;
|
|
}
|
|
Debug.DrawLine(position,position+direction,Color.blue,1);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|