summaryrefslogtreecommitdiffhomepage
path: root/app/ECS/components
diff options
context:
space:
mode:
Diffstat (limited to 'app/ECS/components')
-rw-r--r--app/ECS/components/00_renderable.rb2
-rw-r--r--app/ECS/components/05_interactable.rb (renamed from app/ECS/components/05_map_object.rb)2
-rw-r--r--app/ECS/components/06_level.rb25
-rw-r--r--app/ECS/components/07_collidable.rb (renamed from app/ECS/components/06_grid_singleton.rb)12
-rw-r--r--app/ECS/components/debug_singleton.rb13
5 files changed, 49 insertions, 5 deletions
diff --git a/app/ECS/components/00_renderable.rb b/app/ECS/components/00_renderable.rb
index 270e5f9..4008691 100644
--- a/app/ECS/components/00_renderable.rb
+++ b/app/ECS/components/00_renderable.rb
@@ -4,7 +4,7 @@ class Components
attr_accessor :z
def initialize
- @z = z
+ @z = 0
end
def set(**opts)
diff --git a/app/ECS/components/05_map_object.rb b/app/ECS/components/05_interactable.rb
index 270e5f9..305bb02 100644
--- a/app/ECS/components/05_map_object.rb
+++ b/app/ECS/components/05_interactable.rb
@@ -1,6 +1,6 @@
class Components
# If an entity can be rendered on screen
- class Renderable < BaseComponent
+ class Interactable < BaseComponent
attr_accessor :z
def initialize
diff --git a/app/ECS/components/06_level.rb b/app/ECS/components/06_level.rb
new file mode 100644
index 0000000..4d692e6
--- /dev/null
+++ b/app/ECS/components/06_level.rb
@@ -0,0 +1,25 @@
+class Components
+ # If an entity can be rendered on screen
+ class Level < BaseComponent
+ attr_accessor :z
+
+ def initialize
+ @grid = [[]] #Array.new(1) { Array.new(1) }
+ end
+
+ def set(x: x, y: y, **opts)
+ smart_array(x, y).merge(opts)
+ end
+
+ # Things that the smart_array holds
+ #
+ # player: is the player in the square?
+ # hitbox: true/false
+ # interact: id/false
+ def smart_array(x, y)
+ @grid[x] = [] if @grid[x].nil?
+ @grix[x][y] = {} if @grid[x][y].nil?
+ @grid[x][y]
+ end
+ end
+end
diff --git a/app/ECS/components/06_grid_singleton.rb b/app/ECS/components/07_collidable.rb
index 392d770..207e138 100644
--- a/app/ECS/components/06_grid_singleton.rb
+++ b/app/ECS/components/07_collidable.rb
@@ -1,10 +1,16 @@
class Components
# If an entity can be rendered on screen
- class GridSingleton < BaseComponent
- attr_accessor :z
+ class Collidable < BaseComponent
+ class <<self
+ def add(entity_id)
+ super(entity_id)
+ #add to grid?
+ end
+ end
+ attr_accessor :grid
def initialize
- @z = 0
+ @grid = [[]]
end
def set(**opts)
diff --git a/app/ECS/components/debug_singleton.rb b/app/ECS/components/debug_singleton.rb
new file mode 100644
index 0000000..f298172
--- /dev/null
+++ b/app/ECS/components/debug_singleton.rb
@@ -0,0 +1,13 @@
+class Components
+ # If an entity can be rendered on screen
+ class DebugSingleton
+ class <<self
+ @data = false
+ attr_accessor :data
+
+ def id
+ 0
+ end
+ end
+ end
+end