aboutsummaryrefslogtreecommitdiff
path: root/source/resources/types/TileEntityType.cs
blob: cd405142a36dc76599815d6591f2813bbf33a8dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using Microsoft.Xna.Framework;
using MonoGame.Extended.Entities;

namespace Celesteia.Resources.Types {
    public class TileEntityType : IResourceType {
        private byte id;
        public byte GetID() => id;
        public void SetID(byte value) => id = value;

        public readonly Point Bounds;
        public readonly Point Origin;
        public readonly NamespacedKey PartKey;
        private Action<Entity> InstantiateAction;

        public TileEntityType(NamespacedKey part, Action<Entity> instantiate, int width, int height, int originX = 0, int originY = 0) {
            PartKey = part;
            InstantiateAction = instantiate;
            Bounds = new Point(width, height);
            Origin = new Point(originX, originY);
        }

        public void Instantiate(Entity entity) {
            InstantiateAction.Invoke(entity);
        }
    }
}