Here is my current implementation of a window. It works pretty well… Any recommendations?
[code]#charset “us-ascii”
#include <adv3.h>
#include <en_us.h>
class Window: Occluder, SenseConnector, Fixture
name = getState.name
connectorMaterial = glass
firstLocation = nil
secondLocation = nil
firstDirection = nil
secondDirection = nil
connectedDesc = 'This one provides a view into <<otherLocation.theName>>.'
disconnectedDesc = 'For some reason the glass is so opaque you cannot see through it.'
viewDesc = '<<if connected>><<connectedDesc>><<else>><<disconnectedDesc>><<end>>'
desc() {
inherited; "<<viewDesc>>";
}
inRoomDesc() {
return ' A <<getState.name>> provides a view into <<otherLocation.theName.toTitleCase>>.';
}
connected() {
return (firstLocation != nil || secondLocation != nil);
}
getFirstState() { return getDirectionalState(firstDirection); }
getSecondState() { return getDirectionalState(secondDirection); }
allStates() {
return [getFirstState(), getSecondState()];
}
getState() {
if (gPlayerChar.isIn(firstLocation))
return getFirstState();
return getSecondState();
}
locationList() {
return [firstLocation, secondLocation];
}
otherLocation() {
if (connected()) {
if (gActor.isIn(firstLocation))
return secondLocation;
return firstLocation;
}
}
occludeObj(obj, sense, pov) {
if (obj.isIn(pov.location)) {
return nil;
}
if (obj.isIn(otherLocation)) {
if (obj.isApparent()) {
return nil;
}
}
return true;
}
getDirectionalState(direction) {
switch (direction) {
case northDirection:
return northWindowState;
case southDirection:
return southWindowState;
case westDirection:
return westWindowState;
case eastDirection:
return eastWindowState;
case northwestDirection:
return northwestWindowState;
case southwestDirection:
return southwestWindowState;
case northeastDirection:
return northeastWindowState;
case southeastDirection:
return southeastWindowState;
}
}
dobjFor(LookThrough) {
check() {
if (nil == connected()) {
reportFailure('You can\'t seem to actually see through this window.');
exit;
}
}
action() {
"You peer into the <<otherLocation.name>>. <<otherLocation.desc>>";
}
}
;
eastWindowState: ThingState
stateTokens = [‘east’, ‘e’]
name = ‘east window’
;
westWindowState: ThingState
stateTokens = [‘west’, ‘w’]
name = ‘west window’
;
northWindowState: ThingState
stateTokens = [‘north’, ‘n’]
name = ‘north window’
;
southWindowState: ThingState
stateTokens = [‘south’, ‘s’]
name = ‘south window’
;
southwestWindowState: ThingState
stateTokens = [‘southwest’, ‘s’]
name = ‘southwest window’
;
southeastWindowState: ThingState
stateTokens = [‘southeast’, ‘e’]
name = ‘southeast window’
;
northwestWindowState: ThingState
stateTokens = [‘northwest’, ‘w’]
name = ‘northwest window’
;
northeastWindowState: ThingState
stateTokens = [‘northeast’, ‘n’]
name = ‘northeast window’
;
[/code]