Hi guys im working on lots of different classes as different objects, and it all inherts something from the class ObjectPrototype
public abstract class ObjectPrototype{
private string walkable = consts.walkable_rejectall;//whether the object is walkable, returns a type?
private Owner owner = new Owner();//the owner of the object
private string type = null;//the type of the object
private Position pos; //Position of the object
private bool destroyable;//Whether its destroyable or not
private int hits, hitsMax;//Its hits(health), and maximum hits(health)
public abstract void run();//special funciton of the object, customizable
public string getType(){
return this.type;
}
public string iswalkable(){
return walkable;
}
Position getPosition(){
return new Position(pos.x,pos.y);
}
}
And i tested some features on the “child” classes(? or something idk how to call them), such as the TerrainWall:
public class TerrainWall: ObjectPrototype{
private string type = consts.type_twall;
private bool destroyable = false;
public override void run(){}
}
I created a TerrainWall class outside like this:
TerrainWall blank_twall = new();//blank terrain wall used to replace
For just making it a blank terrain wall which i can use as a template of the class itself later such as replacing something with it, but somehow it did not work, and when i blank_twall.getType() it gets the “null” type from the ObjectPrototype, even though i think i declared it in the TerrainWall.
First time i met this i wasnt so sure it was following ObjectPrototype’s type, so i change the default type for ObjectPrototype to “unset”, and if i debug.log(blank_twall.getType()) is gives me “unset”
Can anyone help me why its not declaring the type in the TerrainWall class?
Or any other suggestion thats related to improving my code would be nice, thank you ![]()