Moved 'building' entity definitions into 'structures', renamed building component to structure, moved svgs the same.
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -6,11 +6,11 @@ rescue LoadError
|
|||||||
require "cyberarm_engine"
|
require "cyberarm_engine"
|
||||||
end
|
end
|
||||||
|
|
||||||
require "nokogiri"
|
|
||||||
|
|
||||||
require "json"
|
require "json"
|
||||||
require "socket"
|
require "socket"
|
||||||
|
|
||||||
|
require "nokogiri"
|
||||||
|
|
||||||
require_relative "lib/exts/string"
|
require_relative "lib/exts/string"
|
||||||
|
|
||||||
require_relative "lib/version"
|
require_relative "lib/version"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class IMICRTS
|
|||||||
|
|
||||||
return unless item
|
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
|
return unless item.progress >= item.entity.build_steps && !item.completed
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class IMICRTS
|
class IMICRTS
|
||||||
class Building < Component
|
class Structure < Component
|
||||||
def setup
|
def setup
|
||||||
data.construction_progress ||= 0
|
data.construction_progress ||= 0
|
||||||
data.construction_goal ||= Entity.get(@parent.name).build_steps
|
data.construction_goal ||= Entity.get(@parent.name).build_steps
|
||||||
@@ -18,7 +18,7 @@ class IMICRTS
|
|||||||
@text.x = @parent.position.x - @text.width / 2
|
@text.x = @parent.position.x - @text.width / 2
|
||||||
@text.draw
|
@text.draw
|
||||||
when :deconstruct
|
when :deconstruct
|
||||||
when :building
|
when :structure
|
||||||
when :idle
|
when :idle
|
||||||
else
|
else
|
||||||
raise "Unknown state!"
|
raise "Unknown state!"
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, :path, :path, :path, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
entity.has(:waypoint)
|
entity.has(:waypoint)
|
||||||
entity.has(:spawner)
|
entity.has(:spawner)
|
||||||
entity.has(:build_queue)
|
entity.has(:build_queue)
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, :path, :path, :path, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
entity.has(:waypoint)
|
entity.has(:waypoint)
|
||||||
entity.has(:spawner)
|
entity.has(:spawner)
|
||||||
entity.has(:build_queue)
|
entity.has(:build_queue)
|
||||||
@@ -48,7 +48,7 @@ IMICRTS::Entity.define_entity(:construction_yard, :building, 2_000, 310, "Provid
|
|||||||
|
|
||||||
entity.on_tick do
|
entity.on_tick do
|
||||||
|
|
||||||
if entity.component(:building).construction_complete?
|
if entity.component(:structure).construction_complete?
|
||||||
item = entity.component(:build_queue).queue.first
|
item = entity.component(:build_queue).queue.first
|
||||||
|
|
||||||
entity.particle_emitters.each_with_index do |emitter, i|
|
entity.particle_emitters.each_with_index do |emitter, i|
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, false, false, false, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
entity.has(:waypoint)
|
entity.has(:waypoint)
|
||||||
entity.has(:spawner)
|
entity.has(:spawner)
|
||||||
entity.has(:build_queue)
|
entity.has(:build_queue)
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, false, :path, false, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
end
|
end
|
||||||
|
|
||||||
entity.radius = 24
|
entity.radius = 24
|
||||||
@@ -37,7 +37,7 @@ IMICRTS::Entity.define_entity(:power_plant, :building, 800, 45, "Generates power
|
|||||||
entity.on_tick do
|
entity.on_tick do
|
||||||
# entity.produce_power
|
# entity.produce_power
|
||||||
|
|
||||||
if entity.component(:building).construction_complete?
|
if entity.component(:structure).construction_complete?
|
||||||
entity.particle_emitters.each do |emitter|
|
entity.particle_emitters.each do |emitter|
|
||||||
emitter.emitting = true
|
emitter.emitting = true
|
||||||
end
|
end
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, false, :path, :path, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
end
|
end
|
||||||
|
|
||||||
entity.radius = 44
|
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.particle_emitters << IMICRTS::SmokeEmitter.new(position: p1, emitting: false)
|
||||||
|
|
||||||
entity.on_tick do
|
entity.on_tick do
|
||||||
if entity.component(:building).data.state == :idle
|
if entity.component(:structure).data.state == :idle
|
||||||
|
|
||||||
entity.particle_emitters.each do |emitter|
|
entity.particle_emitters.each do |emitter|
|
||||||
emitter.emitting = true
|
emitter.emitting = true
|
||||||
@@ -6,9 +6,9 @@ tiles = [
|
|||||||
[false, :path, :path, :path, false],
|
[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
|
unless entity.proto_entity
|
||||||
entity.has(:building)
|
entity.has(:structure)
|
||||||
entity.has(:waypoint)
|
entity.has(:waypoint)
|
||||||
entity.has(:spawner)
|
entity.has(:spawner)
|
||||||
entity.has(:build_queue)
|
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.particle_emitters << IMICRTS::SmokeEmitter.new(position: p2, emitting: false)
|
||||||
|
|
||||||
entity.on_tick do
|
entity.on_tick do
|
||||||
if entity.component(:building).construction_complete?
|
if entity.component(:structure).construction_complete?
|
||||||
item = entity.component(:build_queue).queue.first
|
item = entity.component(:build_queue).queue.first
|
||||||
|
|
||||||
entity.particle_emitters.each do |pe|
|
entity.particle_emitters.each do |pe|
|
||||||
@@ -162,7 +162,7 @@ class IMICRTS
|
|||||||
|
|
||||||
data.assigned_construction_workers ||= 1
|
data.assigned_construction_workers ||= 1
|
||||||
data.construction_speed ||= 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
|
end
|
||||||
|
|
||||||
def on_tick(&block)
|
def on_tick(&block)
|
||||||
|
|||||||
@@ -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)
|
tile = director.map.tile_at(order.vector.x, order.vector.y)
|
||||||
position = tile.position + director.map.tile_size / 2
|
position = tile.position + director.map.tile_size / 2
|
||||||
|
|
||||||
ent = director.spawn_entity(
|
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)
|
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
|
if space_required == true
|
||||||
tile.entity = ent
|
tile.entity = ent
|
||||||
else
|
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
|
# Order ID | Player ID | Vector X | Vector Y | Entity Name
|
||||||
# char | char | integer | integer | string
|
# 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
|
end
|
||||||
|
|
||||||
IMICRTS::Order.define_deserializer(IMICRTS::Order::CONSTRUCT) do |string, director|
|
IMICRTS::Order.define_deserializer(IMICRTS::Order::CONSTRUCT) do |string, director|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
IMICRTS::Order.define_handler(IMICRTS::Order::CONSTRUCTION_COMPLETE, arguments: [:player_id, :entity_id]) do |order, director|
|
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 = director.player(order.player_id).entity(order.entity_id)
|
||||||
|
|
||||||
entity.component(:building).data.construction_complete = true
|
entity.component(:structure).data.construction_complete = true
|
||||||
end
|
end
|
||||||
|
|
||||||
IMICRTS::Order.define_serializer(IMICRTS::Order::CONSTRUCTION_COMPLETE) do |order, director|
|
IMICRTS::Order.define_serializer(IMICRTS::Order::CONSTRUCTION_COMPLETE) do |order, director|
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ class IMICRTS
|
|||||||
player_id: player.id, name: :construction_yard,
|
player_id: player.id, name: :construction_yard,
|
||||||
position: CyberarmEngine::Vector.new(player.spawnpoint.x, player.spawnpoint.y, ZOrder::BUILDING)
|
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(:structure).data.construction_progress = Entity.get(construction_yard.name).build_steps
|
||||||
construction_yard.component(:building).data.construction_complete = true
|
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|
|
@director.each_tile(@director.map.world_to_grid(construction_yard.position), construction_yard.name) do |tile, space_required|
|
||||||
if space_required == true
|
if space_required == true
|
||||||
tile.entity = construction_yard
|
tile.entity = construction_yard
|
||||||
|
|||||||