This commit is contained in:
CortexCore
2023-12-03 17:35:43 +08:00
parent ba342d6627
commit ba9f4eda80
702 changed files with 162078 additions and 21050 deletions

View File

@@ -3,41 +3,32 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BITFALL.Props;
using BITKit;
using BITKit.Entities;
using BITKit.Sensors;
using UnityEngine;
public class Prop_Grenade : MonoBehaviour
namespace BITFALL.Props
{
[SerializeReference, SubclassSelector] private ISensor rangeSensor;
[SerializeReference, SubclassSelector] private IReference[] vfxTags;
[SerializeField] private LayerMask physicsLayer;
[SerializeField] private float explosionRadius;
[SerializeField] private float fuse;
[SerializeField] private AnimationCurve damageCurve;
private async void Start()
public class Prop_Grenade : MonoBehaviour
{
try
[SerializeField] private float fuse;
private async void Start()
{
await Task.Delay(TimeSpan.FromSeconds(fuse), destroyCancellationToken);
}
catch (OperationCanceledException)
{
return;
}
DI.Get<VFXService>().Spawn(new Location(transform), vfxTags.Select(x => x.Value).ToArray());
foreach (var x in rangeSensor.Get())
{
if (x.TryGetComponent<Entity>(out var entity) is false)continue;
entity.Invoke<DamageMessage>(new DamageMessage()
try
{
Target = entity,
Damage = (int)damageCurve.Evaluate(Vector3.Distance(transform.position, entity.transform.position))
});
await Task.Delay(TimeSpan.FromSeconds(fuse), destroyCancellationToken);
GetComponentInChildren<Prop_Explosive>().Explosion(gameObject);
}
catch (OperationCanceledException)
{
return;
}
}
PhysicsHelper.Explosion(transform.position,explosionRadius,physicsLayer,1024*8);
Destroy(gameObject);
}
}