-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
26 changed files
with
407 additions
and
28 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 |
---|---|---|
@@ -1,17 +1,30 @@ | ||
local Entity = _radiant.om.Entity | ||
local TurnToFaceWater = class() | ||
local rng = _radiant.math.get_default_rng() | ||
|
||
TurnToFaceWater.name = 'correct rotation facing the water' | ||
TurnToFaceWater.does = 'archipelago_biome:turn_to_face_water' | ||
TurnToFaceWater.args = { | ||
dock = Entity | ||
dock = Entity | ||
} | ||
TurnToFaceWater.version = 2 | ||
TurnToFaceWater.priority = 1 | ||
|
||
function TurnToFaceWater:run(ai, entity, args) | ||
local face = radiant.entities.get_facing(args.dock) | ||
radiant.entities.turn_to(entity, face) | ||
if radiant.entities.get_posture(entity) == "stonehearth:in_boat" then | ||
radiant.entities.turn_to(entity, rng:get_int(0,360)) | ||
else | ||
local face = 0 | ||
local fisher_field_component = args.dock:get_component("archipelago_biome:fisher_field") | ||
if fisher_field_component then | ||
local water_location = fisher_field_component:get_water_direction(radiant.entities.get_world_grid_location(entity)) | ||
entity:get_component('mob'):turn_to_face_point(water_location) | ||
face = radiant.entities.get_facing(entity) | ||
else | ||
face = radiant.entities.get_facing(args.dock) | ||
end | ||
radiant.entities.turn_to(entity, face+rng:get_int(-35,35)) | ||
end | ||
end | ||
|
||
return TurnToFaceWater |
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,137 @@ | ||
local Color4 = _radiant.csg.Color4 | ||
local Point3 = _radiant.csg.Point3 | ||
local Cube3 = _radiant.csg.Cube3 | ||
|
||
local validator = radiant.validator | ||
|
||
local FishingCallHandler = class() | ||
|
||
function FishingCallHandler._custom_is_valid_location(self_variable, brick) | ||
--i had to hack into this stupid function because it was the only way to make it work 😡 | ||
if not brick then | ||
return false | ||
end | ||
|
||
if radiant.terrain.is_blocked(brick) then | ||
return false | ||
end | ||
if not radiant.terrain.is_supported(brick) then | ||
return false | ||
end | ||
local entities = radiant.terrain.get_entities_at_point(brick) | ||
for _, entity in pairs(entities) do | ||
if not self_variable._can_contain_entity_filter_fn(entity, self_variable) then | ||
return false | ||
end | ||
end | ||
return FishingCallHandler.has_water_below(brick) | ||
end | ||
|
||
function FishingCallHandler:choose_new_fish_location(session, response) | ||
stonehearth.selection:select_xz_region("fish_zone") | ||
:use_designation_marquee(Color4(129, 192, 165, 255)) | ||
:set_cursor('archipelago_biome:cursors:zone_fish') | ||
:set_invalid_cursor('archipelago_biome:cursors:zone_fish_invalid') | ||
:require_unblocked(true) | ||
:require_supported(true) | ||
:allow_unselectable_support_entities(true) | ||
:set_can_contain_entity_filter(function(entity) | ||
if radiant.entities.get_entity_data(entity, 'stonehearth:designation') then | ||
return false | ||
end | ||
if entity:get_component('terrain') then | ||
return false | ||
end | ||
return true | ||
end) | ||
:set_find_support_filter(function(result, select_xz_region) | ||
select_xz_region._is_valid_location = FishingCallHandler._custom_is_valid_location | ||
|
||
local entity = result.entity | ||
if not entity then | ||
return stonehearth.selection.FILTER_IGNORE | ||
end | ||
local rcs = entity:get_component('region_collision_shape') | ||
local region_collision_type = rcs and rcs:get_region_collision_type() | ||
if region_collision_type == _radiant.om.RegionCollisionShape.NONE then | ||
return stonehearth.selection.FILTER_IGNORE | ||
end | ||
|
||
if result.brick then | ||
return true | ||
end | ||
return stonehearth.selection.FILTER_IGNORE | ||
end) | ||
|
||
:done(function(selector, box) | ||
local size = { | ||
x = box.max.x - box.min.x, | ||
y = box.max.z - box.min.z, | ||
} | ||
_radiant.call('archipelago_biome:create_new_field', box.min, size) | ||
:done(function(r) | ||
response:resolve({ field = r.field }) | ||
end) | ||
:always(function() | ||
selector:destroy() | ||
end) | ||
end) | ||
:fail(function(selector) | ||
selector:destroy() | ||
response:reject('no region') | ||
end) | ||
:go() | ||
end | ||
|
||
function FishingCallHandler.has_water_below(origin) | ||
return | ||
FishingCallHandler._get_water_below(origin-Point3.unit_z) or | ||
FishingCallHandler._get_water_below(origin+Point3.unit_z) or | ||
FishingCallHandler._get_water_below(origin-Point3.unit_x) or | ||
FishingCallHandler._get_water_below(origin+Point3.unit_x) | ||
end | ||
|
||
function FishingCallHandler._get_water_below(neighbor_point) | ||
local ground_point = radiant.terrain.get_standable_point(neighbor_point) | ||
local entities_present = radiant.terrain.get_entities_at_point(ground_point) | ||
|
||
for id, entity in pairs(entities_present) do | ||
local water_component = entity:get_component('stonehearth:water') | ||
if water_component then | ||
return true | ||
end | ||
end | ||
return false | ||
end | ||
|
||
function FishingCallHandler:create_new_field(session, response, location, size) | ||
validator.expect_argument_types({'Point3', 'table'}, location, size) | ||
|
||
local entity = radiant.entities.create_entity('archipelago_biome:fisher:field', { owner = session.player_id }) | ||
radiant.terrain.place_entity(entity, location) | ||
|
||
local shape = Cube3(Point3.zero, Point3(size.x, 1, size.y)) | ||
entity:add_component('region_collision_shape') | ||
:set_region_collision_type(_radiant.om.RegionCollisionShape.NONE) | ||
:set_region(_radiant.sim.alloc_region3()) | ||
:get_region():modify(function(cursor) | ||
cursor:add_unique_cube(shape) | ||
end) | ||
entity:add_component('destination') | ||
:set_region(_radiant.sim.alloc_region3()) | ||
:get_region():modify(function(cursor) | ||
cursor:add_unique_cube(shape) | ||
end) | ||
entity:get_component('destination') | ||
:set_adjacent(_radiant.sim.alloc_region3()) | ||
:get_adjacent():modify(function(cursor) | ||
cursor:add_unique_cube(shape) | ||
end) | ||
|
||
local fisher_field = entity:get_component('archipelago_biome:fisher_field') | ||
fisher_field:set_size(size.x,size.y) | ||
|
||
return { field = entity } | ||
end | ||
|
||
return FishingCallHandler |
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,39 @@ | ||
local FisherFieldComponent = class() | ||
local Point2 = _radiant.csg.Point2 | ||
local Point3 = _radiant.csg.Point3 | ||
|
||
function FisherFieldComponent:initialize() | ||
self._sv.size = nil | ||
end | ||
|
||
function FisherFieldComponent:create() | ||
self._sv.size = Point2.zero | ||
end | ||
|
||
function FisherFieldComponent:set_size(x, z) | ||
self._sv.size = Point2(x, z) | ||
self.__saved_variables:mark_changed() | ||
end | ||
|
||
function FisherFieldComponent:get_water_direction(origin) | ||
return | ||
FisherFieldComponent:_get_water_below(origin-Point3.unit_z) or | ||
FisherFieldComponent:_get_water_below(origin+Point3.unit_z) or | ||
FisherFieldComponent:_get_water_below(origin-Point3.unit_x) or | ||
FisherFieldComponent:_get_water_below(origin+Point3.unit_x) | ||
end | ||
|
||
function FisherFieldComponent:_get_water_below(neighbor_point) | ||
local ground_point = radiant.terrain.get_standable_point(neighbor_point) | ||
local entities_present = radiant.terrain.get_entities_at_point(ground_point) | ||
|
||
for id, entity in pairs(entities_present) do | ||
local water_component = entity:get_component('stonehearth:water') | ||
if water_component then | ||
return neighbor_point | ||
end | ||
end | ||
return false | ||
end | ||
|
||
return FisherFieldComponent |
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.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
{ | ||
"type": "entity", | ||
"components": { | ||
"stonehearth:defense_zone": {}, | ||
"archipelago_biome:fisher_field": {}, | ||
"stonehearth:commands": { | ||
"commands": [ | ||
"stonehearth:commands:destroy_item" | ||
] | ||
} | ||
}, | ||
"entity_data": { | ||
"archipelago_biome:fishing_spot":{}, | ||
"stonehearth:designation": { | ||
"allow_placed_items": false | ||
}, | ||
"stonehearth:item": { | ||
"clearable": false | ||
}, | ||
"stonehearth:catalog": { | ||
"display_name": "i18n(archipelago_biome:jobs.fisher.field.display_name)", | ||
"description": "i18n(archipelago_biome:jobs.fisher.field.description)" | ||
} | ||
} | ||
} |
Oops, something went wrong.