Giter Site home page Giter Site logo

godot-ecs's Introduction

godot-ecs

Lightweight ecs framework wirtten with gdscript.

Features

  • Lightweight and high-performance.
  • Independent of Node components.
  • Components and systems support serialization and deserialization.
  • Easy to use.

How To Use

  • Copy the 'ecs' directory to any location within your Godot project.
  • Begin your ECS coding journey with the following code:

# create ecs world
var world = ecs_world.new()

# create entity
var e = world.create_entity()

# add component
e.add_component("c1", ecs_component.new())
e.add_component("c2", ecs_component.new())
e.add_component("c3", ecs_component.new())

# add system
world.add_system("s1", ecs_system.new())
world.add_system("s2", ecs_system.new())
world.add_system("s2", ecs_system.new())

# add command
world.add_command("my_command", ecs_command)

# send notification
world.notify("my_notification", with_param)
world.notify("my_command", with_param)

# fetch components
var component_list = world.fetch_components("c1")
for c in component_list:
	# get component from entity
	var entity = c.entity()
	var c1 = entity.get_component("c1")
	var c2 = entity.get_component("c2")
	var c3 = entity.get_component("c3")
	# get entity's all components
	var all_components = entity.get_components()
	
# serialize components
var serialize_dict = {}
for c in component_list:
	var e: ecs_entity = c.entity()
	var all_components = e.get_components()
	var entity_data = {}
	for cc in all_components:
		var data = {}
		cc.save( data )
		entity_data[ cc.name() ] = data
	var entity_id = e.id()
	serialize_dict[ entity_id ] = entity_data
printt("this is entity serialize data", serialize_dict)

godot-ecs's People

Contributors

baixfeng avatar

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.