bool IFCSStorage.IsAllowedToAdd(Pickupable pickupable, bool verbose) { var eatable = pickupable.gameObject.GetComponent <Eatable>(); if (eatable != null) { if (eatable.decomposes && pickupable.GetTechType() != TechType.CreepvinePiece) { QuickLogger.Message(ExStorageDepotBuildable.FoodNotAllowed(), true); return(false); } } if (_mono.DumpContainer == null) { QuickLogger.Error("DumpContainer returned null"); return(false); } if (!CanBeStored(_mono.DumpContainer.GetCount() + 1, pickupable.GetTechType())) { QuickLogger.Info(ExStorageDepotBuildable.NoMoreSpace(), true); return(false); } return(true); }
public static void Patch() { QuickLogger.Info("Started patching. Version: " + QuickLogger.GetAssemblyVersion(Assembly.GetExecutingAssembly())); #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif try { Config = Mod.LoadConfiguration(); AddTechFabricatorItems(); ExStorageDepotBuildable.PatchHelper(); var harmony = HarmonyInstance.Create("com.exstoragedepot.fcstudios"); harmony.PatchAll(Assembly.GetExecutingAssembly()); QuickLogger.Info("Finished patching"); } catch (Exception ex) { QuickLogger.Error(ex); } }
public override void Initialize() { if (NameController == null) { NameController = new ExStorageDepotNameManager(); NameController.Initialize(this); } if (AnimationManager == null) { AnimationManager = gameObject.AddComponent <ExStorageDepotAnimationManager>(); } if (Storage == null) { Storage = gameObject.AddComponent <ExStorageDepotStorageManager>(); Storage.Initialize(this); } if (DumpContainer == null) { DumpContainer = gameObject.AddComponent <DumpContainer>(); DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage); DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed; } if (Display == null) { Display = gameObject.AddComponent <ExStorageDepotDisplayManager>(); Display.Initialize(this); } var locker = GameObjectHelpers.FindGameObject(gameObject, "Locker", SearchOption.StartsWith); var sRoot = GameObjectHelpers.FindGameObject(gameObject, "StorageRoot"); if (locker != null) { Destroy(locker); } if (sRoot != null) { Destroy(sRoot); } if (FCSConnectableDevice == null) { FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>(); FCSConnectableDevice.Initialize(this, Storage, new ExStoragePowerManager(), true); FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(FCSConnectableDevice, GetPrefabID(), Mod.ExStorageTabID); } _initialized = true; }
public bool AddToStorage(InventoryItem item, out string reason) { if (Storage.CanHoldItem(1)) { reason = String.Empty; Storage.ForceAddItem(item); return(true); } reason = ExStorageDepotBuildable.ContainerFullMessage(); return(false); }
private bool IsAllowedToAdd(Pickupable pickupable, bool verbose) { var containerTotal = ItemTotalCount + 1; if (_container.container.count >= _maxItems || containerTotal > _maxItems) { QuickLogger.Info(ExStorageDepotBuildable.NoMoreSpace(), true); return(false); } return(true); }
private void LoadDisplay(DisplayData data, TechType elementTechType, int techTypeCount) { GameObject buttonPrefab = Instantiate(ExStorageDepotBuildable.ItemPrefab); buttonPrefab.transform.SetParent(data.ItemsGrid.transform, false); var mainBtn = buttonPrefab.AddComponent <InterfaceButton>(); var text = buttonPrefab.GetComponentInChildren <Text>(); text.text = techTypeCount.ToString(); mainBtn.ButtonMode = InterfaceButtonMode.Background; mainBtn.STARTING_COLOR = _startColor; mainBtn.HOVER_COLOR = _hoverColor; mainBtn.TextLineOne = string.Format(ExStorageDepotBuildable.TakeItemFormat(), Language.main.Get(elementTechType)); mainBtn.OnButtonClick = OnButtonClick; mainBtn.BtnName = "ItemBTN"; mainBtn.Tag = elementTechType; uGUI_Icon icon = buttonPrefab.transform.Find("Image").gameObject.AddComponent <uGUI_Icon>(); icon.sprite = SpriteManager.Get(elementTechType); }
public override void Initialize() { if (NameController == null) { NameController = new ExStorageDepotNameManager(); NameController.Initialize(this); } if (AnimationManager == null) { AnimationManager = gameObject.AddComponent <ExStorageDepotAnimationManager>(); } if (Storage == null) { Storage = gameObject.AddComponent <ExStorageDepotStorageManager>(); Storage.Initialize(this); } if (DumpContainer == null) { DumpContainer = gameObject.AddComponent <DumpContainer>(); DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage); DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed; } if (Display == null) { Display = gameObject.AddComponent <ExStorageDepotDisplayManager>(); Display.Initialize(this); } if (FCSConnectableDevice == null) { FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>(); FCSConnectableDevice.Initialize(this, Storage); } _initialized = true; }
internal void Initialize(ExStorageDepotController mono) { _mono = mono; _containerHeight = _maxItems = QPatch.Config.MaxStorage; if (_containerRoot == null) { QuickLogger.Debug("Ex-Storage Root"); var storageRoot = new GameObject("ExStorageRoot"); storageRoot.transform.SetParent(mono.transform, false); _containerRoot = storageRoot.AddComponent <ChildObjectIdentifier>(); _mono = mono; } if (_container == null) { QuickLogger.Debug("Initializing Storage Container"); _container = _mono.gameObject.GetComponentInChildren <StorageContainer>(); _container.width = _containerWidth; _container.height = _containerHeight; _container.container.onRemoveItem += ContainerOnRemoveItem; _container.container.onAddItem += ContainerOnAddItem; _container.container.Resize(_containerWidth, _containerHeight); _container.storageLabel = ExStorageDepotBuildable.StorageContainerLabel(); } if (_dumpContainer == null) { QuickLogger.Debug("Initializing Dump Container"); _dumpContainer = new ItemsContainer(DumpContainerWidth, DumpContainerHeight, _containerRoot.transform, ExStorageDepotBuildable.DumpContainerLabel(), null); _dumpContainer.Resize(DumpContainerWidth, DumpContainerHeight); _dumpContainer.isAllowedToAdd += IsAllowedToAdd; } InvokeRepeating("UpdateStorageDisplayCount", 1, 0.5f); }
internal void Show() { uGUI.main.userInput.RequestString(ExStorageDepotBuildable.RenameStorage(), ExStorageDepotBuildable.Submit(), _currentName, 25, new uGUI_UserInput.UserInputCallback(SetLabel)); }
public override bool FindAllComponents() { try { #region Canvas var canvas = gameObject.GetComponentInChildren <Canvas>()?.gameObject; if (canvas == null) { QuickLogger.Error("Canvas could not be found!"); return(false); } #endregion #region Home Screen var home = InterfaceHelpers.FindGameObject(canvas, "Home"); #endregion #region Multiplier var multiplier = InterfaceHelpers.FindGameObject(home, "Multiplier"); #endregion #region Item Count _itemCount = InterfaceHelpers.FindGameObject(home, "StorageAmount")?.GetComponent <Text>(); #endregion #region Plier _plier = InterfaceHelpers.FindGameObject(multiplier, "plier")?.GetComponent <Text>(); #endregion #region Storage Labels _storageLabels = InterfaceHelpers.FindGameObject(home, "Storage_Labels"); #endregion #region Grid var grid = InterfaceHelpers.FindGameObject(home, "Grid"); _grid = _mono.gameObject.AddComponent <GridHelper>(); _grid.OnLoadDisplay += OnLoadDisplay; _grid.Setup(16, ExStorageDepotBuildable.ItemPrefab, home, _startColor, _hoverColor, OnButtonClick); #endregion #region Dump Button var dumpBTN = InterfaceHelpers.FindGameObject(home, "Dump_Button"); InterfaceHelpers.CreateButton(dumpBTN, "DumpBTN", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ExStorageDepotBuildable.AddToExStorage()); #endregion #region Rename Button var renameBTN = InterfaceHelpers.FindGameObject(home, "Rename_Button"); InterfaceHelpers.CreateButton(renameBTN, "RenameBTN", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ExStorageDepotBuildable.RenameStorage()); #endregion #region Multiplier Previous Button var multiplierPrevBtn = InterfaceHelpers.FindGameObject(multiplier, "Prev_BTN"); InterfaceHelpers.CreateButton(multiplierPrevBtn, "LButton", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ""); #endregion #region Multiplier Next Button var multiplierNextBtn = InterfaceHelpers.FindGameObject(multiplier, "Next_BTN"); InterfaceHelpers.CreateButton(multiplierNextBtn, "RButton", InterfaceButtonMode.Background, OnButtonClick, _startColor, _hoverColor, MAX_INTERACTION_DISTANCE, ""); #endregion _unitID = GameObjectHelpers.FindGameObject(home, "UnitID")?.GetComponent <Text>(); } catch (Exception e) { QuickLogger.Error($"{e.Message}:\n{e.StackTrace}"); return(false); } return(true); }
public override bool FindAllComponents() { var canvas = gameObject.GetComponentInChildren <Canvas>()?.gameObject; if (canvas == null) { QuickLogger.Error("Canvas could not be found!"); return(false); } var home = canvas.FindChild("Home")?.gameObject; if (home == null) { QuickLogger.Error("Couldn't find the gameobject Home"); return(false); } _storageLabels = home.FindChild("Storage_Labels")?.gameObject; if (_storageLabels == null) { QuickLogger.Error("Couldn't find the gameobject Storage_Labels"); return(false); } _grid = home.FindChild("Grid")?.gameObject; if (_grid == null) { QuickLogger.Error("Couldn't find the gameobject Grid"); return(false); } var dumpBTN = home.FindChild("Dump_Button")?.gameObject; if (dumpBTN == null) { QuickLogger.Error("Couldn't find the gameobject Dump_Button"); return(false); } var dumpBtn = dumpBTN.AddComponent <InterfaceButton>(); dumpBtn.BtnName = "DumpBTN"; dumpBtn.OnButtonClick = OnButtonClick; dumpBtn.ButtonMode = InterfaceButtonMode.Background; dumpBtn.HOVER_COLOR = Color.gray; var renameBTN = home.FindChild("Rename_Button")?.gameObject; if (renameBTN == null) { QuickLogger.Error("Couldn't find the gameobject Rename_Button"); return(false); } var renameBtn = renameBTN.AddComponent <InterfaceButton>(); renameBtn.BtnName = "RenameBTN"; renameBtn.OnButtonClick = OnButtonClick; renameBtn.ButtonMode = InterfaceButtonMode.Background; renameBtn.HOVER_COLOR = Color.gray; var paginator = home.FindChild("Paginator")?.gameObject; if (paginator == null) { QuickLogger.Error("Couldn't find the gameobject Paginator"); return(false); } var pprevBTN = paginator.FindChild("Prev_BTN")?.gameObject; if (pprevBTN == null) { QuickLogger.Error("Couldn't find the gameobject Prev_BTN"); return(false); } var ppBtn = pprevBTN.AddComponent <PaginatorButton>(); ppBtn.AmountToChangePageBy = -1; ppBtn.HoverTextLineTwo = ExStorageDepotBuildable.PrevPage(); ppBtn.OnChangePageBy = ChangePageBy; var pnextBTN = paginator.FindChild("Next_BTN")?.gameObject; if (pnextBTN == null) { QuickLogger.Error("Couldn't find the gameobject Next_BTN"); return(false); } var pnBtn = pnextBTN.AddComponent <PaginatorButton>(); pnBtn.AmountToChangePageBy = 1; pnBtn.HoverTextLineTwo = ExStorageDepotBuildable.NextPage(); pnBtn.OnChangePageBy = ChangePageBy; _pageCounter = paginator.FindChild("PageCounter").GetComponent <Text>(); if (_pageCounter == null) { QuickLogger.Error("Couldn't find Text in the PageCounter"); return(false); } var multiplier = home.FindChild("Multiplier")?.gameObject; if (multiplier == null) { QuickLogger.Error("Couldn't find the gameobject Multiplier"); return(false); } var mprevBTN = multiplier.FindChild("Prev_BTN")?.gameObject; if (mprevBTN == null) { QuickLogger.Error("Couldn't find the gameobject Prev_BTN in Multiplier"); return(false); } var mpBtn = mprevBTN.AddComponent <InterfaceButton>(); mpBtn.BtnName = "LButton"; mpBtn.OnButtonClick = OnButtonClick; mpBtn.ButtonMode = InterfaceButtonMode.Background; var mnextBTN = multiplier.FindChild("Next_BTN")?.gameObject; if (mnextBTN == null) { QuickLogger.Error("Couldn't find the gameobject Next_BTN in Multiplier"); return(false); } var mnBtn = mnextBTN.AddComponent <InterfaceButton>(); mnBtn.BtnName = "RButton"; mnBtn.OnButtonClick = OnButtonClick; mnBtn.ButtonMode = InterfaceButtonMode.Background; _plier = multiplier.FindChild("plier").GetComponent <Text>(); if (_pageCounter == null) { QuickLogger.Error("Couldn't find the Text on PageCounter in Multiplier"); return(false); } _itemCount = home.FindChild("StorageAmount").GetComponent <Text>(); if (_pageCounter == null) { QuickLogger.Error("Couldn't find the Text on StorageAmount in Home"); return(false); } return(true); }