diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/Sensing.cpp | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/Sensing.cpp')
| -rw-r--r-- | Minecraft.World/Sensing.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Minecraft.World/Sensing.cpp b/Minecraft.World/Sensing.cpp new file mode 100644 index 00000000..d451f483 --- /dev/null +++ b/Minecraft.World/Sensing.cpp @@ -0,0 +1,35 @@ +#include "stdafx.h" +#include "net.minecraft.world.entity.h" +#include "Sensing.h" + +Sensing::Sensing(Mob *mob) +{ + this->mob = mob; +} + +void Sensing::tick() +{ + seen.clear(); + unseen.clear(); +} + +bool Sensing::canSee(shared_ptr<Entity> target) +{ + //if ( find(seen.begin(), seen.end(), target) != seen.end() ) return true; + //if ( find(unseen.begin(), unseen.end(), target) != unseen.end()) return false; + for(AUTO_VAR(it, seen.begin()); it != seen.end(); ++it) + { + if(target == (*it).lock()) return true; + } + for(AUTO_VAR(it, unseen.begin()); it != unseen.end(); ++it) + { + if(target == (*it).lock()) return false; + } + + //util.Timer.push("canSee"); + bool canSee = mob->canSee(target); + //util.Timer.pop(); + if (canSee) seen.push_back(weak_ptr<Entity>(target)); + else unseen.push_back(weak_ptr<Entity>(target)); + return canSee; +}
\ No newline at end of file |
