当前位置: 首页>>代码示例>>Golang>>正文


Golang base.GetObject函数代码示例

本文整理汇总了Golang中github.com/runningwild/haunts/base.GetObject函数的典型用法代码示例。如果您正苦于以下问题:Golang GetObject函数的具体用法?Golang GetObject怎么用?Golang GetObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetObject函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: MakeHouseFromName

func MakeHouseFromName(name string) *HouseDef {
	var idiot iamanidiotcontainer
	idiot.Defname = name
	base.GetObject("houses", &idiot)
	idiot.HouseDef.setDoorsOpened(false)
	return idiot.HouseDef
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:7,代码来源:house.go

示例2: Reload

func (he *HouseEditor) Reload() {
	for _, floor := range he.house.Floors {
		for i := range floor.Rooms {
			base.GetObject("rooms", floor.Rooms[i])
		}
	}
	for _, tab := range he.widgets {
		tab.Reload()
	}
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:10,代码来源:house.go

示例3: registerInteracts

func registerInteracts() map[string]func() game.Action {
	interact_actions := make(map[string]*InteractDef)
	base.RemoveRegistry("actions-interact_actions")
	base.RegisterRegistry("actions-interact_actions", interact_actions)
	base.RegisterAllObjectsInDir("actions-interact_actions", filepath.Join(base.GetDataDir(), "actions", "interacts"), ".json", "json")
	makers := make(map[string]func() game.Action)
	for name := range interact_actions {
		cname := name
		makers[cname] = func() game.Action {
			a := Interact{Defname: cname}
			base.GetObject("actions-interact_actions", &a)
			return &a
		}
	}
	return makers
}
开发者ID:RickDakan,项目名称:haunts,代码行数:16,代码来源:interact.go

示例4: registerMoves

func registerMoves() map[string]func() game.Action {
	move_actions := make(map[string]*MoveDef)
	base.RemoveRegistry("actions-move_actions")
	base.RegisterRegistry("actions-move_actions", move_actions)
	base.RegisterAllObjectsInDir("actions-move_actions", filepath.Join(base.GetDataDir(), "actions", "movement"), ".json", "json")
	makers := make(map[string]func() game.Action)
	for name := range move_actions {
		cname := name
		makers[cname] = func() game.Action {
			a := Move{Defname: cname}
			base.GetObject("actions-move_actions", &a)
			return &a
		}
	}
	return makers
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:16,代码来源:move.go

示例5: registerBasicConditions

func registerBasicConditions() {
	registry_name := "conditions-basic_conditions"
	base.RemoveRegistry(registry_name)
	base.RegisterRegistry(registry_name, make(map[string]*BasicConditionDef))
	base.RegisterAllObjectsInDir(registry_name, filepath.Join(base.GetDataDir(), "conditions", "basic_conditions"), ".json", "json")
	names := base.GetAllNamesInRegistry(registry_name)
	for _, name := range names {
		cname := name
		f := func() Condition {
			c := BasicCondition{Defname: cname}
			base.GetObject(registry_name, &c)
			return &c
		}
		condition_makers[name] = f
	}
}
开发者ID:RickDakan,项目名称:haunts,代码行数:16,代码来源:conditions.go

示例6: registerSummonActions

func registerSummonActions() map[string]func() game.Action {
	summons_actions := make(map[string]*SummonActionDef)
	base.RemoveRegistry("actions-summons_actions")
	base.RegisterRegistry("actions-summons_actions", summons_actions)
	base.RegisterAllObjectsInDir("actions-summons_actions", filepath.Join(base.GetDataDir(), "actions", "summons"), ".json", "json")
	makers := make(map[string]func() game.Action)
	for name := range summons_actions {
		cname := name
		makers[cname] = func() game.Action {
			a := SummonAction{Defname: cname}
			base.GetObject("actions-summons_actions", &a)
			if a.Ammo > 0 {
				a.Current_ammo = a.Ammo
			} else {
				a.Current_ammo = -1
			}
			return &a
		}
	}
	return makers
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:21,代码来源:summon.go

示例7: SetGear

func (e *Entity) SetGear(gear_name string) bool {
	if e.ExplorerEnt == nil {
		base.Error().Printf("Tried to set gear on a non-explorer entity.")
		return false
	}
	if e.ExplorerEnt.Gear != nil && gear_name != "" {
		base.Error().Printf("Tried to set gear on an explorer that already had gear.")
		return false
	}
	if e.ExplorerEnt.Gear == nil && gear_name == "" {
		base.Error().Printf("Tried to remove gear from an explorer with no gear.")
		return false
	}
	if gear_name == "" {
		algorithm.Choose2(&e.Actions, func(a Action) bool {
			return a.String() != e.ExplorerEnt.Gear.Action
		})
		if e.ExplorerEnt.Gear.Condition != "" {
			e.Stats.RemoveCondition(e.ExplorerEnt.Gear.Condition)
		}
		e.ExplorerEnt.Gear = nil
		return true
	}
	var g Gear
	g.Defname = gear_name
	base.GetObject("gear", &g)
	if g.Name == "" {
		base.Error().Printf("Tried to load gear '%s' that doesn't exist.", gear_name)
		return false
	}
	e.ExplorerEnt.Gear = &g
	if g.Action != "" {
		e.Actions = append(e.Actions, MakeAction(g.Action))
	}
	if g.Condition != "" {
		e.Stats.ApplyCondition(status.MakeCondition(g.Condition))
	}
	return true
}
开发者ID:RickDakan,项目名称:haunts,代码行数:39,代码来源:entity.go

示例8: makeHouseDataTab

func makeHouseDataTab(house *HouseDef, viewer *HouseViewer) *houseDataTab {
	var hdt houseDataTab
	hdt.VerticalTable = gui.MakeVerticalTable()
	hdt.house = house
	hdt.viewer = viewer

	hdt.name = gui.MakeTextEditLine("standard", "name", 300, 1, 1, 1, 1)
	num_floors_options := []string{"1 Floor", "2 Floors", "3 Floors", "4 Floors"}
	hdt.num_floors = gui.MakeComboTextBox(num_floors_options, 300)
	if hdt.house.Icon.Path == "" {
		hdt.house.Icon.Path = base.Path(filepath.Join(datadir, "houses", "icons"))
	}
	hdt.icon = gui.MakeFileWidget(string(hdt.house.Icon.Path), imagePathFilter)

	hdt.VerticalTable.AddChild(hdt.name)
	hdt.VerticalTable.AddChild(hdt.num_floors)
	hdt.VerticalTable.AddChild(hdt.icon)

	names := GetAllRoomNames()
	room_buttons := gui.MakeVerticalTable()
	for _, name := range names {
		n := name
		room_buttons.AddChild(gui.MakeButton("standard", name, 300, 1, 1, 1, 1, func(int64) {
			if hdt.temp_room != nil {
				return
			}
			hdt.temp_room = &Room{Defname: n}
			base.GetObject("rooms", hdt.temp_room)
			hdt.temp_room.temporary = true
			hdt.temp_room.invalid = true
			hdt.house.Floors[0].Rooms = append(hdt.house.Floors[0].Rooms, hdt.temp_room)
			hdt.drag_anchor.x = float32(hdt.temp_room.Size.Dx / 2)
			hdt.drag_anchor.y = float32(hdt.temp_room.Size.Dy / 2)
		}))
	}
	scroller := gui.MakeScrollFrame(room_buttons, 300, 700)
	hdt.VerticalTable.AddChild(scroller)
	return &hdt
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:39,代码来源:house.go

示例9: MakeEntity

func MakeEntity(name string, g *Game) *Entity {
	ent := Entity{Defname: name}
	base.GetObject("entities", &ent)

	for _, action_name := range ent.Action_names {
		ent.Actions = append(ent.Actions, MakeAction(action_name))
	}

	if ent.Side() == SideHaunt || ent.Side() == SideExplorers {
		stats := status.MakeInst(ent.Base)
		stats.OnBegin()
		ent.Stats = &stats
	}

	ent.Info = makeInfo()

	ent.Id = g.Entity_id
	g.Entity_id++

	ent.Load(g)
	g.all_ents_in_memory[&ent] = true

	return &ent
}
开发者ID:RickDakan,项目名称:haunts,代码行数:24,代码来源:entity.go

示例10: Load

func (wt *WallTexture) Load() {
	base.GetObject("wall_textures", wt)
}
开发者ID:RickDakan,项目名称:haunts,代码行数:3,代码来源:wall_texture.go

示例11: MakeGear

func MakeGear(name string) *Gear {
	g := Gear{Defname: name}
	base.GetObject("gear", &g)
	return &g
}
开发者ID:RickDakan,项目名称:haunts,代码行数:5,代码来源:gear.go

示例12: Load

func (d *Door) Load() {
	base.GetObject("doors", d)
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:3,代码来源:house.go

示例13: LuaPushEntity

// Pushes an entity onto the stack, it is a table containing the following:
// e.id -> EntityId of this entity
// e.name -> Name as displayed to the user
// e.gear_options -> Table mapping gear to icon for all available gear
// e.gear -> Name of the selected gear, nil if none is selected
// e.actions -> Array of actions this entity has available
func LuaPushEntity(L *lua.State, ent *Entity) {
	if ent == nil {
		L.PushNil()
		return
	}
	// id and Name can be added to the ent table as static data since they
	// never change.
	L.NewTable()
	L.PushString("Name")
	L.PushString(ent.Name)
	L.SetTable(-3)
	L.PushString("id")
	L.PushInteger(int(ent.Id))
	L.SetTable(-3)
	L.PushString("type")
	L.PushString("Entity")
	L.SetTable(-3)

	// Meta table for the Entity so that any dynamic data is generated
	// on-the-fly
	LuaPushSmartFunctionTable(L, FunctionTable{
		"Conditions": func() {
			L.NewTable()
			for _, condition := range ent.Stats.ConditionNames() {
				L.PushString(condition)
				L.PushBoolean(true)
				L.SetTable(-3)
			}
		},
		"Side": func() {
			L.NewTable()
			sides := map[string]Side{
				"Denizen":  SideHaunt,
				"Intruder": SideExplorers,
				"Npc":      SideNpc,
				"Object":   SideObject,
			}
			for str, side := range sides {
				L.PushString(str)
				L.PushBoolean(ent.Side() == side)
				L.SetTable(-3)
			}
		},
		"State": func() {
			L.PushString(ent.Sprite().State())
		},
		"Master": func() {
			L.NewTable()
			for key, val := range ent.Ai_data {
				L.PushString(key)
				L.PushString(val)
				L.SetTable(-3)
			}
		},
		"GearOptions": func() {
			L.NewTable()
			if ent.ExplorerEnt != nil {
				for _, gear_name := range ent.ExplorerEnt.Gear_names {
					var g Gear
					g.Defname = gear_name
					base.GetObject("gear", &g)
					L.PushString(gear_name)
					L.PushString(g.Large_icon.Path.String())
					L.SetTable(-3)
				}
			}
		},
		"Gear": func() {
			if ent.ExplorerEnt != nil && ent.ExplorerEnt.Gear != nil {
				L.PushString(ent.ExplorerEnt.Gear.Name)
			} else {
				L.PushNil()
			}
		},
		"Actions": func() {
			L.NewTable()
			for _, action := range ent.Actions {
				L.PushString(action.String())
				action.Push(L)
				L.SetTable(-3)
			}
		},
		"Pos": func() {
			x, y := ent.Pos()
			LuaPushPoint(L, x, y)
		},
		"Corpus": func() {
			L.PushInteger(ent.Stats.Corpus())
		},
		"Ego": func() {
			L.PushInteger(ent.Stats.Ego())
		},
		"HpCur": func() {
			L.PushInteger(ent.Stats.HpCur())
//.........这里部分代码省略.........
开发者ID:FlyingCar,项目名称:haunts,代码行数:101,代码来源:script_utils.go

示例14: GobDecode

func (g *Game) GobDecode(data []byte) error {
	g.gameDataPrivate = gameDataPrivate{}
	for ent := range g.all_ents_in_memory {
		ent.Release()
	}
	if g.Ai.intruders != nil {
		g.Ai.intruders.Terminate()
	}
	if g.Ai.minions != nil {
		g.Ai.minions.Terminate()
	}
	if g.Ai.denizens != nil {
		g.Ai.denizens.Terminate()
	}

	g.gameDataGobbable = gameDataGobbable{}

	dec := gob.NewDecoder(bytes.NewBuffer(data))
	if err := dec.Decode(&g.gameDataGobbable); err != nil {
		return err
	}

	base.ProcessObject(reflect.ValueOf(g.House), "")
	g.House.Normalize()
	g.viewer = house.MakeHouseViewer(g.House, 62)
	g.viewer.Edit_mode = true
	for _, ent := range g.Ents {
		base.GetObject("entities", ent)
	}
	g.setup()
	for _, ent := range g.Ents {
		ent.Load(g)
	}
	var sss []sprite.SpriteState
	if err := dec.Decode(&sss); err != nil {
		return err
	}
	if len(sss) != len(g.Ents) {
		return errors.New("SpriteStates were not recorded properly.")
	}
	for i := range sss {
		g.Ents[i].Sprite().SetSpriteState(sss[i])
	}

	// If Ais were bound then their paths will be listed here and we have to
	// reload them
	if g.Ai.Path.Denizens != "" {
		ai_maker(g.Ai.Path.Denizens, g, nil, &g.Ai.denizens, DenizensAi)
	}
	if g.Ai.denizens == nil {
		g.Ai.denizens = inactiveAi{}
	}
	if g.Ai.Path.Intruders != "" {
		ai_maker(g.Ai.Path.Intruders, g, nil, &g.Ai.intruders, IntrudersAi)
	}
	if g.Ai.intruders == nil {
		g.Ai.intruders = inactiveAi{}
	}
	if g.Ai.Path.Minions != "" {
		ai_maker(g.Ai.Path.Minions, g, nil, &g.Ai.minions, MinionsAi)
	}
	if g.Ai.minions == nil {
		g.Ai.minions = inactiveAi{}
	}

	return nil
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:67,代码来源:los.go

示例15: MakeEntityPlacer

func MakeEntityPlacer(game *Game, roster_names []string, roster_costs []int, min, max int, pattern string) (*EntityPlacer, <-chan []*Entity, error) {
	var ep EntityPlacer
	err := base.LoadAndProcessObject(filepath.Join(base.GetDataDir(), "ui", "entity_placer", "config.json"), "json", &ep.layout)
	if err != nil {
		return nil, nil, err
	}
	if len(roster_names) != len(roster_costs) {
		return nil, nil, errors.New("Must have as many names as costs.")
	}
	if len(roster_names) <= 0 || len(roster_names) > ep.layout.Roster.Max_options {
		return nil, nil, errors.New(fmt.Sprintf("Can't have more than %d ents in a roster.", ep.layout.Roster.Max_options))
	}

	ep.layout.Undo.valid_func = func() bool {
		return len(ep.ents) > 0
	}
	ep.layout.Undo.f = func(interface{}) {
		ent := ep.ents[len(ep.ents)-1]
		ep.points += ep.roster[ent.Name]
		ep.ents = ep.ents[0 : len(ep.ents)-1]
		algorithm.Choose2(&game.Ents, func(e *Entity) bool { return e != ent })
		game.viewer.RemoveDrawable(ent)
	}

	ep.layout.Done.valid_func = func() bool {
		return ep.points >= 0 && min <= (max-ep.points)
	}
	done := make(chan []*Entity)
	ep.layout.Done.f = func(interface{}) {
		done <- ep.ents
		close(done)
		house.PopSpawnRegexp()
		game.viewer.RemoveDrawable(game.new_ent)
		game.new_ent = nil
	}
	ep.roster_names = roster_names
	ep.roster = make(map[string]int)
	for i, name := range ep.roster_names {
		ep.roster[name] = roster_costs[i]
	}
	ep.game = game
	ep.show_points = !(min == 1 && max == 1)
	ep.points = max
	ep.pattern = pattern
	house.PushSpawnRegexp(ep.pattern)
	x := ep.layout.Roster.X
	for _, name := range ep.roster_names {
		var b Button
		b.X = x
		x += (ep.layout.Roster.X2 - ep.layout.Roster.X) / (ep.layout.Roster.Max_options - 1)
		b.Y = ep.layout.Roster.Y
		ent := Entity{Defname: name}
		base.GetObject("entities", &ent)
		b.Texture = ent.Still
		cost := ep.roster[name]
		b.valid_func = func() bool {
			return ep.points >= cost
		}
		b.f = func(interface{}) {
			ep.game.viewer.RemoveDrawable(ep.game.new_ent)
			ep.game.new_ent = MakeEntity(ent.Name, ep.game)
			ep.game.viewer.AddDrawable(ep.game.new_ent)
		}
		ep.ent_buttons = append(ep.ent_buttons, &b)
	}

	ep.buttons = []*Button{
		&ep.layout.Undo,
		&ep.layout.Done,
	}
	for _, b := range ep.ent_buttons {
		ep.buttons = append(ep.buttons, b)
	}

	return &ep, done, nil
}
开发者ID:ThalwegIII,项目名称:haunts,代码行数:76,代码来源:ui_entity_placer.go


注:本文中的github.com/runningwild/haunts/base.GetObject函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。