예제 #1
0
        public static void ResistanceInput(ResistanceWrap Resistance,
                                           ElectricalOIinheritance SourceInstance,
                                           IntrinsicElectronicData ComingFrom,
                                           IntrinsicElectronicData Thiswire)
        {
            if (Thiswire.Data.SupplyDependent.TryGetValue(SourceInstance, out ElectronicSupplyData supplyDep))
            {
                if (!supplyDep.ResistanceComingFrom.TryGetValue(ComingFrom, out VIRResistances resComeFrom))
                {
                    resComeFrom = supplyDep.ResistanceComingFrom[ComingFrom] = ElectricalPool.GetVIRResistances();
                }

                resComeFrom.AddResistance(Resistance);
            }

            Thiswire.ResistancyOutput(Resistance, SourceInstance);
        }
예제 #2
0
        public VIRResistances Multiply(float Multiplier)
        {
            var newVIRResistances = ElectricalPool.GetVIRResistances();

            foreach (var ResistanceS in ResistanceSources)
            {
                var newResistanceWrap = ElectricalPool.GetResistanceWrap();
                newResistanceWrap.SetUp(ResistanceS);
                newVIRResistances.AddResistance(newResistanceWrap);
            }

            foreach (var ResistanceS in newVIRResistances.ResistanceSources)
            {
                ResistanceS.Multiply(Multiplier);
            }
            return(newVIRResistances);
        }
예제 #3
0
        public VIRCurrent SplitCurrent(float Multiplier)
        {
            var newVIRCurrent = ElectricalPool.GetVIRCurrent();

            foreach (var CurrentS in CurrentSources)
            {
                var newWCurrent = ElectricalPool.GetWrapCurrent();
                newWCurrent.SetUp(CurrentS);
                newVIRCurrent.CurrentSources.Add(newWCurrent);
            }

            foreach (var CurrentS in newVIRCurrent.CurrentSources)
            {
                CurrentS.Multiply(Multiplier);
            }
            return(newVIRCurrent);
        }
예제 #4
0
        public static void ResistancyOutput(ResistanceWrap Resistance,
                                            ElectricalOIinheritance SourceInstance,
                                            IntrinsicElectronicData Thiswire)
        {
            if (Thiswire.Data.SupplyDependent.TryGetValue(SourceInstance, out ElectronicSupplyData supplyDep))
            {
                foreach (var JumpTo in supplyDep.Upstream)
                {
                    if (!supplyDep.ResistanceGoingTo.TryGetValue(JumpTo, out VIRResistances resGoTo))
                    {
                        resGoTo = supplyDep.ResistanceGoingTo[JumpTo] = ElectricalPool.GetVIRResistances();
                    }

                    resGoTo.AddResistance(Resistance);
                    JumpTo.ResistanceInput(Resistance, SourceInstance, Thiswire);
                }
            }
        }
예제 #5
0
        public static void DirectionOutput(ElectricalOIinheritance SourceInstance,
                                           IntrinsicElectronicData Thiswire,
                                           CableLine RelatedLine = null)
        {
            if (Thiswire.Data.connections.Count == 0)
            {
                Thiswire.FindPossibleConnections();
            }

            if (!(Thiswire.Data.SupplyDependent.TryGetValue(SourceInstance,
                                                            out ElectronicSupplyData outputSupplyingUsingData)))
            {
                outputSupplyingUsingData =
                    Thiswire.Data.SupplyDependent[SourceInstance] = ElectricalPool.GetElectronicSupplyData();
            }

            foreach (IntrinsicElectronicData Relatedindata in Thiswire.Data.connections)
            {
                if (!(outputSupplyingUsingData.Upstream.Contains(Relatedindata)) && (Thiswire != Relatedindata))
                {
                    bool pass = true;
                    if (RelatedLine != null)
                    {
                        if (RelatedLine.Covering.Contains(Relatedindata))
                        {
                            pass = false;
                        }
                    }

                    if (outputSupplyingUsingData.Downstream.Contains(Relatedindata) == false && pass && Relatedindata.Present != SourceInstance)
                    {
                        outputSupplyingUsingData.Downstream.Add(Relatedindata);
                        Relatedindata.DirectionInput(SourceInstance, Thiswire);
                    }
                }
            }
        }
예제 #6
0
        public static void DirectionInput(ElectricalOIinheritance SourceInstance,
                                          IntrinsicElectronicData ComingFrom,
                                          IntrinsicElectronicData Thiswire)
        {
            if (Thiswire.Data.connections.Count == 0)
            {
                Thiswire.FindPossibleConnections();                 //plz don't remove it is necessary for preventing incomplete cleanups when there has been multiple
            }

            if (!Thiswire.Data.SupplyDependent.TryGetValue(SourceInstance, out ElectronicSupplyData supplyDep))
            {
                supplyDep = Thiswire.Data.SupplyDependent[SourceInstance] = ElectricalPool.GetElectronicSupplyData();
            }

            if (ComingFrom != null)
            {
                supplyDep.Upstream.Add(ComingFrom);
            }

            if (Thiswire.ConnectionReaction.TryGetValue(ComingFrom.Categorytype, out PowerInputReactions reaction))
            {
                if (reaction.DirectionReaction || reaction.ResistanceReaction)
                {
                    if (SourceInstance != null)
                    {
                        SupplyBool SupplyBool = null;
                        foreach (var keysvasl in Thiswire.Data.ResistanceToConnectedDevices)
                        {
                            if (keysvasl.Key.Equals(SourceInstance))
                            {
                                SupplyBool = keysvasl.Key;
                            }
                        }

                        if (SupplyBool == null)
                        {
                            SupplyBool                = ElectricalPool.GetSupplyBool();
                            SupplyBool.Data           = SourceInstance;
                            SupplyBool.RequiresUpdate = true;
                            Thiswire.Data.ResistanceToConnectedDevices[SupplyBool] =
                                new Dictionary <Resistance, HashSet <IntrinsicElectronicData> >();
                        }

                        var resToConDev = Thiswire.Data.ResistanceToConnectedDevices[SupplyBool];

                        if (!resToConDev.TryGetValue(reaction.ResistanceReactionA.Resistance,
                                                     out HashSet <IntrinsicElectronicData> resToConDevHash))
                        {
                            resToConDevHash = resToConDev[reaction.ResistanceReactionA.Resistance] =
                                new HashSet <IntrinsicElectronicData>();
                        }

                        resToConDevHash.Add(ComingFrom);
                        SupplyBool.RequiresUpdate = true;
                        SourceInstance.connectedDevices.Add(Thiswire);
                        ElectricalManager.Instance.electricalSync.InitialiseResistanceChange
                        .Add(Thiswire.ControllingDevice);
                    }

                    if (reaction.DirectionReactionA.YouShallNotPass)
                    {
                        return;
                    }
                }
            }

            if (Thiswire.Data.connections.Count > 2)
            {
                ElectricalManager.Instance.electricalSync.DirectionWorkOnNextListWaitADD(Thiswire);
            }
            else
            {
                ElectricalManager.Instance.electricalSync.DirectionWorkOnNextListADD(Thiswire);
            }
        }