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

Commit

Permalink
finished removing "this."
Browse files Browse the repository at this point in the history
  • Loading branch information
amadare42 committed May 5, 2022
1 parent 46818b6 commit 3cbf436
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 158 deletions.
10 changes: 5 additions & 5 deletions TeammateRevive/Configuration/Meta/FloatMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class FloatMetadata : EntryMetadata

public FloatMetadata(float minValue, float maxValue)
{
this.MinValue = minValue;
this.MaxValue = maxValue;
MinValue = minValue;
MaxValue = maxValue;
}

public FloatMetadata(float minValue, float maxValue, float step)
{
this.MinValue = minValue;
this.MaxValue = maxValue;
this.Step = step;
MinValue = minValue;
MaxValue = maxValue;
Step = step;
}
}
8 changes: 4 additions & 4 deletions TeammateRevive/Content/Artifact/DeathCurseArtifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public void EnsureEnabled(ReviveRules rules)
// disable artifact if single player
if (Run.instance.participatingPlayerCount == 1
&& !rules.Values.ForceEnableDeathCurseForSinglePlayer
&& RunArtifactManager.instance.IsArtifactEnabled(this.ArtifactDef))
&& RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef))
{
RunArtifactManager.instance.SetArtifactEnabledServer(this.ArtifactDef, false);
RunArtifactManager.instance.SetArtifactEnabledServer(ArtifactDef, false);
Chat.SendBroadcastChat(new Chat.SimpleChatMessage
{
baseToken = TextFormatter.Yellow("Artifact of Death Curse is disabled because run started in single player.")
Expand All @@ -43,11 +43,11 @@ public void EnsureEnabled(ReviveRules rules)
if (
(Run.instance.participatingPlayerCount > 1 || rules.Values.ForceEnableDeathCurseForSinglePlayer)
&& rules.Values.ForceDeathCurseRule
&& !this.ArtifactEnabled
&& !ArtifactEnabled
&& NetworkHelper.IsServer
) {
var message = "Artifact of Death Curse is enforced by server.";
RunArtifactManager.instance.SetArtifactEnabledServer(this.ArtifactDef, true);
RunArtifactManager.instance.SetArtifactEnabledServer(ArtifactDef, true);
Log.Info(message);
Chat.SendBroadcastChat(new Chat.SimpleChatMessage
{
Expand Down
9 changes: 4 additions & 5 deletions TeammateRevive/Death Totem/DeathTotemBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using TeammateRevive.Logging;
using TeammateRevive.Players;
using TeammateRevive.ProgressBar;
using TeammateRevive.Resources;
using TeammateRevive.Revive.Rules;
using UnityEngine;
using UnityEngine.Networking;
Expand Down Expand Up @@ -104,12 +103,12 @@ public void Setup()
GlobalOnCreated?.Invoke(this);
}

public void SetValuesReceive(NetworkInstanceId deadPlayerId,
List<NetworkInstanceId> _insidePlayerIDs, float scale, float fractionPerSecond)
public void SetValuesReceive(NetworkInstanceId _deadPlayerId,
List<NetworkInstanceId> _insidePlayerIDs, float scale, float _fractionPerSecond)
{
Log.Debug($"Received death totem values. Rad: {scale}");
deadPlayerId = deadPlayerId;
fractionPerSecond = fractionPerSecond;
deadPlayerId = _deadPlayerId;
fractionPerSecond = _fractionPerSecond;
insidePlayerIDs = _insidePlayerIDs;
cachedRadius = scale;
animation.AnimateTo(Vector3.one * scale);
Expand Down
22 changes: 11 additions & 11 deletions TeammateRevive/Death Totem/DeathTotemTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DeathTotemTracker

public readonly HashSet<DeathTotemBehavior> totems = new();

public bool HasAnyTotems => this.totems.Count > 0;
public bool HasAnyTotems => totems.Count > 0;

public DeathTotemTracker(PlayersTracker players, RunTracker run, ReviveRules rules)
{
Expand All @@ -40,7 +40,7 @@ public DeathTotemTracker(PlayersTracker players, RunTracker run, ReviveRules rul

public void Clear()
{
this.totems.Clear();
totems.Clear();
}

void OnPlayerDead(Player player)
Expand All @@ -53,7 +53,7 @@ public void UpdateTotem(Player dead, int insidePlayersBefore, int playersInRange
var totem = dead.deathTotem;

// recalculating range, since it could have been changed after alive/dead interactions
var actualRange = this.rules.CalculateDeathTotemRadius(dead);
var actualRange = rules.CalculateDeathTotemRadius(dead);

// if players inside changed, forcing update
var forceUpdate = totem.GetInsidePlayersHash() != insidePlayersBefore;
Expand All @@ -70,19 +70,19 @@ public void UpdateTotem(Player dead, int insidePlayersBefore, int playersInRange

// if no characters are in range, reduce revive progress
dead.reviveProgress =
Mathf.Clamp01(dead.reviveProgress + this.rules.ReduceReviveProgressSpeed * Time.deltaTime);
Mathf.Clamp01(dead.reviveProgress + rules.ReduceReviveProgressSpeed * Time.deltaTime);

// if reviving progress become 0, remove revive links from all players
if (prevReviveProgress != 0 && dead.reviveProgress == 0)
{
foreach (var player in this.players.All)
foreach (var player in players.All)
{
player.RemoveReviveLink(dead);
}
}

totem.progress = dead.reviveProgress;
totem.SetValuesSend(this.rules.ReduceReviveProgressSpeed, actualRange, forceUpdate);
totem.SetValuesSend(rules.ReduceReviveProgressSpeed, actualRange, forceUpdate);
}
}

Expand All @@ -94,7 +94,7 @@ public DeathTotemBehavior ServerSpawnTotem(Player player)
totem.transform.position = player.groundPosition;
totem.transform.rotation = Quaternion.identity;

if (this.run.IsDeathCurseEnabled)
if (run.IsDeathCurseEnabled)
{
CreateInteraction(totem.gameObject);
}
Expand All @@ -109,7 +109,7 @@ public DeathTotemBehavior ServerSpawnTotem(Player player)

void OnClientTotemSpawned(DeathTotemBehavior totem)
{
if (!this.run.IsDeathCurseEnabled) return;
if (!run.IsDeathCurseEnabled) return;
CreateInteraction(totem.gameObject);
}

Expand Down Expand Up @@ -137,18 +137,18 @@ void CreateInteraction(GameObject gameObject)
private void OnTotemUpdate(DeathTotemBehavior obj)
{
Log.Debug("Totem updated! " + string.Join(", ", obj.insidePlayerIDs.Select(i => i.ToString())));
this.totems.Add(obj);
totems.Add(obj);
}

private void OnTotemDestroy(DeathTotemBehavior obj)
{
Log.Debug("Totem destroyed! " + string.Join(", ", obj.insidePlayerIDs.Select(i => i.ToString())));
this.totems.Remove(obj);
totems.Remove(obj);
}

public DeathTotemBehavior GetDeathTotemInRange(NetworkInstanceId userBodyId)
{
var totem = this.totems.FirstOrDefault(s => s.insidePlayerIDs.Contains(userBodyId));
var totem = totems.FirstOrDefault(s => s.insidePlayerIDs.Contains(userBodyId));
return totem;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ReviveLongRangeActivationManager(RunTracker run, DeathTotemTracker deathT
private GameObject hook_Interactor_FindBestInteractableObject(On.RoR2.Interactor.orig_FindBestInteractableObject orig, RoR2.Interactor self, Ray raycastRay, float maxRaycastDistance, Vector3 overlapposition, float overlapradius)
{
var go = orig(self, raycastRay, maxRaycastDistance, overlapposition, overlapradius);
if (go != null || !this.run.IsDeathCurseEnabled) return go;
if (go != null || !run.IsDeathCurseEnabled) return go;

maxRaycastDistance = GetMaxReviveDistance();
if (maxRaycastDistance == 0) return go;
Expand All @@ -47,8 +47,8 @@ private GameObject hook_Interactor_FindBestInteractableObject(On.RoR2.Interactor

float GetMaxReviveDistance()
{
if (this.deathTotemTracker.totems.Count == 0) return 0;
return this.deathTotemTracker.totems.Max(totem => totem.cachedRadius + RaycastExtraRadius);
if (deathTotemTracker.totems.Count == 0) return 0;
return deathTotemTracker.totems.Max(totem => totem.cachedRadius + RaycastExtraRadius);
}

bool CheckDeathTotemRangeAllowed(GameObject gameObject, RaycastHit hitInfo)
Expand Down
18 changes: 9 additions & 9 deletions TeammateRevive/Death Totem/ScaleAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ public ScaleAnimation(Transform target, float duration)

public void AnimateTo(Vector3 targetValue)
{
this.elapsedTime = 0;
elapsedTime = 0;
this.targetValue = targetValue;
this.finished = false;
this.startValue = this.target.localScale;
finished = false;
startValue = target.localScale;
}

public void Update()
{
if (this.finished) return;
if (finished) return;

this.elapsedTime += Time.deltaTime;
if (this.elapsedTime >= this.duration)
elapsedTime += Time.deltaTime;
if (elapsedTime >= duration)
{
this.finished = true;
this.elapsedTime = this.duration;
finished = true;
elapsedTime = duration;
}

this.target.localScale = Vector3.Lerp(this.startValue, this.targetValue, this.elapsedTime / this.duration);
target.localScale = Vector3.Lerp(startValue, targetValue, elapsedTime / duration);
}
}
}
4 changes: 2 additions & 2 deletions TeammateRevive/Integrations/InLobbyConfigIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ void Register()
{
DisplayName = MainTeammateRevival.PluginName
};
AddSection(configEntry, this.pluginConfig.RuleValuesBindCollection);
AddSection(configEntry, pluginConfig.RuleValuesBindCollection);

#if DEBUG
// Adding debug section only for debug builds - why tempt players? :)
AddSection(configEntry, this.pluginConfig.DebugBindCollection);
AddSection(configEntry, pluginConfig.DebugBindCollection);
#endif

InLobbyConfig.ModConfigCatalog.Add(configEntry);
Expand Down
10 changes: 5 additions & 5 deletions TeammateRevive/Integrations/ItemsStatsModIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ void AddToItemStats()
Stats = new List<ItemStat>
{
new(
(itemCount, ctx) => this.rules.GetReviveIncrease((int)itemCount),
(itemCount, ctx) => rules.GetReviveIncrease((int)itemCount),
(value, ctx) => $"Revive speed increased by {value.FormatPercentage(signed: true, decimalPlaces: 1)}"
),
new(
(itemCount, ctx) => this.rules.GetReviveTime((int)itemCount, ctx.CountItems(DeadMansHandItem.Index)),
(itemCount, ctx) => rules.GetReviveTime((int)itemCount, ctx.CountItems(DeadMansHandItem.Index)),
(value, ctx) => $"Time to revive alone: {value.FormatInt(postfix: "s", decimals: 1)}"
),
new(
(itemCount, ctx) => this.rules.CalculateDeathTotemRadius((int)itemCount, 1),
(itemCount, ctx) => rules.CalculateDeathTotemRadius((int)itemCount, 1),
(value, ctx) => $"Revive circle range: {value.FormatInt(postfix: "m", decimals: 1)}"
),
new(
(itemCount, ctx) => this.rules.GetReviveReduceDamageFactor((int)itemCount, 0) - 1,
(itemCount, ctx) => rules.GetReviveReduceDamageFactor((int)itemCount, 0) - 1,
(value, ctx) => $"Damage from your circle: {value.FormatPercentage(decimalPlaces: 1, signed: true)}"
)
}
Expand All @@ -66,7 +66,7 @@ void AddToItemStats()
Stats = new List<ItemStat>
{
new(
(itemCount, ctx) => this.rules.GetReviveTimeIncrease(ctx.CountItems(CharonsObol.Index), (int)itemCount),
(itemCount, ctx) => rules.GetReviveTimeIncrease(ctx.CountItems(CharonsObol.Index), (int)itemCount),
(value, ctx) => $"Revive time increase: {value.FormatPercentage(decimalPlaces: 1, signed: true)}"
)
}
Expand Down
2 changes: 1 addition & 1 deletion TeammateRevive/Logging/ConsoleLoggerTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ConsoleLoggerTarget(ManualLogSource log)

public void Write(LogLevel level, object msg)
{
this.log.Log(level, msg);
log.Log(level, msg);
}
}
}
10 changes: 5 additions & 5 deletions TeammateRevive/Logging/DebugFileTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public DebugFileTarget(string path, ManualLogSource consoleLogger)
if (string.IsNullOrEmpty(path)) path = DefaultPath;
try
{
this.filePath = NormalizeAndVerifyPath(path);
filePath = NormalizeAndVerifyPath(path);
}
catch
{
consoleLogger.LogError(
$"Couldn't write to specified file logging path! Will write to \"{DefaultPath}\" instead --------------------------------------------");
this.filePath = DefaultPath;
filePath = DefaultPath;
}

try
Expand All @@ -33,7 +33,7 @@ public DebugFileTarget(string path, ManualLogSource consoleLogger)
catch
{
consoleLogger.LogWarning("Log file location unavailable!");
this.IsEnabled = false;
IsEnabled = false;
}
}

Expand All @@ -55,9 +55,9 @@ private string NormalizeAndVerifyPath(string path)

public void Write(LogLevel level, object msg)
{
if (!this.IsEnabled) return;
if (!IsEnabled) return;

using var writer = new StreamWriter(this.filePath, true);
using var writer = new StreamWriter(filePath, true);
writer.WriteLine($"[{level.ToString("G").ToUpper()}] [{DateTime.Now}] {msg} \n");
}
}
Expand Down
Loading

0 comments on commit 3cbf436

Please sign in to comment.