public static void PowerUpdateCurrentChange(ElectricalOIinheritance Supply)
    {
        Supply.FlushSupplyAndUp(Supply.GameObject());
        if (Supply.connectedDevices.Count > 0)
        {
            if (!Supply.Data.ChangeToOff)
            {
                if (Supply.Data.SupplyingCurrent != 0)
                {
                    Supply.ElectricityOutput(Supply.Data.SupplyingCurrent, Supply.GameObject());
                }
                else if (Supply.Data.SupplyingVoltage != 0)
                {
                    int SourceInstanceID = Supply.GameObject().GetInstanceID();
                    Supply.ElectricityOutput((Supply.Data.SupplyingVoltage) / (Supply.Data.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.Data.ResistanceComingFrom[SourceInstanceID])), Supply.GameObject());
                }
            }
            else
            {
                foreach (ElectricalOIinheritance connectedDevice in Supply.connectedDevices)
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
            ELCurrent.Currentloop(Supply.GameObject());
        }

        if (Supply.Data.ChangeToOff)
        {
            Supply.Data.ChangeToOff = false;
            Supply.InData.ControllingDevice.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.InData.ControllingUpdate, Supply.InData.Categorytype);
        }
    }
Exemplo n.º 2
0
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        Supply.ControllingNode.Node.FlushSupplyAndUp(Supply.gameObject);
        if (!Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            if (Supply.ControllingNode.Node.Data.SupplyingCurrent != 0)
            {
                Supply.ControllingNode.Node.ElectricityOutput(Supply.ControllingNode.Node.Data.SupplyingCurrent, Supply.ControllingNode.Node.GameObject());
            }
            else if (Supply.ControllingNode.Node.Data.SupplyingVoltage != 0)
            {
                int   SourceInstanceID = Supply.ControllingNode.Node.GameObject().GetInstanceID();
                float Current          = (Supply.SupplyingVoltage) / (Supply.InternalResistance + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.Data.SupplyDependent[SourceInstanceID].ResistanceComingFrom));
                Supply.ControllingNode.Node.ElectricityOutput(Current, Supply.gameObject);
            }
        }
        else
        {
            foreach (ElectricalOIinheritance connectedDevice in Supply.ControllingNode.Node.connectedDevices)
            {
                if (ElectricalSynchronisation.ReactiveSuppliesSet.Contains(connectedDevice.InData.Categorytype))
                {
                    ElectricalSynchronisation.NUCurrentChange.Add(connectedDevice.InData.ControllingDevice);
                }
            }
        }
        ELCurrent.Currentloop(Supply.gameObject);

        if (Supply.ControllingNode.Node.Data.ChangeToOff)
        {
            Supply.ControllingNode.Node.Data.ChangeToOff = false;
            Supply.ControllingNode.TurnOffCleanup();
            ElectricalSynchronisation.RemoveSupply(Supply.ControllingNode.Node.InData.ControllingDevice, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }