Example #1
0
 public void ConnectToServer(string ip)
 {
     connectingToServer = true;
     try
     {
         var socket   = new TcpClient();
         var remoteEP = new IPEndPoint(IPAddress.Parse(ip), Multiplayer.PORT);
         socket.Connect(remoteEP);
         var stream = socket.GetStream();
         buffer = encoder.GetBytes("connect Client Connecting");
         stream.Write(buffer, 0, buffer.Length);
         stream.Flush();
         stream.Read(buffer, 0, buffer.Length);
         ExitScreen();
         ScreenManager.AddScreen(new OS(socket, stream, false, ScreenManager), ScreenManager.controllingPlayer);
     }
     catch (Exception ex)
     {
         DebugLog.add(ex.ToString());
         isConnecting = false;
     }
 }
Example #2
0
        public void doGui(float t)
        {
            int   num1           = -1;
            Color highlightColor = this.os.highlightColor;

            for (int nodeIndex = 0; nodeIndex < this.nodes.Count; ++nodeIndex)
            {
                Vector2 nodeDrawPos = this.GetNodeDrawPos(this.nodes[nodeIndex], nodeIndex);
                if (this.visibleNodes.Contains(nodeIndex) && !this.nodes[nodeIndex].disabled)
                {
                    for (int index = 0; index < this.nodes[nodeIndex].links.Count; ++index)
                    {
                        if (this.visibleNodes.Contains(this.nodes[nodeIndex].links[index]) && !this.nodes[this.nodes[nodeIndex].links[index]].disabled)
                        {
                            this.drawLine(this.GetNodeDrawPos(this.nodes[nodeIndex], nodeIndex), this.GetNodeDrawPos(this.nodes[this.nodes[nodeIndex].links[index]], this.nodes[nodeIndex].links[index]), new Vector2((float)this.bounds.X, (float)this.bounds.Y));
                        }
                    }
                    if ((double)this.pulseFade > 0.0)
                    {
                        Color color = this.os.highlightColor * (this.pulseFade * this.pulseFade);
                        if (this.DimNonConnectedNodes)
                        {
                            color = Utils.AddativeRed * 0.5f * (this.pulseFade * this.pulseFade);
                        }
                        this.spriteBatch.Draw(this.circleOutline, new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE / 2), (float)(this.bounds.Y + (int)nodeDrawPos.Y + NetworkMap.NODE_SIZE / 2)), new Rectangle?(), color, this.rotation, this.circleOrigin, new Vector2(NetworkMap.ADMIN_CIRCLE_SCALE * (float)(2.0 - 2.0 * (double)this.pulseFade)), SpriteEffects.None, 0.5f);
                    }
                    if (this.nodes[nodeIndex].idName == this.os.homeNodeID && !this.nodes[nodeIndex].disabled)
                    {
                        this.spriteBatch.Draw(this.homeNodeCircle, new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE / 2), (float)(this.bounds.Y + (int)nodeDrawPos.Y + NetworkMap.NODE_SIZE / 2)), new Rectangle?(), this.os.connectedComp == null || this.os.connectedComp != this.nodes[nodeIndex] ? (this.nodes[nodeIndex].Equals((object)this.os.thisComputer) ? this.os.thisComputerNode : this.os.highlightColor) : (this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip ? Utils.AddativeWhite : Utils.AddativeWhite), -1f * this.rotation, this.circleOrigin, new Vector2(NetworkMap.ADMIN_CIRCLE_SCALE), SpriteEffects.None, 0.5f);
                    }
                    if (this.nodes[nodeIndex] == this.lastAddedNode && !this.nodes[nodeIndex].disabled)
                    {
                        float num2 = this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip ? 1f : 4f;
                        this.spriteBatch.Draw(this.targetNodeCircle, new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE / 2), (float)(this.bounds.Y + (int)nodeDrawPos.Y + NetworkMap.NODE_SIZE / 2)), new Rectangle?(), this.os.connectedComp == null || this.os.connectedComp != this.nodes[nodeIndex] ? (this.nodes[nodeIndex].Equals((object)this.os.thisComputer) ? this.os.thisComputerNode : (this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip ? this.os.highlightColor : Utils.AddativeWhite)) : (this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip ? this.os.highlightColor : Utils.AddativeWhite), -1f * this.rotation, this.circleOrigin, new Vector2(NetworkMap.ADMIN_CIRCLE_SCALE) + Vector2.One * ((float)Math.Sin((double)this.os.timer * 3.0) * num2) / (float)this.targetNodeCircle.Height, SpriteEffects.None, 0.5f);
                    }
                    if (this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip && !this.nodes[nodeIndex].disabled)
                    {
                        this.spriteBatch.Draw(this.nodes[nodeIndex].ip.Equals(this.os.thisComputer.ip) ? this.adminCircle : this.nodeGlow, new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE / 2), (float)(this.bounds.Y + (int)nodeDrawPos.Y + NetworkMap.NODE_SIZE / 2)), new Rectangle?(), this.nodes[nodeIndex].Equals((object)this.os.thisComputer) ? this.os.thisComputerNode : this.os.highlightColor, this.rotation, this.circleOrigin, new Vector2(NetworkMap.ADMIN_CIRCLE_SCALE), SpriteEffects.None, 0.5f);
                    }
                }
            }
            lock (this.nodes)
            {
                for (int nodeIndex = 0; nodeIndex < this.nodes.Count; ++nodeIndex)
                {
                    if (this.visibleNodes.Contains(nodeIndex) && !this.nodes[nodeIndex].disabled)
                    {
                        Color color;
                        if (this.os.thisComputer.ip == this.nodes[nodeIndex].ip)
                        {
                            color = this.os.thisComputerNode;
                        }
                        else
                        {
                            color = this.os.connectedComp == null ? (!(this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip) || !(this.nodes[nodeIndex].ip == this.os.opponentLocation) ? (!this.os.shellIPs.Contains(this.nodes[nodeIndex].ip) ? this.os.highlightColor : this.os.shellColor) : Color.DarkRed) : (!(this.os.connectedComp.ip == this.nodes[nodeIndex].ip) ? (!(this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip) || !(this.nodes[nodeIndex].ip == this.os.opponentLocation) ? (!this.os.shellIPs.Contains(this.nodes[nodeIndex].ip) ? this.os.highlightColor : this.os.shellColor) : Color.DarkRed) : Color.White);
                            if ((double)this.nodes[nodeIndex].highlightFlashTime > 0.0)
                            {
                                this.nodes[nodeIndex].highlightFlashTime -= t;
                                color = Color.Lerp(color, Utils.AddativeWhite, Utils.QuadraticOutCurve(this.nodes[nodeIndex].highlightFlashTime));
                            }
                        }
                        Vector2 nodeDrawPos = this.GetNodeDrawPos(this.nodes[nodeIndex], nodeIndex);
                        if (this.DimNonConnectedNodes && this.os.connectedComp != null && this.os.connectedComp.ip != this.nodes[nodeIndex].ip)
                        {
                            color *= 0.3f;
                        }
                        if (Button.doButton(2000 + nodeIndex, this.bounds.X + (int)nodeDrawPos.X, this.bounds.Y + (int)nodeDrawPos.Y, NetworkMap.NODE_SIZE, NetworkMap.NODE_SIZE, "", new Color?(color), this.nodes[nodeIndex].adminIP == this.os.thisComputer.ip ? this.adminNodeCircle : this.nodeCircle) && this.os.inputEnabled)
                        {
                            bool flag = false;
                            if (this.os.terminal.preventingExecution && this.os.terminal.executionPreventionIsInteruptable)
                            {
                                this.os.terminal.executeLine();
                                flag = true;
                            }
                            int    nodeindex = nodeIndex;
                            Action action    = (Action)(() => this.os.runCommand("connect " + this.nodes[nodeindex].ip));
                            if (flag)
                            {
                                this.os.delayer.Post(ActionDelayer.NextTick(), action);
                            }
                            else
                            {
                                action();
                            }
                        }
                        if (GuiData.hot == 2000 + nodeIndex)
                        {
                            num1 = nodeIndex;
                        }
                        if (this.nodes[nodeIndex].idName == this.os.homeAssetServerID && !this.nodes[nodeIndex].disabled)
                        {
                            this.spriteBatch.Draw(this.assetServerNodeOverlay, new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE / 2), (float)(this.bounds.Y + (int)nodeDrawPos.Y + NetworkMap.NODE_SIZE / 2)), new Rectangle?(), num1 == nodeIndex ? GuiData.Default_Lit_Backing_Color : (this.os.connectedComp == null || this.os.connectedComp != this.nodes[nodeIndex] ? (this.nodes[nodeIndex].Equals((object)this.os.thisComputer) ? this.os.thisComputerNode : this.os.highlightColor) : Color.Black), -0.5f * this.rotation, new Vector2((float)(this.assetServerNodeOverlay.Width / 2)), new Vector2(NetworkMap.ADMIN_CIRCLE_SCALE - 0.22f), SpriteEffects.None, 0.5f);
                        }
                    }
                }
            }
            int nodeIndex1 = this.os.connectedComp == null ? 0 : this.nodes.IndexOf(this.os.connectedComp);

            if (this.os.connectedComp != null && !this.os.connectedComp.Equals((object)this.os.thisComputer) && !this.os.connectedComp.adminIP.Equals(this.os.thisComputer.ip))
            {
                GuiData.spriteBatch.Draw(this.nodeGlow, this.GetNodeDrawPos(this.os.connectedComp, nodeIndex1) - new Vector2((float)(this.nodeGlow.Width / 2), (float)(this.nodeGlow.Height / 2)) + new Vector2((float)this.bounds.X, (float)this.bounds.Y) + new Vector2((float)(NetworkMap.NODE_SIZE / 2)), this.os.connectedNodeHighlight);
                if (this.nodeEffect != null && this.os.connectedComp != null)
                {
                    this.nodeEffect.draw(this.spriteBatch, this.GetNodeDrawPos(this.os.connectedComp, nodeIndex1) + new Vector2((float)(NetworkMap.NODE_SIZE / 2)) + new Vector2((float)this.bounds.X, (float)this.bounds.Y));
                }
            }
            else if (this.os.connectedComp != null && !this.os.connectedComp.Equals((object)this.os.thisComputer) && this.adminNodeEffect != null)
            {
                this.adminNodeEffect.draw(this.spriteBatch, this.GetNodeDrawPos(this.os.connectedComp, nodeIndex1) + new Vector2((float)(NetworkMap.NODE_SIZE / 2)) + new Vector2((float)this.bounds.X, (float)this.bounds.Y));
            }
            if (num1 != -1)
            {
                try
                {
                    int     nodeIndex2  = num1;
                    Vector2 nodeDrawPos = this.GetNodeDrawPos(this.nodes[nodeIndex2], nodeIndex2);
                    Vector2 ttpos       = new Vector2((float)(this.bounds.X + (int)nodeDrawPos.X + NetworkMap.NODE_SIZE), (float)(this.bounds.Y + (int)nodeDrawPos.Y));
                    string  text        = this.nodes[nodeIndex2].getTooltipString();
                    Vector2 textSize    = GuiData.tinyfont.MeasureString(text);
                    this.os.postFXDrawActions += (Action)(() =>
                    {
                        GuiData.spriteBatch.Draw(Utils.white, new Rectangle((int)ttpos.X, (int)ttpos.Y, (int)textSize.X, (int)textSize.Y), this.os.netmapToolTipBackground);
                        TextItem.doFontLabel(ttpos, text, GuiData.tinyfont, new Color?(this.os.netmapToolTipColor), float.MaxValue, float.MaxValue, false);
                    });
                }
                catch (Exception ex)
                {
                    DebugLog.add(ex.ToString());
                }
            }
            if (!Settings.debugDrawEnabled)
            {
                return;
            }
            for (int index = 0; index < Corporation.TestedPositions.Count; ++index)
            {
                Vector2 nodeDrawPosDebug = this.GetNodeDrawPosDebug(Corporation.TestedPositions[index]);
                Vector2 position         = new Vector2((float)(this.bounds.X + (int)nodeDrawPosDebug.X + NetworkMap.NODE_SIZE), (float)(this.bounds.Y + (int)nodeDrawPosDebug.Y));
                GuiData.spriteBatch.Draw(Utils.white, position, new Rectangle?(), Utils.AddativeRed, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.8f);
            }
        }
