Exemplo n.º 1
0
 public void LoginActions(string username, InGameComputer terminal)
 {
     loggedInUsers.Add(users[username]);
     users [username].loggedInRemotely = virtualSystem.instanceID != terminal.gameObject.GetComponent <IGC_VirtualSystem> ().instanceID;
     users[username].terminal          = terminal;
     terminal.currentUser = users[username];
 }
Exemplo n.º 2
0
    void Start()
    {
        //if there's a networkview and no multiplayer connection,
        if (Network.peerType == NetworkPeerType.Disconnected && GetComponent <NetworkView>() != null && !InGameComputer.waitForNetwork)
        {
            GetComponent <NetworkView>().enabled = false;
            //Destroy(networkView);
        }

        if (virtualSystem == null)
        {
            virtualSystem = gameObject.GetComponent <IGC_VirtualSystem>();
        }

        cursor   = transform.Find("monitor/display/cursor_holder/cursor");
        output   = transform.Find("monitor/display/output").GetComponent <TextMesh>();
        prompt   = transform.Find("monitor/display/prompt").GetComponent <TextMesh>();
        caret    = transform.Find("monitor/display/caret").GetComponent <TextMesh>();
        infoLine = transform.Find("monitor/display/info_line").GetComponent <TextMesh>();
        screen   = transform.Find("monitor/screenPivot/screen");

        shell = gameObject.GetComponent <IGC_Shell>();

        localhost = this;
    }
Exemplo n.º 3
0
    private void ComputerActions(RaycastHit hit)
    {
        if (hit.transform == null)
        {
            if (currentComp != null)
            {
                currentComp.LeaveComputer();
                currentComp = null;
            }
            pauseMovement = false;
            return;
        }

        if (hit.transform.tag == "computer" && currentComp == null)
        {
            InGameComputer comp = hit.transform.GetComponent <InGameComputer>();

            if (comp.powerState && !comp.bootingUp)
            {
                currentComp   = comp;
                pauseMovement = true;
                currentComp.UseComputer();
            }
        }
        else if (hit.transform.tag != "computer" && currentComp != null)
        {
            pauseMovement = false;
            currentComp.LeaveComputer();
            currentComp = null;
        }
    }
Exemplo n.º 4
0
    public override string command_function()
    {
        IGC_UserRegistry ur = virtualSystem.userRegistry;

        if (argv.Length > 2)
        {
            if (!ur.users.ContainsKey(argv[1]))
            {
                return("user '" + argv[1] + "' does not exist");
            }

            InGameComputer terminal = issuer == null ? virtualSystem.terminal : issuer.terminal;

            IGC_User checkLoggedIn = ur.GetUser(argv[1]);

            if (ur.loggedInUsers.Contains(checkLoggedIn))
            {
                return(argv[1] + " is already logged in");
            }

            if (issuer != null)
            {
                if (issuer.terminal != null)
                {
                    if (issuer.terminal.currentUser != null)
                    {
                        if (issuer.loggedInRemotely)
                        {
                            ur.loggedInUsers.Remove(issuer);                             //the logout function will bounce the user back to their own terminal so here, if remotelogged, we will keep things simple
                        }
                        else
                        {
                            virtualSystem.userRegistry.Logout(issuer.terminal.currentUser);
                        }
                    }
                }
            }

            IGC_User user = ur.Login(argv [1], argv [2], terminal);

            if (user != null)
            {
                return("welcome, " + user.name);
            }
            else
            {
                return("password incorrect, try again");
            }
        }
        else
        {
            return("error: command malformed\n" + usage);
        }
    }
Exemplo n.º 5
0
    public override string command_function()
    {
        string output = "";

        foreach (string key in flags.Keys)
        {
            if (key != "s" && key != "t")
            {
                continue;
            }

            string[] channels = IGC_Utils.SplitString(",", flags[key]);

            if (channels.Length != 3)
            {
                return(malformed_error + "\n" + usage);
            }

            Color color = IGC_Utils.ColorFromString(flags[key]);

            if (key == "s")
            {
                output += "screen color set to " + flags["s"];
                issuer.terminal.SetScreenColor(color);
                issuer.terminal.screenColor = color;
            }
            if (key == "t")
            {
                output += "text color set to " + flags["t"];
                issuer.terminal.SetTextColor(color);
                issuer.terminal.textColor = color;
            }
        }

        output = output == "" ? "please specify a screen or text color\n" + usage : output;

        InGameComputer term = issuer.terminal;

        if (virtualSystem.networkReady)
        {
            term.GetComponent <NetworkView>().RPC("SetColorsRPC", RPCMode.Others,
                                                  IGC_Utils.ColorString(term.screenColor),
                                                  IGC_Utils.ColorString(term.textColor)
                                                  );
        }

        return(output);
    }
