diff --git a/binaries/data/mods/public/simulation/components/Capturable.js b/binaries/data/mods/public/simulation/components/Capturable.js
index 55fdde0..372a424 100644
a
|
b
|
Capturable.prototype.RegisterCapturePointsChanged = function()
|
142 | 142 | Engine.PostMessage(this.entity, MT_CapturePointsChanged, { "capturePoints": this.cp }); |
143 | 143 | |
144 | 144 | var owner = cmpOwnership.GetOwner(); |
145 | | if (owner == -1 || this.cp[owner] > 0) |
| 145 | if (owner == -1) |
146 | 146 | return; |
147 | 147 | |
| 148 | if (this.cp[owner] > 0) |
| 149 | { |
| 150 | this.UpdateBlinking(); |
| 151 | return; |
| 152 | } |
| 153 | |
148 | 154 | // if all cp has been taken from the owner, convert it to the best player |
149 | 155 | var bestPlayer = 0; |
150 | 156 | for (let i in this.cp) |
… |
… |
Capturable.prototype.RegisterCapturePointsChanged = function()
|
160 | 166 | let cmpCapturedPlayerStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker); |
161 | 167 | if (cmpCapturedPlayerStatisticsTracker) |
162 | 168 | cmpCapturedPlayerStatisticsTracker.CapturedEntity(this.entity); |
| 169 | |
| 170 | this.UpdateBlinking(); |
163 | 171 | }; |
164 | 172 | |
| 173 | Capturable.prototype.UpdateBlinking = function() |
| 174 | { |
| 175 | let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); |
| 176 | if (!cmpOwnership) |
| 177 | return; |
| 178 | |
| 179 | let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual); |
| 180 | if (!cmpVisual) |
| 181 | return; |
| 182 | |
| 183 | let owner = cmpOwnership.GetOwner(); |
| 184 | if (this.cp[owner] == this.maxCp) |
| 185 | { |
| 186 | cmpVisual.ClearBlinking(); |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | let bestPlayer = 0; |
| 191 | for (let i in this.cp) |
| 192 | if (i != owner && this.cp[i] >= this.cp[bestPlayer]) |
| 193 | bestPlayer = +i; |
| 194 | |
| 195 | let cmpPlayer = QueryPlayerIDInterface(bestPlayer); |
| 196 | if (!cmpPlayer) |
| 197 | { |
| 198 | cmpVisual.ClearBlinking(); |
| 199 | return; |
| 200 | } |
| 201 | let color = cmpPlayer.GetColor(); |
| 202 | cmpVisual.SetBlinking(color.r, color.g, color.b, 0.4, true, 0.4 + this.cp[owner] / this.maxCp * 4.0); |
| 203 | } |
| 204 | |
165 | 205 | Capturable.prototype.GetRegenRate = function() |
166 | 206 | { |
167 | 207 | var regenRate = +this.template.RegenRate; |
diff --git a/source/simulation2/components/CCmpVisualActor.cpp b/source/simulation2/components/CCmpVisualActor.cpp
index f84dc51..fcfe2e2 100644
a
|
b
|
private:
|
83 | 83 | fixed m_AnimSyncRepeatTime; // 0.0 if not synced |
84 | 84 | fixed m_AnimSyncOffsetTime; |
85 | 85 | |
| 86 | // blinking-related, can use float since this will be purely graphical. |
| 87 | bool m_Blinking; |
| 88 | bool m_BlinkingLoop; |
| 89 | CColor m_BlinkingColor; |
| 90 | float m_BlinkingTime; |
| 91 | float m_BlinkingPeriod; |
| 92 | double m_BlinkingStart; |
| 93 | |
86 | 94 | std::map<CStr, CStr> m_VariantSelections; |
87 | 95 | |
88 | 96 | u32 m_Seed; // seed used for random variations |
… |
… |
public:
|
282 | 290 | { |
283 | 291 | switch (msg.GetType()) |
284 | 292 | { |
| 293 | case MT_Interpolate: |
| 294 | { |
| 295 | Interpolate(); |
| 296 | break; |
| 297 | } |
285 | 298 | case MT_Update_Final: |
286 | 299 | { |
287 | 300 | const CMessageUpdate_Final& msgData = static_cast<const CMessageUpdate_Final&> (msg); |
… |
… |
public:
|
486 | 499 | } |
487 | 500 | } |
488 | 501 | |
| 502 | virtual void SetBlinking(float r, float g, float b, float blinkTime, bool loop, float blinkPeriod) |
| 503 | { |
| 504 | if (!m_Blinking) |
| 505 | m_BlinkingStart = timer_Time(); |
| 506 | |
| 507 | m_BlinkingColor = CColor(r, g, b, 1.0f); |
| 508 | m_Blinking = true; |
| 509 | m_BlinkingTime = blinkTime; |
| 510 | m_BlinkingLoop = loop; |
| 511 | m_BlinkingPeriod = blinkPeriod; |
| 512 | |
| 513 | // subscribe to interpolation. |
| 514 | GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_Interpolate, this, true); |
| 515 | } |
| 516 | |
| 517 | virtual void ClearBlinking() |
| 518 | { |
| 519 | m_Blinking = false; |
| 520 | GetSimContext().GetComponentManager().DynamicSubscriptionNonsync(MT_Interpolate, this, false); |
| 521 | } |
| 522 | |
489 | 523 | virtual void SetVariable(const std::string& name, float value) |
490 | 524 | { |
491 | 525 | if (m_Unit) |
… |
… |
private:
|
536 | 570 | void ReloadUnitAnimation(); |
537 | 571 | |
538 | 572 | void Update(fixed turnLength); |
| 573 | |
| 574 | void Interpolate(); |
539 | 575 | }; |
540 | 576 | |
541 | 577 | REGISTER_COMPONENT_TYPE(VisualActor) |
… |
… |
void CCmpVisualActor::Update(fixed UNUSED(turnLength))
|
783 | 819 | SelectAnimation(name, false, speed, L""); |
784 | 820 | m_AnimRunThreshold = runThreshold; |
785 | 821 | } |
| 822 | |
| 823 | void CCmpVisualActor::Interpolate() |
| 824 | { |
| 825 | if (!m_Blinking) |
| 826 | { |
| 827 | ClearBlinking(); |
| 828 | return; |
| 829 | } |
| 830 | if (!m_Unit) |
| 831 | return; |
| 832 | |
| 833 | CModelAbstract& model = m_Unit->GetModel(); |
| 834 | |
| 835 | double time = fmod(timer_Time()-m_BlinkingStart, (double)(m_BlinkingTime+m_BlinkingPeriod)); |
| 836 | |
| 837 | if (time > m_BlinkingTime) |
| 838 | { |
| 839 | if (!m_BlinkingLoop) |
| 840 | { |
| 841 | ClearBlinking(); |
| 842 | return; |
| 843 | } |
| 844 | model.SetShadingColor(CColor(m_R.ToFloat(), m_G.ToFloat(), m_B.ToFloat(), 1.0f)); |
| 845 | return; |
| 846 | } |
| 847 | |
| 848 | CColor color(0.0f, 0.0f, 0.0f, 1.0f); |
| 849 | float influence = (float)fabs(1.0f - time/(m_BlinkingTime/2.0f)); |
| 850 | color.r = m_R.ToFloat() * influence + m_BlinkingColor.r * (1.0f - influence); |
| 851 | color.g = m_G.ToFloat() * influence + m_BlinkingColor.g * (1.0f - influence); |
| 852 | color.b = m_B.ToFloat() * influence + m_BlinkingColor.b * (1.0f - influence); |
| 853 | model.SetShadingColor(color); |
| 854 | } |
| 855 | |
diff --git a/source/simulation2/components/ICmpVisual.cpp b/source/simulation2/components/ICmpVisual.cpp
index e39942d..b9b9cd1 100644
a
|
b
|
DEFINE_INTERFACE_METHOD_2("ReplaceMoveAnimation", void, ICmpVisual, ReplaceMoveA
|
30 | 30 | DEFINE_INTERFACE_METHOD_1("SetAnimationSyncRepeat", void, ICmpVisual, SetAnimationSyncRepeat, fixed) |
31 | 31 | DEFINE_INTERFACE_METHOD_1("SetAnimationSyncOffset", void, ICmpVisual, SetAnimationSyncOffset, fixed) |
32 | 32 | DEFINE_INTERFACE_METHOD_4("SetShadingColor", void, ICmpVisual, SetShadingColor, fixed, fixed, fixed, fixed) |
| 33 | DEFINE_INTERFACE_METHOD_6("SetBlinking", void, ICmpVisual, SetBlinking, float, float, float, float, bool, float) |
| 34 | DEFINE_INTERFACE_METHOD_0("ClearBlinking", void, ICmpVisual, ClearBlinking) |
33 | 35 | DEFINE_INTERFACE_METHOD_2("SetVariable", void, ICmpVisual, SetVariable, std::string, float) |
34 | 36 | DEFINE_INTERFACE_METHOD_0("GetActorSeed", u32, ICmpVisual, GetActorSeed) |
35 | 37 | DEFINE_INTERFACE_METHOD_1("SetActorSeed", void, ICmpVisual, SetActorSeed, u32) |
diff --git a/source/simulation2/components/ICmpVisual.h b/source/simulation2/components/ICmpVisual.h
index 6b11fdc..6a5b8b3 100644
a
|
b
|
public:
|
143 | 143 | virtual void SetShadingColor(fixed r, fixed g, fixed b, fixed a) = 0; |
144 | 144 | |
145 | 145 | /** |
| 146 | * Set the actor to blink a certain color. Purely graphical. |
| 147 | * @param r red component, expected range [0, 1] |
| 148 | * @param g green component, expected range [0, 1] |
| 149 | * @param b blue component, expected range [0, 1] |
| 150 | * @param loop whether the blinking stops after one period |
| 151 | * @param blinkTime how long should a "blink" take |
| 152 | * @param blinkPeriod how long between two blinks. Irrelevant if not looping |
| 153 | */ |
| 154 | virtual void SetBlinking(float r, float g, float b, float blinkTime, bool loop = false, float blinkPeriod = 0.0f) = 0; |
| 155 | |
| 156 | /** |
| 157 | * Stop blinking |
| 158 | */ |
| 159 | virtual void ClearBlinking() = 0; |
| 160 | |
| 161 | /** |
146 | 162 | * Set an arbitrarily-named variable that the model may use to alter its appearance |
147 | 163 | * (e.g. in particle emitter parameter computations). |
148 | 164 | */ |