Пример #1
0
    public static void ResistanceInput(float Resistance, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire)
    {
        ElectricalOIinheritance IElec = SourceInstance.GetComponent <ElectricalOIinheritance>();

        if (ComingFrom == null)
        {
            if (Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(IElec))
            {
                if (Thiswire.Data.ResistanceToConnectedDevices [IElec].Count > 1)
                {
                    Logger.LogError("oh no!, problem!!!!");
                }
                foreach (PowerTypeCategory ConnectionFrom in Thiswire.Data.ResistanceToConnectedDevices[IElec])
                {
                    Resistance = Thiswire.InData.ConnectionReaction[ConnectionFrom].ResistanceReactionA.Resistance.Ohms;
                    //Logger.Log (Resistance.ToString () + " < to man Resistance |            " + ConnectionFrom.ToString() + " < to man ConnectionFrom |      " + Thiswire.GameObject().name + " < to man IS ");
                    ComingFrom = ElectricalSynchronisation.DeadEnd;
                }
            }
        }
        if (ComingFrom != null | ElectricalSynchronisation.DeadEnd == ComingFrom)
        {
            int SourceInstanceID = SourceInstance.GetInstanceID();
            if (!(Thiswire.Data.ResistanceComingFrom.ContainsKey(SourceInstanceID)))
            {
                Thiswire.Data.ResistanceComingFrom [SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float> ();
            }

            if (!(Thiswire.Data.ResistanceGoingTo.ContainsKey(SourceInstanceID)))
            {
                Thiswire.Data.ResistanceGoingTo[SourceInstanceID] = new Dictionary <ElectricalOIinheritance, float>();
            }

            if (Resistance == 0)
            {
                Thiswire.Data.ResistanceComingFrom [SourceInstanceID].Remove(ComingFrom);
            }
            else
            {
                Thiswire.Data.ResistanceComingFrom[SourceInstanceID][ComingFrom] = Resistance;
            }
            if (Thiswire.Data.connections.Count > 2)
            {
                KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> (IElec, Thiswire);
                ElectricalSynchronisation.ResistanceWorkOnNextListWaitADD(edd);
            }
            else
            {
                KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> (IElec, Thiswire);
                ElectricalSynchronisation.ResistanceWorkOnNextListADD(edd);
            }
        }
    }
Пример #2
0
    public static void ResistanceInput(float Resistance, GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire, int ComingFromOverride = 0)
    {
        ElectricalOIinheritance IElec = SourceInstance.GetComponent <ElectricalOIinheritance>();

        if (ComingFrom == null)
        {
            if (IElec != Thiswire)
            {
                if (Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(IElec))
                {
                    if (Thiswire.Data.ResistanceToConnectedDevices[IElec].Count > 1)
                    {
                        Logger.LogErrorFormat("{0} has too many resistance reactions specified.", Category.Electrical, Thiswire.ToString());
                    }
                    foreach (PowerTypeCategory ConnectionFrom in Thiswire.Data.ResistanceToConnectedDevices[IElec])
                    {
                        Resistance = Thiswire.InData.ConnectionReaction[ConnectionFrom].ResistanceReactionA.Resistance.Ohms;
                        ComingFrom = ElectricalSynchronisation.DeadEnd;
                    }
                }
            }
            else
            {
                return;
            }
        }
        if (ComingFrom != null | ElectricalSynchronisation.DeadEnd == ComingFrom)
        {
            int SourceInstanceID = SourceInstance.GetInstanceID();
            ElectricalSynchronisation.InputSupplyingUsingData = Thiswire.Data.SupplyDependent[SourceInstanceID];
            if (Resistance == 0)
            {
                ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom.Remove(ComingFrom);
            }
            else
            {
                ElectricalSynchronisation.InputSupplyingUsingData.ResistanceComingFrom[ComingFrom] = Resistance;
            }
            if (Thiswire.Data.connections.Count > 2)
            {
                KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance>(IElec, Thiswire);
                ElectricalSynchronisation.ResistanceWorkOnNextListWaitADD(edd);
            }
            else
            {
                KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance> edd = new KeyValuePair <ElectricalOIinheritance, ElectricalOIinheritance>(IElec, Thiswire);
                ElectricalSynchronisation.ResistanceWorkOnNextListADD(edd);
            }
        }
    }