Entitas.Context.SetUser C# (CSharp) Method

SetUser() public method

public SetUser ( System newTimestamp, bool newIsLoggedIn ) : Entity
newTimestamp System
newIsLoggedIn bool
return Entity
        public Entity SetUser(System.DateTime newTimestamp, bool newIsLoggedIn)
        {
            if(hasUser) {
                throw new EntitasException("Could not set user!\n" + this + " already has an entity with UserComponent!",
                    "You should check if the context already has a userEntity before setting it or use context.ReplaceUser().");
            }
            var entity = CreateEntity();
            entity.AddUser(newTimestamp, newIsLoggedIn);
            return entity;
        }

Same methods

Context::SetUser ( string newName, int newAge ) : Entity

Usage Example

Example #1
0
        #pragma warning disable
        static void userComponent(Context context, UserComponent component) {
            var e = context.userEntity;
            var name = context.user.name;
            var has = context.hasUser;

            context.SetUser("John", 42);
            context.ReplaceUser("Max", 24);
            context.RemoveUser();
        }