BMax OOP rocks!

Miscellaneous Forums/General Discussion/BMax OOP rocks!

As far as I know, that would fail (I haven't tested it yet, either). Because of the dynamic nature of polymorphism, the computer would have no way of knowing that p:TEntity is going to be a TPlayer - so it can't allow access to Fire() in that way.

Instead, you could make another Type (which might be called TActor) which Extends TEntity, which would define a "Method Fire() Abstract" or something. Then you can have "Type THuman Extends TActor" and "Type TRobot Extends TActor" if you want.

You could build a Type structure something like this:
    Entity -- Static
      |        / \
    Actor     /   \
    /   \  House  Tree
   /     \
Robot  Human


Then you can do something like this:
For act:TActor = EachIn ActorList
  act.UpdateAI() 'This could update AI appropriately, whether the actor is THuman or TRobot
  act.Shoot() 'You could also do this
Next

For ent:TEntity = EachIn EntityList
  ent.Draw()
Next


It really just depends on how you want to structure your code. I'm sure there's a million different ways to do this.