Aetheria/Assets/Scripts/Gameplay/HullCollider.cs

65 lines
1.8 KiB
C#
Raw Normal View History

using System;
using System.Collections;
2021-01-05 02:56:17 +00:00
using System.Collections.Generic;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using UnityEngine;
using float2 = Unity.Mathematics.float2;
public class HullCollider : MonoBehaviour
{
public Subject<HullHitEventArgs> Hit = new Subject<HullHitEventArgs>();
public Subject<HullSplashEventArgs> Splash = new Subject<HullSplashEventArgs>();
2021-01-05 02:56:17 +00:00
public Entity Entity { get; set; }
2021-02-06 15:29:04 +00:00
public void SendHit(float damage, float penetration, float spread, DamageType damageType, Entity source, Vector2 texCoord, Vector3 direction)
2021-01-05 02:56:17 +00:00
{
Hit.OnNext(new HullHitEventArgs
{
Damage = damage,
2021-01-08 12:44:10 +00:00
Penetration = penetration,
Spread = spread,
2021-01-05 02:56:17 +00:00
DamageType = damageType,
Source = source,
2021-02-06 15:29:04 +00:00
TexCoord = texCoord,
2021-01-08 12:44:10 +00:00
Direction = direction
2021-01-05 02:56:17 +00:00
});
}
public void SendSplash(float damage, DamageType damageType, Entity source, Vector3 direction)
{
Splash.OnNext(new HullSplashEventArgs
{
Damage = damage,
DamageType = damageType,
Source = source,
Direction = direction
});
}
private void OnCollisionEnter(Collision other)
{
Entity.Velocity += ((float3) other.impulse).xz / Time.deltaTime;
}
2021-01-05 02:56:17 +00:00
public class HullHitEventArgs
{
public float Damage;
2021-01-08 12:44:10 +00:00
public float Penetration;
public float Spread;
2021-01-05 02:56:17 +00:00
public DamageType DamageType;
public Entity Source;
2021-02-06 15:29:04 +00:00
public float2 TexCoord;
2021-01-08 12:44:10 +00:00
public float3 Direction;
2021-01-05 02:56:17 +00:00
}
public class HullSplashEventArgs
{
public float Damage;
public DamageType DamageType;
public Entity Source;
public float3 Direction;
}
2021-01-05 02:56:17 +00:00
}