public override void Initialize() { if (PowerManager == null) { PowerManager = gameObject.AddComponent <AlterraGenPowerManager>(); } if (ColorManager == null) { ColorManager = gameObject.AddComponent <ColorManager>(); ColorManager.Initialize(gameObject, AlterraGenBuildable.BodyMaterial); } if (AnimationManager == null) { AnimationManager = gameObject.AddComponent <AnimationManager>(); } if (DumpContainer == null) { DumpContainer = gameObject.AddComponent <DumpContainer>(); DumpContainer.Initialize(transform, "AlterraGen Receptacle", AlterraGenBuildable.NotAllowedItem(), AlterraGenBuildable.StorageFullMessage(), PowerManager, 3, 3); } if (_fcsConnectableDevice == null) { _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>(); _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager); FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(_fcsConnectableDevice, GetPrefabID(), Mod.ModTabID); } if (DisplayManager == null) { DisplayManager = gameObject.AddComponent <AlterraGenDisplayManager>(); DisplayManager.Setup(this); } _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles"); IsInitialized = true; }
public override void Initialize() { if (PowerManager == null) { PowerManager = gameObject.AddComponent <AlterraGenPowerManager>(); } if (ColorManager == null) { ColorManager = gameObject.AddComponent <ColorManager>(); ColorManager.Initialize(gameObject, AlterraGenBuildable.BodyMaterial); } if (AnimationManager == null) { AnimationManager = gameObject.AddComponent <AnimationManager>(); } if (DumpContainer == null) { DumpContainer = gameObject.AddComponent <DumpContainer>(); DumpContainer.Initialize(transform, "AlterraGen Receptacle", "", AlterraGenBuildable.NotAllowedItem(), PowerManager); } if (_fcsConnectableDevice == null) { _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>(); _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager); } if (DisplayManager == null) { DisplayManager = gameObject.AddComponent <AlterraGenDisplayManager>(); DisplayManager.Setup(this); } _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles"); IsInitialized = true; }
public static void Patch() { Version = QuickLogger.GetAssemblyVersion(Assembly.GetExecutingAssembly()); QuickLogger.Info($"Started patching. Version: {Version}"); QuickLogger.ModName = Mod.ModFriendlyName; #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif try { GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI .GlobalBundleName); if (GlobalBundle == null) { QuickLogger.Error("Global Bundle has returned null stopping patching"); throw new FileNotFoundException("Bundle failed to load"); } Configuration = Mod.LoadConfiguration(); AddTechFabricatorItems(); var alterraGen = new AlterraGenBuildable(); alterraGen.Patch(); //var harmony = new Harmony("com.alterragen.fcstudios"); //harmony.PatchAll(Assembly.GetExecutingAssembly()); QuickLogger.Info("Finished patching"); } catch (Exception ex) { QuickLogger.Error(ex); } }
private void OnPowerUpdateCycle(AlterraGenPowerManager obj) { if (obj == null || _breakerStatusLight == null || _powerStateValue == null || _powerUnitValue == null || _grid == null) { return; } //Update the Breaker Status Light _breakerStatusLight.color = obj.ProducingPower ? Color.green : Color.red; //Update the Power State _powerStateValue.text = obj.ProducingPower ? AlterraGenBuildable.Active() : AlterraGenBuildable.InActive(); //Update the Power Amount Stored _powerUnitValue.text = obj.GetTotalPowerString(); //Update Battery Fill UpdateBattery(obj.GetBatteryData()); if (obj.ProducingPower) { _mono.SetXBubbles(true); if (_mono.AnimationManager.GetBoolHash(_isOperational)) { return; } _mono.AnimationManager.SetBoolHash(_isOperational, true); QuickLogger.Debug("Starting Animation", true); } else { _mono.SetXBubbles(false); if (!_mono.AnimationManager.GetBoolHash(_isOperational)) { return; } _mono.AnimationManager.SetBoolHash(_isOperational, false); QuickLogger.Debug("Stopping Animation", true); } }
private void UpdateItemCount(int amount, int maxAmount) { _itemCounter.text = string.Format(AlterraGenBuildable.ItemCounterFormat(), amount, maxAmount); }
public override bool FindAllComponents() { try { #region Canvas var canvas = GameObjectHelpers.FindGameObject(gameObject, "Canvas"); #endregion #region Home Page var homePage = GameObjectHelpers.FindGameObject(canvas, "HomePage"); //Battery Fill _batteryFill = GameObjectHelpers.FindGameObject(homePage, "BatteryFrameFill")?.GetComponent <Image>(); //Power State GameObjectHelpers.FindGameObject(homePage, "PowerState_LBL").GetComponent <Text>().text = AlterraGenBuildable.PowerStateLBL(); _powerStateValue = GameObjectHelpers.FindGameObject(homePage, "PoweredState_Value")?.GetComponent <Text>(); //Counter _itemCounter = GameObjectHelpers.FindGameObject(homePage, "ItemsCount").GetComponent <Text>(); UpdateItemCount(0, _mono.PowerManager.MaxSlots); //Power Unit GameObjectHelpers.FindGameObject(homePage, "PowerUnit_LBL").GetComponent <Text>().text = AlterraGenBuildable.PowerUnitLBL(); _powerUnitValue = GameObjectHelpers.FindGameObject(homePage, "PowerUnit_Value")?.GetComponent <Text>(); //Battery Percentage GameObjectHelpers.FindGameObject(homePage, "BatteryPercentage_LBL").GetComponent <Text>().text = AlterraGenBuildable.BatteryPercentageLBL(); _batteryPercentageValue = GameObjectHelpers.FindGameObject(homePage, "BatteryPercentage_Percentage")?.GetComponent <Text>(); //Breaker State GameObjectHelpers.FindGameObject(homePage, "BreakerState_LBL").GetComponent <Text>().text = AlterraGenBuildable.BreakerStateLBL(); _breakerStatusLight = GameObjectHelpers.FindGameObject(homePage, "BreakerState_StatusLight")?.GetComponent <Image>(); //Power Button var powerBTNObject = GameObjectHelpers.FindGameObject(homePage, "PowerBTN"); InterfaceHelpers.CreateButton(powerBTNObject, "PowerBTN", InterfaceButtonMode.Background, OnButtonClick, Color.white, Color.cyan, MAX_INTERACTION_DISTANCE); //Dump Button var dumpBTN = GameObjectHelpers.FindGameObject(homePage, "DumpBTN"); InterfaceHelpers.CreateButton(dumpBTN, "DumpBTN", InterfaceButtonMode.Background, OnButtonClick, Color.gray, Color.white, MAX_INTERACTION_DISTANCE); //Color Picker BTN var colorPickerBTN = GameObjectHelpers.FindGameObject(homePage, "ColorPickerBTN"); InterfaceHelpers.CreateButton(colorPickerBTN, "ColorPickerBTN", InterfaceButtonMode.Background, OnButtonClick, Color.gray, Color.white, MAX_INTERACTION_DISTANCE); _grid = _mono.gameObject.AddComponent <GridHelper>(); _grid.OnLoadDisplay += OnLoadItemsGrid; _grid.Setup(3, AlterraGenBuildable.ItemPrefab, homePage, Color.gray, Color.gray, OnButtonClick); _unitID = GameObjectHelpers.FindGameObject(homePage, "UnitID")?.GetComponent <Text>(); #endregion #region PowerOff Page var poweroffPage = GameObjectHelpers.FindGameObject(canvas, "PowerOff"); var powerBTNObject2 = GameObjectHelpers.FindGameObject(poweroffPage, "PowerBTN"); InterfaceHelpers.CreateButton(powerBTNObject2, "PowerBTN", InterfaceButtonMode.Background, OnButtonClick, Color.white, Color.cyan, MAX_INTERACTION_DISTANCE); #endregion #region Color Page var colorPage = GameObjectHelpers.FindGameObject(canvas, "ColorPage"); _colorPage.SetupGrid(35, AlterraGenBuildable.ColorItemPrefab, colorPage, OnButtonClick, Color.white, Color.cyan); #endregion } catch (Exception e) { QuickLogger.Error(e.Message); return(false); } return(true); }