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);
    }
Example #2
0
 public override void PowerUpdateStructureChangeReact()
 {
     PowerSupplyFunction.PowerUpdateStructureChangeReact(this);
     ElectricalSynchronisation.NUStructureChangeReact.Add(ControllingNode);
     ElectricalSynchronisation.NUResistanceChange.Add(ControllingNode);
     ElectricalSynchronisation.NUCurrentChange.Add(ControllingNode);
 }
Example #3
0
    public override void PowerUpdateStructureChangeReact()
    {
        PowerSupplyFunction.PowerUpdateStructureChangeReact(this);
        var sync = ElectricalManager.Instance.electricalSync;

        sync.NUResistanceChange.Add(ControllingNode);
        sync.NUCurrentChange.Add(ControllingNode);
    }
Example #4
0
 public override void TurnOffSupply()
 {
     if (InternalResistance > 0)
     {
         foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo)
         {
             ControllingNode.RestoreResistance(Connecting);
         }
     }
     ElectricalSynchronisation.NUResistanceChange.Add(ControllingNode);
     PowerSupplyFunction.TurnOffSupply(this);
 }
 public override void TurnOnSupply()
 {
     if (InternalResistance > 0)
     {
         foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo)
         {
             ControllingNode.OverlayInternalResistance(InternalResistance, Connecting);
         }
         ElectricalManager.Instance.electricalSync.NUResistanceChange.Add(ControllingNode);
     }
     PowerSupplyFunction.TurnOnSupply(this);
 }
Example #6
0
    public override void TurnOffSupply()
    {
        if (InternalResistance > 0)
        {
            foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo)
            {
                ControllingNode.RestoreResistance(Connecting);
            }
        }

        if (ElectricalManager.Instance?.electricalSync?.NUResistanceChange != null)
        {
            ElectricalManager.Instance.electricalSync.NUResistanceChange.Add(ControllingNode);
        }

        PowerSupplyFunction.TurnOffSupply(this);
    }
Example #7
0
    public override void TurnOffSupply()
    {
        if (InternalResistance > 0)
        {
            foreach (PowerTypeCategory Connecting in ControllingNode.CanConnectTo)
            {
                ControllingNode.RestoreResistance(Connecting);
            }
        }


        // On some transitional scenes like the DontDestroyOnLoad scene, we don't have an ElectricalManager.
        // We should not try to update it in those cases.
        if (ElectricalManager.Instance?.electricalSync?.NUResistanceChange != null)
        {
            ElectricalManager.Instance.electricalSync.NUResistanceChange.Add(ControllingNode);
            PowerSupplyFunction.TurnOffSupply(this);
        }
    }
 public override void TurnOffSupply()
 {
     isOnForInterface = false;
     PowerSupplyFunction.TurnOffSupply(this);
 }
 public override void TurnOnSupply()
 {
     isOnForInterface = true;
     PowerSupplyFunction.TurnOnSupply(this);
 }
Example #10
0
 public void PowerUpdateCurrentChange()
 {
     PowerSupplyFunction.PowerUpdateCurrentChange(this);
 }
Example #11
0
 public void PowerUpdateStructureChangeReact()
 {
     PowerSupplyFunction.PowerUpdateStructureChangeReact(this);
 }
Example #12
0
 public void TurnOffSupply()
 {
     PowerSupplyFunction.TurnOffSupply(this);
 }