Find chest openings within interaction range
This commit is contained in:
+24
-16
@@ -69,12 +69,13 @@ class CacheItemsStates:
|
||||
self.area = container['position']
|
||||
self.container_item_ids = container['item_ids']
|
||||
self.is_labeled_container = True
|
||||
for opening in w.find_cache_openings(self.area):
|
||||
navpath = w.path_to_place(p, opening)
|
||||
for opening in w.find_cache_openings(self.area, p):
|
||||
navpath = w.path_to_place(p, opening['position'])
|
||||
if navpath:
|
||||
print('Going to labeled chest', container['labels'],
|
||||
self.area)
|
||||
self.opening = opening
|
||||
self.opening = opening['position']
|
||||
self.open_interaction = opening
|
||||
self.g.path = navpath
|
||||
self.state = self.going_to_trapped_chest
|
||||
return
|
||||
@@ -96,11 +97,12 @@ class CacheItemsStates:
|
||||
chest = self.trapped_chests[0]
|
||||
self.area = chest
|
||||
|
||||
for opening in w.find_cache_openings(chest):
|
||||
navpath = w.path_to_place(p, opening)
|
||||
for opening in w.find_cache_openings(chest, p):
|
||||
navpath = w.path_to_place(p, opening['position'])
|
||||
if navpath:
|
||||
print('navpath to trapped chest:', navpath)
|
||||
self.opening = opening
|
||||
self.opening = opening['position']
|
||||
self.open_interaction = opening
|
||||
self.g.path = navpath
|
||||
self.state = self.going_to_trapped_chest
|
||||
return
|
||||
@@ -110,12 +112,12 @@ class CacheItemsStates:
|
||||
|
||||
def going_to_trapped_chest(self):
|
||||
if utils.pint(self.g.pos) == self.opening:
|
||||
self.g.look_at = self.area
|
||||
self.g.look_at = self.open_interaction['look_at']
|
||||
self.wait_time = 0.5
|
||||
self.state = self.turn_to_trapped_chest
|
||||
|
||||
def turn_to_trapped_chest(self):
|
||||
self.g.look_at = self.area
|
||||
self.g.look_at = self.open_interaction['look_at']
|
||||
self.wait_time -= utils.TICK
|
||||
if self.wait_time <= 0:
|
||||
self.state = self.open_chest
|
||||
@@ -144,12 +146,14 @@ class CacheItemsStates:
|
||||
return
|
||||
|
||||
self.area = area
|
||||
openings = w.find_cache_openings(self.area)
|
||||
openings = w.find_cache_openings(self.area, p)
|
||||
|
||||
for o in openings:
|
||||
navpath = w.path_to_place(p, o)
|
||||
self.opening = o
|
||||
if navpath: break
|
||||
for opening in openings:
|
||||
navpath = w.path_to_place(p, opening['position'])
|
||||
if navpath:
|
||||
self.opening = opening['position']
|
||||
self.open_interaction = opening
|
||||
break
|
||||
else: # for
|
||||
print('Unable to get to cache area', self.area)
|
||||
self.bad_areas.append(self.area)
|
||||
@@ -161,12 +165,12 @@ class CacheItemsStates:
|
||||
|
||||
def going_to_area(self):
|
||||
if utils.pint(self.g.pos) == self.opening:
|
||||
self.g.look_at = self.area
|
||||
self.g.look_at = self.open_interaction['look_at']
|
||||
self.wait_time = 0.5
|
||||
self.state = self.turn_to_cache_spot
|
||||
|
||||
def turn_to_cache_spot(self):
|
||||
self.g.look_at = self.area
|
||||
self.g.look_at = self.open_interaction['look_at']
|
||||
self.wait_time -= utils.TICK
|
||||
if self.wait_time <= 0:
|
||||
self.state = self.place_chest
|
||||
@@ -180,7 +184,10 @@ class CacheItemsStates:
|
||||
print('Opening chest')
|
||||
self.failed_transfer_slots.clear()
|
||||
self.pending_transfer = None
|
||||
self.g.game.open_container(self.area)
|
||||
self.g.game.open_container(
|
||||
self.open_interaction['target'],
|
||||
face=self.open_interaction['face'],
|
||||
cursor=self.open_interaction['cursor'])
|
||||
self.wait_time = 1
|
||||
self.state = self.wait
|
||||
|
||||
@@ -368,6 +375,7 @@ class CacheItemsStates:
|
||||
self.container_item_ids = None
|
||||
self.area = None
|
||||
self.opening = None
|
||||
self.open_interaction = None
|
||||
self.trapped_chests = []
|
||||
self.bad_areas = []
|
||||
self.wait_time = 0
|
||||
|
||||
Reference in New Issue
Block a user