40 lines
1.2 KiB
C#
Raw Normal View History

2021-12-26 21:05:07 -08:00
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.ShipSync.WorldObjects
{
2021-07-12 22:02:50 +01:00
internal class QSBShipComponent : WorldObject<ShipComponent>
{
public void SetDamaged()
{
DebugLog.DebugWrite($"[S COMPONENT] {AttachedObject} Set damaged.");
2021-12-26 20:57:34 -08:00
AttachedObject._damaged = true;
AttachedObject._repairFraction = 0f;
AttachedObject.OnComponentDamaged();
AttachedObject.RaiseEvent(nameof(AttachedObject.OnDamaged), AttachedObject);
AttachedObject.UpdateColliderState();
2021-12-26 20:35:40 -08:00
var damageEffect = AttachedObject._damageEffect;
damageEffect.SetEffectBlend(1f);
}
2021-06-20 09:59:02 +01:00
public void SetRepaired()
{
DebugLog.DebugWrite($"[S COMPONENT] {AttachedObject} Set repaired.");
2021-12-26 20:57:34 -08:00
AttachedObject._damaged = false;
AttachedObject._repairFraction = 1f;
AttachedObject.OnComponentRepaired();
AttachedObject.RaiseEvent(nameof(AttachedObject.OnRepaired), AttachedObject);
AttachedObject.UpdateColliderState();
2021-12-26 20:35:40 -08:00
var damageEffect = AttachedObject._damageEffect;
2021-06-20 09:59:02 +01:00
damageEffect.SetEffectBlend(0f);
}
2021-06-20 10:17:32 +01:00
public void RepairTick(float repairFraction)
{
2021-12-26 20:57:34 -08:00
AttachedObject._repairFraction = repairFraction;
2021-12-26 20:35:40 -08:00
var damageEffect = AttachedObject._damageEffect;
2021-06-20 10:17:32 +01:00
damageEffect.SetEffectBlend(1f - repairFraction);
}
}
}