예제 #1
0
        public bool CanEqualiseWithThis(PipeData Pipe)
        {
            if (Pipe.NetCompatible == false)
            {
                return(PipeFunctions.CanEqualiseWith(this.pipeData, Pipe));
            }

            return(true);
        }
예제 #2
0
        public void RemovePipe(PipeData pipeData)
        {
            pipeData.OnNet = null;

            var Outmix = mixAndVolume.Mix.Take(mixAndVolume.Mix.Total / Covering.Count);

            Covering.Remove(pipeData);
            mixAndVolume.Volume -= pipeData.mixAndVolume.Volume;
            MatrixManager.ReagentReact(Outmix, pipeData.MatrixPos);             //TODO AAAAAAAA Get the correct location
            SplitPipeNets();
        }
예제 #3
0
 public static MixAndVolume PipeOrNet(PipeData pipe)
 {
     if (pipe.NetCompatible && pipe.OnNet != null)
     {
         return(pipe.OnNet.mixAndVolume);
     }
     else
     {
         return(pipe.mixAndVolume);
     }
 }
예제 #4
0
        public static bool CanEqualiseWith(PipeData pipe1, PipeData pipe2)
        {
            var PipeDirectio   = PipesToDirections(pipe1, pipe2);
            int pipe2Direction = (int)PipeDirectio + 2;

            if (pipe2Direction > 3)
            {
                pipe2Direction -= 4;
            }
            return(pipe2.Connections.Directions[pipe2Direction].PortType.HasFlag(OutputType.Can_Equalise_With));
        }
예제 #5
0
        public void ConnectedRemove(PipeData OldConnection)
        {
            ConnectedPipes.Remove(OldConnection);

            if (NetCompatible == false)
            {
                Outputs.Remove(OldConnection);
            }

            //What about net outputs then That should be handle as part of the Reconstruction of the net
        }
예제 #6
0
		public void RemovePipe(PipeData pipeData)
		{
			pipeData.OnNet = null;

			var Outmix = mixAndVolume.Take(pipeData.mixAndVolume);
			Covering.Remove(pipeData);

			pipeData.SpillContent(Outmix);

			SplitPipeNets();
		}
예제 #7
0
        //Stuff for pipes to go in here

        public void Initialise(PipeTile DataToTake, MetaDataNode metaDataNode, Vector3Int searchVec, Matrix locatedon, int RotationOffset)
        {
            RelatedTile = DataToTake;
            IsOn        = metaDataNode;
            pipeData    = new PipeData();
            pipeData.SetUp(DataToTake, RotationOffset);
            pipeData.pipeNode = this;
            NodeLocation      = searchVec;
            LocatedOn         = locatedon;
            pipeData.OnEnable();
        }
예제 #8
0
        public static LiquidPipeNet MakeNewNet(PipeData pipeData)
        {
            var Net = new LiquidPipeNet();

            pipeData.OnNet   = Net;
            Net.mixAndVolume = pipeData.mixAndVolume.Clone();
            Net.Covering.Add(pipeData);
            Net.NetUpdateProxy.OnNet = Net;
            Net.NetUpdateProxy.OnEnable();
            if (pipeData.CustomLogic == CustomLogic.CoolingPipe)
            {
                Net.pipeNetAction = new CoolingNet();
                Net.pipeNetAction.LiquidPipeNet = Net;
            }
            return(Net);
        }
예제 #9
0
 public void AddPipe(PipeData pipeData)
 {
     if (pipeData.OnNet == null)
     {
         pipeData.OnNet = this;
         mixAndVolume.Add(pipeData.mixAndVolume);
         Covering.Add(pipeData);
     }
     else
     {
         if (this != pipeData.OnNet)
         {
             this.CombinePipeNets(pipeData.OnNet);
         }
     }
 }
예제 #10
0
        public void ConnectedAdd(PipeData NewConnection)
        {
            if (MonoPipe != null)
            {
                if (MonoPipe.name == "Filter (1)")
                {
                    Logger.Log("yay");
                }
            }

            ConnectedPipes.Add(NewConnection);
            var pipe1Connection =
                this.Connections.Directions[(int)PipeFunctions.PipesToDirections(this, NewConnection)];

            pipe1Connection.Connected = NewConnection;


            if (NetCompatible == false)
            {
                //This is a special pipe
                if (NewConnection.NetCompatible == false)
                {
                    //NewConnection is a special pipe
                    if (PipeFunctions.IsPipeOutputTo(this, NewConnection) &&
                        PipeFunctions.CanEqualiseWith(this, NewConnection))
                    {
                        pipe1Connection.Connected = NewConnection;
                        Outputs.Add(NewConnection);
                    }
                }
                else
                {
                    //NewConnection is a Pipe net
                    if (PipeFunctions.IsPipeOutputTo(this, NewConnection))
                    {
                        //An input to the pipe net it does not need to be recorded
                        Outputs.Add(NewConnection);
                    }

                    if (this.Connections.Directions[(int)PipeFunctions.PipesToDirections(this, NewConnection)].PortType
                        .HasFlag(OutputType.Can_Equalise_With))
                    {
                        NewConnection.OnNet.AddEqualiseWith(this);
                    }
                }
            }
        }
예제 #11
0
        public void EqualiseWith(PipeData Another)
        {
            float TotalVolume   = Volume + PipeFunctions.PipeOrNet(Another).Volume;
            float TotalReagents = Mix.Total + PipeFunctions.PipeOrNet(Another).Mix.Total;
            float TargetDensity = TotalReagents / TotalVolume;

            float thisAmount    = TargetDensity * Volume;
            float AnotherAmount = TargetDensity * PipeFunctions.PipeOrNet(Another).Volume;

            if (thisAmount > Mix.Total)
            {
                PipeFunctions.PipeOrNet(Another).Mix.TransferTo(Mix, PipeFunctions.PipeOrNet(Another).Mix.Total - AnotherAmount);
            }
            else
            {
                this.Mix.TransferTo(PipeFunctions.PipeOrNet(Another).Mix, AnotherAmount - PipeFunctions.PipeOrNet(Another).Mix.Total);
            }
        }
예제 #12
0
        public static List <PipeData> GetConnectedPipes(List <PipeData> ToPutInto, PipeData pipeData, Vector3Int Location,
                                                        Matrix LocatedOn)
        {
            for (var i = 0; i < pipeData.Connections.Directions.Length; i++)
            {
                if (pipeData.Connections.Directions[i].Bool)
                {
                    Vector3Int SearchVector = Vector3Int.zero;
                    switch (i)
                    {
                    case (int)PipeDirection.North:
                        SearchVector = Vector3Int.up;
                        break;

                    case (int)PipeDirection.East:
                        SearchVector = Vector3Int.right;
                        break;

                    case (int)PipeDirection.South:
                        SearchVector = Vector3Int.down;
                        break;

                    case (int)PipeDirection.West:
                        SearchVector = Vector3Int.left;
                        break;
                    }

                    SearchVector   = Location + SearchVector;
                    SearchVector.z = 0;
                    var PipesOnTile = LocatedOn.GetPipeConnections(SearchVector);
                    foreach (var pipe in PipesOnTile)
                    {
                        if (ArePipeCompatible(pipeData, i, pipe, out var pipe1ConnectAndType))
                        {
                            pipe1ConnectAndType.Connected = pipe;
                            ToPutInto.Add(pipe);
                        }
                    }
                }
            }

            return(ToPutInto);
        }
예제 #13
0
        public void ConnectedRemove(PipeData OldConnection)
        {
            ConnectedPipes.Remove(OldConnection);

            if (NetCompatible == false)
            {
                Outputs.Remove(OldConnection);
            }

            foreach (var Connection in Connections.Directions)
            {
                if (Connection.Connected == OldConnection)
                {
                    Connection.Connected = null;
                }
            }

            //What about net outputs then That should be handle as part of the Reconstruction of the net
        }
