diff options
author | Griffin Smith <root@gws.fyi> | 2019-10-16T16·10-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-10-16T16·10-0400 |
commit | 87fedcb6c9bc251a5a23a632ccf985b674b84bc7 (patch) | |
tree | 739fab972e9ae8af9849f3e8f65dad0f5bf13c7d /src/Xanthous/Entities | |
parent | 4882350f5d7e54a6ae5c8760f2510273dae19c60 (diff) |
Add draw priority
Rather than blindly taking one entity from the list when we have multiple entities on the same tile, add a `drawPriority` method to the Draw typeclass which allows individual entities to request to be drawn on top - this avoids the "noodles floating over your head" bug we saw before.
Diffstat (limited to 'src/Xanthous/Entities')
-rw-r--r-- | src/Xanthous/Entities/Character.hs | 1 | ||||
-rw-r--r-- | src/Xanthous/Entities/Creature.hs | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/Xanthous/Entities/Character.hs b/src/Xanthous/Entities/Character.hs index 7d2d22c9983b..e3cbb2c038ff 100644 --- a/src/Xanthous/Entities/Character.hs +++ b/src/Xanthous/Entities/Character.hs @@ -50,6 +50,7 @@ instance Draw Character where where rloc = Location (negate scrollOffset, negate scrollOffset) rreg = (2 * scrollOffset, 2 * scrollOffset) + drawPriority = const maxBound -- Character should always be on top, for now -- the character does not (yet) have a mind of its own instance Brain Character where step = brainVia Brainless diff --git a/src/Xanthous/Entities/Creature.hs b/src/Xanthous/Entities/Creature.hs index 6ea6f93e4254..4ad751a58240 100644 --- a/src/Xanthous/Entities/Creature.hs +++ b/src/Xanthous/Entities/Creature.hs @@ -35,7 +35,7 @@ import Data.Aeson.Generic.DerivingVia import Data.Aeson (ToJSON, FromJSON) -------------------------------------------------------------------------------- import Xanthous.Entities.RawTypes hiding (Creature, description) -import Xanthous.Entities (Draw(..), DrawRawChar(..)) +import Xanthous.Entities (Draw(..), DrawRawCharPriority(..)) import Xanthous.Data -------------------------------------------------------------------------------- @@ -83,7 +83,7 @@ data Creature = Creature } deriving stock (Eq, Show, Generic) deriving anyclass (NFData, CoArbitrary, Function) - deriving Draw via DrawRawChar "_creatureType" Creature + deriving Draw via DrawRawCharPriority "_creatureType" 1000 Creature deriving (ToJSON, FromJSON) via WithOptions '[ FieldLabelModifier '[Drop 1] ] Creature |