Component Code

Manage Time, Software, and Business, Easily


23 October 2021 by jr101dallas

⇠ Back to Posts

Coding Again

I’m about to start coding simplest case combat. Target an enemy, hit lands, target is removed from play. I’ve got some fun games that don’t have anything more complex than that so I’m actually pretty excited about this plan.

A Little Reorg

Really quickly, since I’m about to start adding a bunch of Components, I’m going to break out a Components folder and namespace for them. I thought about moving IComponent in there as well, but, that means my reference in Entity would be to Components. That seems sloppy. I want a reference to the interfaces but not actually to Components. So, I’ve also split out a folder and namespace for Interfaces. That way, if I decide I need to break out Interfaces into a NuGet package later it should be really easy. So a quick dotnet test after rearranging, then the old git status, add, commit, routine.

Start With a Test

I’m starting with a test this time, with probably additional tests to fill in the blanks as I go. I want to start with test that just says what I have above and then start back filling the code to make it actually compile. So, how about this to start.

        [TestMethod]
        public void TargetEntityRemovedFromPlay()
        {
            var originEntity = new Entity();
            var targetEntity = new Entity();

            originEntity.Target(targetEntity);

            Assert.IsNull(targetEntity);
        }

Targeting Red Squiggles

That’s a line in the sand anyway. I’m not so sure about the Target method at the moment since it doesn’t seem like Entity should know about that, but I’ll start working on it and see how it plays out.

Whoops. Quicksand. I’ll need to work out how to step into this in the tutorial. I started with my test and hit that little recursive problem:

  1. need to call Target
  2. shouldn’t be on Entity, probably an extension method of the System
  3. need Systems
  4. Systems need to be able to tell the difference between Entity instances
  5. need Entity tracking
  6. Entity is all zero Id right now
  7. need Entity Factory
  8. ….

I’ll cut this off here and spend some more time planning with respect to how to keep this small.

tags: code - component

⇠ Component Plan

Entity Factory ⇢