ecs/servers/game/logic/player_rig.go
2025-06-04 18:17:39 +08:00

391 lines
12 KiB
Go

package logic
//type PlayerRig struct {
// Head uint32 `bson:"head"` //itemId
// Body uint32 `bson:"body"` //itemId
// Tail uint32 `bson:"tail"` //itemId
// Team uint32 `bson:"team"` //teams index
// Warship uint32 `bson:"warship"` //uid
//
// Teams proto.Teams `bson:"teams"` //itemId
// Equips proto.Equips `bson:"equips"` //itemId
// Pendants proto.Pendants `bson:"pendants"` //itemId
//
// Attrs proto.Attrs `bson:"-"`
//}
//
//func NewRig() *PlayerRig {
// return &PlayerRig{}
//}
//
//func (this *Player) rigBaseAttrs() (attrs proto.Attrs) {
// var attributeConfigTables = this.manager.tables.AttributeConfig.List()
// for _, attributeConfigTable := range attributeConfigTables {
// if attributeConfigTable.Id > len(attrs) {
// continue
// }
// if attributeConfigTable.Id > 0 && attributeConfigTable.Id <= proto.AttrNum {
// attrs[attributeConfigTable.Id-1] = attributeConfigTable.DefVal
// }
// }
// return
//}
//
//func (this *Player) rigComponentAttrs() (attrs proto.Attrs) {
// for _, component := range this.RigComponent {
// var componentTable = this.manager.tables.RigComponent.Get(int(component.Id))
// if componentTable == nil {
// continue
// }
//
// if component.Setup {
// if componentTable.CarryAttrType1 > 0 && componentTable.CarryAttrType1 <= proto.AttrNum {
// attrs[componentTable.CarryAttrType1-1] += float64(componentTable.CarryAttrValue1)
// }
// } else {
// if componentTable.AttrType1 > 0 && componentTable.AttrType1 <= proto.AttrNum {
// attrs[componentTable.AttrType1-1] += float64(componentTable.AttrValue1)
// }
// }
// }
// return
//}
//
//func (this *Player) rigEquipsAttrs() (attrs proto.Attrs) {
// for _, equip := range this.RigEquip {
// var equipTable = this.manager.tables.RigEquip.Get(int(equip.Id))
// if equipTable == nil {
// continue
// }
//
// if equip.Setup {
// if equipTable.CarryAttrType1 > 0 && equipTable.CarryAttrType1 <= proto.AttrNum {
// attrs[equipTable.CarryAttrType1-1] += float64(equipTable.CarryAttrValue1)
// }
// } else {
// if equipTable.AttrType1 > 0 && equipTable.AttrType1 <= proto.AttrNum {
// attrs[equipTable.AttrType1-1] += float64(equipTable.AttrValue1)
// }
// }
// }
// return
//}
//
//func (this *Player) rigPendantAttrs() (attrs proto.Attrs) {
// for _, pendant := range this.RigPendant {
// var pendantTable = this.manager.tables.RigPendant.Get(int(pendant.Id))
// if pendantTable == nil {
// continue
// }
// if pendant.Setup {
// if pendantTable.CarryAttrType1 > 0 && pendantTable.CarryAttrType1 <= proto.AttrNum {
// attrs[pendantTable.CarryAttrType1-1] += float64(pendantTable.CarryAttrValue1)
// }
// } else {
// if pendantTable.AttrType1 > 0 && pendantTable.AttrType1 <= proto.AttrNum {
// attrs[pendantTable.AttrType1-1] += float64(pendantTable.AttrValue1)
// }
// }
// }
// return
//}
//
//func (this *Player) rigCharacterInTeam(itemId uint32) bool {
// if len(this.Rig.Teams) == 0 {
// return false
// }
//
// for _, member := range this.Rig.Teams[this.Rig.Team] {
// if itemId == member {
// return true
// }
// }
// return false
//}
//
//func (this *Player) rigCharacterAttrs() (attrs proto.Attrs) {
// for _, character := range this.RigCharacter {
// var characterTable = this.manager.tables.RigCharacter.Get(int(character.Id))
// if characterTable == nil {
// continue
// }
//
// if this.rigCharacterInTeam(character.ItemId) {
// if characterTable.CarryAttrType1 > 0 && characterTable.CarryAttrType1 <= proto.AttrNum {
// attrs[characterTable.CarryAttrType1-1] += float64(characterTable.CarryAttrValue1)
// }
// if character.StarId > 0 {
// var characterStarTable = this.manager.tables.RigCharacterStar.Get(int(character.StarId))
// if characterStarTable != nil {
// if characterStarTable.CarryAttrType1 > 0 && characterStarTable.CarryAttrType1 <= proto.AttrNum {
// attrs[characterStarTable.CarryAttrType1-1] += float64(characterStarTable.CarryAttrValue1)
// }
// }
// }
// } else {
// if characterTable.AttrType1 > 0 && characterTable.AttrType1 <= proto.AttrNum {
// attrs[characterTable.CarryAttrType1-1] += float64(characterTable.CarryAttrValue1)
// }
// attrs[characterTable.AttrType1-1] += float64(characterTable.AttrValue1)
// }
// }
// return
//}
//
//func (this *Player) rigRemainsComponentAttr(component *PlayerRigComponent, remainsTable *data.RigRemains) (int, float64) {
// var componentTable = this.manager.tables.RigComponent.Get(int(component.Id))
// if componentTable == nil {
// return 0, 0
// }
//
// if component.Setup {
// if componentTable.CarryAttrType1 > 0 && componentTable.CarryAttrType1 <= proto.AttrNum {
// return componentTable.CarryAttrType1, float64(componentTable.CarryAttrValue1) * (float64(remainsTable.AttrValue2) * proto.AttrRateIn)
// }
// } else {
// if componentTable.AttrType1 > 0 && componentTable.CarryAttrType1 <= proto.AttrNum {
// return componentTable.AttrType1, float64(componentTable.AttrValue1) * float64(remainsTable.AttrValue2) * proto.AttrRateIn
// }
// }
// return 0, 0
//}
//
//func (this *Player) rigRemainsAttrs() (attrs proto.Attrs) {
// for _, remains := range this.RigRemains {
// var remainsTable = this.manager.tables.RigRemains.Get(int(remains.Id))
// if remainsTable != nil {
// if remainsTable.AttrType1 > 0 && remainsTable.AttrType1 <= proto.AttrNum {
// attrs[remainsTable.AttrType1-1] += float64(remainsTable.AttrValue1)
// }
// if remainsTable.RigComponentItemId < 0 {
// continue
// }
//
// if remainsTable.RigComponentItemId == 0 {
// for _, component := range this.RigComponent {
// attrType, attrVal := this.rigRemainsComponentAttr(component, remainsTable)
// if attrType > 0 {
// attrs[attrType-1] += attrVal
// }
// }
// } else {
// var component = this.RigComponent[uint32(remainsTable.RigComponentItemId)]
// if component == nil {
// continue
// }
//
// attrType, attrVal := this.rigRemainsComponentAttr(component, remainsTable)
// if attrType > 0 {
// attrs[attrType-1] += attrVal
// }
// }
// }
// }
// return
//}
//
//func (this *Player) rigCoreAttrs() (attrs proto.Attrs) {
// for _, core := range this.RigCore {
// var coreTable = this.manager.tables.RigCore.Get(int(core.Id))
// if coreTable == nil {
// continue
// }
//
// if core.Socket > 0 {
// if coreTable.CarryAttrType1 > 0 && coreTable.CarryAttrType1 <= proto.AttrNum {
// attrs[coreTable.CarryAttrType1-1] += float64(coreTable.CarryAttrValue1)
// }
// } else {
// if coreTable.AttrType1 > 0 && coreTable.AttrType1 <= proto.AttrNum {
// attrs[coreTable.AttrType1-1] += float64(coreTable.AttrValue1)
// }
// }
// }
// return
//}
//
//func (this *Player) rigTrammelsAttrs() (attrs proto.Attrs) {
// for _, rigTrammels := range this.RigTrammels {
// for level, status := range rigTrammels.Status {
// if proto.TrammelsStatus(status) != proto.TrammelsStatusActivated {
// continue
// }
//
// var rigTrammelsTable = this.manager.tables.RigTrammelsExtend.Get(int(rigTrammels.Group), int(level))
// if rigTrammelsTable == nil {
// continue
// }
//
// if rigTrammelsTable.AttrType1 > 0 && rigTrammelsTable.AttrType1 <= proto.AttrNum {
// attrs[rigTrammelsTable.AttrType1-1] += float64(rigTrammelsTable.AttrValue1)
// }
//
// if rigTrammelsTable.AttrType2 > 0 && rigTrammelsTable.AttrType2 <= proto.AttrNum {
// attrs[rigTrammelsTable.AttrType2-1] += float64(rigTrammelsTable.AttrValue2)
// }
// }
// }
// return
//}
//
//func (this *Player) rigWarshipAttrs() (attrs proto.Attrs) {
// if this.Rig.Warship != 0 {
// var warship = this.RigWarship[this.Rig.Warship]
// if warship != nil {
// var warshipLevelTable = this.manager.tables.WarshipLevel.Get(int(warship.LevelId))
// if warshipLevelTable != nil {
// if warshipLevelTable.AttrType1 > 0 && warshipLevelTable.AttrType1 <= proto.AttrNum {
// attrs[warshipLevelTable.AttrType1] += float64(warshipLevelTable.AttrValue1)
// }
// if warshipLevelTable.AttrType2 > 0 && warshipLevelTable.AttrType2 <= proto.AttrNum {
// attrs[warshipLevelTable.AttrType2] += float64(warshipLevelTable.AttrValue2)
// }
// if warshipLevelTable.AttrType3 > 0 && warshipLevelTable.AttrType3 <= proto.AttrNum {
// attrs[warshipLevelTable.AttrType3] += float64(warshipLevelTable.AttrValue3)
// }
// }
// }
// }
// return
//}
//
//func (this *Player) roleTalentAttrs() (attrs proto.Attrs) {
// for _, talent := range this.RoleTalent {
// var talentLevelTable = this.manager.tables.TalentLevel.Get(int(talent.LevelId))
// if talentLevelTable != nil {
// if talentLevelTable.AttrType1 > 0 && talentLevelTable.AttrType1 <= proto.AttrNum {
// attrs[talentLevelTable.AttrType1-1] += float64(talentLevelTable.AttrValue1)
// }
// }
// }
// return
//}
//
//func (this *Player) planetCivilizationAttrs() (attrs proto.Attrs) {
// for _, planet := range this.Planet {
// var planetTable = this.manager.tables.Planet.Get(int(planet.Id))
// if planetTable == nil {
// continue
// }
//
// for _, civilization := range planet.Civilizations {
// var civilizationTable = this.manager.tables.PlanetCivilization.Get(int(civilization.Id))
// if civilization == nil {
// continue
// }
//
// if civilizationTable.AttrType1 > 0 && civilizationTable.AttrType1 <= proto.AttrNum {
// if civilizationTable.CivilizationType == planetTable.CivilizationType {
// attrs[civilizationTable.AttrType1-1] += float64(civilizationTable.AttrValue1) * (1.0 + float64(planetTable.CivilizationAddition)*proto.AttrRateIn)
// } else {
// attrs[civilizationTable.AttrType1-1] += float64(civilizationTable.AttrValue1)
// }
// }
// }
// }
// return
//}
//
//func (this *Player) calcRigAttrs(allAttrs ...proto.Attrs) bool {
// var newAttrs proto.Attrs
// for _, attrs := range allAttrs {
// for i, attr := range attrs {
// newAttrs[i] += attr
// }
// }
//
// for i := range newAttrs {
// if this.Rig.Attrs[i] != newAttrs[i] {
// this.Rig.Attrs = newAttrs
// return true
// }
// }
//
// return false
//}
//
//func (this *Player) updateRigAttrs() bool {
// return this.calcRigAttrs(
// this.rigBaseAttrs(),
// this.rigComponentAttrs(),
// this.rigEquipsAttrs(),
// this.rigPendantAttrs(),
// this.rigCharacterAttrs(),
// this.rigRemainsAttrs(),
// this.rigCoreAttrs(),
// this.rigTrammelsAttrs(),
// this.rigWarshipAttrs(),
// this.roleTalentAttrs(),
// this.planetCivilizationAttrs(),
// )
//}
//
//func (this *Player) RigAttr(tipe proto.AttrType) float64 {
// return this.Rig.Attrs[tipe]
//}
//
//func (this *Player) RigAttrsCapacity() uint64 {
// return rigAttrsCapacity(this.Rig.Attrs, this.manager.tables.AttributeConfig.List())
//}
//
//func (this *Player) UpdateRigAttrs() {
// if this.updateRigAttrs() {
// _ = this.Send(proto.ModIdRig, proto.MsgIdRigInfoChange, this.BuildMsgRigInfoAck())
// }
//}
//
//func (this *Player) RigTeamSave(team uint32, list []proto.Team) {
// this.Rig.Team = team
// this.Rig.Teams = list
//
// this.SaveField("rig.team", this.Rig.Team)
// this.SaveField("rig.teams", this.Rig.Teams)
//}
//
//func (this *Player) BuildMsgRigInfoAck() *proto.MsgRigInfoAck {
// var rig = &proto.Rig{Attrs: this.Rig.Attrs}
//
// var component *PlayerRigComponent
// component = this.RigComponent[this.Rig.Head]
// if component != nil {
// rig.Head = component.Id
// rig.HeadStar = component.StarId
// }
//
// component = this.RigComponent[this.Rig.Body]
// if component != nil {
// rig.Body = component.Id
// rig.BodyStar = component.StarId
// }
//
// component = this.RigComponent[this.Rig.Tail]
// if component != nil {
// rig.Tail = component.Id
// rig.TailStar = component.StarId
// }
//
// for i := range this.Rig.Equips {
// var equip = this.RigEquip[this.Rig.Equips[i]]
// if equip != nil {
// rig.Equips[i] = equip.Id
// }
// }
//
// for i := range this.Rig.Pendants {
// var pendant = this.RigPendant[this.Rig.Pendants[i]]
// if pendant != nil {
// rig.Pendants[i] = pendant.Id
// }
// }
//
// return &proto.MsgRigInfoAck{Rig: rig}
//}
//
//func (this *Player) BuildMsgRigTeamListAck() *proto.MsgRigTeamListAck {
// var list []*proto.RigTeam
// for _, members := range this.Rig.Teams {
// list = append(list, &proto.RigTeam{Members: members})
// }
// return &proto.MsgRigTeamListAck{Team: this.Rig.Team, List: list}
//}