using System.Collections; using System.Collections.Generic; using System.Runtime.Remoting.Messaging; using BITFALL.Feel; using BITKit; using BITKit.Entities; using PaintIn3D; using UnityEngine; namespace BITFALL.Feel { public class EntityBloodDecal : EntityBehavior { [SerializeField] private P3dModel model; [SerializeField] private P3dPaintableTexture texture; [Inject] private IHealth _health; private bool isDead; public override void OnStart() { base.OnStart(); _health.OnDamageRelease += OnDamageRelease; _health.OnSetAlive += OnSetAlive; _health.OnDamageVoid += OnDamageVoid; } private void OnDamageVoid(DamageMessage obj) { if(_health.IsAlive) return; OnDamageRelease(obj); } private void OnSetAlive(bool obj) { if (obj) { texture.Clear(); } // switch (obj) // { // case true when isDead: // texture.Clear(); // break; // case false: // isDead = true; // break; // } } private void OnDamageRelease(DamageMessage obj) { if (obj.Hit is not EntityHitbox) return; if (obj.RaycastHit.HasValue is false) return; var raycastHit = obj.RaycastHit.Value; //var rotation = Quaternion.LookRotation(raycastHit.normal) * Quaternion.Euler(0, 180, 0); var rotation = Quaternion.LookRotation( obj.Position - raycastHit.point ) * Quaternion.Euler(0, 180, 0); BloodDecalService.Decal.TargetModel = model; BloodDecalService.Decal.TargetTexture = texture; BloodDecalService.Decal.HandleHitLine( false, 0, 1.0f, 0, raycastHit.point+raycastHit.normal*1, raycastHit.point-raycastHit.normal*1, rotation,true ); } } }