Ejemplo n.º 1
0
        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 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 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;
        }