Example #1
0
func init() {
	world.Register("door", world.Visible((*Door)(nil)))
	world.RegisterSpawnFunc(func(s string) world.Visible {
		if s == "door" {
			return &Door{}
		}
		return nil
	})
}
Example #2
0
func init() {
	world.Register("forge", world.Visible((*Forge)(nil)))
	world.RegisterSpawnFunc(func(s string) world.Visible {
		if s == "forge" {
			return &Forge{}
		}
		return nil
	})
}
Example #3
0
func init() {
	world.Register("floor", world.Visible((*Floor)(nil)))
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		if s == "floor" {
			return &Floor{
				material: material,
			}
		}
		return nil
	}))
}
Example #4
0
func init() {
	world.Register("wall", world.Visible((*Wall)(nil)))
	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		if s == "wall" {
			return &Wall{
				material: material,
			}
		}
		return nil
	}))
}
Example #5
0
func init() {
	world.Register("ingot", world.Visible((*Ingot)(nil)))

	world.RegisterSpawnFunc(WrapSpawnFunc(func(material *Material, s string) world.Visible {
		wood, stone, metal := material.Get()
		if len(wood) != 0 || len(stone) != 0 || len(metal) == 0 {
			return nil
		}
		if s == "ingot" {
			return &Ingot{
				material: material,
			}
		}
		return nil
	}))
}
Example #6
0
func init() {
	world.Register("equip", world.Visible((*Equip)(nil)))

	world.RegisterSpawnFunc(material.WrapSpawnFunc(func(mat *material.Material, s string) world.Visible {
		wood, stone, metal := mat.Get()
		for t := range equippables {
			for i, e := range equippables[t] {
				if e.name == s {
					haveWood := false
					haveStone := false
					haveMetal := false
					for _, c := range e.colors {
						if c == woodColor {
							haveWood = true
						}
						if c == stoneColor {
							haveStone = true
						}
						if c == metalColor {
							haveMetal = true
						}
					}
					if !haveWood && len(wood) != 0 {
						continue
					}
					if !haveStone && len(stone) != 0 {
						continue
					}
					if !haveMetal && len(metal) != 0 {
						continue
					}
					return &Equip{
						slot:      EquipSlot(t),
						kind:      uint64(i),
						materials: []*material.Material{mat},
					}
				}
			}
		}
		return nil
	}))
}
Example #7
0
func init() {
	world.Register("logs", world.Visible((*Logs)(nil)))
}
Example #8
0
func init() {
	world.Register("ore", world.Visible((*Ore)(nil)))
}
Example #9
0
func init() {
	world.Register("stone", world.Visible((*Stone)(nil)))
}
Example #10
0
func init() {
	world.Register("slime", world.Visible((*Slime)(nil)))
}