Adam's Lair game development and casual madness
RSS Feed
  • C# Collection Initializers via Extension Methods

    An interesting C# feature that I just stumbled across by accident: You can provide a custom collection initializer for any IEnumerable<T> using an extension method. It allows you to turn something like this:

    List<Vector3> myList = new List<Vector3>
    {
        new Vector3(1.0f, 2.0f, 3.0f),
        new Vector3(4.0f, 5.0f, 6.0f)
    };
    

    into this:

    List<Vector3> myList = new List<Vector3>
    {
        { 1.0f, 2.0f, 3.0f },
        { 4.0f, 5.0f, 6.0f }
    };
    

    by simply providing the Add method that is required for collection initializers as an extension method:

    public static class Vector3Extensions
    {
        public static void Add(this IList<Vector3> list, float x, float y, float z)
        {
            list.Add(new Vector3(x, y, z));
        }
    }
    

    Definitely not something for everyday use, but I can imagine it could clean up some data-heavy bits of code a lot. It appears that this was introduced in C# 6.0, along with indexer initializers.

    Read More »

  • Asset Management Improvements

    I must preface this progress report with an apology: Doing PR work isn’t exactly my greatest strength and sometimes that means skipping it for a while and keeping the public out of the development loop. Sorry everyone! Here it is: A quick update.

    Read More »

  • Duality on itch.io

    Duality is now on itch.io! Go check it out:

    Read More »

  • Duality v2.0 Changelog

    Duality v2.0 is now feature-complete and, until more testing has been done, awaiting its binary release. This posting contains the full changelog since the previous v1.x release.

    Read More »

  • Project Summary: "Shopfloor"

    Shopfloor was a small project from the “Serious Games” category that was developed for Infineon Technologies. Designed as a casual interlude in scheduled in-house trainings for employees, the goal was to create a game that would be engaging and fun to play, while at the same time providing a platform for reflecting the lessons from their everyday work.

    Read More »

Adam
Adam

Software developer, gamedev hobbyist and creator of the Duality framework.

GitHub Twitter Email

Table of Contents