2020-11-22 16:02:42 -05:00
|
|
|
//nolint:dupl,golint,stylecheck // component declarations are supposed to look the same
|
2020-10-13 04:19:38 -04:00
|
|
|
package d2components
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gravestench/akara"
|
|
|
|
)
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// static check that FontTable implements Component
|
|
|
|
var _ akara.Component = &FontTable{}
|
2020-10-13 04:19:38 -04:00
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// FontTable is a component that contains font table data as a byte slice
|
|
|
|
type FontTable struct {
|
2020-10-13 04:19:38 -04:00
|
|
|
Data []byte
|
|
|
|
}
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// New returns a FontTable component. By default, Data is a nil instance.
|
|
|
|
func (*FontTable) New() akara.Component {
|
|
|
|
return &FontTable{}
|
2020-10-13 04:19:38 -04:00
|
|
|
}
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// FontTableFactory is a wrapper for the generic component factory that returns FontTable component instances.
|
|
|
|
// This can be embedded inside of a system to give them the methods for adding, retrieving, and removing a FontTable.
|
|
|
|
type FontTableFactory struct {
|
2020-12-08 16:38:46 -05:00
|
|
|
*akara.ComponentFactory
|
2020-10-13 04:19:38 -04:00
|
|
|
}
|
|
|
|
|
2020-12-08 16:38:46 -05:00
|
|
|
// Add adds a FontTable component to the given entity and returns it
|
|
|
|
func (m *FontTableFactory) Add(id akara.EID) *FontTable {
|
|
|
|
return m.ComponentFactory.Add(id).(*FontTable)
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|
|
|
|
|
2020-12-08 16:38:46 -05:00
|
|
|
// Get returns the FontTable component for the given entity, and a bool for whether or not it exists
|
|
|
|
func (m *FontTableFactory) Get(id akara.EID) (*FontTable, bool) {
|
|
|
|
component, found := m.ComponentFactory.Get(id)
|
2020-11-28 00:45:58 -05:00
|
|
|
if !found {
|
|
|
|
return nil, found
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
return component.(*FontTable), found
|
2020-10-13 04:19:38 -04:00
|
|
|
}
|