License | BSD-3-Clause |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Utilities for describing how to display in-game entities in the TUI.
Synopsis
- type Priority = Int
- data Attribute
- data Display
- defaultChar :: Lens' Display Char
- orientationMap :: Lens' Display (Map AbsoluteDir Char)
- curOrientation :: Lens' Display (Maybe Direction)
- displayAttr :: Lens' Display Attribute
- displayPriority :: Lens' Display Priority
- invisible :: Lens' Display Bool
- displayChar :: Display -> Char
- hidden :: Display -> Display
- defaultTerrainDisplay :: Char -> Attribute -> Display
- defaultEntityDisplay :: Char -> Display
- defaultRobotDisplay :: Display
The display record
Display priority. Entities with higher priority will be drawn on top of entities with lower priority.
An internal attribute name.
Instances
FromJSON Attribute Source # | |
ToJSON Attribute Source # | |
Defined in Swarm.Game.Display | |
Generic Attribute Source # | |
Show Attribute Source # | |
Eq Attribute Source # | |
Ord Attribute Source # | |
Defined in Swarm.Game.Display | |
Hashable Attribute Source # | |
Defined in Swarm.Game.Display | |
type Rep Attribute Source # | |
Defined in Swarm.Game.Display type Rep Attribute = D1 ('MetaData "Attribute" "Swarm.Game.Display" "swarm-0.4-ISnx5FXhZ2Y66vKOx5hQmE" 'False) ((C1 ('MetaCons "ADefault" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ARobot" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "AEntity" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "AWorld" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text)) :+: C1 ('MetaCons "ATerrain" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))))) |
A record explaining how to display an entity in the TUI.
Instances
Fields
orientationMap :: Lens' Display (Map AbsoluteDir Char) Source #
For robots or other entities that have an orientation, this map
optionally associates different display characters with
different orientations. If an orientation is not in the map,
the defaultChar
will be used.
curOrientation :: Lens' Display (Maybe Direction) Source #
The display caches the current orientation of the entity, so we know which character to use from the orientation map.
displayPriority :: Lens' Display Priority Source #
This entity's display priority. Higher priorities are drawn on top of lower.
Rendering
displayChar :: Display -> Char Source #
Look up the character that should be used for a display.
Modify a display to use a ?
character for entities that are
hidden/unknown.
Construction
defaultTerrainDisplay :: Char -> Attribute -> Display Source #
The default way to display some terrain using the given character and attribute, with priority 0.
defaultEntityDisplay :: Char -> Display Source #
Construct a default display for an entity that uses only a single display character, the default entity attribute, and priority 1.
defaultRobotDisplay :: Display Source #
Construct a default robot display for a given orientation, with
display characters "X^>v<"
, the default robot attribute, and
priority 10.
Note that the defaultChar
is used for direction DDown
and is overridden for the special base robot.