Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
68
GameContent/Achievements/CustomFloatCondition.cs
Normal file
68
GameContent/Achievements/CustomFloatCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomFloatCondition
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class CustomFloatCondition : AchievementCondition
|
||||
{
|
||||
[JsonProperty("Value")]
|
||||
private float _value;
|
||||
private float _maxValue;
|
||||
|
||||
public float Value
|
||||
{
|
||||
get => this._value;
|
||||
set
|
||||
{
|
||||
float newValue = Utils.Clamp<float>(value, 0.0f, this._maxValue);
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<float>) this._tracker).SetValue(newValue);
|
||||
this._value = newValue;
|
||||
if ((double) this._value != (double) this._maxValue)
|
||||
return;
|
||||
this.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private CustomFloatCondition(string name, float maxValue)
|
||||
: base(name)
|
||||
{
|
||||
this._maxValue = maxValue;
|
||||
this._value = 0.0f;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
this._value = 0.0f;
|
||||
base.Clear();
|
||||
}
|
||||
|
||||
public override void Load(JObject state)
|
||||
{
|
||||
base.Load(state);
|
||||
this._value = JToken.op_Explicit(state["Value"]);
|
||||
if (this._tracker == null)
|
||||
return;
|
||||
((AchievementTracker<float>) this._tracker).SetValue(this._value, false);
|
||||
}
|
||||
|
||||
protected override IAchievementTracker CreateAchievementTracker() => (IAchievementTracker) new ConditionFloatTracker(this._maxValue);
|
||||
|
||||
public static AchievementCondition Create(string name, float maxValue) => (AchievementCondition) new CustomFloatCondition(name, maxValue);
|
||||
|
||||
public override void Complete()
|
||||
{
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<float>) this._tracker).SetValue(this._maxValue);
|
||||
this._value = this._maxValue;
|
||||
base.Complete();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue