• Stars
    star
    165
  • Rank 227,854 (Top 5 %)
  • Language
    C#
  • License
    Other
  • Created over 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A "traditional" ascii roguelike built using Unity's ECS/DOTS framework.

Unity ECS Roguelike

A "traditional" ascii roguelike built using Unity's ECS/DOTS framework. This project is based on the excellent Rust Roguelike Tutorial by TheBracket.

Contributions are welcome, feel free to create a pull request or open an issue for any suggestions, requests, or bug reports!

Playing The Game

You can run the game in the editor from the "Assets/DotsRogue/Scenes/DotsRogue" scene. In the game you can move in 9 directions using "QWEASDZXC", the keypad, or in the cardinal directions using the arrow keys. You can open your inventory with "I" and use items with the corresponding letter, and you can pick up items with "G".

Project Structure

The project consists of the game itself in the "DotsRogue" folder, and several libraries in the "Lib" folder.

Of particular interest is the "Terminals" library which handles all the rendering for the game. It's built to be fast and efficient, and is completely Burst and Job safe. The terminal will only re-build it's internal mesh when it's been written to.

Using the Terminal

Terminals are fully integrated with ECS. To create a terminal authoring object you can use the menu item "GameObject/Terminals/Create Terminal" and modify it's size and position in the editor. For correct rendering you should also create a Tiled Camera ("GameObject/TiledCamera/Create"), and ensure the terminal is centered and sized properly for the camera. Incorrect terminal/camera positioning will cause noticable rendering artifacts.

After you've created it via the menu option, the terminal authoring object should spawn with a ConvertToEntity script on it. When you play your scene, the terminal will be converted to it's entity representation.

To write to the terminal from code you need to retrieve a "TerminalJobContext" on the main thread and call "GetAccessor" which returns an accessor object which you can use to write to the terminal. If you want to write to the terminal from inside a job you should pass the "TerminalJobContext" into the job first. You can then call "GetAccessor" from inside the job. This is necessary to avoid dependency issues from accessing the underlying buffer data on the main thread. For example:

using Unity.Entities;

using Sark.Terminals;

[UpdateInGroup(typeof(LateSimulationSystemGroup)]
public class HelloWorldSystem : SystemBase
{
    protected override void OnUpdate()
    {
        var termCTX = new TerminalJobContext(this, GetSingletonEntity<Terminal>());
        Job.WithCode(() =>
        {
            var term = termCTX.GetAccessor();
            term.ClearScreen();
            term.DrawBorder();
            term.Print(5, 5, "Hello, world!");
        }).Schedule();
        Enabled = false;
    }
}

You can see a more complete example of this process in the RenderSystem class.

More Repositories

1

dots-blockworld

A block world prototype using Unity DOTS and ECS. Because someone had to do it.
C#
136
star
2

bevy_ascii_terminal

A simple terminal for rendering ascii in bevy.
Rust
92
star
3

rltk_unity

A framework for developing ascii based "traditional" roguelikes in Unity.
C#
52
star
4

bevy_roguelike

A traditional roguelike made in bevy. Originally built from the wonderful Rust Roguelike Tutorial: https://bfnightly.bracketproductions.com/
Rust
37
star
5

ecs-turnbasedprototype

An example of a very simple turn based system in Unity's ecs.
C#
24
star
6

pathfinding

A simple generic solution for pathfinding in Unity that works with jobs and burst.
C#
21
star
7

Unity_FontAtlasGenerator

An editor-only tool for Unity that generates PNG font atlases from arbitrary strings. Built in support for Code Page 437 (if the font supports it).
C#
21
star
8

bevy_tiled_camera

A simple camera for properly displaying tile-based low resolution pixel perfect 2D games in bevy.
Rust
21
star
9

unityecstetristest

Trying to make Tetris with Unity's ECS system
C#
14
star
10

sark_pathfinding_rs

A simple implementation of the pathfinding algorithm from red blob games https://www.redblobgames.com/pathfinding/a-star/implementation.html
Rust
11
star
11

terminals

Utilities for rendering to pixel perfect terminals in Unity.
C#
8
star
12

nativecontainers

NativeContainers for Unity.
C#
6
star
13

adam_fov_rs

A rust implementation of Adam Milazzo's FOV algorithm http://www.adammil.net/blog/v125_Roguelike_Vision_Algorithms.html#mine
Rust
5
star
14

tiled_camera

A simple utility for rendering a pixel perfect viewport in terms of "tiles".
C#
4
star
15

unity_bevymark

C#
3
star
16

unitydots_simplecollision

An example of a simple jobified sphere-sphere collision system in DOTS. Uses a spatial map for broadphase.
C#
3
star
17

sark_grids_rs

Grids for storing data or dealing with grid-based positioning.
Rust
2
star
18

bevy_2d_custom_material

Testing how to create a 2d material with custom vertex attributes using bevy's new pipelined renderer.
Rust
2
star
19

bevy_ascii_snake

A simple version of Snake built in Bevy using Bevy Ascii Terminal.
Rust
2
star
20

bevy_ascii_tetris

Rust
2
star
21

bevy_rust_roguelike_tut_web

JavaScript
1
star
22

bat_ui

Rust
1
star
23

bevy_lazy_prefabs

Bevy prefabs for lazy people.
Rust
1
star