Beispiel #1
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);
        }
    }
 private void Awake()
 {
     electricalNodeControl = GetComponent <ElectricalNodeControl>();
     moduleSupplyingDevice = GetComponent <ModuleSupplyingDevice>();
     pushPull     = GetComponent <PushPull>();
     registerTile = GetComponent <RegisterTile>();
 }
 private void Awake()
 {
     electricalNodeControl = GetComponent <ElectricalNodeControl>();
     moduleSupplyingDevice = GetComponent <ModuleSupplyingDevice>();
     wrenchSecurable       = GetComponent <WrenchSecurable>();
     registerTile          = GetComponent <RegisterTile>();
 }
Beispiel #4
0
 public static void TurnOnSupply(ModuleSupplyingDevice Supply)
 {
     Supply.ControllingNode.Node.Data.ChangeToOff = false;
     ElectricalSynchronisation.AddSupply(Supply.ControllingNode, Supply.ControllingNode.ApplianceType);
     ElectricalSynchronisation.NUStructureChangeReact.Add(Supply.ControllingNode);
     ElectricalSynchronisation.NUResistanceChange.Add(Supply.ControllingNode);
     ElectricalSynchronisation.NUCurrentChange.Add(Supply.ControllingNode);
 }
Beispiel #5
0
 private void Awake()
 {
     if (currentState != TeslaCoilState.Grounding)
     {
         moduleSupplyingDevice = GetComponent <ModuleSupplyingDevice>();
     }
     wrenchSecurable = GetComponent <WrenchSecurable>();
     integrity       = GetComponent <Integrity>();
 }
Beispiel #6
0
    public static void TurnOnSupply(ModuleSupplyingDevice supply)
    {
        supply.ControllingNode.Node.InData.Data.ChangeToOff = false;
        var sync = ElectricalManager.Instance.electricalSync;

        sync.AddSupply(supply.ControllingNode, supply.ControllingNode.ApplianceType);
        sync.NUStructureChangeReact.Add(supply.ControllingNode);
        sync.NUResistanceChange.Add(supply.ControllingNode);
        sync.NUCurrentChange.Add(supply.ControllingNode);
    }
Beispiel #7
0
    /// <summary>
    /// Called when a Supplying Device is turned off.
    /// </summary>
    /// <param name="supply">The supplying device that is turned off</param>
    public static void TurnOffSupply(ModuleSupplyingDevice supply)
    {
        if (supply.ControllingNode == null)
        {
            Logger.LogError("Supply.ControllingNode == null", Category.Electrical);
            return;
        }

        supply.ControllingNode.Node.InData.Data.ChangeToOff = true;
        ElectricalManager.Instance.electricalSync.NUCurrentChange.Add(supply.ControllingNode);
    }