예제 #14
0
		public void SpreadPipenet(PipeData pipe)
		{
			List<PipeData> foundPipes = new List<PipeData>();
			foundPipes.Add(pipe);
			while (foundPipes.Count > 0)
			{
				var foundPipe = foundPipes[0];
				AddPipe(foundPipe);
				foundPipes.Remove(foundPipe);
				for (int i = 0; i < foundPipe.ConnectedPipes.Count; i++)
				{
					var nextPipe = foundPipe.ConnectedPipes[i];
					if (nextPipe.NetCompatible && nextPipe.OnNet == null)
					{
						foundPipes.Add(nextPipe);
					}
				}
			}
		}
예제 #15
0
        public static PipeDirection PipesToDirections(PipeData pipe1, PipeData pipe2)
        {
            var VectorDifference = pipe2.MatrixPos - pipe1.MatrixPos;

            if (VectorDifference == Vector3Int.up)
            {
                return(PipeDirection.North);
            }
            else if (VectorDifference == Vector3Int.right)
            {
                return(PipeDirection.East);
            }
            else if (VectorDifference == Vector3Int.down)
            {
                return(PipeDirection.South);
            }
            else if (VectorDifference == Vector3Int.left)
            {
                return(PipeDirection.West);
            }

            return(PipeDirection.North);
        }
예제 #16
0
		public void AddPipe(PipeData pipeData)
		{
			if (ISNewNet)
			{
				pipeData.OnNet = this;
				this.mixAndVolume = pipeData.mixAndVolume.Clone();
				pipeData.mixAndVolume.Empty();
				this.Covering.Add(pipeData);
				this.NetUpdateProxy.OnNet = this;
				this.NetUpdateProxy.OnEnable();
				if (pipeData.CustomLogic == CustomLogic.CoolingPipe)
				{
					this.pipeNetAction = new CoolingNet();
					this.pipeNetAction.LiquidPipeNet = this;
				}

				ISNewNet = false;

			}
			else
			{
				if (pipeData.OnNet == null)
				{
					pipeData.OnNet = this;
					mixAndVolume.Add(pipeData.mixAndVolume);
					Covering.Add(pipeData);
				}
				else
				{
					if (this != pipeData.OnNet)
					{
						this.CombinePipeNets(pipeData.OnNet);
					}
				}
			}
		}
예제 #17
0
        public static bool ArePipeCompatible(PipeData pipe1, int Direction, PipeData pipe2)
        {
            if (pipe1.PipeType == pipe2.PipeType)
            {
                if (pipe1.PipeLayer == pipe2.PipeLayer)
                {
                    int pipe2Direction = Direction + 2;
                    if (pipe2Direction > 3)
                    {
                        pipe2Direction -= 4;
                    }
                    if (pipe2.Connections.Directions[pipe2Direction].Bool)
                    {
                        if (pipe2.Connections.Directions[pipe2Direction].pipeType
                            .HasFlag(pipe1.Connections.Directions[Direction].pipeType))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
예제 #18
0
		public static LiquidPipeNet MakeNewNet(PipeData pipeData)
		{
			var Net = new LiquidPipeNet();
			Net.AddPipe(pipeData);
			return (Net);
		}
예제 #19
0
        /*public void AddInput(PipeData pipeData)
         * {
         *      Inputs.Add(pipeData);
         * }*/

        public void RemoveEqualiseWith(PipeData pipeData)
        {
            CanEqualiseWith.Remove(pipeData);
            //Inputs.Remove(pipeData);
        }
예제 #20
0
        public static bool IsPipeOutputTo(PipeData pipe1, PipeData pipe2)
        {
            var Data = pipe1.Connections.Directions[(int)PipesToDirections(pipe1, pipe2)];

            return(Data.Bool && Data.PortType.HasFlag(OutputType.Output_Allowed));
        }