Difference between revisions of "Inheritance"

From ECWolf Wiki
(Created page with "==Overview== Inheritance is a concept in DECORATE whereby a new {{Class|actor}} - the child - may inherit its behaviour from another actor, the parent. When a child inher...")
 
m (→‎Overview: Capitalization fix so the DoomEd number link works)
 
Line 10: Line 10:
 
  }
 
  }
  
where xx is the [[DoomEd Number]] of the new actor.
+
where xx is the [[DoomEd number]] of the new actor.
  
 
ECWolf makes use of inheritance in a number of cases where objects share similar basic behaviours. One example of this is the use of {{Class|WolfensteinMonster}} as a parent class for all [[A_Chase|Wolfenstein-style enemies]] in the game.
 
ECWolf makes use of inheritance in a number of cases where objects share similar basic behaviours. One example of this is the use of {{Class|WolfensteinMonster}} as a parent class for all [[A_Chase|Wolfenstein-style enemies]] in the game.

Latest revision as of 18:23, 16 January 2013

Overview

Inheritance is a concept in DECORATE whereby a new actor - the child - may inherit its behaviour from another actor, the parent. When a child inherits from a parent it takes all of the defined states, properties and flags of the parent. These behaviours may then be overridden as required.

In order to inherit from a parent, the child actor defines its DECORATE definition in the following way:

actor ChildActor: ParentActor xx
{
  ... decorate ...
}

where xx is the DoomEd number of the new actor.

ECWolf makes use of inheritance in a number of cases where objects share similar basic behaviours. One example of this is the use of WolfensteinMonster as a parent class for all Wolfenstein-style enemies in the game.

Example

One example of this might be when we wish to create a new SS enemy that behaves just like the standard SS and uses the same graphics, except that it has twice as many hit points and gives the player twice as many points. This would be done in the following way:

actor NewSS: WolfensteinSS 3000
{
  Points 1000
  Health 200
}