public bool CanEqualiseWithThis(PipeData Pipe) { if (Pipe.NetCompatible == false) { return(PipeFunctions.CanEqualiseWith(this.pipeData, Pipe)); } return(true); }
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(); }
public static MixAndVolume PipeOrNet(PipeData pipe) { if (pipe.NetCompatible && pipe.OnNet != null) { return(pipe.OnNet.mixAndVolume); } else { return(pipe.mixAndVolume); } }
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)); }
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 }
public void RemovePipe(PipeData pipeData) { pipeData.OnNet = null; var Outmix = mixAndVolume.Take(pipeData.mixAndVolume); Covering.Remove(pipeData); pipeData.SpillContent(Outmix); SplitPipeNets(); }
//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(); }
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); }
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); } } }
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); } } } }
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); } }
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); }
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 }
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); } } } }
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); }
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); } } } }
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); }
public static LiquidPipeNet MakeNewNet(PipeData pipeData) { var Net = new LiquidPipeNet(); Net.AddPipe(pipeData); return (Net); }
/*public void AddInput(PipeData pipeData) * { * Inputs.Add(pipeData); * }*/ public void RemoveEqualiseWith(PipeData pipeData) { CanEqualiseWith.Remove(pipeData); //Inputs.Remove(pipeData); }
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)); }