public GameEntity ReplaceTime(Assets.Code.Services.ITimeService newValue) { var index = GameComponentsLookup.Time; var component = (Assets.Code.Components.Time)CreateComponent(index, typeof(Assets.Code.Components.Time)); component.Value = newValue; ReplaceComponent(index, component); return(this); }
public GameEntity SetTime(Assets.Code.Services.ITimeService newValue) { if (hasTime) { throw new Entitas.EntitasException("Could not set Time!\n" + this + " already has an entity with Assets.Code.Components.Time!", "You should check if the context already has a timeEntity before setting it or use context.ReplaceTime()."); } var entity = CreateEntity(); entity.AddTime(newValue); return(entity); }
public void ReplaceTime(Assets.Code.Services.ITimeService newValue) { var entity = timeEntity; if (entity == null) { entity = SetTime(newValue); } else { entity.ReplaceTime(newValue); } }