quantum-space-buddies/QSB/ZeroGCaveSync/WorldObjects/QSBSatelliteNode.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2021-11-29 22:57:13 +00:00
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.ZeroGCaveSync.WorldObjects
{
internal class QSBSatelliteNode : WorldObject<SatelliteNode>
{
public void SetRepaired()
{
DebugLog.DebugWrite($"[SATELLITE NODE] {AttachedObject} Set repaired.");
AttachedObject._damaged = false;
var component = Locator.GetPlayerTransform().GetComponent<ReferenceFrameTracker>();
2021-12-27 05:08:36 +00:00
if (component.GetReferenceFrame() == AttachedObject._rfVolume.GetReferenceFrame())
2021-11-29 22:57:13 +00:00
{
component.UntargetReferenceFrame();
}
if (AttachedObject._rfVolume != null)
{
AttachedObject._rfVolume.gameObject.SetActive(false);
}
if (AttachedObject._lanternLight != null)
{
AttachedObject._lanternLight.color = AttachedObject._lightRepairedColor;
}
if (AttachedObject._lanternEmissiveRenderer != null)
{
AttachedObject._lanternEmissiveRenderer.sharedMaterials.CopyTo(AttachedObject._lanternMaterials, 0);
AttachedObject._lanternMaterials[AttachedObject._lanternMaterialIndex] = AttachedObject._lanternRepairedMaterial;
AttachedObject._lanternEmissiveRenderer.sharedMaterials = AttachedObject._lanternMaterials;
}
2021-12-27 05:01:24 +00:00
AttachedObject.RaiseEvent(nameof(AttachedObject.OnRepaired), AttachedObject);
2021-11-29 22:57:13 +00:00
}
public void RepairTick(float repairFraction)
{
DebugLog.DebugWrite($"[SATELLITE NODE] {AttachedObject} repair tick {repairFraction}");
AttachedObject._repairFraction = repairFraction;
var damageEffect = AttachedObject._damageEffect;
damageEffect.SetEffectBlend(1f - repairFraction);
}
}
}