public static void DirectionInput(GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance Thiswire) { int SourceInstanceID = SourceInstance.GetInstanceID(); if (Thiswire.Data.FirstPresent == 0) { Thiswire.Data.FirstPresent = SourceInstanceID; } if (!(Thiswire.Data.Upstream.ContainsKey(SourceInstanceID))) { Thiswire.Data.Upstream[SourceInstanceID] = new HashSet <ElectricalOIinheritance>(); } if (!(Thiswire.Data.Downstream.ContainsKey(SourceInstanceID))) { Thiswire.Data.Downstream[SourceInstanceID] = new HashSet <ElectricalOIinheritance>(); } if (ComingFrom != null) { Thiswire.Data.Upstream[SourceInstanceID].Add(ComingFrom); } bool CanPass = true; if (Thiswire.InData.ConnectionReaction.ContainsKey(ComingFrom.InData.Categorytype)) { if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReaction) { ElectricalOIinheritance SourceInstancPowerSupply = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (SourceInstancPowerSupply != null) { if (!Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(SourceInstancPowerSupply)) { Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply] = new HashSet <PowerTypeCategory>(); } Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply].Add(ComingFrom.InData.Categorytype); SourceInstancPowerSupply.connectedDevices.Add(Thiswire); //Logger.Log(" add " + SourceInstance + " " + Thiswire); ElectricalSynchronisation.InitialiseResistanceChange.Add(Thiswire.InData.ControllingUpdate); } if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReactionA.YouShallNotPass) { CanPass = false; } } } if (CanPass) { if (Thiswire.Data.connections.Count > 2) { ElectricalSynchronisation.DirectionWorkOnNextListWaitADD(Thiswire); } else { ElectricalSynchronisation.DirectionWorkOnNextListADD(Thiswire); } } }
public static void DirectionInput(GameObject SourceInstance, ElectricalOIinheritance ComingFrom, ElectricalOIinheritance 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 } int SourceInstanceID = SourceInstance.GetInstanceID(); if (!(Thiswire.Data.SupplyDependent.ContainsKey(SourceInstanceID))) { Thiswire.Data.SupplyDependent[SourceInstanceID] = new ElectronicSupplyData(); } if (ComingFrom != null) { Thiswire.Data.SupplyDependent[SourceInstanceID].Upstream.Add(ComingFrom); } bool CanPass = true; if (Thiswire.InData.ConnectionReaction.ContainsKey(ComingFrom.InData.Categorytype)) { if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReaction || Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].ResistanceReaction) { ElectricalOIinheritance SourceInstancPowerSupply = SourceInstance.GetComponent <ElectricalOIinheritance>(); if (SourceInstancPowerSupply != null) { if (!Thiswire.Data.ResistanceToConnectedDevices.ContainsKey(SourceInstancPowerSupply)) { Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply] = new HashSet <PowerTypeCategory>(); } Thiswire.Data.ResistanceToConnectedDevices[SourceInstancPowerSupply].Add(ComingFrom.InData.Categorytype); SourceInstancPowerSupply.connectedDevices.Add(Thiswire); ElectricalSynchronisation.InitialiseResistanceChange.Add(Thiswire.InData.ControllingDevice); } if (Thiswire.InData.ConnectionReaction[ComingFrom.InData.Categorytype].DirectionReactionA.YouShallNotPass) { CanPass = false; } } } if (CanPass) { if (Thiswire.Data.connections.Count > 2) { ElectricalSynchronisation.DirectionWorkOnNextListWaitADD(Thiswire); } else { ElectricalSynchronisation.DirectionWorkOnNextListADD(Thiswire); } } }