當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ICreature.GetUID方法代碼示例

本文整理匯總了Golang中gameserver/interfaces.ICreature.GetUID方法的典型用法代碼示例。如果您正苦於以下問題:Golang ICreature.GetUID方法的具體用法?Golang ICreature.GetUID怎麽用?Golang ICreature.GetUID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gameserver/interfaces.ICreature的用法示例。


在下文中一共展示了ICreature.GetUID方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: OnCreatureMove

func (p *Player) OnCreatureMove(_creature interfaces.ICreature, _from position.Position, _to position.Position, _teleport bool) {
	// Call base function
	p.Creature.OnCreatureMove(_creature, _from, _to, _teleport)

	// Do nothing is creature is me
	if p.GetUID() == _creature.GetUID() {
		return
	}

	canSeeFromPosition := p.CanSeePosition(_from)
	canSeeToPosition := p.CanSeePosition(_to)

	if canSeeFromPosition && canSeeToPosition {
		// We can see both from and to positions, meaning the creature is moving inside the viewport
		p.netSendCreatureMove(_creature, _from, _to, _teleport)
	} else if canSeeFromPosition && !canSeeToPosition {
		// We can see the from position but not the to positioin, meaning the creature is leaving our viewport
		// Send CreatureMove message to client before removing the creature from the visible creatures list
		p.netSendCreatureMove(_creature, _from, _to, _teleport)

		p.RemoveVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(p)
	} else if !canSeeFromPosition && canSeeToPosition {
		// We can't see the from position but we can see the to position, meaning the creature is entering our viewport
		// First add the creature to our visible creature list before sending the CreatureMove message to the client
		p.AddVisibleCreature(_creature)
		_creature.AddVisibleCreature(p)

		p.netSendCreatureMove(_creature, _from, _to, _teleport)
	} else {
		// Somehow it's impossible to see the creature, may this ever happen somehow
		p.RemoveVisibleCreature(_creature)
		_creature.RemoveVisibleCreature(p)
	}
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:35,代碼來源:Player.go

示例2: KnowsVisibleCreature

func (c *Creature) KnowsVisibleCreature(_creature interfaces.ICreature) bool {
	c.visibleCreaturesMutex.RLock()
	defer c.visibleCreaturesMutex.RUnlock()

	_, found := c.visibleCreatures[_creature.GetUID()]
	return found
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:7,代碼來源:Creature.go

示例3: AddCreature

func (t *TilePointLayer) AddCreature(_creature interfaces.ICreature, _checkEvents bool) ReturnValue {
	ret := RET_NOERROR

	/*if _checkEvents && t.Events.Len() > 0 {
		for e := t.events.Front(); e != nil; e = e.Next() {
			event, valid := e.Value.(pulogic.ITileEvent)
			if valid {
				ret = event.OnCreatureEnter(_creature, ret)
			}

			if ret == RET_NOTPOSSIBLE {
				return
			}
		}
	}*/

	t.creaturesMutex.Lock()
	defer t.creaturesMutex.Unlock()
	_, found := t.creatures[_creature.GetUID()]
	if !found {
		t.creatures[_creature.GetUID()] = _creature
	}

	return ret
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:25,代碼來源:TilePointLayer.go

示例4: OnCreatureTurn

func (p *Player) OnCreatureTurn(_creature interfaces.ICreature) {
	p.Creature.OnCreatureTurn(_creature)

	// Do nothing is creature is me
	if p.GetUID() == _creature.GetUID() {
		return
	}

	p.netSendCreatureTurn(_creature)
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:10,代碼來源:Player.go

示例5: internalAddCreature

/***********************
	Private Methods
************************/
func internalAddCreature(_creature interfaces.ICreature) bool {
	_, found := g.creatures[_creature.GetUID()]

	if !found {
		g.creatures[_creature.GetUID()] = _creature
	} else {
		log.Warning("Game", "AddCreature", "Could not add creature. Creature with UID '%d' already exists", _creature.GetUID())
	}

	return !found
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:14,代碼來源:Game.go

示例6: RemoveVisibleCreature

func (c *Creature) RemoveVisibleCreature(_creature interfaces.ICreature) bool {
	if _creature.GetUID() != c.GetUID() {
		c.visibleCreaturesMutex.Lock()
		defer c.visibleCreaturesMutex.Unlock()

		delete(c.visibleCreatures, _creature.GetUID())

		return true
	}

	return false
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:12,代碼來源:Creature.go

示例7: AddVisibleCreature

// Methods for all creatures who need to see other creatures
func (c *Creature) AddVisibleCreature(_creature interfaces.ICreature) bool {
	if _creature.GetUID() != c.GetUID() {
		c.visibleCreaturesMutex.Lock()
		defer c.visibleCreaturesMutex.Unlock()

		if _, found := c.visibleCreatures[_creature.GetUID()]; !found {
			c.visibleCreatures[_creature.GetUID()] = _creature

			return true
		}
	}

	return false
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:15,代碼來源:Creature.go

示例8: OnCreatureMove

// Methods for all moving creatures
func (c *Creature) OnCreatureMove(_creature interfaces.ICreature, _from position.Position, _to position.Position, _teleport bool) {
	if _creature.GetUID() == c.GetUID() {
		c.lastStep = interfaces.PUSYS_TIME()
	}
}
開發者ID:toophy,項目名稱:go-gameserver,代碼行數:6,代碼來源:Creature.go


注:本文中的gameserver/interfaces.ICreature.GetUID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。