public override void Action(string[] args) { List <HackableObject> connections = new List <HackableObject>(); foreach (Router r in Router.unlockedRouters) { connections.AddRange(r.connections); } // invalid arguments if (args.Length != 1) { comRef.PrintToTerminal("Please input device name after \"hack\" command."); } // everything good! else { HackableObject toHack = FindHackableObjectByUID(connections, args[0]); if (toHack != null) { // SUCCESS PATH if (toHack.online && !toHack.active) // hackable object found and not { comRef.PrintToTerminal("<color=\"green\">" + toHack.ToString() + " successfully hacked.</color>"); AudioHelper.PlaySound("hack", false); // already active // for loop through all hackable objects and turn them off /// TODO: Make sure to check if object should be made inactive /// or not (i.e. camera, etc. should not be when others are hacked) foreach (Router r in Router.unlockedRouters) { r.ClosePanel(toHack.panelNo); } toHack.SetEnabled(true); // FAILURE PATH } else if (toHack.online) // hackable object active { comRef.PrintToTerminal("Already connected to " + toHack.ToString()); } else // hackable object offline { comRef.PrintToTerminal("<color=\"red\">ERROR: " + toHack.ToString() + " is offline.</color>"); AudioHelper.PlaySound("error", false); } } else // hackable object not found { comRef.PrintToTerminal("<color=\"red\">ERROR: Connection doesn't exist.</color>"); AudioHelper.PlaySound("error", false); } } }