public static void FlushSupplyAndUp(IElectricityIO Object, GameObject SourceInstance = null)
        {
            if (SourceInstance == null)
            {
                if (Object.CurrentComingFrom.Count > 0)
                {
                    //Logger.Log ("Flushing!!", Category.Electrical);
                    Object.CurrentComingFrom.Clear();
                    foreach (IElectricityIO JumpTo in Object.connections)
                    {
                        JumpTo.FlushSupplyAndUp();
                    }
                    Object.CurrentGoingTo.Clear();

                    Object.SourceVoltages.Clear();
                    Object.CurrentInWire = new float();
                    Object.ActualVoltage = new float();
                }
            }
            else
            {
                int InstanceID = SourceInstance.GetInstanceID();
                if (Object.CurrentComingFrom.ContainsKey(InstanceID))
                {
                    //Logger.Log ("Flushing!!", Category.Electrical);
                    Object.CurrentGoingTo.Remove(InstanceID);
                    Object.CurrentComingFrom.Remove(InstanceID);
                    foreach (IElectricityIO JumpTo in Object.connections)
                    {
                        JumpTo.FlushSupplyAndUp(SourceInstance);
                    }
                }
                else if (Object.CurrentGoingTo.ContainsKey(InstanceID))
                {
                    //Logger.Log ("Flushing!!", Category.Electrical);
                    Object.CurrentGoingTo.Remove(InstanceID);
                    Object.CurrentComingFrom.Remove(InstanceID);
                    foreach (IElectricityIO JumpTo in Object.connections)
                    {
                        JumpTo.FlushSupplyAndUp(SourceInstance);
                    }
                }
                Object.CurrentGoingTo.Remove(InstanceID);
                Object.SourceVoltages.Remove(InstanceID);

                Object.ActualCurrentChargeInWire = ElectricityFunctions.WorkOutActualNumbers(Object);

                Object.CurrentInWire       = Object.ActualCurrentChargeInWire.Current;
                Object.ActualVoltage       = Object.ActualCurrentChargeInWire.Voltage;
                Object.EstimatedResistance = Object.ActualCurrentChargeInWire.EstimatedResistant;
            }
        }
        public static void FlushSupplyAndUp(ElectricalOIinheritance Object, GameObject SourceInstance = null)
        {
            if (SourceInstance == null)
            {
                bool pass = false;
                foreach (var Supply in Object.Data.SupplyDependent)
                {
                    if (Supply.Value.CurrentComingFrom.Count > 0)
                    {
                        pass = true;
                    }
                }
                if (pass)
                {
                    foreach (var Supply in Object.Data.SupplyDependent)
                    {
                        Supply.Value.CurrentComingFrom.Clear();
                        Supply.Value.CurrentGoingTo.Clear();
                        Supply.Value.SourceVoltages = 0;
                    }
                    foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
                    {
                        JumpTo.FlushSupplyAndUp();
                    }
                    Object.Data.CurrentInWire = new float();
                    Object.Data.ActualVoltage = new float();
                }
            }
            else
            {
                int InstanceID = SourceInstance.GetInstanceID();
                if (Object.Data.SupplyDependent.ContainsKey(InstanceID))
                {
                    if (Object.Data.SupplyDependent[InstanceID].CurrentComingFrom.Count > 0 || Object.Data.SupplyDependent[InstanceID].CurrentGoingTo.Count > 0)
                    {
                        Object.Data.SupplyDependent[InstanceID].CurrentGoingTo.Clear();
                        Object.Data.SupplyDependent[InstanceID].CurrentComingFrom.Clear();
                        foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
                        {
                            JumpTo.FlushSupplyAndUp(SourceInstance);
                        }
                    }
                    Object.Data.SupplyDependent[InstanceID].SourceVoltages = 0;
                }

                ElectricityFunctions.WorkOutActualNumbers(Object);
            }
        }
Пример #3
0
 public static void FlushSupplyAndUp(IntrinsicElectronicData Object, ElectricalOIinheritance SourceInstance = null)
 {
     if (SourceInstance == null)
     {
         bool pass = false;
         foreach (var Supply in Object.Data.SupplyDependent)
         {
             if (Supply.Value.CurrentComingFrom.Count > 0)
             {
                 pass = true;
             }
         }
         if (pass)
         {
             foreach (var Supply in Object.Data.SupplyDependent)
             {
                 Pool(Supply.Value.CurrentComingFrom);
                 Pool(Supply.Value.CurrentGoingTo);
                 Supply.Value.SourceVoltage = 0;
             }
             foreach (IntrinsicElectronicData JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushSupplyAndUp();
             }
             Object.Data.CurrentInWire = 0;
             Object.Data.ActualVoltage = 0;
         }
     }
     else
     {
         if (Object.Data.SupplyDependent.ContainsKey(SourceInstance))
         {
             if (Object.Data.SupplyDependent[SourceInstance].CurrentComingFrom.Count > 0 ||
                 Object.Data.SupplyDependent[SourceInstance].CurrentGoingTo.Count > 0)
             {
                 Pool(Object.Data.SupplyDependent[SourceInstance].CurrentGoingTo);
                 Pool(Object.Data.SupplyDependent[SourceInstance].CurrentComingFrom);
                 foreach (IntrinsicElectronicData JumpTo in Object.Data.connections)
                 {
                     JumpTo.FlushSupplyAndUp(SourceInstance);
                 }
             }
             Object.Data.SupplyDependent[SourceInstance].SourceVoltage = 0;
         }
     }
 }
 public static void FlushSupplyAndUp(ElectricalOIinheritance Object, GameObject SourceInstance = null)
 {
     if (SourceInstance == null)
     {
         if (Object.Data.CurrentComingFrom.Count > 0)
         {
             Object.Data.CurrentComingFrom.Clear();
             foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushSupplyAndUp();
             }
             Object.Data.CurrentGoingTo.Clear();
             Object.Data.SourceVoltages.Clear();
             Object.Data.CurrentInWire = new float();
             Object.Data.ActualVoltage = new float();
         }
     }
     else
     {
         int InstanceID = SourceInstance.GetInstanceID();
         //Logger.Log(Object.GameObject().name);
         if (Object.Data.CurrentComingFrom.ContainsKey(InstanceID))
         {
             Object.Data.CurrentGoingTo.Remove(InstanceID);
             Object.Data.CurrentComingFrom.Remove(InstanceID);
             foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushSupplyAndUp(SourceInstance);
             }
         }
         else if (Object.Data.CurrentGoingTo.ContainsKey(InstanceID))
         {
             Object.Data.CurrentGoingTo.Remove(InstanceID);
             Object.Data.CurrentComingFrom.Remove(InstanceID);
             foreach (ElectricalOIinheritance JumpTo in Object.Data.connections)
             {
                 JumpTo.FlushSupplyAndUp(SourceInstance);
             }
         }
         Object.Data.CurrentGoingTo.Remove(InstanceID);
         Object.Data.SourceVoltages.Remove(InstanceID);
         ElectricityFunctions.WorkOutActualNumbers(Object);
     }
 }