Feature (of Object
)¶
-
class
Feature
¶ Defined in Feature.sc.
Feature forms the base class for interactable items in the game. Actor, Prop and View all extend from this class. It can also be used on its own, generally for attaching interactions to static portions of the background.
Feature has support for displaying messages when the player performs actions (verbs) by clicking on it. It will also optionally direct the ego to approach the feature.
Example usage:
; Define a red plant that displays messages associated with the noun N_PLANT ; when the use clicks on the white control color on the pic background. ; The (x, y) coordinates are used to identify the "center of interest" of the feature, ; which determines the direction in which the ego should face when interacting with it. (instance redPlant of Feature (properties x 217 y 121 noun N_PLANT onMeCheck ctlWHITE ) )
There are two main ways to identify the bounds of a feature: control colors, and polygons. Even if onMeCheck has been set in the Feature declaration, this needs to be done with the setOnMeCheck() method.
You can also indicate for which verbs the ego should approach the feature (as opposed to just facing it). This is done with the approachVerbs() method.
Example initialization:
(redPlanet approachVerbs: V_DO V_LOOK setOnMeCheck: omcCOLORS ctlWHITE init: )
Subclasses: View
.
Properties¶
Inherited from Object
:
Property | Description |
---|---|
name |
Defined in Feature:
Property | Description |
---|---|
x | “center of interest” for the Feature. |
y | |
z | |
heading | |
noun | Message noun associated with the Feature. |
case | Message case associated with the Feature. |
modNum | |
nsTop | |
nsLeft | |
nsBottom | |
nsRight | |
sightAngle | |
actions | |
onMeCheck | omcDISABLE, omcCOLORS or omcPOLYGON. See setOnMeCheck(). |
state | |
approachX | The approach spot x. |
approachY | The approach spot y. |
approachDist | The approach distance. |
_approachVerbs | Bitmask for verbs that cause the ego to approach the Feature. |
Methods¶
-
init
([initCode]) Initializes the Feature. This must be done prior to it being active in the scene.
Parameters: initCode (heapPtr) – Optional initialization Code
for the feature. Generally, this is left unspecified.
-
dispose
()
-
initialize
(param1)
-
handleEvent
(pEvent)
-
doVerb
(theVerb) This method can be overridden by Feature instances to provide custom logic when the player interacts with the feature. By default, it displays any message resource associated with the given verb for this Feature’s noun.
-
notFacing
()
-
facingMe
([theObj]) Parameters: theObj (heapPtr) – Optional object that the Feature might be facing. If not specified, the player’s ego is used. Returns TRUE if this Feature is facing the specified object (or ego).
-
isNotHidden
()
-
onMe
(theObj)
-
onMe
(x y) Parameters: - theObj (heapPtr) – The object that might be on the Feature.
- x (number) – The x coordinate.
- y (number) – The y coordinate.
Returns: TRUE if the (x, y) or object is on the Feature.
-
approachVerbs
([verbs ...]) Indicates which verbs should cause the ego to approach the feature.
Parameters: verbs (number) – An optional series of verbs. Example usage:
(theToy approachVerbs: V_DO V_EAT)
-
setName
(theName)
-
setOnMeCheck
(omcDISABLE)
-
setOnMeCheck
(omcPOLYGON polygon)
-
setOnMeCheck
(omcCOLORS [colors ...]) Controls how the Feature is identified (colors or polygon), or disables the onMe check.
Parameters: - polygon (heapPtr) – A polygon defining the boundaries of the Feature
- colors (number) – Control color(s) defining the Feature.
Example usage:
(theTable setOnMeCheck: omcCOLORS ctlWHITE ctlGREY) (theRock setOnMeCheck: omcPOLYGON (CreateNewPolygon @P_TheRock))