NearbyAttachable class | extras.t[3311]

A "nearby" attachable is a subclass of Attachable that adds a requirement that the attached objects be in a given location. By default, we simply require that they have a common immediate container, but this can be overridden so that each object's location is negotiated separately. This is a simple and effective pattern that avoids many of the potential anomalies with attachment (see the Attachable comments for examples).

In AttachTo actions, we enforce the nearby requirement with a precondition requiring the direct object to be in the same immediate container as the indirect object, and vice versa. In moveWhileAttached(), we enforce the rule by detaching the objects if one is being moved away from the other's immediate container.

`class NearbyAttachable : Attachable`

Superclass Tree (in declaration order)

`NearbyAttachable`
`Attachable`
`object`

Subclass Tree

(none)

Global Objects

(none)

Summary of Properties

``

Inherited from `Attachable` :
`attachedObjects attachmentLister majorAttachmentLister`

Summary of Methods

`dobjFor(AttachTo) getNearbyAttachmentLocs iobjFor(AttachTo) moveWhileAttached nestedDetachFrom`

Inherited from `Attachable` :
`attachTo beforeTravel canAttachTo canDetachFrom cannotDetachMsgFor detachFrom dobjFor(Detach) dobjFor(DetachFrom) dobjFor(TakeFrom) examineStatus explainCannotAttachTo getNonPermanentAttachments handleAttach handleDetach initializeThing iobjFor(DetachFrom) iobjFor(TakeFrom) isAttachedTo isListedAsAttachedTo isListedAsMajorFor isMajorItemFor isPermanentlyAttachedTo mainMoveInto maybeHandleAttach maybeHandleDetach travelWhileAttached`

Properties

(none)

Methods

`dobjFor(AttachTo)`OVERRIDDEN | `extras.t[3312]`

no description available

`getNearbyAttachmentLocs (other)` | `extras.t[3347]`

Get the target locations for attaching to the given other object. The "target locations" are the locations where the objects are required to be in order to carry out the ATTACH command to attach this object to the other object (or vice versa).

This method returns a list with three elements. The first element is the target location for 'self', and the second is the target location for 'other', the object we're attaching to. The third element is an integer giving the priority; a higher number means higher priority.

The priority is an arbitrary value that we use to determine which of the two objects involved in the attach gets to decide on the target locations. We call this method on both of the two objects being attached to one another, then we use the target locations returned by the object that claims the higher priority. If the two priorities are equal, we pick one arbitrarily.

The default implementation chooses my own immediate container as the target location for both objects. However, if the other object is non-portable, we'll choose its immediate location instead, since we obviously can't move it to our container.

`iobjFor(AttachTo)`OVERRIDDEN | `extras.t[3317]`

require that the objects be in the negotiated locations

`moveWhileAttached (movedObj, newCont)`OVERRIDDEN | `extras.t[3373]`

when an attached object is being moved, detach the objects

`nestedDetachFrom (obj)` | `extras.t[3404]`

perform a nested DetachFrom action on the given object

TADS 3 Library Manual
Generated on 8/21/2012 from TADS version 3.1.2