public void PlaceWorldEntity(Tile tile, string worldObjectType) { var worldObjectData = ContentChest.WorldObjectData[worldObjectType]; var worldObjectTexture = ContentChest.WorldObjectTextures[worldObjectType]; var entity = new Entity(CurrentGameAreaEntityId) { X = tile.X, Y = tile.Y, Bounds = worldObjectData.Width == -1 ? new RectangleF(0, 0, worldObjectTexture.Width, worldObjectTexture.Height) : new RectangleF(0, 0, worldObjectData.Width, worldObjectData.Height), GameWorld = GameWorld, GameArea = this }; entity.AddComponent(new MoveComponent()); entity.AddComponent(new GravityComponent()); entity.AddComponent(new WorldObjectManagerComponent(worldObjectType)); if (worldObjectData.CanBeUsed) { var worldUseComponent = new UsableWorldObjectComponent(GameWorld.RequestClientPlayer?.Invoke(), worldObjectData); worldUseComponent.InRangeOfWorldObject += GameWorld.PlayerInRangeOfWorldObject; worldUseComponent.LeftRangeOfWorldObject += GameWorld.PlayerLeftRangeOfWorldObject; entity.AddComponent(worldUseComponent); } WorldObjects.Add(entity); GameWorld.AddTrackedEntity(entity); }
public ItemDrop DropItem(ItemDrop item) { item.GameWorld = GameWorld; item.GameArea = this; WorldItems.Add(item); GameWorld.AddTrackedEntity(item); return(item); }