Giter Site home page Giter Site logo

powerfulbacon / corgeng Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 0.0 1.76 MB

A modularised, multi-threaded C# game engine based on the Entity Component System architecture. Uses OpenGL for rendering and contains many optional modules for easier development. Includes a user interface library, networking, a layered rendering solution, dynamic XML content loading, ECS framework and an example programs. Primarilly for 2D games.

C# 99.58% GLSL 0.42%
2d 2d-game-engine ecs engine game game-development game-engine gamedev opengl rendering rendering-2d-graphics user-interface

corgeng's Introduction

image

image

Some things I have worked on:

Space Station 13 Fancy Lighting

A beautiful shadow based lighting system utilising some fun transformation math. Unfortunately due to the restrictions of the engine, I was unable to overcome the client lag caused by Byond's KEEP_TOGETHER flag causing lag when rendering lights. ss13_lighting_2 ss13_lighting_3

Random art

syndie base png space ian

GGJ2022

Some screenshots of a rimworld inspired game I made in 10 days for the global game jam 2022.

151660809-42c4ef5e-74f9-451c-80ab-d45a63042c6b

image

corgeng's People

Contributors

hackmd-deploy avatar powerfulbacon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

corgeng's Issues

Update events overload the system and make it kablooey

Keyboard presses raise a global event every rendering frame.
If the system waiting for keyboard events runs slower than the rendering thread, the events come in faster than they can be processed which completely overloads the system.

Better event trace handling

If an exception occurs as a result of some processing, then the event that caused that process should have a stack trace generated and printed out.
Obviously we can't generate the stack trace for every event, and we should only do it when we error if possible.

This would make it significantly easier to diagnose issues that occur as a result of a sequence of events rather than issues that occur in isolation.

Keybinds

There should be a basic keybind framework, so rather than checking if a key was pressed we can detect when a keybind is pressed

User interface tags

Implement tags for user interface components.
Add the ability to get a component with some tag.

This allows us to open up user interface components when we click a button.

Contents

We need to be able to put entities inside of other entities.

Add in ITextureSprite

Make it so we can get a texture and the position of that sprite within a texture.

CreateEntity is very slow due to synchronous events.

We should rewrite synchronous events to work like this:

  • If the system is currently running on its own thread, tell it to pause
  • Wait until the system is paused and all synchronous events are handled on that system.
  • Run our event on the thread that the synchronous event was called from.

In most cases the entity system will be sleeping, meaning that we can skip straight to immediately executing the event on the current thread which saves time while keeping entitysystems non-concurrent.

Rendering locks the batches

This will slow down other entity systems as they can't update the batch until drawing is done.
Use double buffering instead.

Way to define prototypes without creating them.

I need a way to define prototypes without actually creating and then deleting an entity.
Perhaps this should be integrated into the ContentLoading system and that should be refactored.

Workaround:

  • Create an entity
  • Generate prototype from entity
  • Delete the entity

Networking Notes

We need to transmit component add and remove events.
When a player joins they need to recieve the current state of entities and events.
Not all components need to be networked.
Not all entities need to be networked.
We need to figure out how to decide what should render what.
We need to transmit relevent server side events so that clients can handle them.

Content Loading Lists

Content loading needs the ability to be able to load in lists.

<Property name="BehaviourList">
  <Object type="List">
    <ListElement>4</ListElement>
    <ListElement>5</ListElement>
    <ListElement>6</ListElement>
  </Object>
</Property>

<Property name="BehaviourList">
  <Object type="List">
    <ListElement>
      <Object type="BehaviourNode">
        <Property name="Priority">5</Property>
      </Object>
    </ListElement>
    <ListElement>
      <Object type="BehaviourNode">
        <Property name="Priority">5</Property>
      </Object>
    </ListElement>
  </Object>
</Property>

Issues with sprite rendering component

There seems to be some kind of issue with batches or at least the sprite rendering component in general, where sometimes things don't render and deleting them causes other things to stop rendering instead.
Is this a case of something not being added to the list, causing the offsets to shift by 1?

We need regular interval processing

Want:

//1 second delay
override double ProcessDelay = 1000;

RegisterProcessEvent<GComponent>(targetEntity, OnProcess);
UnregisterProcessEvent(targetEntity);


void OnProcess(IComponent component, double deltaTime)
{
    ...
}

Text Rendering Goals

  • Ability to render text
  • Changing the text or position of the text, or any variables will automatically update the batch and update the text object without more required updates.

Linux support / Move to .NET Core

Supporting as many operating systems as possible is a good thing, since it means we have more audience for games created using CorgEng. We need to move to .NET Core instead of .NET framework to accomodate anyone who suffers the fate of linux.

Convert signals to tasks and have it possible to await their handling

Make it so we can await the completion of a task, the thread executing will wait until the task is handled before continuing.
Alternatively we could handle the task on that thread instead of going through the system, however this would result in complications with multi-threading if the system/component has shared reasources.

Multi-threaded systems

Make systems multi-threaded.
When a signal is sent it will be handled on the appropriate thread.

Content Loading Snippets/Defines

Add in the ability to create content loading blueprints, which can be used inside other content loading xml files and act as a replacement.

Example idea:

<Define name="group">
  <Property name="value">5</Property>
</Define>

<Object type="NumberHolder">
  <Define name="group" />
</Object>

Overlay rendering

We need a way to render overlays onto an already rendering object (Clothes and stuff need drawing)

Add in global events

Allows systems to register to global events, which will trigger a system callback when triggered.
These will include keyboard and mouse events.

Component has pretty high memory usage.

Due to having lambda functions per event registered to component per component, the component signal handler lambda functions use an absolute ton of memory.

Before entities created (Its high due to reflection caches mainly):
image

With somewhere between 32000 and 64000 entities:
image

Its not awful, but something to consider optimising

Potentially rework AI behaviour

After using the AI behaviour system in implementations, there are some clear flaws, mainly with the memory system causing issues with claiming when tasks fail or are cancelled.

Perhaps it would be better to do something like:

  • Memory is local, you pass on calculated things in chain

Currently the tree looks like this:

image

The memory system is just messy

Removing from a batch is bugged

There is a bug with removing from batches which causes failures when trying to change a sprite.
Reproduce by making something render, removing it from the batch then change some texture for an item in the batch after the thing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.