Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CryMono Technical Presentation

CryMono Technical Presentation

Why we built CryMono.

Avatar for returnstring

returnstring

January 18, 2012
Tweet

Other Decks in Programming

Transcript

  1. bringing the power of .NET and C# to CryENGINE3 ©

    2011 Ink Studios Ltd. Development by: Filip Lundgren Ruan Pearce-Authers Director Technical Director [email protected] [email protected] Please direct business correspondence and enquiries to [email protected]
  2. Problem #1 C++ is the preferred language for CryENGINE development,

    whilst other engines support more modern systems. Whilst this makes sense for performance-critical subsystems, C++ can be considered outdated in the developer-facing components of the engine for the following reasons: 1. The lack of a well defined and documented base class library 2. Manual memory management 3. A lengthy compilation process hinders iterative development 4. No runtime reloading of code
  3. Problem #2 CryENGINE attempts to solve this problem by providing

    Lua scriptbinds for certain engine features, most notably game rules and the more basic entities. However, Lua shares many of the same problems as C++, and introduces a few of its own: 1. The language is extremely loosely typed • Performance considerations • Objects are not constructed intuitively (i.e. tables for properties) 2. Once again, there is no base class library 3. Prebuilt libraries are few and far between
  4. The Spec The requirements for a more developer-friendly platform can

    essentially then be expressed as follows: 1. A robust base class library 2. A strong developer community 3. Support for extension via libraries 4. Modern language features such as reflection 5. The ability to perform Just In Time compilation at runtime 6. Cross-platform compatibility
  5. The Solution After much searching, we decided on using C#

    embedded via Mono. 1. .NET features an enormous base class library for almost any operation 2. C# is one of the fastest-growing modern languages 3. Modern features such as reflection allow us to make the developer- facing components of the engine far more friendly and logical 4. By embedding Mono, no dependencies are required on end-user’s machines 5. C# provides built-in support for library loading, and has a wealth of preexisting libraries for features not included in the BCL 6. Our internal Mono fork adds x64 Windows support
  6. New Systems To simplify game development using CryMono, we expose

    three main classes that can be extended to handle almost all aspects of game logic: 1. BaseEntity Create custom entities to populate your game world. Supports all the traditional property types as used in the Sandbox. 2. BaseGameRules Define how entities can interact, win/lose conditions, multiplayer options and more. 3. BaseFlowNode CryENGINE’s flowgraph system is well-known for simplifying level logic and encounters; create your own flownodes to extend this system.
  7. Tech Info Tying a brand new system to existing code

    is complicated. To that end, we’ve constructed a framework that abstracts all the heavy lifting away from the developer and enables them to focus on programming. 1. CryMono This C++ library handles the calls between the managed and unmanaged environments, object marshalling, etc 2. CryBrary Written in C#, this library contains the CryEngine namespace that exposes our newly abstracted systems, as well as handling framework logic such as script loading and dynamic assembly generation.
  8. System Flow Engine CryGame CryMono (C++) CryBrary (C#) Custom Mono

    Framework (C) JIT Compiled C# scripts Developer Facing Behind the Scenes Effective Link Actual Process
  9. Samples using CryEngine; [Entity(Category = "TestCategory", EditorHelper = "Editor/Objects/anchor.cgf", Icon

    = "", Flags = EntityClassFlags.Default)] public class SampleEntity : BaseEntity { public override void OnUpdate() { //Per-frame logic goes here, CryTime.DeltaTime can be used to make operations framerate independent } public override void OnSpawn() { CryConsole.LogAlways("Spawned our test entity, ID is {0}", this.Id); } [EditorProperty(Description = "How awesome is this entity?", Min = 0, Max = 9001)] public float awesomenessLevel; [EditorProperty(Type = EntityPropertyType.Object)] public string objectSelector; [EditorProperty] public Vec3 vectorTest; } How quickly can you build an entity with CryMono? In the time it takes you to read this slide.
  10. Samples using CryEngine; [FlowNode(UICategory = "MathSamples", Description = "Reimplementation of

    multiplication in C#", Category = FlowNodeCategory.Approved)] public class Multiplier : BaseFlowNode { [InputPort(Name = "Activate", Description = "Do the maths")] public void Activate() { ActivateOutput(answerOutput, GetFloatValue(LeftSide) * GetFloatValue(RightSide)); } //We could store these in managed memory but using Get...Value is quicker when we need default values [InputPort(Name = "Left Side", Description = "The left side of the calculation")] public void LeftSide(float value) { } [InputPort(Name = "Right Side", Description = "The right side of the calculation")] public void RightSide(float value) { } [OutputPort(Name = "Answer", Description = "Get the answer", Type = NodePortType.Float)] public static int answerOutput; } Need to give your designers some supporting flownodes? Equally simple, equally fast.
  11. From here: We believe that in extending the engine with

    modern language support, the user base for the engine can be vastly increased, in terms of independent development and AAA studio uptake alike. In enabling programmers to concentrate on the logic, not the language, CryMono users save valuable development time and gain access to a wealth of preexisting code resources. And, coming in a future release, runtime code reloading will make the lengthy write-compile-test cycle a thing of the past. For questions regarding licensing, please contact [email protected]. All enquiries will receive a response within 48 hours maximum.