1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-30 15:15:56 -04:00
OpenDiablo2/d2core/d2object/init_function.go
Ziemas 3757ff1ac5
New package d2object, first object initFun (#537)
* Move MapEntity to d2interface

* New package d2object, first object initFun

Moves objects out to their own package and implements the very first
init function, torches/braziers now gets their animation mode set at creation.

* Apply name again

* Turn on waypoints
2020-07-04 00:48:31 -04:00

38 lines
725 B
Go

package d2object
import (
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
)
// Finds an init function for the given object
func initObject(ob *Object) bool {
funcs := map[int]func(*Object){
8: initTorch,
14: initTorch,
17: initWaypoint,
}
fun, ok := funcs[ob.objectRecord.InitFn]
if !ok {
return false
}
fun(ob)
return true
}
// Initializes torch/brazier type objects
func initTorch(ob *Object) {
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
ob.setMode("ON", 0)
}
}
func initWaypoint(ob *Object) {
// Turn these on unconditionally for now, they look nice :)
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
ob.setMode("ON", 0)
}
}