/// <summary> /// Creates an entity from a template pulled from the entitydb /// </summary> /// <param name="entityTemplateName">name of the template</param> /// <returns>Created Entity</returns> public Entity CreateEntity(string entityTemplateName) { EntityTemplate template = _entityTemplateDatabase.GetTemplate(entityTemplateName); //TODO: Throw exception here return(template == null ? null : template.CreateEntity()); }
public AddEntityAction(EntityTemplate model, Vector2 position) : this() { this.model = model; this.position = position; Map map = EditorEngine.Instance.CurrentMap; this.worldEntity = model.CreateEntity(map.Factory); this.worldEntity.Position = position * new Vector2(16, 16); }
public void Draw(GameTime gameTime) { EntityTemplate model = FrmEntitySelector.Instance.selectedEntity; if (model != null && entered) { MapEntity entity = model.CreateEntity(EditorEngine.Instance.World.EntityFactory, true); entity.Opacity = .5f; entity.Color = Color.LightGray; entity.Position = new Vector2(xt * 16, yt * 16); entity.Shadow = false; entity.Draw(gameTime); } }
public GameScene(GameData data, SpriteBatch SpriteBatch) { this.SpriteBatch = SpriteBatch; this.UIManager = new UIManager(); this.Data = data; World = Data.RegionData.CreateWorld(this, SpriteBatch.GraphicsDevice); World.Maps.Add(Data.MapDatas[0].CreateMap(World)); EntityTemplate templatePlayer = World.EntityContainer.GetPlayers()[0]; Player = templatePlayer.CreateEntity(World.EntityFactory, true) as PlayerEntity; World.Player = Player; World.Maps[0].AddEntity(Player); new LivingController(Player); World.CurrentMap = Player.Map; this.SceneState = SceneState.Alive; }
public IEncodable Decode(General.Encoding.BinaryInput stream) { Name = stream.ReadString(); Author = stream.ReadString(); Width = stream.ReadInt32(); Height = stream.ReadInt32(); int c1 = stream.ReadInt32(); for (int i = 0; i < c1; i++) { Tilesets.Add(stream.ReadObject <MockupTileset>()); } /*Initialize Tiles jagged multidimensional array*/ this.Tiles = new MockupTile[Width][][]; for (int i = 0; i < Width; i++) { Tiles[i] = new MockupTile[Height][]; for (int j = 0; j < Height; j++) { Tiles[i][j] = new MockupTile[Map.LayerCount]; } } for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { for (int z = 0; z < LayerCount; z++) { Tiles[x][y][z] = stream.ReadObject <MockupTile>(); } } } int c2 = stream.ReadInt32(); for (int i = 0; i < c2; i++) { EntityTemplate e = stream.ReadObject <EntityTemplate>(); Entities.Add(e.CreateEntity(World.EntityFactory)); } return(this); }