Class: Aspect
Extends: adventurejs.Atom
Defined in: adventure/assets/Aspect.js, line 6
More info: Aspects
Aspect is a special class that creates spaces within any Tangible Asset, which can contain other Tangibles and/or Substances, with the addition of a Vessel. The five most commonly used aspects are behind, in, on, under, and attached, and a lot of default logic is predicated on using one of these. However it is possible to create aspects at any preposition. Just note that it might lead to unexpected results and require custom code.
this.aspects.behind = {};
Here is an example of how to set the properties of a Aspect of an existing class using createAsset. If you use a preposition that hasn't been defined for the class you're using, a new Aspect will be constructed automatically during construction.
MyGame.createAsset({
class: "Desk",
name: "desk",
place: { in: "Office" },
behind: {
list_in_room: false,
list_in_examine: true,
maxheight: 1,
maxwidth: 6,
maxdepth: 4,
}
});
To define a new class with an Aspect, use the Aspect constructor within the class constructor. Here is a very simple example of a new class with a behind Aspect.
class NewClass {
constructor( name, game_name ) {
super( name, game_name );
this.aspects.newaspect = new adventurejs.Aspect( "newaspect", this.game_name )
.set({
"parent_id": this.id,
});
}
}
adventurejs.NewClass = NewClass;
};
Private Constructor:
var foo = new adventurejs.Aspect(game_name, name)
Parameters:
-
game_name
String
Name of top level game instance that is scoped to window. -
name
String
Instance name.
- Index
- Methods
- Properties
Index
Methods:
- Inherited from Atom getInheritance
- Inherited from Atom hasClass
- Inherited from Atom Overrides from Atom set
Properties:
- Inherited from Atom game
- is_false_nest
- Inherited from Atom Name
- orientation
- player
- player_can_reach
- things_player_can_reach_from_positions_of_this_aspect
Methods Collapse all |
getInheritance() → {Array}
Defined in: adventure/Atom.js, line 151
Inherited from: adventurejs.Atom#getInheritance
Returns:
Array
hasClass(prop) → {Boolean}
Defined in: adventure/Atom.js, line 131
Inherited from: adventurejs.Atom#hasClass
Parameters:
-
prop
String
Name of the class to test for.
Returns:
Boolean
set(props) → {Object}
Defined in: adventure/Atom.js, line 119
Overrides from: adventurejs.Atom#set
Parameters:
-
props
Object
A generic object containing properties to copy to the Object instance.
Returns:
Object
Returns the instance the method is called on (useful for chaining calls.)
Properties |
game :Getter
Defined in: adventure/Atom.js, line 110
Inherited from: adventurejs.Atom#game
this.game
.
is_false_nest :boolean
Defined in: adventure/assets/Aspect.js, line 129
Default value: false
Name :String
Defined in: adventure/Atom.js, line 97
Inherited from: adventurejs.Atom#Name
orientation :String
Defined in: adventure/assets/Aspect.js, line 119
Default value: "horizontal"
player :boolean
Defined in: adventure/assets/Aspect.js, line 100
Default value: {} Aspect_Player
player_can_reach :boolean
Defined in: adventure/assets/Aspect.js, line 135
Default value: true
things_player_can_reach_from_positions_of_this_aspect :Object|Array
Defined in: adventure/assets/Aspect.js, line 146
Todos: for this to work properly each aspect needs its own local coordinates