Skip to content

Commit

Permalink
-Updated to be compatible with Alpha 13
Browse files Browse the repository at this point in the history
-Fixed a ton of region collision shapes to be much more accurate
-Changed water outlet to find the lowest point and place the water there
-Changed water outlet to use the WETTING_VOLUME constant instead of a hardcoded value
-Changed gearbox machine model to indicate the direction of power transfer
-Changed smelt forge machine model to be centered better
-Adjusted smelt forge effects to suit the above change
-Changed liquid api service _get_connection_region() to better detect actual pipe connections
  • Loading branch information
chessmaster42 committed Dec 2, 2015
1 parent 868dad6 commit fda24fa
Show file tree
Hide file tree
Showing 24 changed files with 108 additions and 57 deletions.
1 change: 1 addition & 0 deletions ai/actions/deliver_item.luac
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local DeliverItemAction = class()
DeliverItemAction.name = 'deliver item'
DeliverItemAction.does = 'mechanicalmod:deliver_item'
DeliverItemAction.args = {uri='string',entity=Entity,}
DeliverItemAction.status_text = 'taking items to machine...'
DeliverItemAction.version = 2
DeliverItemAction.priority = 1

Expand Down
1 change: 1 addition & 0 deletions ai/actions/deliver_material.luac
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ local DeliverMaterialAction = class()
DeliverMaterialAction.name = 'deliver material'
DeliverMaterialAction.does = 'mechanicalmod:deliver_material'
DeliverMaterialAction.args = {material='string',entity=Entity,}
DeliverMaterialAction.status_text = 'taking materials to machine...'
DeliverMaterialAction.version = 2
DeliverMaterialAction.priority = 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local PowerLib = require 'lib.power_lib'
local Point3 = _radiant.csg.Point3
local rng = _radiant.csg.get_default_rng()
local rng = _radiant.math.get_default_rng()
local log = radiant.log.create_logger('machines')

local AdvancedProcessingMachineComponent = class()
Expand Down Expand Up @@ -285,6 +285,8 @@ function AdvancedProcessingMachineComponent:_fill_inventory()

-- If we are not full, schedule a task to have more brought in
if self:get_inventory_level() < 1.0 and not self._deliver_ingredients_task then
--log:error('DEBUG - Advanced Processing Machine - Scheduling ingredients delivery ...')

local ingredient = self:get_random_recipe_ingredient()
if ingredient then
local args = {}
Expand All @@ -298,23 +300,31 @@ function AdvancedProcessingMachineComponent:_fill_inventory()
args.uri = ingredient.uri
end
if action then
--log:error('DEBUG - Advanced Processing Machine - Creating ingredient delivery task ...')

self._deliver_ingredients_task = town:create_task_for_group('stonehearth:task_group:restock', action, args):set_priority(stonehearth.constants.priorities.simple_labor.PLACE_ITEM):once():start()
self._deliver_ingredients_task:notify_completed(
function()
self._deliver_ingredients_task = nil
end
)
else
--log:error('DEBUG - Advanced Processing Machine - No action found. We should not be here')
end
else
--log:error('DEBUG - Advanced Processing Machine - No ingredients found. We should not be here')
end
end

-- If we are not full, schedule a task to have more brought in
if self:get_fuel_level() < 1.0 and not self._deliver_fuel_task then
--log:error('DEBUG - Advanced Processing Machine - Creating fuel delivery task ...')

