mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
squid hero phasing
This commit is contained in:
parent
36e912bcb0
commit
f3d0757fa3
|
@ -143,6 +143,9 @@ impl EntityMap {
|
||||||
|
|
||||||
let desired_location = entity_location + direction.into();
|
let desired_location = entity_location + direction.into();
|
||||||
let surface = map.get(desired_location);
|
let surface = map.get(desired_location);
|
||||||
|
|
||||||
|
let mut should_die_later = false;
|
||||||
|
|
||||||
let (can_move, explicit_stay_put, fake_out_effect) = if surface == MapElement::Wall {
|
let (can_move, explicit_stay_put, fake_out_effect) = if surface == MapElement::Wall {
|
||||||
(false, true, None)
|
(false, true, None)
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,7 +156,9 @@ impl EntityMap {
|
||||||
let move_attempt_resolutions: Vec<_> = self
|
let move_attempt_resolutions: Vec<_> = self
|
||||||
.whats_at(desired_location)
|
.whats_at(desired_location)
|
||||||
.filter(|(k, _)| *k != entity_to_update_key)
|
.filter(|(k, _)| *k != entity_to_update_key)
|
||||||
.map(|(key, other_entity)| (key, resolve_move(entity_to_update, other_entity)))
|
.map(|(key, other_entity)| {
|
||||||
|
(key, resolve_move(entity_to_update, other_entity, direction))
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for (other_entity_key, move_resolution) in move_attempt_resolutions {
|
for (other_entity_key, move_resolution) in move_attempt_resolutions {
|
||||||
|
@ -204,6 +209,9 @@ impl EntityMap {
|
||||||
explicit_stay_put = true;
|
explicit_stay_put = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MoveAttemptResolution::DieLater => {
|
||||||
|
should_die_later = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +282,10 @@ impl EntityMap {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if should_die_later {
|
||||||
|
hero_has_died |= self.kill_entity(entity_to_update_key, animations);
|
||||||
|
}
|
||||||
|
|
||||||
(
|
(
|
||||||
HasMoved(can_move),
|
HasMoved(can_move),
|
||||||
ActionResult::new(hero_has_died, win_has_triggered),
|
ActionResult::new(hero_has_died, win_has_triggered),
|
||||||
|
@ -455,6 +467,7 @@ enum MoveAttemptResolution {
|
||||||
Die,
|
Die,
|
||||||
KillDie,
|
KillDie,
|
||||||
CoExist,
|
CoExist,
|
||||||
|
DieLater,
|
||||||
StayPut,
|
StayPut,
|
||||||
AttemptPush,
|
AttemptPush,
|
||||||
}
|
}
|
||||||
|
@ -498,9 +511,16 @@ fn resolve_overlap(me: &Entity, other: &Entity) -> OverlapResolution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn holding_attack_resolve(holding: Option<&EntityType>) -> MoveAttemptResolution {
|
fn holding_attack_resolve(
|
||||||
match holding {
|
holding: Option<&EntityType>,
|
||||||
Some(&EntityType::Item(Item::Sword)) => MoveAttemptResolution::Kill,
|
other: &Entity,
|
||||||
|
direction: Direction,
|
||||||
|
) -> MoveAttemptResolution {
|
||||||
|
match (holding, &other.entity) {
|
||||||
|
(Some(&EntityType::Item(Item::Sword)), _) => MoveAttemptResolution::Kill,
|
||||||
|
(_, EntityType::Enemy(Enemy::Squid(squid))) => {
|
||||||
|
hero_walk_into_squid_interaction(squid, direction)
|
||||||
|
}
|
||||||
_ => MoveAttemptResolution::CoExist,
|
_ => MoveAttemptResolution::CoExist,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -549,10 +569,18 @@ fn switch_door_resolve(door: &Switchable) -> MoveAttemptResolution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_move(mover: &Entity, into: &Entity) -> MoveAttemptResolution {
|
fn hero_walk_into_squid_interaction(squid: &Squid, direction: Direction) -> MoveAttemptResolution {
|
||||||
|
if direction == -squid.direction {
|
||||||
|
MoveAttemptResolution::DieLater
|
||||||
|
} else {
|
||||||
|
MoveAttemptResolution::CoExist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn resolve_move(mover: &Entity, into: &Entity, direction: Direction) -> MoveAttemptResolution {
|
||||||
match (&mover.entity, &into.entity) {
|
match (&mover.entity, &into.entity) {
|
||||||
(EntityType::Hero(hero), EntityType::Hero(_) | EntityType::Enemy(_)) => {
|
(EntityType::Hero(hero), EntityType::Hero(_) | EntityType::Enemy(_)) => {
|
||||||
holding_attack_resolve(hero.holding.as_deref())
|
holding_attack_resolve(hero.holding.as_deref(), into, direction)
|
||||||
}
|
}
|
||||||
(EntityType::Hero(hero), EntityType::Door) => holding_door_resolve(hero.holding.as_deref()),
|
(EntityType::Hero(hero), EntityType::Door) => holding_door_resolve(hero.holding.as_deref()),
|
||||||
(EntityType::Enemy(Enemy::Squid(squid)), EntityType::Hero(_) | EntityType::Enemy(_)) => {
|
(EntityType::Enemy(Enemy::Squid(squid)), EntityType::Hero(_) | EntityType::Enemy(_)) => {
|
||||||
|
|
Loading…
Reference in a new issue