Example #1
0
    public void Remove(bool reorder = true)
    {
        if (Removing)
        {
            logger.Log("Attempting to remove an object already being removed");
            return;
        }
        Removing = true;

        UrbAgentManager.UnregisterAgent(this);

        CurrentTile?.OnAgentLeave(this, reorder);

        CurrentMap = null;
        if (TotalAgents > 0)
        {
            TotalAgents--;
        }

        if (Debug.developerConsoleVisible)
        {
            logger.Log(LogType.Log, "Remove entity, destroying game object", context: this);
        }
        Destroy(gameObject);
    }
Example #2
0
    public override void OnDisable()
    {
        Assert.IsNotNull(CurrentTile);
        Assert.IsNotNull(CurrentTile.Occupants);

        CurrentTile.Occupants.Remove(this);

        //generally we don't actually care if
        //the underlying objects are non-null
        //only if it's null and we don't know about it
        IsCurrentMapNull = true;
        CurrentTile      = null;
        CurrentMap       = null;
        UrbAgentManager.UnregisterAgent(this);
        base.OnDisable();
    }