public ExtrudedTilemap(EtmManager manager, IAssetId id, string name, int tileCount, DungeonTileMapProperties properties, IPalette dayPalette, IPalette nightPalette) { if (dayPalette == null) { throw new ArgumentNullException(nameof(dayPalette)); } _manager = manager ?? throw new ArgumentNullException(nameof(manager)); _tiles = new MultiBuffer <DungeonTile>(tileCount, BufferUsage.VertexBuffer) { Name = $"B_Inst{name}" }; _properties = new SingleBuffer <DungeonTileMapProperties>(properties, BufferUsage.UniformBuffer) { Name = $"B_TileProps:{name}" }; AttachChild(_tiles); AttachChild(_properties); Name = name; _dayFloors = new CompositedTexture(id, "FloorTiles:" + name, dayPalette); _dayWalls = new CompositedTexture(id, "WallTiles:" + name, dayPalette); if (nightPalette != null) { _nightFloors = new CompositedTexture(id, "FloorTiles:" + name, nightPalette); _nightWalls = new CompositedTexture(id, "WallTiles:" + name, nightPalette); } OpaqueWindow = new EtmWindow($"{Name}_Opaque", this, tileCount, false); AlphaWindow = new EtmWindow($"{Name}_Alpha", this, tileCount, true); AttachChild(OpaqueWindow); AttachChild(AlphaWindow); }
public SimpleTexture(IAssetId id, string name, int width, int height, IEnumerable <Region> regions = null) { Id = id; Name = name; Width = width; Height = height; _pixelData = new T[Width * Height]; _regions = regions?.ToList() ?? new List <Region>(); }
public SimpleTexture(IAssetId id, int width, int height, IEnumerable <Region> regions = null) { Id = id ?? throw new ArgumentNullException(nameof(id)); Name = id.ToString(); Width = width; Height = height; _pixelData = new T[Width * Height]; _regions = regions?.ToList() ?? new List <Region>(); }
public ArrayTexture(IAssetId id, string name, int width, int height, int layers = 1, IEnumerable <Region> regions = null) { Id = id; Name = name; Width = width; Height = height; ArrayLayers = layers; _pixelData = new T[Width * Height * ArrayLayers]; _regions = regions?.ToList() ?? new List <Region>(); }
public SimpleTexture(IAssetId id, string name, int width, int height, ReadOnlySpan <T> pixelData, IEnumerable <Region> regions = null) { Id = id; Name = name; Width = width; Height = height; int pixelCount = Width * Height; if (pixelData.Length != pixelCount) { throw new ArgumentException($"A span of {pixelData.Length} pixels was given to create an image of dimensions {Width}x{Height} ({pixelCount} expected)"); } _pixelData = pixelData.ToArray(); _regions = regions?.ToList() ?? new List <Region>(); }
public static IReadOnlyTexture <T> CombineFramesVertically <T>(IAssetId id, IList <IReadOnlyTexture <T> > frames) where T : unmanaged { if (frames == null) { throw new ArgumentNullException(nameof(frames)); } int[] yOffsets = new int[frames.Count]; int currentY = 0; int totalWidth = 0; for (int i = 0; i < frames.Count; i++) { yOffsets[i] = currentY; currentY += frames[i].Height; if (frames[i].Width > totalWidth) { totalWidth = frames[i].Width; } } if (totalWidth == 0 || currentY == 0) { throw new InvalidOperationException($"Tried to combine frames, but the width or height was 0"); } var result = new SimpleTexture <T>(id, totalWidth, currentY); for (int i = 0; i < frames.Count; i++) { var fy = yOffsets[i]; var frame = frames[i]; result.AddRegion(0, fy, frame.Width, frame.Height); BlitDirect(frame.GetLayerBuffer(0), result.GetMutableRegionBuffer(i)); } return(result); }
public ITexture LoadTexture(IAssetId id) => (ITexture)_modApplier.LoadAsset(SpriteId.FromUInt32(id?.ToUInt32() ?? 0));
public static Sprite CharacterSprite(IAssetId id) =>