local args = {}
args.entity = self._entity
-- TODO - Hardcoded fuel material here for now. Need better action to accept full fuel list
args.material = 'coal ore resource'
self._deliver_fuel_task = town:create_task_for_group('stonehearth:task_group:restock', 'mechanicalmod:deliver_material', args):set_priority(stonehearth.constants.priorities.simple_labor.PLACE_ITEM):once():start()
-- TODO - Hardcoded fuel item here for now. Need better action to accept full fuel list
args.uri = 'stonehearth:resources:coal:lump_of_coal'
self._deliver_fuel_task = town:create_task_for_group('stonehearth:task_group:restock', 'mechanicalmod:deliver_item', args):set_priority(stonehearth.constants.priorities.simple_labor.PLACE_ITEM):once():start()
self._deliver_fuel_task:notify_completed(
function()
self._deliver_fuel_task = nil
Expand Down Expand Up @@ -376,7 +386,7 @@ function AdvancedProcessingMachineComponent:_process_resources()
-- Set the mutex
self._is_processing = true

self._processing_delay = stonehearth.calendar:set_timer(self:get_processing_time() * 200,
self._processing_delay = stonehearth.calendar:set_timer('mechanicalmod resource processing delay', self:get_processing_time() * 200,
function()
-- Consume all of the recipe ingredients
for _,resource in pairs(resources) do
Expand Down
14 changes: 8 additions & 6 deletions components/outlet/outlet_component.luac
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local constants = require 'stonehearth.constants'
local PowerLib = require 'lib.power_lib'
local Point3 = _radiant.csg.Point3
local Region3 = _radiant.csg.Region3
Expand Down Expand Up @@ -96,20 +97,21 @@ function OutletComponent:_on_tick()

location = location + offset

local liquid_removed = liquid_drain:remove_liquid(self:get_rate() / 1)
--Temporary code to get around some issues with waterfalls
while (not radiant.terrain.is_standable(location)) do
location.y = location.y - 1
end

--log:error('DEBUG - Liquid removed is %s', tostring(liquid_removed))
local liquid_removed = liquid_drain:remove_liquid(self:get_rate() / 1)

if not stonehearth.hydrology:get_water_tight_region() then
local terrain_component = radiant.terrain.get_terrain_component()
stonehearth.hydrology._water_tight_region = terrain_component:get_water_tight_region()
end

--Accumulate the dumped water because the water component nils out volume changes less than the constants.hydrology.WETTING_VOLUME (0.25)
--Accumulate the dumped water because the water component nils out volume changes less than the constants.hydrology.WETTING_VOLUME
self._stored_water = self._stored_water + liquid_removed / 1000.0
if self._stored_water > (0.25 + self._keep_alive_water) then
--log:error('DEBUG - Water added is %s', tostring(self._stored_water))

if self._stored_water > (constants.hydrology.WETTING_VOLUME + self._keep_alive_water) then
--Add the water to the world and reset the counters
stonehearth.hydrology:add_water(self._stored_water, location, nil)
self._stored_water = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ function ProcessingMachineComponent:_fill_inventory()

-- If we are not full, schedule a task to have more brought in
if resource_count <= self:get_inventory_size() and not self._processing_task then
--log:error('DEBUG - Processing Machine - Scheduling ingredients delivery of %s ...', tostring(self:get_material()))

local args = {}
args.material = self:get_material()
args.entity = self._entity
Expand Down Expand Up @@ -187,7 +189,7 @@ function ProcessingMachineComponent:_process_resources()
radiant.entities.remove_child(self._entity, first_resource)
radiant.entities.destroy_entity(first_resource)

self._processing_delay = stonehearth.calendar:set_interval(self:get_processing_time() * 200,
self._processing_delay = stonehearth.calendar:set_timer('mechanicalmod resource processing delay', self:get_processing_time() * 200,
function()
local origin = radiant.entities.get_world_grid_location(self._entity)
if not origin then
Expand Down
6 changes: 3 additions & 3 deletions data/effects/smelt_forge_effect/smelt_forge_effect.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"cubemitter": "/mechanicalmod/data/horde/particles/machines/smelt_forge.cubemitter.json",
"loop": true,
"transforms": {
"x":4,
"x":0,
"y":0,
"z":0,
"rx":90,
Expand All @@ -23,7 +23,7 @@
"volume": 70,
"track" : "stonehearth:sounds:firepit_loop_sound",
"transforms": {
"x":4,
"x":0,
"y":0,
"z":0
}
Expand All @@ -32,7 +32,7 @@
"type": "light",
"light": "/mechanicalmod/data/horde/animatedlights/fire/fire.animatedlight.json",
"transforms": {
"x":4,
"x":0,
"y":1,
"z":0
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
{
"min" : { "x" : -0.5, "y" : 0, "z" : 0 },
"max" : { "x" : 1, "y" : 1, "z" : 1 }
"max" : { "x" : 0, "y" : 1, "z" : 1 }
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"max" : { "x" : 1, "y" : 1, "z" : 1.5 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : 0 },
"min" : { "x" : 1, "y" : 0, "z" : 0 },
"max" : { "x" : 1.5, "y" : 1, "z" : 1 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -0.5 },
"max" : { "x" : 1, "y" : 1, "z" : 1 }
"max" : { "x" : 1, "y" : 1, "z" : 0 }
},
{
"min" : { "x" : -0.5, "y" : 0, "z" : 0 },
"max" : { "x" : 1, "y" : 1, "z" : 1 }
"max" : { "x" : 0, "y" : 1, "z" : 1 }
}
]
},
Expand Down
18 changes: 17 additions & 1 deletion entities/containers/storage_tank/storage_tank.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 6, "z" : 2 }
"max" : { "x" : 2, "y" : 7, "z" : 2 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -1.5 },
"max" : { "x" : 1, "y" : 1, "z" : -1 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : 2 },
"max" : { "x" : 1, "y" : 1, "z" : 2.5 }
},
{
"min" : { "x" : -1.5, "y" : 0, "z" : 0 },
"max" : { "x" : -1, "y" : 1, "z" : 1 }
},
{
"min" : { "x" : 2, "y" : 0, "z" : 0 },
"max" : { "x" : 2.5, "y" : 1, "z" : 1 }
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions entities/machines/clutch_shaft/clutch_shaft.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 1, "z" : 2 }
"min" : { "x" : -1, "y" : 0, "z" : -0.5 },
"max" : { "x" : 2, "y" : 2, "z" : 1.5 }
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion entities/machines/drive_shaft/drive_shaft.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : 0 },
"max" : { "x" : 2, "y" : 1, "z" : 1 }
"max" : { "x" : 2, "y" : 2, "z" : 1 }
}
]
},
Expand Down
14 changes: 13 additions & 1 deletion entities/machines/fermenter/fermenter.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"region": [
{
"min" : { "x" : -2, "y" : 0, "z" : 0 },
"max" : { "x" : -1, "y" : 1, "z" : 1 }
"max" : { "x" : -1, "y" : 2, "z" : 1 }
},
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 7, "z" : 2 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -3 },
"max" : { "x" : 1, "y" : 2, "z" : -1 }
}
]
},
Expand All @@ -29,6 +37,10 @@
{
"uri" : "stonehearth:resources:coal:lump_of_coal",
"duration" : 10
},
{
"material" : "wood resource",
"duration" : 2
}
],
"inventory_size" : {
Expand Down
4 changes: 2 additions & 2 deletions entities/machines/gear_box_shaft/gear_box_shaft.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 1, "z" : 2 }
"min" : { "x" : -1, "y" : 0, "z" : -0.5 },
"max" : { "x" : 2, "y" : 2, "z" : 1.5 }
}
]
},
Expand Down
Binary file modified entities/machines/gear_box_shaft/gear_box_shaft.qb
Binary file not shown.
2 changes: 1 addition & 1 deletion entities/machines/long_drive_shaft/long_drive_shaft.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"region": [
{
"min" : { "x" : -3, "y" : 0, "z" : 0 },
"max" : { "x" : 4, "y" : 1, "z" : 1 }
"max" : { "x" : 4, "y" : 2, "z" : 1 }
}
]
},
Expand Down
8 changes: 6 additions & 2 deletions entities/machines/saw_mill/saw_mill.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 2, "z" : 2 }
"min" : { "x" : -1.5, "y" : 0, "z" : -0.5 },
"max" : { "x" : 0, "y" : 2, "z" : 1.5 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -2.5 },
"max" : { "x" : 2, "y" : 2, "z" : 3.5 }
}
]
},
Expand Down
20 changes: 8 additions & 12 deletions entities/machines/smelt_forge/smelt_forge.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,20 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : 1, "y" : 0, "z" : -4 },
"max" : { "x" : 8, "y" : 4, "z" : 5 }
"min" : { "x" : -5, "y" : 0, "z" : -1 },
"max" : { "x" : -3, "y" : 2, "z" : 2 }
},
{
"min" : { "x" : 4, "y" : 4, "z" : 0 },
"max" : { "x" : 5, "y" : 6, "z" : 1 }
"min" : { "x" : -3, "y" : 0, "z" : -4 },
"max" : { "x" : 4, "y" : 4, "z" : 5 }
},
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 1, "y" : 1, "z" : 2 }
"min" : { "x" : 0, "y" : 4, "z" : 0 },
"max" : { "x" : 1, "y" : 6, "z" : 1 }
},
{
"min" : { "x" : 0, "y" : 1, "z" : -1 },
"max" : { "x" : 1, "y" : 2, "z" : 2 }
},
{
"min" : { "x" : 3, "y" : 0, "z" : 4 },
"max" : { "x" : 6, "y" : 1, "z" : 7 }
"min" : { "x" : -1, "y" : 0, "z" : -6 },
"max" : { "x" : 2, "y" : 1, "z" : -4 }
}
]
},
Expand Down
Binary file modified entities/machines/smelt_forge/smelt_forge.qb
Binary file not shown.
8 changes: 6 additions & 2 deletions entities/machines/spinning_mule/spinning_mule.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 2, "z" : 2 }
"min" : { "x" : -1.5, "y" : 0, "z" : -0.5 },
"max" : { "x" : 0, "y" : 2, "z" : 1.5 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -2.5 },
"max" : { "x" : 2, "y" : 2, "z" : 3.5 }
}
]
},
Expand Down
8 changes: 8 additions & 0 deletions entities/machines/water_pump/water_pump.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
{
"min" : { "x" : -1, "y" : 0, "z" : -1 },
"max" : { "x" : 2, "y" : 2, "z" : 2 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : -1.5 },
"max" : { "x" : 1, "y" : 1, "z" : -1 }
},
{
"min" : { "x" : 0, "y" : 0, "z" : 2 },
"max" : { "x" : 1, "y" : 1, "z" : 2.5 }
}
]
},
Expand Down
8 changes: 6 additions & 2 deletions entities/machines/wind_sail/wind_sail.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
"region_collision_shape" : {
"region": [
{
"min" : { "x" : -1, "y" : 0, "z" : 0 },
"max" : { "x" : 2, "y" : 4, "z" : 1 }
"min" : { "x" : -1, "y" : 0, "z" : -0.5 },
"max" : { "x" : 2, "y" : 4.5, "z" : 1.5 }
},
{
"min" : { "x" : 2, "y" : 0, "z" : -2.5 },
"max" : { "x" : 3, "y" : 7, "z" : 3.5 }
}
]
},
Expand Down
9 changes: 0 additions & 9 deletions mixins/base_human/base_human.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"components" : {
"stonehearth:equipment_piece" : {
"injected_ai" : {
"ai_packs" : [
"mechanicalmod:ai_pack:core"
]
}
}
},
"entity_data" : {
"stonehearth:ai_packs" : {
"packs" : [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ function AdvancedProcessingMachineRenderer:_update()
local inventory_height = inventory_level * 3
local fuel_height = fuel_level * 3

local inventory_cube = Cube3(Point3(-0.75, offset, 0.25), Point3(-1.25, inventory_height + offset, 0.75))
local fuel_cube = Cube3(Point3(-0.25, offset, 0.25), Point3(-0.75, fuel_height + offset, 0.75))
local inventory_cube = Cube3(Point3(-1.25, offset, 0.25), Point3(-0.75, inventory_height + offset, 0.75))
local fuel_cube = Cube3(Point3(-0.75, offset, 0.25), Point3(-0.25, fuel_height + offset, 0.75))

render_region:add_cube(inventory_cube)
render_region:add_cube(fuel_cube)
Expand Down
Loading

0 comments on commit fda24fa

Please sign in to comment.