public IEntity CreateEntity(string prettyName = "") { ContentEntity added = new ContentEntity(EntityIdGenerator.Next(), prettyName); AddedEntities.Add(added); return(added); }
public static ContentEntity CreateContentEntity() { ContentEntity entity = new ContentEntity(); entity.Initialize(new ContentEntitySerializationFormat() { Data = new List <ContentEntity.DataInstance>(), PrettyName = "", UniqueId = _idGenerator.Next() }); return(entity); }
ITemplate ITemplateGroup.CreateTemplate() { ITemplate template = new ContentTemplate(TemplateIdGenerator.Next()); Templates.Add(template); return(template); }
public GameSnapshot() { EntityIdGenerator = new UniqueIntGenerator(); GlobalEntity = new ContentEntity(EntityIdGenerator.Next(), "Global Entity"); ActiveEntities = new List <IEntity>(); AddedEntities = new List <IEntity>(); RemovedEntities = new List <IEntity>(); _systems = new SystemSerializationContainer(); }
public void UniqueIntGeneratorConsumeStartsAtNextInt() { var gen = new UniqueIntGenerator(); gen.Consume(5); Assert.Equal(6, gen.Next()); gen.Consume(3); Assert.Equal(7, gen.Next()); gen.Consume(7); Assert.Equal(8, gen.Next()); gen.Consume(9); Assert.Equal(10, gen.Next()); gen.Consume(-32); gen.Consume(-35); gen.Consume(3); gen.Consume(-10000); Assert.Equal(11, gen.Next()); }
/// <summary> /// Returns the identifier/integer for the given type, constructing if it necessary. /// </summary> /// <param name="type">The type to get.</param> /// <returns>The identifier/integer</returns> public static int GetId(Type type) { if (type == typeof(Data.IData) || type == typeof(Data.IVersioned) || type == typeof(Data.NonVersioned) || type == typeof(Data.IConcurrent) || type == typeof(Data.ConcurrentNonVersioned) || typeof(Data.IData).IsAssignableFrom(type) == false) { throw new ArgumentException(string.Format("Type {0} is not a subtype of {1}", type, typeof(Data.IData))); } if (_ids.ContainsKey(type) == false) { _ids[type] = _idGenerator.Next(); } return(_ids[type]); }
public void UniqueIntGeneratorStartsAt0() { var gen = new UniqueIntGenerator(); Assert.Equal(0, gen.Next()); }
public static int GetUnorderedListMetadataIndex() { return(_unorderedListKeys.Next()); }