blocks codegen

This commit is contained in:
Tnze
2022-03-09 10:08:44 +08:00
parent ec4eef2331
commit 86592931c6
902 changed files with 8657 additions and 0 deletions

28
level/block/block.go Normal file
View File

@ -0,0 +1,28 @@
package block
type Block interface {
ID() string
}
var toStateID = make(map[Block]int)
var fromStateID []Block
var fromID = make(map[string]Block)
func init() {
//regState := func(s Block) {
// if _, ok := toStateID[s]; ok {
// panic(fmt.Errorf("state %#v already exist", s))
// }
// toStateID[s] = len(fromStateID)
// fromStateID = append(fromStateID, s)
//}
//regBlock := func(b Block) {
// fromID[b.ID()] = b
// b.forEachState(regState)
//}
//regBlock(Air{})
}
func NewFromStateID(stateID int) Block {
return fromStateID[stateID]
}