internal bool TakePower(QTTeleportTypes type) { QuickLogger.Debug($"Available power {ConnectedRelay?.GetPower()}", true); if (HasEnoughPower(type)) { float amountConsumed; switch (type) { case QTTeleportTypes.Global: ConnectedRelay.ConsumeEnergy(_interPowerUsage, out amountConsumed); break; case QTTeleportTypes.Intra: ConnectedRelay.ConsumeEnergy(_intraPowerUsage, out amountConsumed); break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } QuickLogger.Debug($"Consumed {amountConsumed} amount of power for this operation", true); return(true); } return(false); }
public override void OnButtonClick(string btnName, object tag) { switch (btnName) { case "ColorPageBTN": _mono.AnimationManager.SetIntHash(_page, 2); break; case "HomeBTN": _mono.AnimationManager.SetIntHash(_page, 1); break; case "ColorItem": _mono.ColorManager.ChangeColor((Color)tag); break; case "Unit": _toUnit = (QuantumTeleporterController)tag; var ttype = QTTeleportTypes.Global; if (SelectedTab == QTTabs.Intra) { ttype = QTTeleportTypes.Intra; } _tType = ttype; if (_toUnit.PowerManager.HasEnoughPower(ttype)) { _destination.text = $"[{_toUnit.GetName()}]"; _mono.AnimationManager.SetIntHash(_page, 3); } break; case "RenameBTN": _mono.NameController.Show(); break; case "GlobalTeleBtn": SetTab(QTTabs.Global); break; case "IntraTeleBtn": SetTab(QTTabs.Intra); break; case "ConfirmYesBtn": ConfirmTeleport(); break; case "ConfirmNoBtn": _mono.AnimationManager.SetIntHash(_page, 1); break; } }
private static void InitializeTeleport(QuantumTeleporterController mono, QTTeleportTypes type) { mono.AudioManager.PlayAudio(); mono.AnimationManager.SetBoolHash(_animationRunning, true); mono.AnimationManager.SetBoolHash(_isPanelVisible, false); mono.DisplayManager.ShowTeleportPage(true); mono.QTDoorManager.CloseDoor(); mono.PowerManager.TakePower(type); SetIsTeleporting(true); }
internal bool HasEnoughPower(QTTeleportTypes type) { bool requiresEnergy = GameModeUtils.RequiresPower(); if (!requiresEnergy) { return(true); } switch (type) { case QTTeleportTypes.Global: return(ConnectedRelay != null && ConnectedRelay.GetPower() >= _interPowerUsage); case QTTeleportTypes.Intra: return(ConnectedRelay != null && ConnectedRelay.GetPower() >= _intraPowerUsage); } return(false); }
internal static void TeleportPlayer(QuantumTeleporterController fromUnit, QuantumTeleporterController toUnit, QTTeleportTypes type) { if (_initialized) { _fromUnit = fromUnit; _toUnit = toUnit; if (!fromUnit.PowerManager.HasEnoughPower(type)) { QuickLogger.Message(QuantumTeleporterBuildable.BaseNotEnoughPower(), true); return; } if (!_toUnit.PowerManager.HasEnoughPower(type)) { QuickLogger.Message(QuantumTeleporterBuildable.ToBaseNotEnoughPower(), true); return; } InitializeTeleport(_toUnit, type); InitializeTeleport(_fromUnit, type); Player.main.playerController.SetEnabled(false); var target = _toUnit.GetTarget(); if (target != null) { _target = target; SetIsTeleporting(true); } } }