Beispiel #1
0
func (rs *RenderSystem) New(w *ecs.World) {
	for k := range rs.renders {
		rs.renders[k] = nil
	}
	rs.System = ecs.NewSystem()
	rs.world = w
	rs.ShouldSkipOnHeadless = true

	if !headless {
		if !Shaders.setup {
			Shaders.def.Initialize(Width(), Height())

			hud := &HUDShader{}
			hud.Initialize(Width(), Height())
			for i := HUDGround; i <= HighestGround; i++ {
				Shaders.Register(i, hud)
			}

			Shaders.setup = true
		}
	}

	Mailbox.Listen("renderChangeMessage", func(m Message) {
		rs.changed = true
	})
}
Beispiel #2
0
func (as *AudioSystem) New(*ecs.World) {
	as.System = ecs.NewSystem()

	if as.HeightModifier == 0 {
		as.HeightModifier = defaultHeightModifier
	}

	if err := al.OpenDevice(); err != nil {
		log.Println("Error initializing AudioSystem:", err)
		return
	}

	Mailbox.Listen("CameraMessage", func(msg Message) {
		_, ok := msg.(CameraMessage)
		if !ok {
			return
		}

		// Hopefully not that much of an issue, when we receive it before the CameraSystem does
		// TODO: but it is when the CameraMessage is not Incremental (i.e. the changes are big)
		al.SetListenerPosition(al.Vector{cam.X() / Width(), cam.Y() / Height(), cam.Z() * as.HeightModifier})
	})
}
Beispiel #3
0
func (cam *cameraSystem) New(*ecs.World) {
	cam.System = ecs.NewSystem()

	cam.x = WorldBounds.Max.X / 2
	cam.y = WorldBounds.Max.Y / 2
	cam.z = 1

	cam.AddEntity(ecs.NewEntity([]string{cam.Type()}))

	Mailbox.Listen("CameraMessage", func(msg Message) {
		cammsg, ok := msg.(CameraMessage)
		if !ok {
			return
		}

		if cammsg.Incremental {
			switch cammsg.Axis {
			case XAxis:
				cam.moveX(cammsg.Value)
			case YAxis:
				cam.moveY(cammsg.Value)
			case ZAxis:
				cam.zoom(cammsg.Value)
			}
		} else {
			switch cammsg.Axis {
			case XAxis:
				cam.moveToX(cammsg.Value)
			case YAxis:
				cam.moveToY(cammsg.Value)
			case ZAxis:
				cam.zoomTo(cammsg.Value)
			}
		}
	})
}
Beispiel #4
0
func (ns *NilSystem) New() {
	ns.System = ecs.NewSystem()
}
Beispiel #5
0
func (cs *CollisionSystem) New(*ecs.World) {
	cs.System = ecs.NewSystem()
}
Beispiel #6
0
func (as *AudioSystem) New(*ecs.World) {
	as.System = ecs.NewSystem()

	log.Println("Warning: audio is not yet implemented on Windows")
}
Beispiel #7
0
func (c *MouseZoomer) New(*ecs.World) {
	if !c.isSetup {
		c.System = ecs.NewSystem()
		c.isSetup = true
	}
}
Beispiel #8
0
func (c *EdgeScroller) New(*ecs.World) {
	if !c.isSetup {
		c.System = ecs.NewSystem()
		c.isSetup = true
	}
}
Beispiel #9
0
// New initializes the MouseSystem
func (m *MouseSystem) New(*ecs.World) {
	m.System = ecs.NewSystem()
}
Beispiel #10
0
func (a *AnimationSystem) New(*ecs.World) {
	a.System = ecs.NewSystem()
}