Inheritance

From ECWolf Wiki
(Redirected from Using inheritance)

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
}