/// <summary> /// Called after the entity is added into the world. /// </summary> /// <param name="loaded"><b>true</b> if the entity has been loaded; otherwise, <b>false</b>.</param> /// <seealso cref="Engine.EntitySystem.Entity.PostCreate()"/> /// <seealso cref="Engine.EntitySystem.Entity.OnPostCreate2(bool)"/> protected override void OnPostCreate(bool loaded) { if (instance == null) //for undo support { instance = this; } base.OnPostCreate(loaded); Entities.Instance.BeforeEntityTick += Entities_BeforeEntityTick; Map.Instance.BeforeMapGeneralObjectOnRenderFrame += Map_BeforeMapGeneralObjectOnRenderFrame; Map.Instance.BeforeMapGeneralObjectOnRender += Map_BeforeMapGeneralObjectOnRender; needRegenerateGrid = true; }
/// <summary> /// Called when the entity is removed from the world. /// </summary> protected override void OnDestroy() { ClearGrid(); if (Entities.Instance != null) { Entities.Instance.BeforeEntityTick -= Entities_BeforeEntityTick; } if (Map.Instance != null) { Map.Instance.BeforeMapGeneralObjectOnRenderFrame -= Map_BeforeMapGeneralObjectOnRenderFrame; Map.Instance.BeforeMapGeneralObjectOnRender -= Map_BeforeMapGeneralObjectOnRender; } base.OnDestroy(); if (instance == this) //for undo support { instance = null; } }
/////////////////////////////////////////// public FreezeObjectsManager() { instance = this; }