EDIT: Found it. There was an error in player constructor. I changed my game system, so it uses IDs for entites and tiles. Before that i had to do new instances of everything. I forgot to put inventory initialization from constructor to PostInitialize() so it used the null world of non existing entity. Thank you all.
i have a problem. I am doing an XNA game and i need to change entity’s map so it can do it’s stuff but I’ve ran into a problem. Method receives argument map that is not null, i set entity.currentMap to the argument but currentMap is still null.
public Entity getCopy(Vector2 po, Map.Map map)
{
Entity t = (Entity)this.MemberwiseClone();
t.currentMap = map;
t.Position = po;
t.LoadTextures();
t.PostInitialize();
return t;
}
First, you say that
mapis definitely not null when being passed in. Thus, there are two possibilities.One: The setter for
currentMapis not working. Either post the code associated with the setter or make sure it’s actually storing the value properly by stepping into it. Make sure on the very next line, the value is still there.Two: The value is getting lost elsewhere in the method. Are you sure
LoadTexturesand/orPostInitializeare not clearing thecurrentMapvariable?