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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user