Design Suggestions

Apr 10, 2013 at 6:21 PM
Edited Apr 10, 2013 at 6:38 PM
I didn't read the previous discussion.It may have been mentioned

[assembly: AssemblyTitle("XNAFinalEngine")]
[assembly: AssemblyProduct("XNAFinalEngine")]
[assembly: AssemblyVersion("1.0.0.0")]

public class GameObjectContentManager : Disposable
public void Unload()
    {
        List<GameObject> gameObjectsTemporalList = new List<GameObject>(); 
        gameObjectsTemporalList.AddRange(GameObjects);
        foreach (GameObject gameObject in gameObjectsTemporalList)
        {
            //gameObject.ContentManager = null; //This may be redundant
            gameObject.Dispose();
        }
        gameObjectsTemporalList.Clear();
        GarbageCollector.CollectGarbage();
    }
BECAUSE

public abstract class GameObject
{
   protected override void DisposeManagedResources()
    {
        ContentManager = null;  //look here,set null twice
        //...
    }
}
    public void Dispose()
    {
        Dispose(true);// true
        GC.SuppressFinalize(this);
    }

    private void Dispose(bool disposing)
    {
        if (!disposed)
        {
            if (disposing)//true,look here
            {
                DisposeManagedResources();//look here
            }
            DisposeUnmanagedResources();
            disposed = true;
        }
    }
IF above is acceptable,
in class GameObject

public GameObjectContentManager ContentManager
    {
        get { return contentManager; }
        internal set   //should switch to private set
        {
            if (contentManager != null)
                contentManager.GameObjects.Remove(this);
            contentManager = value;
            if (value != null)
                value.GameObjects.Add(this);
        }
    }
Apr 13, 2013 at 3:23 AM
Edited Apr 16, 2013 at 5:27 AM
Rely ring
GameObject2D --> HudText --> HudElement -->Renderer-->GameObject2D
Shader --> Asset --> AssetContentManager --> Shader

This shows that the abstract level definition is not appropriate.

Ugly if means that propetry Transform should be statemented in base class GameObject.

public abstract class Renderer : Component
if (Owner is GameObject2D)
        {
            OnWorldMatrixChanged(((GameObject2D)Owner).Transform.WorldMatrix);
            ((GameObject2D)Owner).Transform.WorldMatrixChanged += OnWorldMatrixChanged;
        }
        else
        {
            OnWorldMatrixChanged(((GameObject3D)Owner).Transform.WorldMatrix);
            ((GameObject3D)Owner).Transform.WorldMatrixChanged += OnWorldMatrixChanged;
        }

Coordinator
May 10, 2013 at 5:53 PM
Sorry for the delay. I was taking a big and deserved break from the project because of the changes in my life, positive changes by the way, a new work in a another country.

I have fixed the problems in the first post, thank you very much. In a couple of hours I will upload a new commit.
I understand the problem in the second post and I will try to fix it if possible but I am still not sure how to do it.

Sorry again for the delay. Bye. José.