Exemplo n.º 6
0
    public IGC_User Login(string username, string password, InGameComputer terminal)
    {
        if (users[username].CheckPassword(password))
        {
            LoginActions(username, terminal);

            if (virtualSystem.networkReady)
            {
                GetComponent <NetworkView>().RPC("LoginRPC", RPCMode.Others, username, terminal.instanceID);
            }

            return(users[username]);
        }
        else
        {
            return(null);
        }
    }
Exemplo n.º 7
0
    public void BuildUsersFromUserString(string usersString)
    {
        if (usersString == "NONE" || usersString == "" || usersString == null)
        {
            return;
        }

        string[] userStringList = IGC_Utils.SplitString("\n", usersString);

        //foreach user in usersting
        for (int i = 0; i < userStringList.Length; i++)
        {
            string[] user = IGC_Utils.SplitString(":", userStringList[i]);

            int terminalID = user[4] == "-1"
                                ? System.Int32.Parse(user[4])
                                : gameObject.GetComponent <InGameComputer>().instanceID;

            string
                username = user[0],
                userCwd  = user[5];
            bool
                isAdmin        = user[2] == "True" ? true : false,
                loggedIn       = user[6] == "True" ? true : false,
                loggedRemotely = user[3] == "True" ? true : false;

            IGC_User newUser = AddUser(new IGC_User(username, "", isAdmin, virtualSystem, true), systemUser);

            newUser.password         = user[1];     //need to assign it directly since the user class encrypts whatever you hand to it
            newUser.loggedInRemotely = loggedRemotely;
            newUser.terminal         = InGameComputer.GetInstanceByID(terminalID);
            newUser.cwd = userCwd;

            if (loggedIn)
            {
                loggedInUsers.Add(newUser);
            }
        }
    }
Exemplo n.º 8
0
    void Start()
    {
        computer = gameObject.GetComponent <InGameComputer>();
        terminal = computer;
        cursor   = computer.transform.Find("monitor/display/cursor_holder/cursor");
        lang     = computer.virtualSystem.language;
        output   = computer.output;
        prompt   = computer.prompt;
        infoLine = computer.infoLine;

        displayXY     = new int[2];
        displayXY [0] = displayWidth;
        displayXY [1] = displayHeight;
        promptWidth   = displayXY [0] - 4;

        FieldInfo[] keyProps = keys.GetType().GetFields();
        keyStrings = new string[keyProps.Length];
        int i = 0;

        foreach (FieldInfo prop in keyProps)
        {
            keyStrings[i++] = (string)prop.GetValue(keys);
        }

        //set cursor and char dimensions
        float
            resolution = (Screen.dpi + 1) * 150f,
            fontWidth  = (output.fontSize == 0 ? 1 : output.fontSize) * 16.6f;

        gameUnitCharWidth  = fontWidth / resolution;
        gameUnitCharHeight = gameUnitCharWidth * 1.5f;
        gameUnitLineHeight = ((output.lineSpacing * fontWidth) / resolution) * 2;

        cursor.localScale = new Vector3(gameUnitCharWidth, gameUnitCharHeight, 1);

        StartCoroutine(BlinkCursor());
        output.text = FormatForCLI("");
    }
Exemplo n.º 9
0
    void Awake()
    {
        GenerateUniqueID();

        if (IP == "")
        {
            GenerateIP();
        }
        else
        {
            hasPermanentIP = true;
        }

        if (eraseSaveDataOnStart || !hasPermanentIP)
        {
            EraseSaveData();
            gameObject.GetComponent <InGameComputer>().EraseSaveData();
        }

        terminal     = gameObject.GetComponent <InGameComputer> ();
        userRegistry = gameObject.GetComponent <IGC_UserRegistry> ();
        fileSystem   = gameObject.GetComponent <IGC_FileSystem> ();
    }
