mingli1/Symbol

Allow enemies and/or projectiles to go through portals?

Closed this issue · 1 comments

  • It would be cool for enemies who have movement patterns to go through portals
  • Shooting projectiles through portals would teleport the projectile with the same velocity elsewhere allowing for some clever attacks

Based on a initial attempt by simply having something like

affectedEntities = Family.one(PlayerComponent::class.java, EnemyComponent::class.java, ProjectileComponent::class.java).get()

and then doing

for (aEntity in affectedEntities) {
    // portal code with aEntity instead of player
}

these lines are causing trouble:

if (portalSource.teleported && !playerBounds.rect.overlaps(bounds.rect)) {
    portalSource.teleported = false
}

because portalSource.teleported gets set to false on every entity iteration not overlapping the portal.

So PortalComponent or the logic behind stopping infinite teleporting from rectangle overlaps has to be refactored for this feature to be implemented.