2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2002, 2003 Gordon McNutt
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 2 of the License, or (at your option)
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 // You should have received a copy of the GNU General Public License along with
16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 // Suite 330, Boston, MA 02111-1307 USA
20 // gmcnutt@users.sourceforge.net
27 bool FieldType::isType(int classID)
29 if (classID == FIELD_TYPE_ID)
31 return ObjectType::isType(classID);
34 int FieldType::getType()
39 FieldType::FieldType(const char *tag, const char *name, struct sprite *sprite,
40 int light_, int duration_, int pclass_, closure_t *clx)
41 : ObjectType(tag, name, sprite, field_layer),
42 pclass(pclass_), light(light_), duration(duration_)
52 FieldType::~FieldType()
54 closure_unref_safe(effect);
57 int FieldType::getLight()
62 void FieldType::setLight(int val)
67 void FieldType::setDuration(int val)
72 int FieldType::getDuration()
77 class Object *FieldType::createInstance()
79 return new Field(this);
82 class FieldType * Field::getObjectType()
84 return (class FieldType *) Object::getObjectType();
87 bool FieldType::isPermanent()
89 return (duration < 0);
92 //////////////////////////////////////////////////////////////////////////////
94 Field::Field(FieldType *type)
97 duration = type->getDuration();
100 Field::Field(FieldType *type, int dur)
106 Field::Field() : duration(0)
114 int Field::getLight()
116 return getObjectType()->getLight();
125 if (getObjectType()->isPermanent())
129 assert(duration >= 0);
134 void Field::save(struct save *save)
136 save->write(save, "(kern-mk-field %s %d)", getObjectType()->getTag(),
140 int Field::getPclass()
142 return getObjectType()->pclass;