Exemplo n.º 10
0
    public override string command_function()
    {
        //terminal
        string termOutput = "___TERMINAL___\n";

        InGameComputer igc = issuer.terminal;

        termOutput += "instance id: " + igc.instanceID + "\n";
        termOutput += "current power state: " + igc.powerState + "\n";
        termOutput += "login name/pass: "******"/" + issuer.terminal.loginPass + "\n";
        termOutput += "start in on state: " + igc.startInOnState + "\n";
        termOutput += "current user: "******"null") + "\n";
        termOutput += "bounce back user: "******"null") + "\n";
        termOutput += "remote login: "******"\n";
        termOutput += "in use: " + igc.inUse + "\n";
        termOutput += "terminal occupied: " + igc.terminalOccupied + "\n";
        termOutput += "booting up: " + igc.bootingUp + "\n";
        termOutput += "network ready: " + igc.networkReady + "\n";

        //shell
        string shellOutput = "___SHELL___\n";

        IGC_Shell sh = issuer.terminal.shell;

        shellOutput += "display width/height: " + sh.displayWidth + "/" + sh.displayHeight + "\n";
        shellOutput += "prompt width: " + sh.promptWidth + "\n";
        shellOutput += "language: " + sh.lang.LangName + "\n";
        shellOutput += "terminal id: " + sh.computer.instanceID + "\n";
        shellOutput += "input mode: " + sh.inputMode + "\n";
        shellOutput += "capslock: " + sh.capslock + "\n";
        shellOutput += "ctrl: " + sh.ctrl + "\n";
        shellOutput += "history count: " + sh.history.Count + "\n";
        shellOutput += "cursor offset x/y: " + sh.cursorOffset + "/" + sh.cursorOffsetVertical + "\n";
        shellOutput += "display line offset: " + sh.lineOffset + "\n";
        shellOutput += "last edited: " + (sh.lastEditedFile != null ? sh.lastEditedFile.path : "null") + "\n";
        shellOutput += "raw edit string len: " + sh.rawEditString.Length + "\n";
        shellOutput += "raw display text len: " + sh.rawDisplayText.Length + "\n";
        shellOutput += "formatted display len: " + sh.output.text.Length + "\n";
        shellOutput += "raw prompt text len: " + sh.rawPromptText.Length + "\n";
        shellOutput += "formatted prompt len: " + sh.prompt.text.Length + "\n";
        shellOutput += "infoline len: " + sh.infoLine.text.Length + "\n";


        //virtual system
        string vsOutput = "___VIRTUAL SYSTEM___\n";

        IGC_VirtualSystem vs = virtualSystem;

        vsOutput += "instance id: " + vs.instanceID + "\n";
        vsOutput += "model name: " + vs.modelName + "\n";
        vsOutput += "ip: " + vs.IP + "\n";
        vsOutput += "permanent ip: " + vs.hasPermanentIP + "\n";
        vsOutput += "language: " + vs.language.LangName + "\n";
        vsOutput += "startup stasks complete: " + vs.startUpTasksComplete + "\n";
        vsOutput += "network ready: " + vs.networkReady + "\n";
        vsOutput += "erase save data on start: " + vs.eraseSaveDataOnStart + "\n";
        vsOutput += "resore data len: " + vs.restoreData.Length + "\n";

        //userregistry
        string urOutput = "___USER REGISTRY___\n";

        IGC_UserRegistry ur = virtualSystem.userRegistry;

        urOutput += "virtual system id: " + ur.virtualSystem.instanceID + "\n";
        urOutput += "ready for use: " + ur.ready + "\n";
        urOutput += "users logged in: " + ur.loggedInUsers.Count + "\n";
        urOutput += "users: " + ur.users.Count + "\n";
        urOutput += "groups: " + ur.groups.Count + "\n";
        urOutput += "users editor string: \n" + string.Join("\n", ur.usersList) + "\n";
        urOutput += "groups editor string: \n" + string.Join("\n", ur.groupsList) + "\n";

        //file system
        string fsOutput = "___FILE SYSTEM___\n";

        IGC_FileSystem fs = virtualSystem.fileSystem;

        fsOutput += "virtual system id: " + fs.virtualSystem.instanceID + "\n";
        fsOutput += "ready for use: " + fs.ready + "\n";
        fsOutput += "files: " + fs.files.Count + "\n";
        fsOutput += "root node: " + fs.rootNode.name + "\n";

        //unique game instance id
        string gameID = "unique game instance id: " + IGC_VirtualSystem.uniqueID + "\n";

        string output = "";

        if (flags.Count > 0)
        {
            foreach (var k in flags.Keys)
            {
                if (k == "g")
                {
                    output = gameID;
                }
                if (k == "t")
                {
                    output = termOutput;
                }
                if (k == "s")
                {
                    output = shellOutput;
                }
                if (k == "vs")
                {
                    output = vsOutput;
                }
                if (k == "fs")
                {
                    output = fsOutput;
                }
                if (k == "ur")
                {
                    output = urOutput;
                }
            }
            if (output == "")
            {
                return("flag(s) not recognised");
            }
        }
        else
        {
            output = gameID + termOutput + shellOutput + vsOutput + urOutput + fsOutput;
        }

        issuer.terminal.shell.EnterViewMode(output);

        return("");
    }
Exemplo n.º 11
0
 //assign id and add to instance list
 private void GenerateUniqueID(InGameComputer instance)
 {
     instance.instanceID = IDCounter++;
     instances.Add(instance);
 }
Exemplo n.º 12
0
 [RPC] private void LoginRPC(string username, int terminalID)
 {
     LoginActions(username, InGameComputer.GetInstanceByID(terminalID));
 }