aboutsummaryrefslogtreecommitdiff
path: root/activeobject.go
blob: 6b61e5cbb6bf21fe24d65921d214b9277b326024 (plain) (blame)
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
28
29
30
31
package proxy

import "github.com/HimbeerserverDE/mt"

func (sc *ServerConn) swapAOID(ao *mt.AOID) {
	if sc.client() != nil {
		if *ao == sc.client().playerCAO {
			*ao = sc.client().currentCAO
		} else if *ao == sc.client().currentCAO {
			*ao = sc.client().playerCAO
		}
	}
}

func (sc *ServerConn) handleAOMsg(aoMsg mt.AOMsg) {
	switch msg := aoMsg.(type) {
	case *mt.AOCmdAttach:
		sc.swapAOID(&msg.Attach.ParentID)
	case *mt.AOCmdProps:
		for j := range msg.Props.Textures {
			prependTexture(sc.mediaPool, &msg.Props.Textures[j])
		}
		prepend(sc.mediaPool, &msg.Props.Mesh)
		prepend(sc.mediaPool, &msg.Props.Itemstring)
		prependTexture(sc.mediaPool, &msg.Props.DmgTextureMod)
	case *mt.AOCmdSpawnInfant:
		sc.swapAOID(&msg.ID)
	case *mt.AOCmdTextureMod:
		prependTexture(sc.mediaPool, &msg.Mod)
	}
}