Require hostile mobs have line of sight before reacting

This commit is contained in:
Tanner committed 2026-11-13 23:53:48 +00:00
1 parent 586772cb3b
commit 8447a85ff0
2 files changed
+43 -1

No files matched your search

+25
View File
@@ -141,6 +141,31 @@ class TestThreatDetection(unittest.TestCase):
self.assertEqual(monitor.safety, spot)
self.assertEqual(g.path[-1], spot)
def test_watching_ignores_hostile_mobs_without_line_of_sight(self):
mob = Munch(entity_id=13, type=mobs.MOBS[
'minecraft:pillager']['protocol_id'],
x=3.0, y=64.0, z=0.0)
class OccludedWorld:
@staticmethod
def find_monsters(_center, _distance):
return [mob]
@staticmethod
def _has_cache_line_of_sight(_start, _end, _target):
return False
job = FakeJob()
monitor = ThreatMonitor(Munch(
world=OccludedWorld(), pos=(0.5, 64.0, 0.5), job=job))
with patch('mosfet.jobs.check_threats.time.monotonic',
return_value=0.0):
monitor.tick()
self.assertIs(monitor.state.__func__, monitor.watching.__func__)
self.assertEqual(job.stop_calls, 0)
def test_threat_monitor_does_not_scan_without_an_active_job(self):
class IdleJob:
def idle(self):