コード例 #1
0
func (resource *WorkspaceResource) objectEntity(project *core.Project, objID res.ObjectID) (entity model.GameObject) {
	entity.ID = fmt.Sprintf("%d/%d/%d", objID.Class, objID.Subclass, objID.Type)
	entity.Href = "/projects/" + project.Name() + "/objects/" + entity.ID
	entity.Properties = project.GameObjects().Properties(objID)

	return
}
コード例 #2
0
func getLevelTileEntity(project *core.Project, level *core.Level, x int, y int) (entity model.Tile) {
	entity.Href = "/projects/" + project.Name() + "/archive/levels/" + fmt.Sprintf("%d", level.ID()) +
		"/tiles/" + fmt.Sprintf("%d", y) + "/" + fmt.Sprintf("%d", x)
	entity.Properties = level.TileProperties(int(x), int(y))

	return
}
コード例 #3
0
func (resource *WorkspaceResource) textureEntity(project *core.Project, textureID int) (entity model.Texture) {
	entity.ID = fmt.Sprintf("%d", textureID)
	entity.Href = "/projects/" + project.Name() + "/textures/" + entity.ID
	entity.Properties = project.Textures().Properties(textureID)
	for _, size := range model.TextureSizes() {
		entity.Images = append(entity.Images, model.Link{Rel: string(size), Href: entity.Href + "/" + string(size)})
	}

	return
}
コード例 #4
0
func (resource *WorkspaceResource) getLevelEntity(project *core.Project, archive *core.Archive, levelID int) (entity model.Level) {
	entity.ID = fmt.Sprintf("%d", levelID)
	entity.Href = "/projects/" + project.Name() + "/archive/levels/" + entity.ID
	level := archive.Level(levelID)
	entity.Properties = level.Properties()

	entity.Links = []model.Link{}
	entity.Links = append(entity.Links, model.Link{Rel: "tiles", Href: entity.Href + "/tiles/{y}/{x}"})
	if !entity.Properties.CyberspaceFlag {
		entity.Links = append(entity.Links, model.Link{Rel: "textures", Href: entity.Href + "/textures"})
	}

	return
}