Moved 'building' entity definitions into 'structures', renamed building component to structure, moved svgs the same.

This commit is contained in:
2021-01-15 11:05:57 -06:00
parent 36f79c6f57
commit e30d73d4d7
19 changed files with 29 additions and 29 deletions

View File

Before

Width:  |  Height:  |  Size: 9.3 KiB

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -6,11 +6,11 @@ rescue LoadError
require "cyberarm_engine"
end
require "nokogiri"
require "json"
require "socket"
require "nokogiri"
require_relative "lib/exts/string"
require_relative "lib/version"

View File

@@ -5,7 +5,7 @@ class IMICRTS
return unless item
item.progress += 1 if @parent.component(:building).construction_complete?
item.progress += 1 if @parent.component(:structure).construction_complete?
return unless item.progress >= item.entity.build_steps && !item.completed

View File

@@ -1,5 +1,5 @@
class IMICRTS
class Building < Component
class Structure < Component
def setup
data.construction_progress ||= 0
data.construction_goal ||= Entity.get(@parent.name).build_steps
@@ -18,7 +18,7 @@ class IMICRTS
@text.x = @parent.position.x - @text.width / 2
@text.draw
when :deconstruct
when :building
when :structure
when :idle
else
raise "Unknown state!"

View File

@@ -6,9 +6,9 @@ tiles = [
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:barracks, :building, 400, 40, "Builds and heals soldiers", tiles) do |entity|
IMICRTS::Entity.define_entity(:barracks, :structure, 400, 40, "Builds and heals soldiers", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
entity.has(:waypoint)
entity.has(:spawner)
entity.has(:build_queue)

View File

@@ -6,9 +6,9 @@ tiles = [
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:construction_yard, :building, 2_000, 310, "Provides radar and builds construction workers", tiles) do |entity|
IMICRTS::Entity.define_entity(:construction_yard, :structure, 2_000, 310, "Provides radar and builds construction workers", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
entity.has(:waypoint)
entity.has(:spawner)
entity.has(:build_queue)
@@ -48,7 +48,7 @@ IMICRTS::Entity.define_entity(:construction_yard, :building, 2_000, 310, "Provid
entity.on_tick do
if entity.component(:building).construction_complete?
if entity.component(:structure).construction_complete?
item = entity.component(:build_queue).queue.first
entity.particle_emitters.each_with_index do |emitter, i|

View File

@@ -6,9 +6,9 @@ tiles = [
[false, false, false, false, false],
]
IMICRTS::Entity.define_entity(:helipad, :building, 1_000, 100, "Builds and rearms aircraft", tiles) do |entity|
IMICRTS::Entity.define_entity(:helipad, :structure, 1_000, 100, "Builds and rearms aircraft", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
entity.has(:waypoint)
entity.has(:spawner)
entity.has(:build_queue)

View File

@@ -6,9 +6,9 @@ tiles = [
[false, false, :path, false, false],
]
IMICRTS::Entity.define_entity(:power_plant, :building, 800, 45, "Generates power", tiles) do |entity|
IMICRTS::Entity.define_entity(:power_plant, :structure, 800, 45, "Generates power", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
end
entity.radius = 24
@@ -37,7 +37,7 @@ IMICRTS::Entity.define_entity(:power_plant, :building, 800, 45, "Generates power
entity.on_tick do
# entity.produce_power
if entity.component(:building).construction_complete?
if entity.component(:structure).construction_complete?
entity.particle_emitters.each do |emitter|
emitter.emitting = true
end

View File

@@ -6,9 +6,9 @@ tiles = [
[false, false, :path, :path, false],
]
IMICRTS::Entity.define_entity(:refinery, :building, 1_400, 200, "Generates credits", tiles) do |entity|
IMICRTS::Entity.define_entity(:refinery, :structure, 1_400, 200, "Generates credits", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
end
entity.radius = 44
@@ -28,7 +28,7 @@ IMICRTS::Entity.define_entity(:refinery, :building, 1_400, 200, "Generates credi
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
entity.on_tick do
if entity.component(:building).data.state == :idle
if entity.component(:structure).data.state == :idle
entity.particle_emitters.each do |emitter|
emitter.emitting = true

View File

@@ -6,9 +6,9 @@ tiles = [
[false, :path, :path, :path, false],
]
IMICRTS::Entity.define_entity(:war_factory, :building, 2_000, 310, "Builds and repairs ground vehicles", tiles) do |entity|
IMICRTS::Entity.define_entity(:war_factory, :structure, 2_000, 310, "Builds and repairs ground vehicles", tiles) do |entity|
unless entity.proto_entity
entity.has(:building)
entity.has(:structure)
entity.has(:waypoint)
entity.has(:spawner)
entity.has(:build_queue)
@@ -37,7 +37,7 @@ IMICRTS::Entity.define_entity(:war_factory, :building, 2_000, 310, "Builds and r
entity.particle_emitters << IMICRTS::SmokeEmitter.new(position: p2, emitting: false)
entity.on_tick do
if entity.component(:building).construction_complete?
if entity.component(:structure).construction_complete?
item = entity.component(:build_queue).queue.first
entity.particle_emitters.each do |pe|

View File

@@ -162,7 +162,7 @@ class IMICRTS
data.assigned_construction_workers ||= 1
data.construction_speed ||= 1
component(:building).construction_work(data.assigned_construction_workers * data.construction_speed) if component(:building)
component(:structure).construction_work(data.assigned_construction_workers * data.construction_speed) if component(:structure)
end
def on_tick(&block)

View File

@@ -1,13 +1,13 @@
IMICRTS::Order.define_handler(IMICRTS::Order::CONSTRUCT, arguments: [:player_id, :vector, :building]) do |order, director|
IMICRTS::Order.define_handler(IMICRTS::Order::CONSTRUCT, arguments: [:player_id, :vector, :structure]) do |order, director|
tile = director.map.tile_at(order.vector.x, order.vector.y)
position = tile.position + director.map.tile_size / 2
ent = director.spawn_entity(
player_id: order.player_id, name: order.building,
player_id: order.player_id, name: order.structure,
position: CyberarmEngine::Vector.new(position.x, position.y, IMICRTS::ZOrder::BUILDING)
)
director.each_tile(order.vector, order.building) do |tile, space_required|
director.each_tile(order.vector, order.structure) do |tile, space_required|
if space_required == true
tile.entity = ent
else
@@ -24,7 +24,7 @@ IMICRTS::Order.define_serializer(IMICRTS::Order::CONSTRUCT) do |order, director|
# Order ID | Player ID | Vector X | Vector Y | Entity Name
# char | char | integer | integer | string
[IMICRTS::Order::CONSTRUCT, order.player_id, order.vector.x, order.vector.y, order.building.to_s].pack("CCNNA*")
[IMICRTS::Order::CONSTRUCT, order.player_id, order.vector.x, order.vector.y, order.structure.to_s].pack("CCNNA*")
end
IMICRTS::Order.define_deserializer(IMICRTS::Order::CONSTRUCT) do |string, director|

View File

@@ -1,7 +1,7 @@
IMICRTS::Order.define_handler(IMICRTS::Order::CONSTRUCTION_COMPLETE, arguments: [:player_id, :entity_id]) do |order, director|
entity = director.player(order.player_id).entity(order.entity_id)
entity.component(:building).data.construction_complete = true
entity.component(:structure).data.construction_complete = true
end
IMICRTS::Order.define_serializer(IMICRTS::Order::CONSTRUCTION_COMPLETE) do |order, director|

View File

@@ -59,8 +59,8 @@ class IMICRTS
player_id: player.id, name: :construction_yard,
position: CyberarmEngine::Vector.new(player.spawnpoint.x, player.spawnpoint.y, ZOrder::BUILDING)
)
construction_yard.component(:building).data.construction_progress = Entity.get(construction_yard.name).build_steps
construction_yard.component(:building).data.construction_complete = true
construction_yard.component(:structure).data.construction_progress = Entity.get(construction_yard.name).build_steps
construction_yard.component(:structure).data.construction_complete = true
@director.each_tile(@director.map.world_to_grid(construction_yard.position), construction_yard.name) do |tile, space_required|
if space_required == true
tile.entity = construction_yard