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