public static void FlushResistanceAndUp(ElectricalOIinheritance Object, GameObject SourceInstance = null)
        {
            if (SourceInstance == null)
            {
                bool pass = false;
                foreach (var Supply in Object.Data.SupplyDependent)
                {
                    if (Supply.Value.ResistanceComingFrom.Count > 0)
                    {
                        pass = true;
                    }
                }
                if (pass)
                {
                    foreach (var Supply in Object.Data.SupplyDependent)
                    {
                        Supply.Value.ResistanceComingFrom.Clear();
                        Supply.Value.ResistanceGoingTo.Clear();
                        Supply.Value.CurrentGoingTo.Clear();
                        Supply.Value.CurrentComingFrom.Clear();
                        Supply.Value.SourceVoltages = 0;
                    }
                    foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
                    {
                        JumpTo.FlushResistanceAndUp();
                    }
                    Object.Data.CurrentInWire = new float();
                    Object.Data.ActualVoltage = new float();
                }
            }
            else
            {
                int InstanceID = SourceInstance.GetInstanceID();

                if (Object.Data.SupplyDependent[InstanceID].ResistanceComingFrom.Count > 0 || Object.Data.SupplyDependent[InstanceID].ResistanceGoingTo.Count > 0)
                {
                    Object.Data.SupplyDependent[InstanceID].ResistanceComingFrom.Clear();
                    Object.Data.SupplyDependent[InstanceID].ResistanceGoingTo.Clear();
                    foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
                    {
                        JumpTo.FlushResistanceAndUp(SourceInstance);
                    }
                    Object.Data.SupplyDependent[InstanceID].CurrentGoingTo.Clear();
                    Object.Data.SupplyDependent[InstanceID].CurrentComingFrom.Clear();
                    Object.Data.SupplyDependent[InstanceID].SourceVoltages = 0;
                    Object.Data.CurrentInWire = new float();
                    Object.Data.ActualVoltage = new float();
                }
            }
        }
Ejemplo n.º 2
0
 public static void FlushResistanceAndUp(IntrinsicElectronicData Object, ElectricalOIinheritance SourceInstance = null)
 {
     if (SourceInstance == null)
     {
         bool pass = false;
         foreach (var Supply in Object.Data.SupplyDependent)
         {
             if (Supply.Value.ResistanceComingFrom.Count > 0)
             {
                 pass = true;
                 break;
             }
         }
         if (pass)
         {
             foreach (var Supply in Object.Data.SupplyDependent)
             {
                 Pool(Supply.Value.ResistanceComingFrom);
                 Pool(Supply.Value.ResistanceGoingTo);
                 Pool(Supply.Value.CurrentGoingTo);
                 Pool(Supply.Value.CurrentComingFrom);
                 Supply.Value.SourceVoltage = 0;
             }
             foreach (IntrinsicElectronicData JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushResistanceAndUp();
             }
             Object.Data.CurrentInWire = 0;
             Object.Data.ActualVoltage = 0;
         }
     }
     else
     {
         ElectronicSupplyData supplyDep = Object.Data.SupplyDependent[SourceInstance];
         if (supplyDep.ResistanceComingFrom.Count > 0 || supplyDep.ResistanceGoingTo.Count > 0)
         {
             Pool(supplyDep.ResistanceComingFrom);
             Pool(supplyDep.ResistanceGoingTo);
             foreach (IntrinsicElectronicData JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushResistanceAndUp(SourceInstance);
             }
             Pool(supplyDep.CurrentGoingTo);
             Pool(supplyDep.CurrentComingFrom);
             supplyDep.SourceVoltage   = 0;
             Object.Data.CurrentInWire = new float();
             Object.Data.ActualVoltage = new float();
         }
     }
 }
        public static void FlushResistanceAndUp(IElectricityIO Object, GameObject SourceInstance = null)
        {
            if (SourceInstance == null)
            {
                if (Object.ResistanceComingFrom.Count > 0)
                {
                    Object.ResistanceComingFrom.Clear();
                    foreach (IElectricityIO JumpTo in Object.connections)
                    {
                        JumpTo.FlushResistanceAndUp();
                    }

                    Object.ResistanceGoingTo.Clear();
                    Object.CurrentGoingTo.Clear();
                    Object.CurrentComingFrom.Clear();
                    Object.SourceVoltages.Clear();
                    Object.CurrentInWire = new float();
                    Object.ActualVoltage = new float();
                }
            }
            else
            {
                //Logger.Log ("FlushResistanceAndUp");
                int InstanceID = SourceInstance.GetInstanceID();
                if (Object.ResistanceComingFrom.ContainsKey(InstanceID) || Object.ResistanceGoingTo.ContainsKey(InstanceID))
                {
                    //if (Object.ResistanceComingFrom [InstanceID].Count > 0) {
                    Object.ResistanceComingFrom.Remove(InstanceID);
                    Object.ResistanceGoingTo.Remove(InstanceID);
                    foreach (IElectricityIO JumpTo in Object.connections)
                    {
                        JumpTo.FlushResistanceAndUp(SourceInstance);
                    }
                    Object.CurrentGoingTo.Remove(InstanceID);
                    Object.CurrentComingFrom.Remove(InstanceID);
                    Object.SourceVoltages.Remove(InstanceID);
                    Object.CurrentInWire = new float();
                    Object.ActualVoltage = new float();
                }
            }
        }
 public static void FlushResistanceAndUp(ElectricalOIinheritance Object, GameObject SourceInstance = null)
 {
     if (SourceInstance == null)
     {
         Logger.Log("yo do not?");
         if (Object.Data.ResistanceComingFrom.Count > 0)
         {
             Object.Data.ResistanceComingFrom.Clear();
             foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushResistanceAndUp();
             }
             Object.Data.ResistanceGoingTo.Clear();
             Object.Data.CurrentGoingTo.Clear();
             Object.Data.CurrentComingFrom.Clear();
             Object.Data.SourceVoltages.Clear();
             Object.Data.CurrentInWire = new float();
             Object.Data.ActualVoltage = new float();
         }
     }
     else
     {
         int InstanceID = SourceInstance.GetInstanceID();
         if (Object.Data.ResistanceComingFrom.ContainsKey(InstanceID) || Object.Data.ResistanceGoingTo.ContainsKey(InstanceID))
         {
             Object.Data.ResistanceComingFrom.Remove(InstanceID);
             Object.Data.ResistanceGoingTo.Remove(InstanceID);
             foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushResistanceAndUp(SourceInstance);
             }
             Object.Data.CurrentGoingTo.Remove(InstanceID);
             Object.Data.CurrentComingFrom.Remove(InstanceID);
             Object.Data.SourceVoltages.Remove(InstanceID);
             Object.Data.CurrentInWire = new float();
             Object.Data.ActualVoltage = new float();
         }
     }
 }