quantum-space-buddies/QSB/ShipSync/WorldObjects/QSBShipComponent.cs

40 lines
1.2 KiB
C#
Raw Normal View History

2021-12-27 05:05:07 +00:00
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.ShipSync.WorldObjects
{
2021-07-12 21:02:50 +00:00
internal class QSBShipComponent : WorldObject<ShipComponent>
{
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;
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);
}
}
}