public void Check() { InNorth = '0'; InSouth = '0'; InWest = '0'; InEast = '0'; Syncstring = "0000"; HashSet <ElectricalOIinheritance> connections = new HashSet <ElectricalOIinheritance>(); connections = ElectricityFunctions.SwitchCaseConnections(Wire.transform.localPosition, Wire.Matrix, Wire.InData.CanConnectTo, Connection.MachineConnect, Wire); foreach (var cn in connections) { Vector3 v3 = (cn.transform.localPosition - Wire.transform.localPosition).CutToInt(); if (v3 == Vector3.up) { InNorth = '1'; } else if (v3 == Vector3.down) { InSouth = '1'; } else if (v3 == Vector3.right) { InEast = '1'; } else if (v3 == Vector3.left) { InWest = '1'; } } Syncstring = InNorth.ToString() + InSouth.ToString() + InWest.ToString() + InEast.ToString(); UpdateSprites(null, Syncstring); }
/// <summary> /// <para>Replaces, builds a new electrical connection, and consumes /// cables from the hand.</para> /// <para>Destroys the electrical connection (if we're given one) and /// then adds a new electrical connection by adding an electrical /// node. We then calculate and consume a number of cables from the /// hand.</para> /// </summary> /// <param name="position">Position of the electrical connection.</param> /// <param name="eConn">Electrical connection we're replacing.</param> /// <param name="wireEndA">Connection direction of one end.</param> /// <param name="wireEndB">Connection direction of the other end.</param> private void ReplaceEConn(Vector3 position, IntrinsicElectronicData eConn, Connection wireEndA, Connection wireEndB, ConnectionApply interaction) { // Cost of cable coils to construct the original cable tile. Assume // 0 until we verify whether or not we are given an electrical // connection. int oldTileCost = 0; // Get the cost of the old tile. Then destroy the current // electrical connection only if we were given a connection. if (eConn != null) { oldTileCost = eConn.MetaDataPresent.RelatedTile.SpawnAmountOnDeconstruct; eConn.DestroyThisPlease(); } // Get the electrical cable tile with the wire connection direction. ElectricalCableTile tile = ElectricityFunctions.RetrieveElectricalTile(wireEndA, wireEndB, powerTypeCategory); // Then, add an electrical node at the tile. interaction.Performer.GetComponentInParent <Matrix>().AddElectricalNode(position.RoundToInt(), tile, true); // We only want to consume the difference needed to build the new // cable. int newTileCost = tile.SpawnAmountOnDeconstruct; int finalCost = newTileCost - oldTileCost; // Finally, consume the cables in the hands using the final cost // we found. Inventory.ServerConsume(interaction.HandSlot, finalCost); }
public static void ElectricityInput(float Current, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire) { //Logger.Log (tick.ToString () + " <tick " + Current.ToString () + " <Current " + SourceInstance.ToString () + " <SourceInstance " + ComingFrom.ToString () + " <ComingFrom " + Thiswire.ToString () + " <Thiswire ", Category.Electrical); int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Thiswire.Data.SourceVoltages.ContainsKey(SourceInstanceID))) { Thiswire.Data.SourceVoltages[SourceInstanceID] = new float(); } if (!(Thiswire.Data.CurrentComingFrom.ContainsKey(SourceInstanceID))) { Thiswire.Data.CurrentComingFrom[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>(); } Thiswire.Data.CurrentComingFrom[SourceInstanceID][ComingFrom] = Current; if (!(Thiswire.Data.ResistanceComingFrom.ContainsKey(SourceInstanceID))) { ElectricalSynchronisation.StructureChange = true; ElectricalSynchronisation.NUStructureChangeReact.Add(Thiswire.InData.ControllingUpdate); ElectricalSynchronisation.NUResistanceChange.Add(Thiswire.InData.ControllingUpdate); ElectricalSynchronisation.NUCurrentChange.Add(Thiswire.InData.ControllingUpdate); Logger.LogErrorFormat("Resistance isn't initialised on {1}", Category.Electrical, SourceInstance); return; } Thiswire.Data.SourceVoltages[SourceInstanceID] = Current * (ElectricityFunctions.WorkOutResistance(Thiswire.Data.ResistanceComingFrom[SourceInstanceID])); ELCurrent.CurrentWorkOnNextListADD(Thiswire); Thiswire.Data.CurrentStoreValue = ElectricityFunctions.WorkOutCurrent(Thiswire.Data.CurrentComingFrom[SourceInstanceID]); }
public void PowerNetworkUpdate() { //Logger.Log("humm..."); if (!(CashOfConnectedDevices == ElectricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices.Count)) { CashOfConnectedDevices = ElectricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices.Count; ConnectedDepartmentBatteries.Clear(); foreach (var Device in ElectricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices) { if (Device.Key.InData.Categorytype == PowerTypeCategory.DepartmentBattery) { if (!(ConnectedDepartmentBatteries.Contains(Device.Key.GetComponent <DepartmentBattery>()))) { ConnectedDepartmentBatteries.Add(Device.Key.GetComponent <DepartmentBattery>()); } } } } BatteryCharging = false; foreach (var bat in ConnectedDepartmentBatteries) { if (bat.BatterySupplyingModule.ChargingWatts > 0) { BatteryCharging = true; } } ElectricityFunctions.WorkOutActualNumbers(ElectricalNodeControl.Node.InData); SyncVoltage(voltageSync, ElectricalNodeControl.Node.InData.Data.ActualVoltage); Current = ElectricalNodeControl.Node.InData.Data.CurrentInWire; HandleDevices(); UpdateDisplay(); }
public override void ElectricityOutput(float Current, GameObject SourceInstance) { Data.ActualCurrentChargeInWire = ElectricityFunctions.WorkOutActualNumbers(this); Data.CurrentInWire = Data.ActualCurrentChargeInWire.Current; Data.ActualVoltage = Data.ActualCurrentChargeInWire.Voltage; Data.EstimatedResistance = Data.ActualCurrentChargeInWire.EstimatedResistant; }
public static void ElectricityOutput(int tick, float Current, GameObject SourceInstance, IElectricityIO Thiswire) { int SourceInstanceID = SourceInstance.GetInstanceID(); float SimplyTimesBy = 0; float SupplyingCurrent = 0; Dictionary <IElectricityIO, float> ThiswireResistance = new Dictionary <IElectricityIO, float>(); if (Thiswire.Data.ResistanceComingFrom.ContainsKey(SourceInstanceID)) { ThiswireResistance = Thiswire.Data.ResistanceComingFrom[SourceInstanceID]; } else { Logger.LogError("now It doesn't" + SourceInstanceID.ToString() + " with this " + Thiswire.GameObject().name.ToString(), Category.Electrical); } float Voltage = Current * (ElectricityFunctions.WorkOutResistance(ThiswireResistance)); foreach (KeyValuePair <IElectricityIO, float> JumpTo in Thiswire.Data.ResistanceComingFrom[SourceInstanceID]) { if (Voltage > 0) { SupplyingCurrent = (Voltage / JumpTo.Value); } else { SupplyingCurrent = Current; } if (!(Thiswire.Data.CurrentGoingTo.ContainsKey(SourceInstanceID))) { Thiswire.Data.CurrentGoingTo [SourceInstanceID] = new Dictionary <IElectricityIO, float> (); } Thiswire.Data.CurrentGoingTo [SourceInstanceID] [JumpTo.Key] = SupplyingCurrent; JumpTo.Key.ElectricityInput(tick, SupplyingCurrent, SourceInstance, Thiswire); } }
public override void PowerUpdateCurrentChange() { if (ControllingNode.Node.Data.SupplyDependent[ControllingNode.Node.gameObject.GetInstanceID()].ResistanceComingFrom.Count > 0) { if (!(SlowResponse && PullingWatts == 0)) { ControllingNode.Node.FlushSupplyAndUp(ControllingNode.Node.gameObject); //Room for optimisation CircuitResistance = ElectricityFunctions.WorkOutResistance(ControllingNode.Node.Data.SupplyDependent[ControllingNode.Node.gameObject.GetInstanceID()].ResistanceComingFrom); // //!! VoltageAtChargePort = ElectricityFunctions.WorkOutVoltageFromConnector(ControllingNode.Node, ResistanceSourceModule.ReactionTo.ConnectingDevice); VoltageAtSupplyPort = ElectricityFunctions.WorkOutVoltageFromConnectors(ControllingNode.Node, ControllingNode.CanConnectTo); BatteryCalculation.PowerUpdateCurrentChange(this); if (current != Previouscurrent) { if (Previouscurrent == 0 && !(current <= 0)) { } else if (current == 0 && !(Previouscurrent <= 0)) { ControllingNode.Node.FlushSupplyAndUp(ControllingNode.Node.gameObject); } ControllingNode.Node.Data.SupplyingCurrent = current; Previouscurrent = current; } } } else { CircuitResistance = 999999999999; } PowerSupplyFunction.PowerUpdateCurrentChange(this); }
public void DirectionInput(int tick, GameObject SourceInstance, IElectricityIO ComingFrom, IElectricityIO PassOn = null) { //Logger.Log(SourceInstance.ToString() + " < SourceInstance " + ComingFrom.ToString() + " < ComingFrom " + this.name + " < this " ); if (connections.Count > 2) { ElectricityFunctions.DirectionInput(tick, SourceInstance, ComingFrom, this); FirstPresentInspector = FirstPresent; } else { int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Upstream.ContainsKey(SourceInstanceID))) { Upstream [SourceInstanceID] = new HashSet <IElectricityIO> (); } if (!(Downstream.ContainsKey(SourceInstanceID))) { Downstream [SourceInstanceID] = new HashSet <IElectricityIO> (); } if (FirstPresent == 0) { //Logger.Log ("to It's been claimed", Category.Electrical); FirstPresent = SourceInstanceID; //Thiswire.FirstPresentInspector = SourceInstanceID; } if (ComingFrom != null) { Upstream [SourceInstanceID].Add(ComingFrom); } CameFromMemory = PassOn; SourceInstance.GetComponent <IProvidePower> ().DirectionWorkOnNextList.Add(this); } }
public virtual void PowerUpdateCurrentChange() { //Logger.Log("PowerUpdateCurrentChange()"+ this); if (powerSupply.Data.ResistanceComingFrom.Count > 0) { powerSupply.FlushSupplyAndUp(powerSupply.gameObject); //Room for optimisation CircuitResistance = ElectricityFunctions.WorkOutResistance(powerSupply.Data.ResistanceComingFrom[powerSupply.gameObject.GetInstanceID()]); // //!! ActualVoltage = powerSupply.Data.ActualVoltage; BatteryCalculation.PowerUpdateCurrentChange(this); if (current != Previouscurrent) { if (Previouscurrent == 0 && !(current <= 0)) { } else if (current == 0 && !(Previouscurrent <= 0)) { powerSupply.FlushSupplyAndUp(powerSupply.gameObject); } powerSupply.Data.SupplyingCurrent = current; Previouscurrent = current; } } powerSupply.PowerUpdateCurrentChange(); _PowerUpdateCurrentChange(); }
public void PowerUpdateCurrentChange() { RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject); //Room for optimisation CircuitResistance = ElectricityFunctions.WorkOutResistance(RelatedDevice.ResistanceComingFrom [RelatedDevice.gameObject.GetInstanceID()]); // //!! ActualVoltage = RelatedDevice.ActualVoltage; BatteryCalculation.PowerUpdateCurrentChange(this); if (current != Previouscurrent) { if (Previouscurrent == 0 && !(current <= 0)) { // } else if (current == 0 && !(Previouscurrent <= 0)) { RelatedDevice.FlushSupplyAndUp(RelatedDevice.gameObject); //powerSupply.TurnOffSupply(); } RelatedDevice.SupplyingCurrent = current; Previouscurrent = current; } //if (current > 0) { RelatedDevice.PowerUpdateCurrentChange(); //} }
/// <summary> ///The function for out putting current into other nodes (Basically doing ElectricityInput On another one) /// </summary> public virtual void ElectricityOutput(float Current, GameObject SourceInstance) { //SourceInstance.GetComponent<ElectricalOIinheritance>(); //Logger.Log("oh man?"); InputOutputFunctions.ElectricityOutput(Current, SourceInstance, this); ElectricityFunctions.WorkOutActualNumbers(this); }
public void ElectricityInput(int tick, float Current, GameObject SourceInstance, IElectricityIO ComingFrom) { Current = RelatedDevice.ModifyElectricityInput(tick, Current, SourceInstance, ComingFrom); //Logger.Log(Current.ToString() + "yoree"); ElectricityFunctions.ElectricityInput(tick, Current, SourceInstance, ComingFrom, this); }
public static void ElectricityOutput(VIRCurrent Current, ElectricalOIinheritance SourceInstance, IntrinsicElectronicData Thiswire) { //Logger.Log("4 > " + Current); //Logger.Log("poke > " + SourceInstance.InData.Data.SupplyDependent[SourceInstance].ToString()); var OutputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstance]; VIRCurrent SupplyingCurrent = null; float Divider = (ElectricityFunctions.WorkOutResistance(OutputSupplyingUsingData.ResistanceComingFrom)); foreach (KeyValuePair <IntrinsicElectronicData, VIRResistances> JumpTo in OutputSupplyingUsingData .ResistanceComingFrom) { if (OutputSupplyingUsingData.ResistanceComingFrom.Count > 1) { SupplyingCurrent = Current.SplitCurrent(Divider / JumpTo.Value.Resistance()); } else { SupplyingCurrent = Current; } OutputSupplyingUsingData.CurrentGoingTo[JumpTo.Key] = SupplyingCurrent; if (JumpTo.Key != null && JumpTo.Key.Categorytype != PowerTypeCategory.DeadEndConnection) { JumpTo.Key.ElectricityInput(SupplyingCurrent, SourceInstance, Thiswire); } } }
public void PowerNetworkUpdate() { if (cacheOfConnectedDevices != electricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices.Count) { cacheOfConnectedDevices = electricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices.Count; connectedDepartmentBatteries.Clear(); foreach (var device in electricalNodeControl.Node.InData.Data.ResistanceToConnectedDevices) { if (device.Key.Data.InData.Categorytype != PowerTypeCategory.DepartmentBattery) { continue; } if (!connectedDepartmentBatteries.Contains(device.Key.Data.GetComponent <DepartmentBattery>())) { connectedDepartmentBatteries.Add(device.Key.Data.GetComponent <DepartmentBattery>()); } } } batteryCharging = false; foreach (var bat in connectedDepartmentBatteries) { if (bat.BatterySupplyingModule.ChargingWatts > 0) { batteryCharging = true; } } ElectricityFunctions.WorkOutActualNumbers(electricalNodeControl.Node.InData); SyncVoltage(voltageSync, electricalNodeControl.Node.InData.Data.ActualVoltage); Current = electricalNodeControl.Node.InData.Data.CurrentInWire; HandleDevices(); }
public static void ResistanceInput(int tick, float Resistance, GameObject SourceInstance, IElectricityIO ComingFrom, IElectricityIO Thiswire) { if (ComingFrom == null) { Resistance = Thiswire.PassedDownResistance; ComingFrom = ElectricalSynchronisation.DeadEnd; //Logger.Log (ComingFrom.ToString () + " ComingFrom "); } int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Thiswire.ResistanceComingFrom.ContainsKey(SourceInstanceID))) { Thiswire.ResistanceComingFrom [SourceInstanceID] = new Dictionary <IElectricityIO, float> (); } if (!(Thiswire.ResistanceGoingTo.ContainsKey(SourceInstanceID))) { Thiswire.ResistanceGoingTo [SourceInstanceID] = new Dictionary <IElectricityIO, float> (); } //Logger.Log (Resistance.ToString () + " Resistance 3w"); //if (ComingFrom != null) { Thiswire.ResistanceComingFrom [SourceInstanceID] [ComingFrom] = Resistance; //} Thiswire.ResistancyOutput(tick, ElectricityFunctions.WorkOutResistance(Thiswire.ResistanceComingFrom [SourceInstanceID]), SourceInstance); // } else { // Logger.Log ("Is it this "); // } }
protected override void ShowDetails() { if (isServer) { ElectricityFunctions.WorkOutActualNumbers(this); Logger.Log("connections " + (string.Join(",", Data.connections)), Category.Electrical); Logger.Log("ID " + (this.GetInstanceID()), Category.Electrical); Logger.Log("Type " + (InData.Categorytype.ToString()), Category.Electrical); Logger.Log("Can connect to " + (string.Join(",", InData.CanConnectTo)), Category.Electrical); foreach (var Supply in Data.SupplyDependent) { LogSupply(Supply); } if (RelatedLine != null) { Logger.Log("line heree!!!"); ElectricityFunctions.WorkOutActualNumbers(RelatedLine.TheEnd); Data.ActualVoltage = RelatedLine.TheEnd.Data.ActualVoltage; Data.CurrentInWire = RelatedLine.TheEnd.Data.CurrentInWire; Data.EstimatedResistance = RelatedLine.TheEnd.Data.EstimatedResistance; foreach (var Supply in RelatedLine.TheEnd.Data.SupplyDependent) { LogSupply(Supply); } } Logger.Log(" ActualVoltage > " + Data.ActualVoltage + " CurrentInWire > " + Data.CurrentInWire + " EstimatedResistance > " + Data.EstimatedResistance, Category.Electrical); } RequestElectricalStats.Send(PlayerManager.LocalPlayer, gameObject); }
public virtual void ShowDetails() { ElectricityFunctions.WorkOutActualNumbers(this); Logger.Log("connections " + (string.Join(",", Data.connections)), Category.Electrical); //Logger.Log("ID " + (this.GetInstanceID()), Category.Electrical); Logger.Log("Type " + (Categorytype.ToString()), Category.Electrical); Logger.Log("Can connect to " + (string.Join(",", CanConnectTo)), Category.Electrical); Logger.Log("WireEndA > " + WireEndA + " WireEndB > " + WireEndB, Category.Electrical); foreach (var Supply in Data.SupplyDependent) { string ToLog; ToLog = "Supply > " + Supply.Key + "\n"; ToLog += "Upstream > "; ToLog += string.Join(",", Supply.Value.Upstream) + "\n"; ToLog += "Downstream > "; ToLog += string.Join(",", Supply.Value.Downstream) + "\n"; ToLog += "ResistanceGoingTo > "; ToLog += string.Join(",", Supply.Value.ResistanceGoingTo) + "\n"; ToLog += "ResistanceComingFrom > "; ToLog += string.Join(",", Supply.Value.ResistanceComingFrom) + "\n"; ToLog += "CurrentComingFrom > "; ToLog += string.Join(",", Supply.Value.CurrentComingFrom) + "\n"; ToLog += "CurrentGoingTo > "; ToLog += string.Join(",", Supply.Value.CurrentGoingTo) + "\n"; ToLog += "SourceVoltages > "; ToLog += string.Join(",", Supply.Value.SourceVoltage) + "\n"; Logger.Log(ToLog, Category.Electrical); } Logger.Log(" ActualVoltage > " + Data.ActualVoltage + " CurrentInWire > " + Data.CurrentInWire + " EstimatedResistance > " + Data.EstimatedResistance, Category.Electrical); }
public void ResistancyOutput(int tick, GameObject SourceInstance) { int SourceInstanceID = SourceInstance.GetInstanceID(); float Resistance = ElectricityFunctions.WorkOutResistance(Data.ResistanceComingFrom [SourceInstanceID]); InputOutputFunctions.ResistancyOutput(tick, Resistance, SourceInstance, this); }
protected virtual void ShowDetails() { if (isServer) { ElectricityFunctions.WorkOutActualNumbers(this); Logger.Log("connections " + (string.Join(",", Data.connections)), Category.Electrical); Logger.Log("ID " + (this.GetInstanceID()), Category.Electrical); Logger.Log("Type " + (InData.Categorytype.ToString()), Category.Electrical); Logger.Log("Can connect to " + (string.Join(",", InData.CanConnectTo)), Category.Electrical); foreach (var Supply in Data.SupplyDependent) { string ToLog; ToLog = "Supply > " + Supply.Key + "\n"; ToLog += "Upstream > "; ToLog += string.Join(",", Supply.Value.Upstream) + "\n"; ToLog += "Downstream > "; ToLog += string.Join(",", Supply.Value.Downstream) + "\n"; ToLog += "ResistanceGoingTo > "; ToLog += string.Join(",", Supply.Value.ResistanceGoingTo) + "\n"; ToLog += "ResistanceComingFrom > "; ToLog += string.Join(",", Supply.Value.ResistanceComingFrom) + "\n"; ToLog += "CurrentComingFrom > "; ToLog += string.Join(",", Supply.Value.CurrentComingFrom) + "\n"; ToLog += "CurrentGoingTo > "; ToLog += string.Join(",", Supply.Value.CurrentGoingTo) + "\n"; ToLog += Supply.Value.SourceVoltages.ToString(); Logger.Log(ToLog, Category.Electrical); } Logger.Log(" ActualVoltage > " + Data.ActualVoltage + " CurrentInWire > " + Data.CurrentInWire + " EstimatedResistance > " + Data.EstimatedResistance, Category.Electrical); } RequestElectricalStats.Send(PlayerManager.LocalPlayer, gameObject); }
/// <summary> /// [Message Handler] Perform cable cutting interaction on server side /// </summary> private void ServerPerformCableCuttingInteraction(NetworkConnection conn, CableCuttingWindow.CableCuttingMessage message) { // get object at target position GameObject hit = MouseUtils.GetOrderedObjectsAtPoint(message.targetWorldPosition).FirstOrDefault(); // get matrix Matrix matrix = hit.GetComponentInChildren <Matrix>(); // return if matrix is null if (matrix == null) { return; } // convert world position to cell position and set Z value to Z value from message Vector3Int targetCellPosition = matrix.MetaTileMap.WorldToCell(message.targetWorldPosition); targetCellPosition.z = message.positionZ; // get electical tile from targetCellPosition ElectricalCableTile electricalCable = matrix.UnderFloorLayer.GetTileUsingZ(targetCellPosition) as ElectricalCableTile; if (electricalCable == null) { return; } // add messages to chat string othersMessage = Chat.ReplacePerformer(othersStartActionMessage, message.performer); Chat.AddActionMsgToChat(message.performer, performerStartActionMessage, othersMessage); // source: ElectricalCableDeconstruction.cs var metaDataNode = matrix.GetMetaDataNode(targetCellPosition); foreach (var ElectricalData in metaDataNode.ElectricalData) { if (ElectricalData.RelatedTile != electricalCable) { continue; } // Electrocute the performer. If shock is painful enough, cancel the interaction. ElectricityFunctions.WorkOutActualNumbers(ElectricalData.InData); float voltage = ElectricalData.InData.Data.ActualVoltage; var electrocution = new Electrocution(voltage, message.targetWorldPosition, "cable"); var performerLHB = message.performer.GetComponent <LivingHealthBehaviour>(); var severity = performerLHB.Electrocute(electrocution); if (severity > LivingShockResponse.Mild) { return; } ElectricalData.InData.DestroyThisPlease(); Spawn.ServerPrefab(electricalCable.SpawnOnDeconstruct, message.targetWorldPosition, count: electricalCable.SpawnAmountOnDeconstruct); return; } }
public override void ResistancyOutput(GameObject SourceInstance) { int SourceInstanceID = SourceInstance.GetInstanceID(); float Resistance = ElectricityFunctions.WorkOutResistance(Data.ResistanceComingFrom[SourceInstanceID]); Resistance = RelatedDevice.ModifyResistancyOutput(Resistance, SourceInstance); InputOutputFunctions.ResistancyOutput(Resistance, SourceInstance, this); }
public void ElectricityOutput(int tick, float Current, GameObject SourceInstance) { InputOutputFunctions.ElectricityOutput(tick, Current, SourceInstance, this); Data.ActualCurrentChargeInWire = ElectricityFunctions.WorkOutActualNumbers(this); Data.CurrentInWire = Data.ActualCurrentChargeInWire.Current; Data.ActualVoltage = Data.ActualCurrentChargeInWire.Voltage; Data.EstimatedResistance = Data.ActualCurrentChargeInWire.EstimatedResistant; }
public void ElectricityOutput(int tick, float Current, GameObject SourceInstance) { ActualCurrentChargeInWire = ElectricityFunctions.WorkOutActualNumbers(this); CurrentInWire = ActualCurrentChargeInWire.Current; ActualVoltage = ActualCurrentChargeInWire.Voltage; EstimatedResistance = ActualCurrentChargeInWire.EstimatedResistant; //Logger.Log (Voltage.ToString () + "Voltage man", Category.Electrical); }
public override void ResistancyOutput(GameObject SourceInstance) { int SourceInstanceID = SourceInstance.GetInstanceID(); float Resistance = ElectricityFunctions.WorkOutResistance(Data.SupplyDependent[SourceInstanceID].ResistanceComingFrom); Resistance = InData.ControllingDevice.ModifyResistancyOutput(Resistance, SourceInstance); InputOutputFunctions.ResistancyOutput(Resistance, SourceInstance, this); }
public void ResistanceInput(int tick, float Resistance, GameObject SourceInstance, IElectricityIO ComingFrom) { //if (Time.time > 20) { //Logger.Log ("heLP!!!"); //} else { ElectricityFunctions.ResistanceInput(tick, Resistance, SourceInstance, ComingFrom, this); //} }
public void ElectricityOutput(int tick, float Current, GameObject SourceInstance) { //Logger.Log(Current.ToString() + "yoree"); //Logger.Log (CurrentInWire.ToString () + " How much current", Category.Electrical); ElectricityFunctions.ElectricityOutput(tick, Current, SourceInstance, this); CurrentInWire = ActualCurrentChargeInWire.Current; ActualVoltage = ActualCurrentChargeInWire.Voltage; EstimatedResistance = ActualCurrentChargeInWire.EstimatedResistant; }
public void PowerNetworkUpdate() { powerSupply.PowerNetworkUpdate(); ActualVoltage = powerSupply.ActualVoltage; BatteryCalculation.PowerNetworkUpdate(this); if (ChangeToOff) { ChangeToOff = false; //PassChangeToOff = true; //ElectricalSynchronisation.ResistanceChange = true; //ElectricalSynchronisation.CurrentChange = true; //powerSupply.TurnOffSupply(); powerSupply.TurnOffSupply(); BatteryCalculation.TurnOffEverything(this); ElectricalSynchronisation.RemoveSupply(this, ApplianceType); } if (current != Previouscurrent) { if (Previouscurrent == 0 && !(current <= 0)) { // } else if (current == 0 && !(Previouscurrent <= 0)) { Logger.Log("FlushSupplyAndUp"); powerSupply.FlushSupplyAndUp(powerSupply.gameObject); //powerSupply.TurnOffSupply(); } powerSupply.SupplyingCurrent = current; Previouscurrent = current; ElectricalSynchronisation.CurrentChange = true; } if (Resistance != PreviousResistance) { if (PreviousResistance == 0 && !(Resistance == 0)) { powerSupply.CanProvideResistance = true; } else if (Resistance == 0 && !(PreviousResistance <= 0)) { powerSupply.CanProvideResistance = false; ElectricityFunctions.CleanConnectedDevices(powerSupply); } powerSupply.PassedDownResistance = Resistance; PreviousResistance = Resistance; ElectricalSynchronisation.ResistanceChange = true; ElectricalSynchronisation.CurrentChange = true; } Logger.Log(CurrentCapacity.ToString() + " < CurrentCapacity", Category.Electrical); }
public virtual void PowerNetworkUpdate() { ElectricityFunctions.WorkOutActualNumbers(wireConnect); if (MaximumInstantBreakCurrent != 0 && CanOverCurrent) { if (MaximumInstantBreakCurrent < wireConnect.Data.CurrentInWire) { QueueForDemolition(this); return; } if (MaximumBreakdownCurrent < wireConnect.Data.CurrentInWire) { if (CheckDestruction) { if (wireConnect.RelatedLine != null) { foreach (var CB in wireConnect.RelatedLine.Covering) { CB.gameObject.GetComponent <CableInheritance>()?.Smoke.Stop(); } } QueueForDemolition(this); return; } else { if (wireConnect.RelatedLine != null) { foreach (var CB in wireConnect.RelatedLine.Covering) { CB.gameObject.GetComponent <CableInheritance>()?.Smoke.Play(); } } Smoke.Play(); StartCoroutine(WaitForDemolition()); return; } } if (CheckDestruction) { CheckDestruction = false; if (wireConnect.RelatedLine != null) { foreach (var CB in wireConnect.RelatedLine.Covering) { CB.gameObject.GetComponent <CableInheritance>()?.Smoke.Stop(); } } Smoke.Stop(); } if (IsSparking()) { Sparks.Stop(); } } }
//Output electricity to this next wire/object public void ResistancyOutput(int tick, float Resistance, GameObject SourceInstance) { //Logger.Log (SourceInstance.GetInstanceID().ToString() + " < Receive | is > " + this.gameObject.GetInstanceID().ToString() ); if (!(SourceInstance == this.gameObject)) { ElectricityFunctions.ResistancyOutput(tick, Resistance, SourceInstance, this); } //VisibleResistance = Resistance; }
public void PowerNetworkUpdate() { ElectricityFunctions.WorkOutActualNumbers(Node); UpPowerNetworkUpdate(); if (NodeControl != null) { NodeControl.PowerNetworkUpdate(); } }