public void AttemptedWireSlotting(WireBehaviour wire, PanelSystem panel) { if (panel.CurrentDamageState == DamageState.Malfunction) { if (panel.CanSlotWire(wire)) { panel.SlotWire(wire); } } }
public void SlotWire(WireBehaviour wire) { var slot = GetFittingSlot(wire); slot.occupied = true; RegenerateSingleWireVisuals(slot); if (IsFullyRepaired()) { ChangeDamageState(DamageState.Operational); } Destroy(wire.gameObject); }
private WireSlot GetFittingSlot(WireBehaviour wire) => wireSlots .Where(slot => !slot.occupied) .FirstOrDefault(slot => slot.wire == wire.wireType);
public bool CanSlotWire(WireBehaviour wire) { var fittingSlot = GetFittingSlot(wire); return(fittingSlot != null); }