Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
- fix progress bar not displaying percentage in normal mode
Browse files Browse the repository at this point in the history
- fix post revive regen buff not applied in normal mode
- add post revive regen buff configurable time
- fix post revive regen sprite icon
  • Loading branch information
amadare42 committed Mar 13, 2022
1 parent 7c8ec53 commit 267f275
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
9 changes: 7 additions & 2 deletions TeammateRevive/Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static BindCollection BindRuleValues(ConfigFile configFile, ReviveRuleValues val
defaultValue: values.ReduceReviveProgressFactor)
.Bind(
key: "Revive Link buff duration factor",
description: "[Only with Death Curse enabled] How long Revive Link buff will stay after player leave revive range. " +
description: "How long Revive Link buff will stay after player leave revive range. " +
"\nBuffTime = TimeInCircle / ReduceReviveProgressFactor * ReviveLinkBuffTimeFactor + 1 second" +
"\nBasically, when 1 - buff will be applied for exactly as long as it will take to remove all added revive progress (+1 second)." +
"\nSo, when 0.5 - only half of that.",
Expand Down Expand Up @@ -208,7 +208,12 @@ static BindCollection BindRuleValues(ConfigFile configFile, ReviveRuleValues val
description: "[Only with Death Curse enabled] Chance to receive Death Curse on revival (Range: 0-100%)",
set: v => values.DeathCurseChance = v,
defaultValue: values.DeathCurseChance)
;
.Bind(
key: "Post revive regeneration time",
description: "After reviving, 40% of revivee and linked revivers HP is restored. This value specify how long regeneration buff is active in seconds. If set to 0 - revive regen is disabled.",
set: v => values.PostReviveRegenDurationSec = v,
defaultValue: values.PostReviveRegenDurationSec
);
}
}
}
3 changes: 2 additions & 1 deletion TeammateRevive/Content/ReviveRegen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using TeammateRevive.Common;
using TeammateRevive.Revive.Rules;
using UnityEngine;
using UnityEngine.AddressableAssets;

namespace TeammateRevive.Content
{
Expand All @@ -20,7 +21,7 @@ public ReviveRegen(ReviveRules rules)

public override void Init()
{
var sprite = LegacyResourcesAPI.Load<Sprite>("textures/bufficons/texBuffRegenBoostIcon");
var sprite = Addressables.LoadAssetAsync<BuffDef>("RoR2/Junk/Common/bdMeatRegenBoost.asset").WaitForCompletion().iconSprite;

BuffDef buffDefinition = ScriptableObject.CreateInstance<BuffDef>();
buffDefinition.name = Name;
Expand Down
4 changes: 1 addition & 3 deletions TeammateRevive/ProgressBar/ReviveProgressBarTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ public void Update()
{
this.progressBar.SetFraction(this.trackingSkull.progress);
this.progressBar.SetColor(this.trackingSkull.fractionPerSecond >= 0 ? PositiveProgressColor : NegativeProgressColor);
#if DEBUG
// for debug purposes, display speed and percentage
this.progressBar.UpdateText(this.trackingSkull.PlayerName, this.trackingSkull.progress);
#endif
}

// player moved out of skull circle, queuing to hide
Expand All @@ -106,6 +103,7 @@ public void Update()
RemoveTracking();
}

// hiding based on time
if (this.IsQueuedToHide && Time.time > this.queuedToHideAt)
{
Log.DebugMethod($"removing tracking after delay ({Time.time} > {this.queuedToHideAt})");
Expand Down
15 changes: 8 additions & 7 deletions TeammateRevive/Revive/RevivalTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ public void Update()
dead.reviveProgress = Mathf.Clamp01(dead.reviveProgress);

// if player in range, update revive revive links
if (this.run.IsDeathCurseEnabled)
{
reviver.IncreaseReviveLinkDuration(dead, Time.deltaTime + Time.deltaTime / this.rules.Values.ReduceReviveProgressFactor * this.rules.Values.ReviveLinkBuffTimeFactor);
}
reviver.IncreaseReviveLinkDuration(dead, Time.deltaTime + Time.deltaTime / this.rules.Values.ReduceReviveProgressFactor * this.rules.Values.ReviveLinkBuffTimeFactor);

DamageReviver(playerBody, dead);
}
Expand All @@ -168,7 +165,8 @@ public void Update()
this.skullTracker.UpdateSkull(dead, insidePlayersHash, playersInRange, totalReviveSpeed);
}

// update revive links
// update revive link buffs
// NOTE: revive links are tracked in Normal Mode, but no buff is displayed
if (this.run.IsDeathCurseEnabled)
UpdateReviveLinkBuffs();

Expand Down Expand Up @@ -196,8 +194,11 @@ void Revive(Player dead)
player.RemoveReviveLink(dead);

// add post-revive regeneration to revivers
foreach (var player in linkedPlayers)
player.GetBody().AddTimedBuff(ReviveRegen.Index, this.rules.Values.PostReviveRegenDurationSec);
if (this.rules.Values.PostReviveRegenDurationSec != 0)
{
foreach (var player in linkedPlayers)
player.GetBody().AddTimedBuff(ReviveRegen.Index, this.rules.Values.PostReviveRegenDurationSec);
}
}

private void ApplyDeathCurses(Player dead, Player[] linkedPlayers)
Expand Down
2 changes: 2 additions & 0 deletions TeammateRevive/Revive/Rules/SetRulesMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void Serialize(NetworkWriter writer)
writer.Write(this.ruleValues.DebugKeepSkulls);
writer.Write(this.ruleValues.EnableRevivalToken);
writer.Write(this.ruleValues.CutReviveeHp);
writer.Write(this.ruleValues.PostReviveRegenDurationSec);
Log.Info("Sending new rule values");
}

Expand All @@ -54,6 +55,7 @@ public void Deserialize(NetworkReader reader)
this.ruleValues.DebugKeepSkulls = reader.ReadBoolean();
this.ruleValues.EnableRevivalToken = reader.ReadBoolean();
this.ruleValues.CutReviveeHp = reader.ReadBoolean();
this.ruleValues.PostReviveRegenDurationSec = reader.ReadSingle();
}

public void OnReceived()
Expand Down

0 comments on commit 267f275

Please sign in to comment.