Class:Aspect
Extends: adventurejs.Atom
Defined in: adventure/assets/Aspect.js, line 5
More info: Aspects
Description
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_contents_in_room: false,
list_contents_in_examine: true,
contents_limits: {
height: 1,
width: 6,
depth: 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( "behind", this.game_name, this.id )
.set({
// optional params
});
}
}
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 getClassInheritance
- Inherited from Atom hasClass
- Inherited from Atom Overrides from Atom set
Properties:
- contents
- contents_limits
- Inherited from Atom game
- know_contents_with_parent
- list_contents_in_examine
- list_contents_in_room
- Inherited from Atom Name
- nest
- orientation
- player_can_add_assets_to_contents
- player_can_remove_assets_from_contents
- scale_increment
- see_contents_with_parent
- vessel
- with_assets
- with_classes
Methods Collapse all |
getClassInheritance
getClassInheritance() → {Array}
Defined in: adventure/Atom.js, line 168
Inherited from: adventurejs.Atom#getClassInheritance
Returns:
Array
hasClass
hasClass(prop) → {Boolean}
Defined in: adventure/Atom.js, line 148
Inherited from: adventurejs.Atom#hasClass
Parameters:
-
prop
String
Name of the class to test for.
Returns:
Boolean
set
set(props) → {Object}
Defined in: adventure/Atom.js, line 136
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 |
contents
contents :Array
Defined in: adventure/assets/Aspect.js, line 150
Default value: []
contents_limits
contents_limits :Array
Defined in: adventure/assets/Aspect.js, line 157
Default value: { height: -1, width: -1, depth: -1, count: -1, weight: -1, }
game
game :Getter
Defined in: adventure/Atom.js, line 115
Inherited from: adventurejs.Atom#game
this.game
.
know_contents_with_parent
know_contents_with_parent :boolean
Defined in: adventure/assets/Aspect.js, line 116
Default value: true
list_contents_in_examine
list_contents_in_examine :boolean
Defined in: adventure/assets/Aspect.js, line 104
Default value: true
list_contents_in_room
list_contents_in_room :boolean
Defined in: adventure/assets/Aspect.js, line 89
Default value: true
Name
Name :String
Defined in: adventure/Atom.js, line 102
Inherited from: adventurejs.Atom#Name
nest
nest :Object
Defined in: adventure/assets/Aspect.js, line 232
Default value: {}
this.nest = new adventurejs.Nest(
"nest",
this.game_name,
this.context_id
).set({
preposition: this.name,
});
orientation
orientation :String
Defined in: adventure/assets/Aspect.js, line 253
Default value: "horizontal"
player_can_add_assets_to_contents
player_can_add_assets_to_contents :boolean
Defined in: adventure/assets/Aspect.js, line 205
Default value: true
player_can_remove_assets_from_contents
player_can_remove_assets_from_contents :boolean
Defined in: adventure/assets/Aspect.js, line 212
Default value: true
scale_increment
scale_increment :Array
Defined in: adventure/assets/Aspect.js, line 171
Default value: -1
see_contents_with_parent
see_contents_with_parent :boolean
Defined in: adventure/assets/Aspect.js, line 132
Default value: true
vessel
vessel :Object
Defined in: adventure/assets/Aspect.js, line 219
Default value: {}
with_assets
with_assets :Array
Defined in: adventure/assets/Aspect.js, line 185
Default value: []
with_classes
with_classes :Array
Defined in: adventure/assets/Aspect.js, line 195
Default value: []