-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5935018
commit c343f55
Showing
18 changed files
with
283 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
local GoblinMarketComponent = class() | ||
|
||
function GoblinMarketComponent:initialize() | ||
self._sv._restock_timer = nil | ||
end | ||
|
||
function GoblinMarketComponent:post_activate() | ||
self.json = radiant.entities.get_json(self) | ||
end | ||
|
||
|
||
function GoblinMarketComponent:create_shop() | ||
local player_id = radiant.entities.get_player_id(self._entity) | ||
local population = stonehearth.population:get_population(player_id) | ||
local city_tier = population:get_city_tier() or 0 | ||
if city_tier < 1 then | ||
city_tier = 1 | ||
end | ||
city_tier = "tier_" .. city_tier | ||
local info = radiant.resources.load_json(self.json[city_tier]).shop_info | ||
local shop_name = radiant.entities.get_entity_data(self._entity, 'stonehearth:catalog').display_name | ||
info.name = shop_name or info.name | ||
info.title = shop_name or info.title | ||
|
||
local shop = stonehearth.shop:create_shop(player_id, info.name, info.inventory) | ||
|
||
local bulletin = stonehearth.bulletin_board:post_bulletin(player_id) | ||
:set_ui_view('StonehearthShopBulletinDialog') | ||
:set_callback_instance(self) | ||
:set_sticky(true) | ||
:set_data({ | ||
shop = shop, | ||
title = info.title, | ||
opened_callback = '_on_opened', | ||
closed_callback = '_on_closed' | ||
}) | ||
self.shop = shop | ||
self.bulletin = bulletin | ||
|
||
local commands_component = self._entity:get_component("stonehearth:commands") | ||
commands_component:set_command_enabled('swamp_goblins:commands:market',false) | ||
end | ||
|
||
function GoblinMarketComponent:destroy() | ||
self:close_shop() | ||
if self._sv._restock_timer then | ||
self._sv._restock_timer:destroy() | ||
self._sv._restock_timer = nil | ||
end | ||
end | ||
|
||
function GoblinMarketComponent:_on_opened() | ||
radiant.effects.run_effect(self._entity, 'emote_count') | ||
end | ||
|
||
function GoblinMarketComponent:_on_closed() | ||
self:close_shop() | ||
self._sv._restock_timer = stonehearth.calendar:set_persistent_timer('shopkeeper restocking', '1d', function() | ||
self:open_shop() | ||
end) | ||
radiant.effects.run_effect(self._entity, 'stonehearth:effects:spawn_entity') | ||
end | ||
|
||
function GoblinMarketComponent:open_shop() | ||
local commands_component = self._entity:get_component("stonehearth:commands") | ||
commands_component:set_command_enabled('swamp_goblins:commands:market',true) | ||
self._entity:get_component('render_info'):set_model_variant("default") | ||
end | ||
|
||
function GoblinMarketComponent:close_shop() | ||
self._entity:get_component('render_info'):set_model_variant("closed") | ||
if self.shop then | ||
stonehearth.shop:destroy_shop(self.shop) | ||
self.shop = nil | ||
end | ||
if self.bulletin then | ||
stonehearth.bulletin_board:remove_bulletin(self.bulletin) | ||
self.bulletin = nil | ||
end | ||
end | ||
|
||
return GoblinMarketComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "command", | ||
"name": "market", | ||
"display_name": "i18n(swamp_goblins:data.commands.market.display_name)", | ||
"description": "i18n(swamp_goblins:data.commands.market.description)", | ||
"disabled_description": "i18n(swamp_goblins:data.commands.market.disabled_description)", | ||
"icon": "/stonehearth/data/commands/call_trader/call_trader.png", | ||
"ordinal": 9, | ||
"action": "call", | ||
"function": "swamp_goblins:market", | ||
"args": [] | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"type": "entity", | ||
"mixins": "file(goblin_market_ghost.json)", | ||
"components": { | ||
"stonehearth:entity_forms": { | ||
"iconic_form": "file(goblin_market_iconic.json)", | ||
"ghost_form": "file(goblin_market_ghost.json)", | ||
"placeable_on_ground": true | ||
}, | ||
"destination": { | ||
"region": [ | ||
{ | ||
"min": {"x": -2, "y": 0, "z": -1 }, | ||
"max": {"x": 4, "y": 2, "z": 2 } | ||
} | ||
] | ||
}, | ||
"region_collision_shape": { | ||
"region": [ | ||
{ | ||
"min": {"x": -2, "y": 0, "z": -1 }, | ||
"max": {"x": 4, "y": 2, "z": 2 } | ||
} | ||
] | ||
}, | ||
"stonehearth:commands": { | ||
"commands": [ | ||
"swamp_goblins:commands:market" | ||
] | ||
}, | ||
"swamp_goblins:market": { | ||
"tier_1":"swamp_goblins/data/gm/campaigns/trader/arcs/encounters/tier_1_shops/firefly_shop_1.json", | ||
"tier_2":"swamp_goblins/data/gm/campaigns/trader/arcs/encounters/tier_2_shops/firefly_shop_2.json", | ||
"tier_3":"swamp_goblins/data/gm/campaigns/trader/arcs/encounters/tier_3_shops/firefly_shop_3.json" | ||
} | ||
}, | ||
"entity_data": { | ||
"stonehearth:net_worth": { | ||
"value_in_gold": 28, | ||
"rarity": "uncommon", | ||
"shop_info": { | ||
"buyable": true, | ||
"sellable": true, | ||
"shopkeeper_level": 2, | ||
"shopkeeper_type": "caravan" | ||
} | ||
}, | ||
"stonehearth:appeal": { | ||
"appeal": 18 | ||
}, | ||
"stonehearth:item_quality": { | ||
"variable_quality": true | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
40 changes: 40 additions & 0 deletions
40
entities/decoration/goblin_market/goblin_market_ghost.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"mixins": "stonehearth:mixins:placed_object", | ||
"components": { | ||
"render_info": { | ||
"animation_table": "stonehearth:skeletons:humanoid:female", | ||
"scale": 0.09 | ||
}, | ||
"effect_list": { | ||
"default": "stonehearth/data/rigs/entities/humans/effects/sitting_idle.json" | ||
}, | ||
"model_variants": { | ||
"default": { | ||
"models": [ | ||
"file(goblin_market.qb)", | ||
"file(open.qb)", | ||
"file(trader.qb)" | ||
] | ||
}, | ||
"closed": { | ||
"models": [ | ||
"file(goblin_market.qb)", | ||
"file(closed.qb)" | ||
] | ||
} | ||
}, | ||
"mob": { | ||
"model_origin": { "x": -0.05, "y": 0, "z": 0 }, | ||
"region_origin": { "x": 0.5, "y": 0, "z": 0.5 } | ||
} | ||
}, | ||
"entity_data": { | ||
"stonehearth:catalog": { | ||
"display_name": "i18n(swamp_goblins:entities.decoration.goblin_market.display_name)", | ||
"description": "i18n(stonehearth:entities.furniture.blue_market_stall.blue_market_stall_ghost.description)", | ||
"icon": "file(goblin_market.png)", | ||
"category": "decoration", | ||
"material_tags": ["firefly_made", "wood","decoration","cloth","crafted","utility","stockpile_decoration"] | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
entities/decoration/goblin_market/goblin_market_iconic.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"mixins": "stonehearth:mixins:item_properties", | ||
"type": "entity", | ||
"components": { | ||
"model_variants": { | ||
"default": { | ||
"models": [ | ||
"file(goblin_market_iconic.qb)" | ||
] | ||
} | ||
}, | ||
"mob": { | ||
"model_origin": { "x": 0, "y": 0, "z": 0 } | ||
} | ||
}, | ||
"entity_data": { | ||
"stonehearth:catalog": { | ||
"is_item": true, | ||
"category": "decoration" | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
jobs/bonesmith/recipes/decorations/goblin_market_recipe.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"type": "recipe", | ||
"effort": 44, | ||
"work_units": 15, | ||
"recipe_name": "i18n(swamp_goblins:entities.decoration.goblin_market.display_name)", | ||
"description": "i18n(stonehearth:entities.furniture.blue_market_stall.blue_market_stall_ghost.description)", | ||
"flavor": "i18n(stonehearth:jobs.carpenter.recipes.blue_market_stall_recipe.flavor)", | ||
"portrait": "/swamp_goblins/entities/decoration/goblin_market/goblin_market.png", | ||
"workshop": "swamp_goblins:bonesmith:workbench", | ||
"level_requirement": 3, | ||
"ingredients": [ | ||
{ | ||
"material": "wood resource", | ||
"count": 1 | ||
}, | ||
{ | ||
"material": "fiber resource", | ||
"count": 1 | ||
}, | ||
{ | ||
"uri": "swamp_goblins:decoration:certificate", | ||
"count": 1 | ||
}, | ||
{ | ||
"uri": "swamp_goblins:decoration:potted_cattail", | ||
"count": 1 | ||
} | ||
], | ||
"produces": [ | ||
{ | ||
"item": "swamp_goblins:decoration:goblin_market" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters