Example #1
0
    void Apply(EntityChange change)
    {
        var e = input.GetEntityWithId(change.entityId);

        if (e == null)
        {
            if (change.isRemoval)
            {
                UnityEngine.Debug.Log("Can't apply an EntityChange, since it's Entity doesn't exist.");
                return;
            }

            Debug.LogFormat("Entity with id {0} not found. Creating...", change.entityId);
            e = input.CreateEntity();
        }

        change.Apply(e);
    }
    void Apply(GameStateUpdateMessage message, EntityChange change)
    {
        var e = game.GetEntityWithId(change.entityId);

        if (e == null)
        {
            if (change.isRemoval)
            {
                UnityEngine.Debug.Log("Can't apply an EntityChange, since it's Entity doesn't exist.");
                return;
            }

            //Debug.LogFormat("Entity with id {0} not found. Creating...", change.entityId);
            e = game.CreateEntity();
        }

        change.Apply(e);
        OnDidApply(message, change, e);
    }