Exemple #1
0
        protected override void OnSpawn()
        {
            base.OnSpawn();
            _spawned = true;
            Debug.Log($"[MultiIO] ConduitIO.OnSpawn() -> ConduitType: {ConduitType.ToString()}  CellOffset: {CellOffset.x + "," + CellOffset.y}");
            portCell = GetPortCell();
            MultiIOExtensions.RegisterPort(portCell, this);
            //Register an event listener for any changes to the grid at the location of this port.
            ScenePartitionerLayer layer = GameScenePartitioner.Instance.objectLayers[(int)GetConduitObjectLayer()];

            partitionerEntry = GameScenePartitioner.Instance.Add("ConduitIO.OnSpawn", _parent, portCell, layer, delegate
            {
                UpdateConduitExistsStatus();
            });
            //Register this conduit to the relevant network. Allows the network to determine flow direction.
            IUtilityNetworkMgr networkManager = GetNetworkManager();

            _networkItem = new FlowUtilityNetwork.NetworkItem(ConduitType, EndpointType, portCell, _parent);
            networkManager.AddToNetworks(portCell, _networkItem, EndpointType != Endpoint.Conduit);

            if (UseConduitUpdater)
            {
                GetConduitManager().AddConduitUpdater(ConduitTick, FlowPriority);
            }

            UpdateConduitExistsStatus(true);
        }
Exemple #2
0
        string ISliderControl.GetSliderTooltipKey(int index)
        {
            switch (Type)
            {
            case ConduitType.Gas:
                return("STRINGS.UI.UISIDESCREENS.GASSOURCE.TOOLTIP");

            case ConduitType.Liquid:
                return("STRINGS.UI.UISIDESCREENS.LIQUIDSOURCE.TOOLTIP");

            case ConduitType.Solid:
                return("STRINGS.UI.UISIDESCREENS.SOLIDSOURCE.TOOLTIP");

            default:
                throw new Exception("Invalid ConduitType provided to InfiniteSource: " + Type.ToString());
            }
        }
    private IConduitFlow GetConduitFlow()
    {
        switch (conduitType)
        {
        case ConduitType.Gas:
            return(Game.Instance.gasConduitFlow);

        case ConduitType.Liquid:
            return(Game.Instance.liquidConduitFlow);

        case ConduitType.Solid:
            return(Game.Instance.solidConduitFlow);

        default:
            Debug.LogWarning("GetConduitFlow() called with unexpected conduitType: " + conduitType.ToString());
            return(null);
        }
    }
Exemple #4
0
        public static float GetMaxCapacityWithObject(int cell, ConduitType type, out GameObject obj, bool isBridge = false)
        {
            if (type != ConduitType.Gas && type != ConduitType.Liquid)
            {
                throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()}  Type must be ConduitType.Gas or ConduitType.Liquid.", "type");
            }
            ConduitFlow manager     = Conduit.GetFlowManager(type);
            Pressurized pressurized = GetPressurizedAt(cell, type, isBridge);

            if (pressurized == null)
            {
                obj = null;
            }
            else
            {
                obj = pressurized.gameObject;
            }
            if (Pressurized.IsDefault(pressurized))
            {
                return(manager.MaxMass());
            }
            else
            {
                return(pressurized.Info.IncreaseMultiplier * manager.MaxMass());
            }
        }
Exemple #5
0
        public static float GetMaxCapacityAt(int cell, ConduitType type, bool isBridge = false)
        {
            if (type != ConduitType.Gas && type != ConduitType.Liquid)
            {
                throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()}  Type must be ConduitType.Gas or ConduitType.Liquid.", "type");
            }
            ConduitFlow manager = Conduit.GetFlowManager(type);

            return(Pressurized.GetMaxCapacity(GetPressurizedAt(cell, type, isBridge)));
        }
Exemple #6
0
 protected IConduitFlow GetConduitManager()
 {
     if (ConduitType == ConduitType.Gas)
     {
         return(Game.Instance.gasConduitFlow);
     }
     if (ConduitType == ConduitType.Liquid)
     {
         return(Game.Instance.liquidConduitFlow);
     }
     if (ConduitType == ConduitType.Solid)
     {
         return(Game.Instance.solidConduitFlow);
     }
     Debug.LogError($"[MultiIO] ConduitIO.GetConduitManager() -> Invalid ConduitType, could not find manager. ConduitType: {ConduitType.ToString()}");
     return(null);
 }