% File "active.tu". % % Written by Phil Edmonds, Feb 97. % % An active object is a kind of object that lives in the world, and takes % an active part in the simulation % %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unit class ActiveObject inherit Object in "object.tu" import World in "world.ti" export InitActiveObject, JoinWorld, TakeTurn %========== INSTANCE VARIABLES ============================== %============================================================ var frequency : int % how many time steps to wait before taking a turn var world : ^World % which world I'm in. %========== INITIALIZE ====================================== %============================================================ proc InitActiveObject (x, y : real, n : string, c : int, f : int) Object.Init (x, y, n, c) frequency := f end InitActiveObject %========== PUBLIC FUNCTIONS ================================ %============================================================ % A basic active object doesn't know how to take a turn in the % simulation, but its descendants should %------------------------------------------------------------ deferred proc TakeTurn % Tells the object which world it is in, and adds itself to the % world %------------------------------------------------------------ proc JoinWorld (w : ^World) world := w world -> AddDenizen (self) end JoinWorld end ActiveObject