GetMembers() is the core feature of this, everything works off of it.
()
| 13 | |
| 14 | // GetMembers() is the core feature of this, everything works off of it. |
| 15 | func (p ScriptParty) GetMembers() []ScriptActor { |
| 16 | |
| 17 | partyMembers := []ScriptActor{} |
| 18 | addedUsers := map[int]struct{}{} // Track so we never accidentally add someone twice |
| 19 | addedMobs := map[int]struct{}{} // Track so we never accidentally add someone twice |
| 20 | |
| 21 | // Usually we would include self, but just in case... |
| 22 | if p.includeSelf { |
| 23 | |
| 24 | partyMembers = append(partyMembers, *p.actor) |
| 25 | |
| 26 | if p.actor.characterRecord != nil { |
| 27 | addedUsers[p.actor.userId] = struct{}{} |
| 28 | } else if p.actor.mobRecord != nil { |
| 29 | addedMobs[p.actor.mobInstanceId] = struct{}{} |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | partyUserId := p.actor.UserId() |
| 34 | sourceRoomId := p.actor.GetRoomId() |
| 35 | |
| 36 | if p.actor.userRecord == nil { |
| 37 | if p.actor.mobRecord.Character.Charmed == nil { |
| 38 | return partyMembers |
| 39 | } |
| 40 | |
| 41 | partyUserId = p.actor.mobRecord.Character.Charmed.UserId |
| 42 | } |
| 43 | |
| 44 | if partyUserId < 1 { |
| 45 | return partyMembers |
| 46 | } |
| 47 | |
| 48 | // If in a party, give to all party members. |
| 49 | if party := parties.Get(partyUserId); party != nil { |
| 50 | for _, userId := range party.GetMembers() { |
| 51 | |
| 52 | if _, ok := addedUsers[userId]; ok { |
| 53 | continue |
| 54 | } |
| 55 | |
| 56 | if a := GetActor(userId, 0); a != nil { |
| 57 | |
| 58 | if a.GetRoomId() == sourceRoomId { |
| 59 | if !p.includePresent { |
| 60 | continue |
| 61 | } |
| 62 | } else { |
| 63 | if !p.includeMissing { |
| 64 | continue |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | partyMembers = append(partyMembers, *a) |
| 69 | addedUsers[userId] = struct{}{} |
| 70 | |
| 71 | } |
| 72 |
no test coverage detected