Skip to content

Create spawn and remove methods for entities #4

@jwgmeligmeyling

Description

@jwgmeligmeyling

Current scenario

  • entity.setLocation(Location) is used to update the location and send the proper SpawnPackets and EntityRemovePackets.
  • Location for players is set in the constructor, to prevent setLocation() to be triggered
  • Locations for monsters is set through the constructor, setLocation() is invoked to immidiately spawn monsters to it's surroundings
  • entity.spawn() is used to invoke setLocation with the current location provided through the constructor, to spawn players.

Conclusion
This is nasty. It's really confusing and causes entities to spawn too soon or to late, throwing NullPointerExceptions or making the client crash.

Suggested implementation

  • Remove setLocation(), it's ambigious and should be never used.
  • Set the initial coordinates for an entity through it's constructor, but don't spawn it yet!
  • Use the walk, jump and teleport (windscroll/portal) methods to spawn and move entities. These methods should remove the moving identity from players that resist only in the old view, send an entity spawn packet to the clients only in the new view, and optionally propagate a walk or jump packet.
  • Use the spawn() (=teleport(CurrentLocation)) method to spawn entities initially and append them to the array of entities within the map (remove it from the old map as well)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions