-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 重构 moving 包实现,移除对 game.Actor、game.Position2D 等接口的依赖
- Loading branch information
1 parent
d56ebde
commit 0a22f6d
Showing
6 changed files
with
81 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
package moving | ||
|
||
import "github.com/kercylan98/minotaur/game" | ||
import ( | ||
"github.com/kercylan98/minotaur/utils/generic" | ||
"github.com/kercylan98/minotaur/utils/geometry" | ||
) | ||
|
||
// TwoDimensionalEntity 2D移动对象接口定义 | ||
type TwoDimensionalEntity interface { | ||
game.Actor | ||
game.Position2D | ||
game.Position2DSet | ||
|
||
type TwoDimensionalEntity[EID generic.Basic, PosType generic.SignedNumber] interface { | ||
// GetTwoDimensionalEntityID 获取 Moving 对象 ID | ||
GetTwoDimensionalEntityID() EID | ||
// GetSpeed 获取移动速度 | ||
GetSpeed() float64 | ||
// GetPosition 获取位置 | ||
GetPosition() geometry.Point[PosType] | ||
// SetPosition 设置位置 | ||
SetPosition(geometry.Point[PosType]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
package moving | ||
|
||
import "github.com/kercylan98/minotaur/utils/generic" | ||
|
||
type ( | ||
Position2DChangeEventHandle func(moving *TwoDimensional, entity TwoDimensionalEntity, oldX, oldY float64) | ||
Position2DDestinationEventHandle func(moving *TwoDimensional, entity TwoDimensionalEntity) | ||
Position2DStopMoveEventHandle func(moving *TwoDimensional, entity TwoDimensionalEntity) | ||
Position2DChangeEventHandle[EID generic.Basic, PosType generic.SignedNumber] func(moving *TwoDimensional[EID, PosType], entity TwoDimensionalEntity[EID, PosType], oldX, oldY PosType) | ||
Position2DDestinationEventHandle[EID generic.Basic, PosType generic.SignedNumber] func(moving *TwoDimensional[EID, PosType], entity TwoDimensionalEntity[EID, PosType]) | ||
Position2DStopMoveEventHandle[EID generic.Basic, PosType generic.SignedNumber] func(moving *TwoDimensional[EID, PosType], entity TwoDimensionalEntity[EID, PosType]) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters