示例#1
0
    public override void DirectionOutput(GameObject SourceInstance)
    {
        int SourceInstanceID = SourceInstance.GetInstanceID();

        //Logger.Log (this.gameObject.GetInstanceID().ToString() + " <ID | Downstream = "+Data.Downstream[SourceInstanceID].Count.ToString() + " Upstream = " + Data.Upstream[SourceInstanceID].Count.ToString () + this.name + " <  name! ", Category.Electrical);
        if (RelatedLine == null)
        {
            InputOutputFunctions.DirectionOutput(SourceInstance, this);
        }
        else
        {
            IElectricityIO GoingTo;
            if (RelatedLine.TheEnd == this.GetComponent <IElectricityIO> ())
            {
                GoingTo = RelatedLine.TheStart;
            }
            else if (RelatedLine.TheStart == this.GetComponent <IElectricityIO> ())
            {
                GoingTo = RelatedLine.TheEnd;
            }
            else
            {
                GoingTo = null;
                return;
            }

            if (!(Data.Upstream.ContainsKey(SourceInstanceID)))
            {
                Data.Upstream[SourceInstanceID] = new HashSet <IElectricityIO>();
            }
            if (!(Data.Downstream.ContainsKey(SourceInstanceID)))
            {
                Data.Downstream[SourceInstanceID] = new HashSet <IElectricityIO>();
            }

            if (GoingTo != null)
            {
                //Logger.Log ("to" + GoingTo.GameObject ().name);///wow
            }


            foreach (IElectricityIO bob in Data.Upstream[SourceInstanceID])
            {
                //Logger.Log("Upstream" + bob.GameObject ().name );
            }
            if (!(Data.Downstream [SourceInstanceID].Contains(GoingTo) || Data.Upstream [SourceInstanceID].Contains(GoingTo)))
            {
                Data.Downstream [SourceInstanceID].Add(GoingTo);

                RelatedLine.DirectionInput(SourceInstance, this);
            }
            else
            {
                InputOutputFunctions.DirectionOutput(SourceInstance, this, RelatedLine);
            }
        }

        Data.DownstreamCount = Data.Downstream[SourceInstanceID].Count;
        Data.UpstreamCount   = Data.Upstream[SourceInstanceID].Count;
    }
示例#2
0
    public override void DirectionOutput(GameObject SourceInstance)
    {
        int SourceInstanceID = SourceInstance.GetInstanceID();

        //Logger.Log (this.gameObject.GetInstanceID().ToString() + " <ID | Downstream = "+Data.Downstream[SourceInstanceID].Count.ToString() + " Upstream = " + Data.Upstream[SourceInstanceID].Count.ToString () + this.name + " <  name! ", Category.Electrical);
        if (RelatedLine == null)
        {
            InputOutputFunctions.DirectionOutput(SourceInstance, this);
        }
        else
        {
            ElectricalOIinheritance GoingTo;
            if (RelatedLine.TheEnd == this.GetComponent <ElectricalOIinheritance>())
            {
                GoingTo = RelatedLine.TheStart;
            }
            else if (RelatedLine.TheStart == this.GetComponent <ElectricalOIinheritance>())
            {
                GoingTo = RelatedLine.TheEnd;
            }
            else
            {
                GoingTo = null;
                return;
            }

            if (!(Data.SupplyDependent[SourceInstanceID].Downstream.Contains(GoingTo) ||
                  Data.SupplyDependent[SourceInstanceID].Upstream.Contains(GoingTo)))
            {
                Data.SupplyDependent[SourceInstanceID].Downstream.Add(GoingTo);

                RelatedLine.DirectionInput(SourceInstance, this);
            }
            else
            {
                InputOutputFunctions.DirectionOutput(SourceInstance, this, RelatedLine);
            }
        }
    }