2020-11-22 16:02:42 -05:00
|
|
|
package d2components
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gravestench/akara"
|
|
|
|
)
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// static check that MainViewport implements Component
|
|
|
|
var _ akara.Component = &MainViewport{}
|
2020-11-22 16:02:42 -05:00
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// MainViewport is used to flag viewports as the main viewport of a scene
|
|
|
|
type MainViewport struct{}
|
2020-11-22 16:02:42 -05:00
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// New returns a new MainViewport instance. It is always a nil instance.
|
|
|
|
func (*MainViewport) New() akara.Component {
|
|
|
|
return (*MainViewport)(nil)
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
// MainViewportFactory is a wrapper for the generic component factory that returns MainViewport component instances.
|
|
|
|
// This can be embedded inside of a system to give them the methods for adding, retrieving, and removing a MainViewport.
|
|
|
|
type MainViewportFactory struct {
|
2020-12-08 16:38:46 -05:00
|
|
|
*akara.ComponentFactory
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|
|
|
|
|
2020-12-08 16:38:46 -05:00
|
|
|
// Add adds a MainViewport component to the given entity and returns it
|
|
|
|
func (m *MainViewportFactory) Add(id akara.EID) *MainViewport {
|
|
|
|
return m.ComponentFactory.Add(id).(*MainViewport)
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|
|
|
|
|
2020-12-08 16:38:46 -05:00
|
|
|
// Get returns the MainViewport component for the given entity, and a bool for whether or not it exists
|
|
|
|
func (m *MainViewportFactory) Get(id akara.EID) (*MainViewport, 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.(*MainViewport), found
|
2020-11-22 16:02:42 -05:00
|
|
|
}
|