public virtual void ServerPerformInteraction(HandApply interaction) { if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wrench)) { var ZeroedLocation = new Vector3Int(x: registerItem.LocalPosition.x, y: registerItem.LocalPosition.y, 0); var metaData = registerItem.Matrix.MetaDataLayer.Get(ZeroedLocation); var thisConnections = GetConnections(); int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); thisConnections.Rotate(Offset); foreach (var Pipeo in metaData.PipeData) { var TheConnection = Pipeo.pipeData.Connections; for (int i = 0; i < thisConnections.Directions.Length; i++) { if (thisConnections.Directions[i].Bool && TheConnection.Directions[i].Bool) { return; } } } ToolUtils.ServerPlayToolSound(interaction); BuildPipe(); } rotatable.Rotate(); }
public static Connections GetRotatedConnection(PipeTile pipeTile, Matrix4x4 matrixStruct) { var offset = PipeFunctions.GetOffsetAngle(matrixStruct.rotation.eulerAngles.z); var connection = pipeTile.Connections.Copy(); connection.Rotate(offset); return(connection); }
public bool CanEqualiseWithThis(PipeData Pipe) { if (Pipe.NetCompatible == false) { return(PipeFunctions.CanEqualiseWith(this.pipeData, Pipe)); } return(true); }
public void InitialiseNode(Vector3Int Location, Matrix matrix) { var ZeroedLocation = new Vector3Int(x: Location.x, y: Location.y, 0); var metaData = matrix.MetaDataLayer.Get(ZeroedLocation); var pipeNode = new PipeNode(); var rotation = matrix.UnderFloorLayer.Tilemap.GetTransformMatrix(Location); int Offset = PipeFunctions.GetOffsetAngle(rotation.rotation.eulerAngles.z); pipeNode.Initialise(this, metaData, ZeroedLocation, matrix, Offset); metaData.PipeData.Add(pipeNode); }
public void InitialiseNodeNew(Vector3Int Location, Matrix matrix, Matrix4x4 Matrix4x4) { var ZeroedLocation = new Vector3Int(x: Location.x, y: Location.y, 0); var metaData = matrix.MetaDataLayer.Get(ZeroedLocation); var pipeNode = new PipeNode(); var rotation = Matrix4x4; int Offset = PipeFunctions.GetOffsetAngle(rotation.rotation.eulerAngles.z); pipeNode.Initialise(this, metaData, ZeroedLocation, matrix, Offset); metaData.PipeData.Add(pipeNode); }
public override void TickUpdate() { if (IsOn == false) { return; } var PressureDensity = pipeData.mixAndVolume.Density(); if (PressureDensity.x > MaxPressure && PressureDensity.y > MaxPressure) { return; } var tomove = new Vector2(Mathf.Abs((PressureDensity.x / MaxPressure) - 1), Mathf.Abs((PressureDensity.y / MaxPressure) - 1)); Vector2 AvailableReagents = new Vector2(0f, 0f); foreach (var Pipe in pipeData.ConnectedPipes) { if (pipeData.Outputs.Contains(Pipe) == false && CanEqualiseWithThis(Pipe)) { var Data = PipeFunctions.PipeOrNet(Pipe); AvailableReagents += Data.Total; } } Vector2 TotalRemove = Vector2.zero; TotalRemove.x = (TransferMoles) > AvailableReagents.x ? AvailableReagents.x : TransferMoles; TotalRemove.y = (TransferMoles) > AvailableReagents.y ? AvailableReagents.y : TransferMoles; TotalRemove.x = tomove.x > 1 ? 0 : TotalRemove.x; TotalRemove.y = tomove.y > 1 ? 0 : TotalRemove.y; foreach (var Pipe in pipeData.ConnectedPipes) { if (pipeData.Outputs.Contains(Pipe) == false && CanEqualiseWithThis(Pipe)) { //TransferTo var Data = PipeFunctions.PipeOrNet(Pipe); Data.TransferTo(pipeData.mixAndVolume, (Data.Total / AvailableReagents) * TotalRemove); } } pipeData.mixAndVolume.EqualiseWithOutputs(pipeData.Outputs); }
protected void SetUpPipes() { if (pipeData.PipeAction == null) { pipeData.PipeAction = new MonoActions(); } registerTile.SetPipeData(pipeData); pipeData.MonoPipe = this; int Offset = PipeFunctions.GetOffsetAngle(transform.localRotation.eulerAngles.z); pipeData.Connections.Rotate(Offset); pipeData.OnEnable(); spritehandler.OrNull()?.gameObject.OrNull()?.SetActive(true); spritehandler.OrNull()?.SetColor(Colour); }
public override void BuildPipe() { var pipe = GetPipeObject(); if (pipe == null) { return; } int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion?rot = Quaternion.Euler(0.0f, 0.0f, Offset); var New = Spawn.ServerPrefab(pipe.gameObject, registerItem.WorldPositionServer, localRotation: rot); New.GameObject.GetComponent <MonoPipe>().SetColour(Colour); _ = Despawn.ServerSingle(gameObject); }
public override void TickUpdate() { Vector2 AvailableReagents = new Vector2(0f, 0f); foreach (var Pipe in pipeData.ConnectedPipes) { if (pipeData.Outputs.Contains(Pipe) == false && CanEqualiseWithThis(Pipe)) { var Data = PipeFunctions.PipeOrNet(Pipe); AvailableReagents += Data.Total; } } Vector2 TotalRemove = Vector2.zero; if ((UnitPerTick * PowerPercentage) > AvailableReagents.x) { TotalRemove.x = AvailableReagents.x; } else { TotalRemove.x = (UnitPerTick * PowerPercentage); } if ((UnitPerTick * PowerPercentage) > AvailableReagents.y) { TotalRemove.y = AvailableReagents.y; } else { TotalRemove.y = (UnitPerTick * PowerPercentage); } foreach (var Pipe in pipeData.ConnectedPipes) { if (pipeData.Outputs.Contains(Pipe) == false && CanEqualiseWithThis(Pipe)) { //TransferTo var Data = PipeFunctions.PipeOrNet(Pipe); Data.TransferTo(pipeData.mixAndVolume, (Data.Total / AvailableReagents) * TotalRemove); } } pipeData.mixAndVolume.EqualiseWithOutputs(pipeData.Outputs); }
private void OnDrawGizmos() { var density = pipeData.mixAndVolume.Density(); Gizmos.color = Color.white; DebugGizmoUtils.DrawText(density.ToString(), transform.position, 10); Gizmos.color = Color.magenta; Connections InCopy = pipeData.Connections; if (Application.isPlaying == false) { InCopy = pipeData.Connections.Copy(); int offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); InCopy.Rotate(offset); } if (InCopy.Directions[0].Bool) { var Toues = transform.position; Toues.y += 0.25f; Gizmos.DrawCube(Toues, Vector3.one * 0.08f); } if (InCopy.Directions[1].Bool) { var Toues = transform.position; Toues.x += 0.25f; Gizmos.DrawCube(Toues, Vector3.one * 0.08f); } if (InCopy.Directions[2].Bool) { var Toues = transform.position; Toues.y += -0.25f; Gizmos.DrawCube(Toues, Vector3.one * 0.08f); } if (InCopy.Directions[3].Bool) { var Toues = transform.position; Toues.x += -0.25f; Gizmos.DrawCube(Toues, Vector3.one * 0.08f); } }
public override void BuildPipe() { var searchVec = registerItem.LocalPosition; var tile = GetPipeTile(); if (tile == null) { return; } int Offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); Quaternion rot = Quaternion.Euler(0.0f, 0.0f, Offset); var Matrix = Matrix4x4.TRS(Vector3.zero, rot, Vector3.one); searchVec = registerItem.Matrix.TileChangeManager.UpdateTile(searchVec, tile, Matrix, Colour); tile.InitialiseNodeNew(searchVec, registerItem.Matrix, Matrix); _ = Despawn.ServerSingle(this.gameObject); }
/// <summary> /// Ensures that all containers have the same pressure /// </summary> /// <param name="otherGas"></param> public void MergeGasMixes(List <PipeData> otherGas) { float totalVolume = Volume; float totalInternalEnergy = InternalEnergy; float totalWholeHeatCapacity = WholeHeatCapacity; foreach (var gasMix in otherGas) { totalInternalEnergy += PipeFunctions.PipeOrNet(gasMix).GetGasMix().InternalEnergy; totalWholeHeatCapacity += PipeFunctions.PipeOrNet(gasMix).GetGasMix().WholeHeatCapacity; totalVolume += PipeFunctions.PipeOrNet(gasMix).GetGasMix().Volume; } float Newtemperature = totalInternalEnergy / totalWholeHeatCapacity; for (int i = 0; i < Gas.Count; i++) { float gas = (Gases[i]); foreach (var gasMix in otherGas) { gas += PipeFunctions.PipeOrNet(gasMix).GetGasMix().Gases[i]; } gas /= totalVolume; Gases[i] = gas * Volume; foreach (var gasMix in otherGas) { var Ingas = PipeFunctions.PipeOrNet(gasMix).GetGasMix(); Ingas.Gases[i] = gas * Ingas.Volume; PipeFunctions.PipeOrNet(gasMix).SetGasMix(Ingas); } } SetTemperature(Newtemperature); foreach (var gasMix in otherGas) { var getMixAndVolume = gasMix.GetMixAndVolume; var gasm = getMixAndVolume.GetGasMix(); gasm.SetTemperature(Newtemperature); getMixAndVolume.SetGasMix(gasm); } }
public virtual void ServerPerformInteraction(HandApply interaction) { if (Validations.HasItemTrait(interaction.UsedObject, CommonTraits.Instance.Wrench)) { var metaDataNode = registerItem.Matrix.MetaDataLayer.Get(registerItem.LocalPositionServer); var connectionsCopy = GetConnections(); int offset = PipeFunctions.GetOffsetAngle(transform.localEulerAngles.z); connectionsCopy.Rotate(offset); if (PipeTile.CanAddPipe(metaDataNode, connectionsCopy) == false) { return; } ToolUtils.ServerPlayToolSound(interaction); BuildPipe(); } else { rotatable.Rotate(); } }