180 likes | 198 Views
XNA DEBUG TERMINAL. Created By: Kevin Cherry. What is XNA Debug Terminal?. A library that creates a display to run on top of your game allowing you to retrieve/set values and invoke methods. How Does it Work?.
E N D
XNA DEBUG TERMINAL Created By: Kevin Cherry
What is XNA Debug Terminal? A library that creates a display to run on top of your game allowing you to retrieve/set values and invoke methods.
How Does it Work? To understand how this is possible, we need to examine some basic and .Net specific concepts
Compiled Vs. Interpreted • Interpreted languages evaluate source code at runtime • Code is not compiled but rather parsed and evaluated as needed. • Examples: JavaScript, PHP, Python, Ruby • Compiled languages compile to assembly or special/proprietary intermediate language losing type information in the process, making arbitrary code execution at runtime impossible. • Examples: C#, C++, Java, VB
MSIL And Metadata • Why it is possible to interpret strings containing code at runtime with a .Net language • .Net converts code into Microsoft Intermediate Language and a metadata file. The metadata file contains all the information obtained from parsing the source types and MSIL contains the instructions for execution. Querying this metadata we can obtain links to type members.
Reflection • To query this metadata file, we use reflections. This part of the .Net framework provides information on the specified object’s type which can be used to retrieve fields/properties or invoke methods.
So, How Does XNA Debug Terminal Work? It converts your expression into subexpressions, then parses and evaluates them using reflections.
Basic Layout Pressing custom set key shows/hides display
Example Invoke method for restoring health of player
Currently Allowed Expressions • Casting • Enums • Identifiers • Literals • Methods • New • Object chains • Types
Not Yet Allowed Expressions • Anonymous Types/Functions • Array indexing or initialization • Arithmetic • Collection initialization • Conditional logic • Generics • Keywords: • as, base, default (e.g. default(int)), fixed, is, out, ref, sizeof, stackalloc, this, throw, typeof, unchecked, unsafe • Lambda Functions • LINQ • Logic Operators (&, |, ^, &&, ||) • Property indexers
Version Priorities • Bugs in expression parsing • Common/Frequently used C# expressions • Bugs elsewhere • Common/Frequently used C# keywords • New Terminal commands • Terminal UI improvements • Speed optimizations • Other improvements
Getting Involved • Email me at: kcherr1@tigers.lsu.edu • with subject “XNA Debug Terminal Source Code" to obtain the source code • Look over code and decide on a single task to undertake • Email me details of the task (what it is and about how long it will take you) • Email back the original source code with all of your changes when done • All contributors will get name in Authors file and Getting Involved, News, and Download webpages
Guidelines For Contributing • Document all types, fields, properties, and methods you add using the "///" xml documentation • Add test cases to the test project that cover your newly added functionality and ensure that each one passes. All previous test cases must pass as well • Try to follow the coding convention used by the existing code • Only change existing code when it concerns your single task
XNA Debug Terminal Website http://www.protohacks.net/xna_debug_terminal