Example #1
0
 public override void OnUpdate()
 {
     if (this.vessel == FlightGlobals.ActiveVessel)
     {
         this.vessel.rigidbody.AddRelativeForce(Vector3.up * 100f * FlightInputHandler.state.mainThrottle);
         CommEngrUtils.Log(FlightInputHandler.state.mainThrottle.ToString());
     }
 }
Example #2
0
 public override void OnStart(PartModule.StartState state)
 {
     if (state != StartState.Editor) // if not in editor, then in flight
     {
         if (!hasInitStyles)
         {
             InitStyles();
         }
         RenderingManager.AddToPostDrawQueue(0, OnDraw);
     }
     CommEngrUtils.Log("RCSPrototype OnStart()");
 }
Example #3
0
        public CommBlock FindDataSource()
        {
            var qDataSource = from block in blockDiagram
                              where block.Face == nodeFace.DataSource
                              select block;

            if (qDataSource.Count() == 1)
            {
                return(qDataSource.First());
            }
            else
            {
                CommEngrUtils.Log("Error at CommSystem.FindDataSource(): one data source must be implemented!");
                return(null);
            }
        }
Example #4
0
 public CommSystem(XDocument xmlCSDoc = null)
 {
     if (xmlCSDoc == null)
     {
         // Simple DSB Receiver
         CommEngrUtils.Log("CommSystem: Allocation for DSB Receiver Start");
         blockDiagram.AddRange(new CommBlock[] {
             new CommBlock(nodeFace.DataSource, new Rect(400f, 400f, 60f, 60f)),
             new CommBlock(nodeFace.Multiplier, new Rect(500f, 500f, 60f, 60f)),
             new CommBlock(nodeFace.LocalOscillator, new Rect(600f, 600f, 60f, 60f)),
             new CommBlock(nodeFace.LowpassFilter, new Rect(700f, 700f, 60f, 60f)),
             new CommBlock(nodeFace.DataStore, new Rect(800f, 800f, 60f, 60f))
             {
             }
         });
         CommEngrUtils.Log("CommSystem: Allocation for DSB Receiver End");
     }
 }
Example #5
0
        public void DrawBlockNode()
        {
            // Draggable Block Node
            if (Position.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && !(edgeNodeSelected || edgeNodeHovered))
            {
                blockSelected = true;
            }

            if (blockSelected && Event.current.type == EventType.MouseUp)
            {
                blockSelected = false;
                offsetPos     = null;
            }

            if (blockSelected)
            {
                guiDepth = 1;

                // Enables drag and drop from any section of the block clicked
                if (offsetPos == null)
                {
                    offsetPos = new Vector2(Mouse.screenPos.x - Position.x, Mouse.screenPos.y - Position.y);
                }

                // Utilize grid class for quantizing movement
                Position.x = Grid.SnapToGrid(Mouse.screenPos.x - offsetPos.Value.x);
                Position.y = Grid.SnapToGrid(Mouse.screenPos.y - offsetPos.Value.y);
                UpdateEdgeNodes();
            }
            else
            {
                guiDepth = 2;
            }

            // Render Block Node, followed by its connectors
            GUI.depth = guiDepth;
            if (GUI.Button(Position, Icon, GetBlockStyle(Icon)))
            {
                CommEngrUtils.Log(string.Format("Block with Rect({0}, {1}, {2}, {3}) clicked!",
                                                Position.x, Position.y, Position.width, Position.height));
            }

            // Selectable Edge Nodes
            GUI.depth = 0;
            foreach (var edgeNode in EdgeNodes)
            {
                if (edgeNode.Value.Position.Contains(Event.current.mousePosition))
                {
                    edgeNodeHovered = true;
                }
                else
                {
                    edgeNodeHovered = false;
                }

                if (edgeNodeHovered && Input.GetMouseButtonDown(0))
                {
                    screenPt1        = new Vector2(edgeNode.Value.Position.x, (float)Screen.height - edgeNode.Value.Position.y);
                    edgeNodeSelected = true;
                    callDrawEdge     = true;
                }

                if (edgeNodeSelected && Input.GetMouseButtonDown(1))
                {
                    callDrawEdge     = false;
                    edgeNodeHovered  = false;
                    edgeNodeSelected = false;
                }
                if (GUI.Button(edgeNode.Value.Position, "EN"))
                {
                }

                if (edgeNodeSelected)
                {
                }

                if (callDrawEdge)
                {
                    GLUtils.DrawConnection(screenPt1 + new Vector2(edgeNode.Value.Position.width / 2f, edgeNode.Value.Position.height / 2f), Mouse.screenPos, Color.red, 10f);
                }
            }
        }
Example #6
0
 public void Awake()
 {
     CommEngrUtils.Log("Ground Station Activated");
 }