First attempt at character orientation
This commit is contained in:
@@ -49,24 +49,37 @@ func (a *AssetStore) AnimationsObject() (*Object, error) {
|
||||
return obj, nil
|
||||
}
|
||||
|
||||
func (a *AssetStore) Animation(groupIdx, recIdx int) (*Animation, error) {
|
||||
idx, err := a.AnimationsIndex()
|
||||
func (a *AssetStore) Animation(groupIdx int, recId int, compass int) (*Animation, error) {
|
||||
realIdx, err := a.AnimationsIndex()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// FIXME: are we using the right value if we need to make this change?
|
||||
if compass == 0 {
|
||||
compass = 8
|
||||
}
|
||||
|
||||
obj, err := a.AnimationsObject()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
group := idx.Groups[groupIdx]
|
||||
group := realIdx.Groups[groupIdx]
|
||||
if group.Spec.Count == 0 {
|
||||
return &Animation{}, nil
|
||||
}
|
||||
|
||||
// rec := group.Records[recIdx]
|
||||
det := group.Details[recIdx]
|
||||
var det *idx.Detail
|
||||
for i, rec := range group.Records {
|
||||
if /*int(rec.ActionID) == int(action) && */ int(rec.Compass) == compass {
|
||||
det = &group.Details[i]
|
||||
}
|
||||
}
|
||||
|
||||
if det == nil {
|
||||
return nil, fmt.Errorf("Couldn't find anim (%v %v %v)", groupIdx, recId, compass)
|
||||
}
|
||||
|
||||
first := int(group.Spec.SpriteIdx) + int(det.FirstSprite)
|
||||
last := int(group.Spec.SpriteIdx) + int(det.LastSprite)
|
||||
@@ -80,7 +93,7 @@ func (a *AssetStore) Animation(groupIdx, recIdx int) (*Animation, error) {
|
||||
return &Animation{Frames: sprites}, nil
|
||||
}
|
||||
|
||||
func (a *AssetStore) CharacterAnimation(ctype data.CharacterType, action data.AnimAction) (*Animation, error) {
|
||||
func (a *AssetStore) CharacterAnimation(ctype data.CharacterType, action data.AnimAction, compass int) (*Animation, error) {
|
||||
ha, err := a.HasAction()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -122,7 +135,5 @@ func (a *AssetStore) CharacterAnimation(ctype data.CharacterType, action data.An
|
||||
return nil, fmt.Errorf("Unknown character type: %s", ctype)
|
||||
}
|
||||
|
||||
rec := ha.Index(ctype, action)
|
||||
|
||||
return a.Animation(group, rec)
|
||||
return a.Animation(group, int(action), compass)
|
||||
}
|
||||
|
@@ -103,8 +103,8 @@ func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error) {
|
||||
sprites = append(sprites, sprite)
|
||||
}
|
||||
if chr := m.CharacterAt(x, y, z); chr != nil {
|
||||
// Look up the correct animation, get the frame, boom
|
||||
anim, err := m.assets.CharacterAnimation(chr.Type, data.AnimActionNone)
|
||||
// Look up the correct animation, get the frame, boom shakalaka
|
||||
anim, err := m.assets.CharacterAnimation(chr.Type, data.AnimActionNone, int(chr.Orientation))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -124,7 +124,9 @@ type Character struct {
|
||||
XPos int `struc:"byte"`
|
||||
Unknown7 []byte `struc:"[317]byte"`
|
||||
SquadNumber byte `struc:"byte"`
|
||||
Unknown8 []byte `struc:"[927]byte"`
|
||||
Unknown8 []byte `struc:"[895]byte"`
|
||||
Orientation byte `struc:"byte"`
|
||||
Unknown9 []byte `struc:"[31]byte"`
|
||||
// TODO: each character may have a fixed number of subrecords for inventory
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user