Example #1
0
    public override string GetPopupText()
    {
        string str1;
        string str2;
        string str3;
        string str4 = "";
        string str5 = "";

        str1 = "Track Junction (ID: " + this.JunctionID + ")\n";
        int    count = 0;
        string str   = "";

        for (int n = 0; n < 4; n++)
        {
            switch (this.DirectionResults [n])
            {
            case FreightTrackDirectionResults.Good:
                count++;
                break;

            case FreightTrackDirectionResults.Self:
                str += "@";
                break;

            case FreightTrackDirectionResults.Trap:
                str += "L@"; //L for Loop may be easier to understand?
                break;

            case FreightTrackDirectionResults.Bad:
                str += "D@";
                break;
            }
            str += SegmentDistances [n].ToString() + ", ";
        }
        str2 = count.ToString() + " valid track connections\n";
        str3 = "Track lengths: " + str.Substring(0, str.Length - 2) + "\nPress Q to reset the junction\n";
        if (this.TrackNetwork != null)
        {
            str4 = "Track Network ID: " + this.TrackNetwork.NetworkID.ToString() + "\nJunction Count: " + this.TrackNetwork.TrackJunctions.Count.ToString() + "\n";
            //for (int n = 0; n < this.TrackNetwork.TrackJunctions.Count; n++)
            //    str5 += this.TrackNetwork.TrackJunctions[n].JunctionID.ToString() + ", ";
            //if (str5.Length > 0)
            //    str5 = str5.Substring(0, str5.Length - 2) + "\n";
        }

        if (Input.GetButtonDown("Extract"))
        {
            TrackJunctionWindow.ResetJunction(this);
        }

        return(str1 + str2 + str3 + str4 + str5);
    }
    public override string GetPopupText()
    {
        string str1;
        string str2;
        string str3;
        string str4 = "";
        string str5 = "";

        str1 = "Track Junction (ID: " + this.JunctionID + ")\n";
        int    count = 0;
        string str   = "";

        for (int n = 0; n < 4; n++)
        {
            if (this.ConnectedJunctions[n] != null)
            {
                count++;
                str += SegmentDistances[n].ToString() + ", ";
            }
        }
        if (count > 0)
        {
            str2 = count.ToString() + " valid track connections\n";
            str3 = "Track lengths: " + str.Substring(0, str.Length - 2) + "\nPress Q to reset the junction\n";
        }
        else
        {
            str2 = "No valid track connections detected\n";
            str3 = "";
        }
        if (this.TrackNetwork != null)
        {
            str4 = "Track Network ID: " + this.TrackNetwork.NetworkID.ToString() + "\nJunction Count: " + this.TrackNetwork.TrackJunctions.Count.ToString() + "\n";
            //for (int n = 0; n < this.TrackNetwork.TrackJunctions.Count; n++)
            //    str5 += this.TrackNetwork.TrackJunctions[n].JunctionID.ToString() + ", ";
            //if (str5.Length > 0)
            //    str5 = str5.Substring(0, str5.Length - 2) + "\n";
        }

        if (Input.GetButtonDown("Extract"))
        {
            TrackJunctionWindow.ResetJunction(this);
        }

        return(str1 + str2 + str3 + str4 + str5);
    }
    public static NetworkInterfaceResponse HandleNetworkCommand(Player player, NetworkInterfaceCommand nic)
    {
        FreightTrackJunction junction = nic.target as FreightTrackJunction;

        string command = nic.command;

        if (command != null)
        {
            if (command == InterfaceResetJunction)
            {
                TrackJunctionWindow.ResetJunction(junction);
            }
        }

        return(new NetworkInterfaceResponse
        {
            entity = junction,
            inventory = player.mInventory
        });
    }