public new static Entity Spawn(EntityUniverseFacade facade, Tile tile, Vector3I location) { var entity = new Entity(facade.AllocateNewEntityId(), false, KindCode, true); entity.Construct(GetBaseBlob(tile, location), facade); facade.AddEntity(entity); return(entity); }
public new static Entity Spawn(EntityUniverseFacade facade, Tile tile, Vector3I location) { var entity = new Entity(facade.AllocateNewEntityId(), false, KindCode, true); var blob = BlobAllocator.Blob(true); blob.SetString(nameof(tile), tile.Configuration.Code); blob.SetLong("variant", tile.Variant()); blob.FetchBlob(nameof(location)).SetVector3I(location); blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero); entity.Construct(blob, facade); facade.AddEntity(entity); return(entity); }
public static Entity Spawn(Vector3I position, Blob config, EntityUniverseFacade universe) { var entity = new Entity(universe.AllocateNewEntityId(), false, KindCode, true); var blob = BlobAllocator.Blob(true); blob.SetString("kind", KindCode); blob.FetchBlob("position").SetVector3D(position.ToTileCenterVector3D()); blob.FetchBlob("location").SetVector3I(position); blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero); blob.SetString("tile", config.GetString("tile")); entity.Construct(blob, universe); universe.AddEntity(entity); //var itemBlob = BlobAllocator.Blob(true); //itemBlob.SetString("kind", "staxel.item.Placer"); //itemBlob.SetString("tile", config.GetString("tile")); //var item = GameContext.ItemDatabase.SpawnItem(itemBlob, null); //if (item == Item.NullItem) { // return entity; //} //if (entity.Inventory == null) { // var inventory = new EntityInventory(entity); // entity.GetType().GetProperty("Inventory").GetSetMethod(true).Invoke(entity, new[] { inventory }); // var inventoryBlob = BlobAllocator.Blob(true); // inventoryBlob.SetLong("index", 0); // inventoryBlob.SetLong("swapIndex", 0); // inventoryBlob.SetLong("revision", 0); // entity.Inventory.RestoreFrom(inventoryBlob); //} //if (entity.Collections == null) { // var collections = new EntityCollections(entity); // entity.GetType().GetProperty("Collections").GetSetMethod(true).Invoke(entity, new[] { collections }); // var collectionBlob = BlobAllocator.Blob(true); // collectionBlob.SetLong("version", 2L); // collectionBlob.FetchBlob("items"); // collectionBlob.SetLong("count", 0L); // entity.Collections.RestoreFrom(collectionBlob); //} //entity.Inventory.SetActiveIndex(0); //entity.Inventory.GiveItem(new ItemStack(item, 1)); return(entity); }
public static Entity Spawn(EntityUniverseFacade facade, Tile tile, Vector3I location) { var spawnRecord = facade.AllocateNewEntityId(); var entity = new Entity(spawnRecord, false, KindCode, true); var blob = BlobAllocator.Blob(true); blob.SetString("tile", tile.Configuration.Code); blob.FetchBlob("location").SetVector3I(location); blob.SetLong("variant", tile.Variant()); blob.FetchBlob("position").SetVector3D(location.ToTileCenterVector3D()); entity.Construct(blob, facade); Blob.Deallocate(ref blob); facade.AddEntity(entity); return(entity); }
public static Entity Spawn(EntityUniverseFacade facade, Tile tile, Vector3I location) { Entity entity = new Entity(facade.AllocateNewEntityId(), false, StormMakerTileStateEntityBuilder.KindCode, true); Blob blob = BlobAllocator.Blob(true); blob.SetString(nameof(tile), tile.Configuration.Code); blob.FetchBlob(nameof(location)).SetVector3I(location); blob.SetLong("variant", (long)tile.Variant()); blob.FetchBlob("position").SetVector3D(location.ToTileCenterVector3D()); blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero); entity.Construct(blob, facade); Blob.Deallocate(ref blob); facade.AddEntity(entity); return(entity); }
public static Entity Spawn(Vector3I position, EntityUniverseFacade universe, Entity owner) { var entity = new Entity(universe.AllocateNewEntityId(), false, KindCode, true); var blob = BlobAllocator.Blob(true); blob.SetString("kind", KindCode); blob.FetchBlob("position").SetVector3D(position.ToTileCenterVector3D()); blob.FetchBlob("location").SetVector3I(position); blob.SetLong("owner", owner.Id.Id); entity.Construct(blob, universe); universe.AddEntity(entity); return(entity); }
public static Entity Spawn(Vector3I position, Blob config, EntityUniverseFacade universe) { var entity = new Entity(universe.AllocateNewEntityId(), false, KindCode, true); var blob = BlobAllocator.Blob(true); blob.SetString("kind", KindCode); blob.FetchBlob("position").SetVector3D(position.ToTileCenterVector3D()); blob.FetchBlob("location").SetVector3I(position); blob.FetchBlob("velocity").SetVector3D(Vector3D.Zero); blob.FetchBlob("config").MergeFrom(config); entity.Construct(blob, universe); universe.AddEntity(entity); return(entity); }
public static Entity Spawn(Vector3I position, EntityUniverseFacade universe, string owner, string uid, string bot = "nimbusfox.worldedit.entity.bot") { var entity = new Entity(universe.AllocateNewEntityId(), false, bot, true); var blob = BlobAllocator.Blob(true); blob.SetString("kind", bot); blob.FetchBlob("position").SetVector3D(position.ToTileCenterVector3D()); blob.FetchBlob("location").SetVector3I(position); blob.SetString("owner", owner); blob.SetString("uid", uid); entity.Construct(blob, universe); universe.AddEntity(entity); return(entity); }