mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-01-14 05:16:43 -05:00
Only draw shadows for layers that should have them (#704)
* Don't draw shadows for transparent layers * Also use cof shadow setting
This commit is contained in:
parent
8d87c19532
commit
dccb930f5c
@ -40,3 +40,11 @@ const (
|
|||||||
// no effect
|
// no effect
|
||||||
DrawEffectNone
|
DrawEffectNone
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (d DrawEffect) Transparent() bool {
|
||||||
|
if d == DrawEffectNone {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
@ -38,4 +38,5 @@ type Animation interface {
|
|||||||
GetPlayedCount() int
|
GetPlayedCount() int
|
||||||
ResetPlayedCount()
|
ResetPlayedCount()
|
||||||
SetEffect(effect d2enum.DrawEffect)
|
SetEffect(effect d2enum.DrawEffect)
|
||||||
|
SetShadow(shadow bool)
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ type animation struct {
|
|||||||
originAtBottom bool
|
originAtBottom bool
|
||||||
playLoop bool
|
playLoop bool
|
||||||
hasSubLoop bool // runs after first animation ends
|
hasSubLoop bool // runs after first animation ends
|
||||||
|
hasShadow bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSubLoop sets a sub loop for the animation
|
// SetSubLoop sets a sub loop for the animation
|
||||||
@ -158,7 +159,7 @@ func (a *animation) RenderFromOrigin(target d2iface.Surface, shadow bool) error
|
|||||||
defer target.Pop()
|
defer target.Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
if shadow {
|
if shadow && !a.effect.Transparent() && a.hasShadow {
|
||||||
_, height := a.GetFrameBounds()
|
_, height := a.GetFrameBounds()
|
||||||
height = int(math.Abs(float64(height)))
|
height = int(math.Abs(float64(height)))
|
||||||
|
|
||||||
@ -338,3 +339,7 @@ func (a *animation) ResetPlayedCount() {
|
|||||||
func (a *animation) SetEffect(e d2enum.DrawEffect) {
|
func (a *animation) SetEffect(e d2enum.DrawEffect) {
|
||||||
a.effect = e
|
a.effect = e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *animation) SetShadow(shadow bool) {
|
||||||
|
a.hasShadow = shadow
|
||||||
|
}
|
||||||
|
@ -275,6 +275,7 @@ func (c *Composite) createMode(animationMode animationMode, weaponClass string)
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
layer.SetPlaySpeed(mode.animationSpeed)
|
layer.SetPlaySpeed(mode.animationSpeed)
|
||||||
layer.PlayForward()
|
layer.PlayForward()
|
||||||
|
layer.SetShadow(cofLayer.Shadow != 0)
|
||||||
|
|
||||||
if err := layer.SetDirection(c.direction); err != nil {
|
if err := layer.SetDirection(c.direction); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user