Ignore:
Timestamp:
09/04/13 19:16:09 (8 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Phase:
public
Message:

Add hints for the level editor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nagslang/game_object.py

    r229 r235  
    99from nagslang.resources import resources
    1010from nagslang.events import DoorEvent
     11
     12
     13def get_editable_game_objects():
     14    classes = []
     15    for cls_name, cls in globals().iteritems():
     16        if isinstance(cls, type) and hasattr(cls, 'requires'):
     17            classes.append((cls_name, cls))
     18    return classes
    1119
    1220
     
    137145        return True
    138146
     147    @classmethod
     148    def requires(cls):
     149        """Hints for the level editor"""
     150        return [("name", "string")]
     151
    139152
    140153class FloorSwitch(GameObject):
     
    155168        )
    156169
     170    @classmethod
     171    def requires(cls):
     172        return [("name", "string"), ("position", "coordinates")]
     173
    157174
    158175class Note(GameObject):
     
    169186            render.TextOverlay(message),
    170187        )
     188
     189    @classmethod
     190    def requires(cls):
     191        return [("name", "string"), ("position", "coordinates"),
     192                ("message", "text")]
    171193
    172194
     
    187209            puzzle.StateProxyPuzzler(state_source),
    188210        )
     211
     212    @classmethod
     213    def requires(cls):
     214        return [("name", "string"), ("position", "coordinates"),
     215                ("state_source", "puzzler")]
    189216
    190217
     
    201228        )
    202229
     230    @classmethod
     231    def requires(cls):
     232        return [("name", "string"), ("position", "coordinates"),
     233                ("state_source", "puzzler")]
     234
    203235
    204236class Door(GameObject):
     
    226258        if self.puzzler.get_state():
    227259            DoorEvent.post(self.destination, self.dest_pos)
     260
     261    @classmethod
     262    def requires(cls):
     263        return [("name", "string"), ("position", "coordinates"),
     264                ("destination", "level name"), ("dest_pos", "coordinate"),
     265                ("key_state", "puzzler")]
    228266
    229267
     
    250288            return False
    251289        return True
     290
     291    @classmethod
     292    def requires(cls):
     293        return [("name", "string"), ("end1", "coordinates"),
     294                ("end2", "coordinates"), ("key_state", "puzzler")]
Note: See TracChangeset for help on using the changeset viewer.