Beispiel #8
0
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        var sync = ElectricalManager.Instance.electricalSync;

        if (Supply.ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(Supply.ControllingNode.Node))
        {
            //Logger.Log("PowerUpdateCurrentChange for Supply  > " + Supply.name);
            Supply.ControllingNode.Node.InData.FlushSupplyAndUp(Supply.ControllingNode.Node);             //Needs change

            if (!Supply.ControllingNode.Node.InData.Data.ChangeToOff)
            {
                if (Supply.current != 0)
                {
                    PushCurrentDownline(Supply, Supply.current);
                }
                else if (Supply.SupplyingVoltage != 0)
                {
                    float Current = (Supply.SupplyingVoltage) / (Supply.InternalResistance
                                                                 + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.InData.Data.SupplyDependent[Supply.ControllingNode.Node].ResistanceComingFrom));
                    PushCurrentDownline(Supply, Current);
                }
                else if (Supply.ProducingWatts != 0)
                {
                    float Current = (float)(Math.Sqrt(Supply.ProducingWatts *
                                                      ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.InData.Data.SupplyDependent[Supply.ControllingNode.Node].ResistanceComingFrom))
                                            / ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.InData.Data.SupplyDependent[Supply.ControllingNode.Node].ResistanceComingFrom));
                    PushCurrentDownline(Supply, Current);
                }
            }
            else
            {
                foreach (var connectedDevice in Supply.ControllingNode.Node.connectedDevices)
                {
                    if (sync.ReactiveSuppliesSet.Contains(connectedDevice.Categorytype))
                    {
                        sync.NUCurrentChange.Add(connectedDevice.ControllingDevice);
                    }
                }
            }
        }
        //ELCurrent.Currentloop(Supply.gameObject);

        if (Supply.ControllingNode.Node.InData.Data.ChangeToOff)
        {
            Supply.ControllingNode.Node.InData.RemoveSupply(Supply.ControllingNode.Node);
            Supply.ControllingNode.Node.InData.Data.ChangeToOff = false;
            Supply.ControllingNode.TurnOffCleanup();

            sync.RemoveSupply(Supply.ControllingNode, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }
Beispiel #9
0
    public static void PushCurrentDownline(ModuleSupplyingDevice Supply, float FloatCurrent)
    {
        Supply.CurrentSource.current = FloatCurrent;
        var WrapCurrentSource = ElectricalPool.GetWrapCurrent();

        WrapCurrentSource.Current  = Supply.CurrentSource;
        WrapCurrentSource.Strength = 1;
        var VIR = ElectricalPool.GetVIRCurrent();

        VIR.addCurrent(WrapCurrentSource);
        Supply.ControllingNode.Node.InData.ElectricityOutput(VIR,
                                                             Supply.ControllingNode.Node
                                                             );
    }
Beispiel #10
0
 public static void PowerUpdateStructureChangeReact(ModuleSupplyingDevice supply)
 {
     ElectricalManager.Instance.electricalSync.CircuitSearchLoop(supply.ControllingNode.Node);
 }
Beispiel #11
0
public static class PowerSupplyFunction {  //Responsible for keeping the update and day to clean up off the supply in check
    public static void TurnOffSupply(ModuleSupplyingDevice Supply)
    {
        Supply.ControllingNode.Node.InData.Data.ChangeToOff = true;
        ElectricalManager.Instance.electricalSync.NUCurrentChange.Add(Supply.ControllingNode);
    }
Beispiel #12
0
 private void Start()
 {
     moduleSupplyingDevice = GetComponent <ModuleSupplyingDevice>();
 }
 // Start is called before the first frame update
 void Start()
 {
     moduleSupplyingDevice = this.GetComponent <ModuleSupplyingDevice>();
 }
Beispiel #14
0
public static class PowerSupplyFunction {  //Responsible for keeping the update and day to clean up off the supply in check
    public static void TurnOffSupply(ModuleSupplyingDevice Supply)
    {
        Supply.ControllingNode.Node.Data.ChangeToOff = true;
        ElectricalSynchronisation.NUCurrentChange.Add(Supply.ControllingNode);
    }
Beispiel #15
0
 public static void PowerUpdateStructureChangeReact(ModuleSupplyingDevice Supply)
 {
     ElectricalSynchronisation.CircuitSearchLoop(Supply.ControllingNode.Node);
 }
    public static void PowerUpdateCurrentChange(ModuleSupplyingDevice Supply)
    {
        var sync = ElectricalManager.Instance.electricalSync;

        if (Supply.ControllingNode.Node.InData.Data.SupplyDependent.ContainsKey(Supply.ControllingNode.Node))
        {
            //Logger.Log("PowerUpdateCurrentChange for Supply  > " + Supply.name);
            Supply.ControllingNode.Node.InData.FlushSupplyAndUp(Supply.ControllingNode.Node);             //Needs change

            if (!Supply.ControllingNode.Node.InData.Data.ChangeToOff)
            {
                if (Supply.ControllingNode.Node.InData.Data.SupplyingCurrent != 0)
                {
                    Supply.CurrentSource.current = Supply.ControllingNode.Node.InData.Data.SupplyingCurrent;
                    var WrapCurrentSource = ElectricalPool.GetWrapCurrent();
                    WrapCurrentSource.Current  = Supply.CurrentSource;
                    WrapCurrentSource.Strength = 1;

                    var VIR = ElectricalPool.GetVIRCurrent();
                    VIR.addCurrent(WrapCurrentSource);



                    Supply.ControllingNode.Node.InData.ElectricityOutput(VIR,
                                                                         Supply.ControllingNode.Node);
                }
                else if (Supply.ControllingNode.Node.InData.Data.SupplyingVoltage != 0)
                {
                    float Current = (Supply.SupplyingVoltage) / (Supply.InternalResistance
                                                                 + ElectricityFunctions.WorkOutResistance(Supply.ControllingNode.Node.InData.Data.SupplyDependent[Supply.ControllingNode.Node].ResistanceComingFrom));


                    Supply.CurrentSource.current = Current;
                    var WrapCurrentSource = ElectricalPool.GetWrapCurrent();
                    //Logger.Log("Supply.CurrentSource.current" + Supply.CurrentSource.current);
                    WrapCurrentSource.Current  = Supply.CurrentSource;
                    WrapCurrentSource.Strength = 1;
                    //Logger.Log("2 > " + WrapCurrentSource.Current.current);
                    var VIR = ElectricalPool.GetVIRCurrent();
                    VIR.addCurrent(WrapCurrentSource);

                    //Logger.Log("3 > " + VIR);
                    Supply.ControllingNode.Node.InData.ElectricityOutput(VIR,
                                                                         Supply.ControllingNode.Node
                                                                         );
                    //Logger.Log("END > " + VIR);
                }
            }
            else
            {
                foreach (var connectedDevice in Supply.ControllingNode.Node.connectedDevices)
                {
                    if (sync.ReactiveSuppliesSet.Contains(connectedDevice.Categorytype))
                    {
                        sync.NUCurrentChange.Add(connectedDevice.ControllingDevice);
                    }
                }
            }
        }
        //ELCurrent.Currentloop(Supply.gameObject);

        if (Supply.ControllingNode.Node.InData.Data.ChangeToOff)
        {
            Supply.ControllingNode.Node.InData.RemoveSupply(Supply.ControllingNode.Node);
            Supply.ControllingNode.Node.InData.Data.ChangeToOff = false;
            Supply.ControllingNode.TurnOffCleanup();

            sync.RemoveSupply(Supply.ControllingNode.Node.InData.ControllingDevice, Supply.ControllingNode.Node.InData.Categorytype);
        }
    }