mirror of
https://github.com/motajs/template.git
synced 2026-11-24 14:54:30 +08:00
refactor(02-03): extract hero pass predicate
- Move passability and hit checks behind IPassPredicate - Keep hero mover event dispatch and move codes unchanged
This commit is contained in:
1 parent
3770e56c4d
commit
68a150882c
2 files changed
+80
-52
No files matched your search
@@ -180,9 +180,16 @@ export class HeroMover<T extends IHeroLocation>
|
||||
if (this.ignoreTerrain) {
|
||||
return HeroMoveCode.Step;
|
||||
} else {
|
||||
const canPass = this.topImpl.canPass(handler);
|
||||
const passHandler = {
|
||||
currLoc: handler.currLoc,
|
||||
nextLoc: handler.nextLoc,
|
||||
direction: handler.direction,
|
||||
floorId: handler.floorId
|
||||
};
|
||||
const predicate = this.topImpl.predicate();
|
||||
const canPass = predicate.canPass(passHandler);
|
||||
if (canPass) {
|
||||
const hit = this.topImpl.shouldHit(handler);
|
||||
const hit = predicate.shouldHit(passHandler);
|
||||
if (hit) return HeroMoveCode.Hit;
|
||||
else return HeroMoveCode.Step;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user