Example #3
0
        public void doGui(float t)
        {
            var num1   = -1;
            var color1 = os.highlightColor;

            for (var index1 = 0; index1 < nodes.Count; ++index1)
            {
                var nodeDrawPos = GetNodeDrawPos(nodes[index1].location);
                if (visibleNodes.Contains(index1) && !nodes[index1].disabled)
                {
                    for (var index2 = 0; index2 < nodes[index1].links.Count; ++index2)
                    {
                        if (visibleNodes.Contains(nodes[index1].links[index2]) &&
                            !nodes[nodes[index1].links[index2]].disabled)
                        {
                            drawLine(GetNodeDrawPos(nodes[index1].location),
                                     GetNodeDrawPos(nodes[nodes[index1].links[index2]].location),
                                     new Vector2(bounds.X, bounds.Y));
                        }
                    }
                    if (pulseFade > 0.0)
                    {
                        var color2 = os.highlightColor * (pulseFade * pulseFade);
                        if (DimNonConnectedNodes)
                        {
                            color2 = Utils.AddativeRed * 0.5f * (pulseFade * pulseFade);
                        }
                        spriteBatch.Draw(circleOutline,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(), color2, rotation,
                                         circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE * (float)(2.0 - 2.0 * pulseFade)),
                                         SpriteEffects.None, 0.5f);
                    }
                    if (nodes[index1].idName == os.homeNodeID && !nodes[index1].disabled)
                    {
                        spriteBatch.Draw(homeNodeCircle,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                         os.connectedComp == null || os.connectedComp != nodes[index1]
                                ? (nodes[index1].Equals(os.thisComputer) ? os.thisComputerNode : os.highlightColor)
                                : (nodes[index1].adminIP == os.thisComputer.ip
                                    ? Utils.AddativeWhite
                                    : Utils.AddativeWhite), -1f * rotation, circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE),
                                         SpriteEffects.None, 0.5f);
                    }
                    if (nodes[index1] == lastAddedNode && !nodes[index1].disabled)
                    {
                        var num2 = nodes[index1].adminIP == os.thisComputer.ip ? 1f : 4f;
                        spriteBatch.Draw(targetNodeCircle,
                                         new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                     bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                         os.connectedComp == null || os.connectedComp != nodes[index1]
                                ? (nodes[index1].Equals(os.thisComputer)
                                    ? os.thisComputerNode
                                    : (nodes[index1].adminIP == os.thisComputer.ip
                                        ? os.highlightColor
                                        : Utils.AddativeWhite))
                                : (nodes[index1].adminIP == os.thisComputer.ip ? os.highlightColor : Utils.AddativeWhite),
                                         -1f * rotation, circleOrigin,
                                         new Vector2(ADMIN_CIRCLE_SCALE) +
                                         Vector2.One * ((float)Math.Sin(os.timer * 3.0) * num2) / targetNodeCircle.Height,
                                         SpriteEffects.None, 0.5f);
                    }
                }
                if (nodes[index1].adminIP == os.thisComputer.ip && !nodes[index1].disabled)
                {
                    spriteBatch.Draw(nodes[index1].ip.Equals(os.thisComputer.ip) ? adminCircle : nodeGlow,
                                     new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE / 2,
                                                 bounds.Y + (int)nodeDrawPos.Y + NODE_SIZE / 2), new Rectangle?(),
                                     nodes[index1].Equals(os.thisComputer) ? os.thisComputerNode : os.highlightColor, rotation,
                                     circleOrigin, new Vector2(ADMIN_CIRCLE_SCALE), SpriteEffects.None, 0.5f);
                }
            }
            lock (nodes)
            {
                for (var local_7 = 0; local_7 < nodes.Count; ++local_7)
                {
                    if (visibleNodes.Contains(local_7) && !nodes[local_7].disabled)
                    {
                        Color local_1_1;
                        if (os.thisComputer.ip == nodes[local_7].ip)
                        {
                            local_1_1 = os.thisComputerNode;
                        }
                        else
                        {
                            local_1_1 = os.connectedComp == null
                                ? (!(nodes[local_7].adminIP == os.thisComputer.ip) ||
                                   !(nodes[local_7].ip == os.opponentLocation)
                                    ? (!os.shellIPs.Contains(nodes[local_7].ip) ? os.highlightColor : os.shellColor)
                                    : Color.DarkRed)
                                : (!(os.connectedComp.ip == nodes[local_7].ip)
                                    ? (!(nodes[local_7].adminIP == os.thisComputer.ip) ||
                                       !(nodes[local_7].ip == os.opponentLocation)
                                        ? (!os.shellIPs.Contains(nodes[local_7].ip) ? os.highlightColor : os.shellColor)
                                        : Color.DarkRed)
                                    : Color.White);
                            if (nodes[local_7].highlightFlashTime > 0.0)
                            {
                                nodes[local_7].highlightFlashTime -= t;
                                local_1_1 = Color.Lerp(local_1_1, Utils.AddativeWhite,
                                                       Utils.QuadraticOutCurve(nodes[local_7].highlightFlashTime));
                            }
                        }
                        var local_8 = GetNodeDrawPos(nodes[local_7].location);
                        if (DimNonConnectedNodes && os.connectedComp != null && os.connectedComp.ip != nodes[local_7].ip)
                        {
                            local_1_1 *= 0.3f;
                        }
                        if (
                            Button.doButton(2000 + local_7, bounds.X + (int)local_8.X, bounds.Y + (int)local_8.Y,
                                            NODE_SIZE, NODE_SIZE, "", local_1_1,
                                            nodes[local_7].adminIP == os.thisComputer.ip ? adminNodeCircle : nodeCircle) &&
                            os.inputEnabled)
                        {
                            var local_9 = false;
                            if (os.terminal.preventingExecution && os.terminal.executionPreventionIsInteruptable)
                            {
                                os.terminal.executeLine();
                                local_9 = true;
                            }
                            var    nodeindex = local_7;
                            Action local_10  = () => os.runCommand("connect " + nodes[nodeindex].ip);
                            if (local_9)
                            {
                                os.delayer.Post(ActionDelayer.NextTick(), local_10);
                            }
                            else
                            {
                                local_10();
                            }
                        }
                        if (GuiData.hot == 2000 + local_7)
                        {
                            num1 = local_7;
                        }
                        if (nodes[local_7].idName == os.homeAssetServerID && !nodes[local_7].disabled)
                        {
                            spriteBatch.Draw(assetServerNodeOverlay,
                                             new Vector2(bounds.X + (int)local_8.X + NODE_SIZE / 2,
                                                         bounds.Y + (int)local_8.Y + NODE_SIZE / 2), new Rectangle?(),
                                             num1 == local_7
                                    ? GuiData.Default_Lit_Backing_Color
                                    : (os.connectedComp == null || os.connectedComp != nodes[local_7]
                                        ? (nodes[local_7].Equals(os.thisComputer)
                                            ? os.thisComputerNode
                                            : os.highlightColor)
                                        : Color.Black), -0.5f * rotation, new Vector2(assetServerNodeOverlay.Width / 2),
                                             new Vector2(ADMIN_CIRCLE_SCALE - 0.22f), SpriteEffects.None, 0.5f);
                        }
                    }
                }
            }
            if (os.connectedComp != null && !os.connectedComp.Equals(os.thisComputer) &&
                !os.connectedComp.adminIP.Equals(os.thisComputer.ip))
            {
                GuiData.spriteBatch.Draw(nodeGlow,
                                         GetNodeDrawPos(os.connectedComp.location) - new Vector2(nodeGlow.Width / 2, nodeGlow.Height / 2) +
                                         new Vector2(bounds.X, bounds.Y) + new Vector2(NODE_SIZE / 2), os.connectedNodeHighlight);
                if (nodeEffect != null && os.connectedComp != null)
                {
                    nodeEffect.draw(spriteBatch,
                                    GetNodeDrawPos(os.connectedComp.location) + new Vector2(NODE_SIZE / 2) +
                                    new Vector2(bounds.X, bounds.Y));
                }
            }
            else if (os.connectedComp != null && !os.connectedComp.Equals(os.thisComputer) && adminNodeEffect != null)
            {
                adminNodeEffect.draw(spriteBatch,
                                     GetNodeDrawPos(os.connectedComp.location) + new Vector2(NODE_SIZE / 2) +
                                     new Vector2(bounds.X, bounds.Y));
            }
            if (num1 != -1)
            {
                try
                {
                    var index       = num1;
                    var nodeDrawPos = GetNodeDrawPos(nodes[index].location);
                    var ttpos       = new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE, bounds.Y + (int)nodeDrawPos.Y);
                    var text        = nodes[index].getTooltipString();
                    var textSize    = GuiData.tinyfont.MeasureString(text);
                    os.postFXDrawActions += () =>
                    {
                        GuiData.spriteBatch.Draw(Utils.white,
                                                 new Rectangle((int)ttpos.X, (int)ttpos.Y, (int)textSize.X, (int)textSize.Y),
                                                 os.netmapToolTipBackground);
                        TextItem.doFontLabel(ttpos, text, GuiData.tinyfont, os.netmapToolTipColor, float.MaxValue,
                                             float.MaxValue);
                    };
                }
                catch (Exception ex)
                {
                    DebugLog.add(ex.ToString());
                }
            }
            if (!Settings.debugDrawEnabled)
            {
                return;
            }
            for (var index = 0; index < Corporation.TestedPositions.Count; ++index)
            {
                var nodeDrawPos = GetNodeDrawPos(Corporation.TestedPositions[index]);
                var position    = new Vector2(bounds.X + (int)nodeDrawPos.X + NODE_SIZE, bounds.Y + (int)nodeDrawPos.Y);
                GuiData.spriteBatch.Draw(Utils.white, position, new Rectangle?(), Utils.AddativeRed, 0.0f, Vector2.Zero,
                                         Vector2.One, SpriteEffects.None, 0.8f);
            }
        }