public override bool CanDeconstruct(out string reason) { reason = string.Empty; if (FridgeComponent == null) { return(true); } if (FridgeComponent.IsEmpty()) { return(true); } reason = ARSSeaBreezeFCS32Buildable.NotEmpty(); return(false); }
public static void Patch() { Configuration = Mod.LoadConfiguration(); var assembly = Assembly.GetExecutingAssembly(); QuickLogger.Info("Started patching. Version: " + QuickLogger.GetAssemblyVersion(assembly)); #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif try { LoadAssetBundle(); OptionsPanelHandler.RegisterModOptions(new Options()); GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI.GlobalBundleName); AddTechFabricatorItems(); ARSSeaBreezeFCS32Buildable.PatchHelper(); var harmony = HarmonyInstance.Create("com.arsseabreezefcs32.fcstudios"); harmony.PatchAll(assembly); QuickLogger.Info("Finished patching"); QuickLogger.Debug($"{Configuration.StorageLimit}"); } catch (Exception ex) { QuickLogger.Error(ex); } }
internal void OnContainerUpdate(int numberofItems, int storageLimit) { _itemCounter_LBL.text = $"{numberofItems}/{storageLimit} {ARSSeaBreezeFCS32Buildable.Items()}"; UpdateContainers(); }
public override bool FindAllComponents() { try { #region Canvas var canvasGameObject = gameObject.GetComponentInChildren <Canvas>()?.gameObject; if (canvasGameObject == null) { QuickLogger.Error("Canvas not found."); return(false); } #endregion #region Home var home = InterfaceHelpers.FindGameObject(canvasGameObject, "HomeScreen"); #endregion #region Battery var homeBattery = InterfaceHelpers.FindGameObject(home, "Battery"); _batteryPercent = InterfaceHelpers.FindGameObject(homeBattery, "Text").GetComponent <Text>(); _batteryFill = InterfaceHelpers.FindGameObject(homeBattery, "Fill").GetComponent <Image>(); #endregion #region Food var food = InterfaceHelpers.FindGameObject(canvasGameObject, "FoodScreen"); #endregion #region Drinks var drinks = InterfaceHelpers.FindGameObject(canvasGameObject, "DrinksScreen"); #endregion #region Trash var trash = InterfaceHelpers.FindGameObject(canvasGameObject, "TrashScreen"); #endregion #region Color Picker var colorPicker = InterfaceHelpers.FindGameObject(canvasGameObject, "ColorPicker"); #endregion #region PowerOff var powerOff = InterfaceHelpers.FindGameObject(canvasGameObject, "PoweredOffScreen"); #endregion #region PowerButton var powerBtn = InterfaceHelpers.FindGameObject(home, "Power_BTN"); InterfaceHelpers.CreateButton(powerBtn, "HPPBtn", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.PowerBTNMessage()); #endregion #region PowerOFf PowerButton var ppowerBtn = InterfaceHelpers.FindGameObject(powerOff, "Power_BTN"); InterfaceHelpers.CreateButton(ppowerBtn, "PPBtn", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.PowerBTNMessage()); #endregion #region PowerOFf PowerButton var powerOffLbl = InterfaceHelpers.FindGameObject(powerOff, "Powered_Off_LBL"); powerOffLbl.GetComponent <Text>().text = ARSSeaBreezeFCS32Buildable.NoPower(); #endregion #region DumpBTNButton var dumpBtn = InterfaceHelpers.FindGameObject(home, "DumpBTN"); InterfaceHelpers.CreateButton(dumpBtn, "DumpBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.DumpButton(), ARSSeaBreezeFCS32Buildable.DumpMessage()); #endregion #region FoodCButton var foodContainterBtn = InterfaceHelpers.FindGameObject(home, "FoodCBTN"); InterfaceHelpers.CreateButton(foodContainterBtn, "FoodCBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.FoodCButton()); #endregion #region WaterCButton var WaterContainterBtn = InterfaceHelpers.FindGameObject(home, "WaterCBTN"); InterfaceHelpers.CreateButton(WaterContainterBtn, "WaterCBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.WaterCButton()); #endregion #region Rename Button var RenameBtn = InterfaceHelpers.FindGameObject(home, "RenameBTN"); InterfaceHelpers.CreateButton(RenameBtn, "RenameBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.RenameButton()); #endregion #region Trash Button var TrashBtn = InterfaceHelpers.FindGameObject(home, "TrashCBTN"); InterfaceHelpers.CreateButton(TrashBtn, "TrashBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.TrashButton(), ARSSeaBreezeFCS32Buildable.TrashMessage()); #endregion #region ColorBTN Button var colorBtn = InterfaceHelpers.FindGameObject(home, "ColorPickerBTN"); InterfaceHelpers.CreateButton(colorBtn, "ColorBTN", InterfaceButtonMode.Background, OnButtonClick, Color.black, Color.white, MAX_INTERACTION_DISTANCE, ARSSeaBreezeFCS32Buildable.ColorPicker()); #endregion #region ColorPage _colorPage.SetupGrid(48, ARSSeaBreezeFCS32Buildable.ColorItemPrefab, colorPicker, OnButtonClick, _startColor, _hoverColor); #endregion #region Food Page _foodPage = _mono.gameObject.AddComponent <GridHelper>(); _foodPage.OnLoadDisplay += OnLoadFoodDisplay; _foodPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, food, _startColor, _hoverColor, OnButtonClick); #endregion #region Drink Page _waterPage = _mono.gameObject.AddComponent <GridHelper>(); _waterPage.OnLoadDisplay += OnLoadWaterDisplay; _waterPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, drinks, _startColor, _hoverColor, OnButtonClick); #endregion #region Trash Page _trashPage = _mono.gameObject.AddComponent <GridHelper>(); _trashPage.OnLoadDisplay += OnLoadTrashDisplay; _trashPage.Setup(17, ARSSeaBreezeFCS32Buildable.ItemPrefab, trash, _startColor, _hoverColor, OnButtonClick); #endregion #region StorageAmount _itemCounter_LBL = InterfaceHelpers.FindGameObject(home, "ItemCounter_LBL").GetComponent <Text>(); #endregion #region Unit Name _seaBreeze_LBL = InterfaceHelpers.FindGameObject(home, "SeaBreeze_LBL").GetComponent <Text>(); #endregion } catch (Exception e) { QuickLogger.Error($"{e.Message}:\n{e.StackTrace}"); return(false); } return(true); }
public override void Initialize() { PageStateHash = Animator.StringToHash("PageState"); QPatch.Configuration.OnModModeChanged += OnModModeChanged; if (PrefabId == null) { PrefabId = GetComponentInParent <PrefabIdentifier>() ?? GetComponent <PrefabIdentifier>(); } if (PowerManager == null) { PowerManager = gameObject.AddComponent <ARSolutionsSeaBreezePowerManager>(); PowerManager.Initialize(this); PowerManager.OnBreakerTripped += OnBreakerTripped; PowerManager.OnBreakerReset += OnBreakerReset; PowerManager.OnPowerResume += OnPowerResume; PowerManager.OnPowerOutage += OnPowerOutage; } if (FridgeComponent == null) { FridgeComponent = gameObject.AddComponent <Fridge>(); FridgeComponent.Initialize(this, QPatch.Configuration.StorageLimit); FridgeComponent.OnContainerUpdate += OnContainerUpdate; FridgeComponent.SetModMode(QPatch.Configuration.ModMode); } if (ColorManager == null) { ColorManager = gameObject.AddComponent <ColorManager>(); ColorManager.Initialize(gameObject, ARSSeaBreezeFCS32Buildable.BodyMaterial); } if (FridgeDumpContainer == null) { FridgeDumpContainer = gameObject.AddComponent <DumpContainer>(); FridgeDumpContainer.Initialize(gameObject.transform, ARSSeaBreezeFCS32Buildable.StorageLabel(), ARSSeaBreezeFCS32Buildable.ItemNotAllowed(), ARSSeaBreezeFCS32Buildable.SeaBreezeFull(), FridgeComponent, _dumpStorageSizeXY, _dumpStorageSizeXY); } if (NameController == null) { NameController = gameObject.EnsureComponent <NameController>(); NameController.Initialize(ARSSeaBreezeFCS32Buildable.Submit(), Mod.FriendlyName); NameController.SetCurrentName(Mod.GetNewSeabreezeName()); NameController.OnLabelChanged += OnLabelChangedMethod; } if (AnimationManager == null) { AnimationManager = gameObject.AddComponent <AnimationManager>(); } if (DisplayManager == null) { DisplayManager = gameObject.AddComponent <ARSolutionsSeaBreezeDisplay>(); DisplayManager.Setup(this); } if (FCSConnectableDevice == null) { FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>(); FCSConnectableDevice.Initialize(this, FridgeComponent); } IsInitialized = true; }