|
2 | 2 | using Google.ProtocolBuffers;
|
3 | 3 | using MHServerEmu.Core.Logging;
|
4 | 4 | using MHServerEmu.Core.Serialization;
|
| 5 | +using MHServerEmu.Games.Entities.Avatars; |
5 | 6 | using MHServerEmu.Games.GameData;
|
6 | 7 | using MHServerEmu.Games.GameData.Prototypes;
|
7 | 8 | using MHServerEmu.Games.Network;
|
@@ -105,23 +106,57 @@ private Power AssignPowerInternal(PrototypeId powerProtoRef, PowerIndexPropertie
|
105 | 106 | PowerCollectionRecord powerRecord = GetPowerRecordByRef(powerProtoRef);
|
106 | 107 | if (powerRecord == null)
|
107 | 108 | {
|
108 |
| - // Determine the source of this power |
109 |
| - bool isAvatarPowerProgressionPower = false; |
110 |
| - bool isTeamUpPassivePowerWhileAway = false; |
| 109 | + // Determine source flags for this power |
| 110 | + // (TODO: it would probably be cleaner to do this as a separate method with early returns) |
| 111 | + bool isPowerProgressionPower = false; |
| 112 | + bool isTeamUpPassiveWhileAway = false; |
111 | 113 |
|
112 |
| - // Inherit the source from the triggering power if we have one |
| 114 | + // Inherit the flags from the triggering power if we have one |
113 | 115 | PowerCollectionRecord triggeringPowerRecord = GetPowerRecordByRef(triggeringPowerRef);
|
114 | 116 | if (triggeringPowerRecord != null)
|
115 | 117 | {
|
116 |
| - isAvatarPowerProgressionPower = triggeringPowerRecord.IsAvatarPowerProgressionPower; |
117 |
| - isTeamUpPassivePowerWhileAway = triggeringPowerRecord.IsTeamUpPassivePowerWhileAway; |
| 118 | + isPowerProgressionPower = triggeringPowerRecord.IsPowerProgressionPower; |
| 119 | + isTeamUpPassiveWhileAway = triggeringPowerRecord.IsTeamUpPassiveWhileAway; |
118 | 120 | }
|
119 |
| - else //if (_owner != null) |
| 121 | + else |
120 | 122 | {
|
121 |
| - // Figure out the source from the power collection's owner, skip this for now |
| 123 | + if (_owner != null) |
| 124 | + { |
| 125 | + if (_owner is Agent agentOwner) |
| 126 | + { |
| 127 | + isPowerProgressionPower = agentOwner.HasPowerInPowerProgression(powerProtoRef); |
| 128 | + |
| 129 | + if (isPowerProgressionPower == false) |
| 130 | + { |
| 131 | + var avatarOwner = _owner.GetMostResponsiblePowerUser<Avatar>(); |
| 132 | + if (avatarOwner != null) |
| 133 | + { |
| 134 | + Agent teamUpAgent = avatarOwner.CurrentTeamUpAgent; |
| 135 | + if (teamUpAgent != null) |
| 136 | + { |
| 137 | + teamUpAgent.GetPowerProgressionInfo(powerProtoRef, out var info); |
| 138 | + if (info.IsForTeamUp) |
| 139 | + { |
| 140 | + isPowerProgressionPower = true; |
| 141 | + isTeamUpPassiveWhileAway = info.IsPassivePowerOnAvatarWhileAway; |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + else |
| 149 | + { |
| 150 | + isTeamUpPassiveWhileAway = _owner.Properties[PropertyEnum.IsTeamUpAwaySource]; |
| 151 | + } |
| 152 | + } |
| 153 | + else |
| 154 | + { |
| 155 | + Logger.Warn("AssignPowerInternal(): _owner == null"); |
| 156 | + } |
122 | 157 | }
|
123 | 158 |
|
124 |
| - powerRecord = CreatePowerRecord(powerProtoRef, indexProps, triggeringPowerRef, isAvatarPowerProgressionPower, isTeamUpPassivePowerWhileAway); |
| 159 | + powerRecord = CreatePowerRecord(powerProtoRef, indexProps, triggeringPowerRef, isPowerProgressionPower, isTeamUpPassiveWhileAway); |
125 | 160 | if (powerRecord == null) return Logger.WarnReturn<Power>(null, "AssignPowerInternal(): powerRecord == null");
|
126 | 161 | }
|
127 | 162 | else
|
|
0 commit comments