Terraria 1.3.5.3 Source Code
This commit is contained in:
commit
4b21dac4b6
503 changed files with 409032 additions and 0 deletions
311
GameContent/Achievements/AchievementsHelper.cs
Normal file
311
GameContent/Achievements/AchievementsHelper.cs
Normal file
|
@ -0,0 +1,311 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.AchievementsHelper
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class AchievementsHelper
|
||||
{
|
||||
private static bool _isMining;
|
||||
private static bool mayhemOK;
|
||||
private static bool mayhem1down;
|
||||
private static bool mayhem2down;
|
||||
private static bool mayhem3down;
|
||||
|
||||
public static event AchievementsHelper.ItemPickupEvent OnItemPickup;
|
||||
|
||||
public static event AchievementsHelper.ItemCraftEvent OnItemCraft;
|
||||
|
||||
public static event AchievementsHelper.TileDestroyedEvent OnTileDestroyed;
|
||||
|
||||
public static event AchievementsHelper.NPCKilledEvent OnNPCKilled;
|
||||
|
||||
public static event AchievementsHelper.ProgressionEventEvent OnProgressionEvent;
|
||||
|
||||
public static bool CurrentlyMining
|
||||
{
|
||||
get => AchievementsHelper._isMining;
|
||||
set => AchievementsHelper._isMining = value;
|
||||
}
|
||||
|
||||
public static void NotifyTileDestroyed(Player player, ushort tile)
|
||||
{
|
||||
if (Main.gameMenu || !AchievementsHelper._isMining || AchievementsHelper.OnTileDestroyed == null)
|
||||
return;
|
||||
AchievementsHelper.OnTileDestroyed(player, tile);
|
||||
}
|
||||
|
||||
public static void NotifyItemPickup(Player player, Item item)
|
||||
{
|
||||
if (AchievementsHelper.OnItemPickup == null)
|
||||
return;
|
||||
AchievementsHelper.OnItemPickup(player, (short) item.netID, item.stack);
|
||||
}
|
||||
|
||||
public static void NotifyItemPickup(Player player, Item item, int customStack)
|
||||
{
|
||||
if (AchievementsHelper.OnItemPickup == null)
|
||||
return;
|
||||
AchievementsHelper.OnItemPickup(player, (short) item.netID, customStack);
|
||||
}
|
||||
|
||||
public static void NotifyItemCraft(Recipe recipe)
|
||||
{
|
||||
if (AchievementsHelper.OnItemCraft == null)
|
||||
return;
|
||||
AchievementsHelper.OnItemCraft((short) recipe.createItem.netID, recipe.createItem.stack);
|
||||
}
|
||||
|
||||
public static void Initialize() => Player.Hooks.OnEnterWorld += new Action<Player>(AchievementsHelper.OnPlayerEnteredWorld);
|
||||
|
||||
private static void OnPlayerEnteredWorld(Player player)
|
||||
{
|
||||
if (AchievementsHelper.OnItemPickup != null)
|
||||
{
|
||||
for (int index = 0; index < 58; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.inventory[index].type, player.inventory[index].stack);
|
||||
for (int index = 0; index < player.armor.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.armor[index].type, player.armor[index].stack);
|
||||
for (int index = 0; index < player.dye.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.dye[index].type, player.dye[index].stack);
|
||||
for (int index = 0; index < player.miscEquips.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.miscEquips[index].type, player.miscEquips[index].stack);
|
||||
for (int index = 0; index < player.miscDyes.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.miscDyes[index].type, player.miscDyes[index].stack);
|
||||
for (int index = 0; index < player.bank.item.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.bank.item[index].type, player.bank.item[index].stack);
|
||||
for (int index = 0; index < player.bank2.item.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.bank2.item[index].type, player.bank2.item[index].stack);
|
||||
for (int index = 0; index < player.bank3.item.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.bank3.item[index].type, player.bank3.item[index].stack);
|
||||
}
|
||||
if (player.statManaMax > 20)
|
||||
Main.Achievements.GetCondition("STAR_POWER", "Use").Complete();
|
||||
if (player.statLifeMax == 500 && player.statManaMax == 200)
|
||||
Main.Achievements.GetCondition("TOPPED_OFF", "Use").Complete();
|
||||
if (player.miscEquips[4].type > 0)
|
||||
Main.Achievements.GetCondition("HOLD_ON_TIGHT", "Equip").Complete();
|
||||
if (player.miscEquips[3].type > 0)
|
||||
Main.Achievements.GetCondition("THE_CAVALRY", "Equip").Complete();
|
||||
for (int index = 0; index < player.armor.Length; ++index)
|
||||
{
|
||||
if (player.armor[index].wingSlot > (sbyte) 0)
|
||||
{
|
||||
Main.Achievements.GetCondition("HEAD_IN_THE_CLOUDS", "Equip").Complete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (player.armor[0].stack > 0 && player.armor[1].stack > 0 && player.armor[2].stack > 0)
|
||||
Main.Achievements.GetCondition("MATCHING_ATTIRE", "Equip").Complete();
|
||||
if (player.armor[10].stack > 0 && player.armor[11].stack > 0 && player.armor[12].stack > 0)
|
||||
Main.Achievements.GetCondition("FASHION_STATEMENT", "Equip").Complete();
|
||||
bool flag = true;
|
||||
for (int index = 0; index < player.extraAccessorySlots + 3 + 5; ++index)
|
||||
{
|
||||
if (player.dye[index].type < 1 || player.dye[index].stack < 1)
|
||||
flag = false;
|
||||
}
|
||||
if (!flag)
|
||||
return;
|
||||
Main.Achievements.GetCondition("DYE_HARD", "Equip").Complete();
|
||||
}
|
||||
|
||||
public static void NotifyNPCKilled(NPC npc)
|
||||
{
|
||||
if (Main.netMode == 0)
|
||||
{
|
||||
if (!npc.playerInteraction[Main.myPlayer])
|
||||
return;
|
||||
AchievementsHelper.NotifyNPCKilledDirect(Main.player[Main.myPlayer], npc.netID);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int remoteClient = 0; remoteClient < (int) byte.MaxValue; ++remoteClient)
|
||||
{
|
||||
if (npc.playerInteraction[remoteClient])
|
||||
NetMessage.SendData(97, remoteClient, number: npc.netID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void NotifyNPCKilledDirect(Player player, int npcNetID)
|
||||
{
|
||||
if (AchievementsHelper.OnNPCKilled == null)
|
||||
return;
|
||||
AchievementsHelper.OnNPCKilled(player, (short) npcNetID);
|
||||
}
|
||||
|
||||
public static void NotifyProgressionEvent(int eventID)
|
||||
{
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
NetMessage.SendData(98, number: eventID);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (AchievementsHelper.OnProgressionEvent == null)
|
||||
return;
|
||||
AchievementsHelper.OnProgressionEvent(eventID);
|
||||
}
|
||||
}
|
||||
|
||||
public static void HandleOnEquip(Player player, Item item, int context)
|
||||
{
|
||||
if (context == 16)
|
||||
Main.Achievements.GetCondition("HOLD_ON_TIGHT", "Equip").Complete();
|
||||
if (context == 17)
|
||||
Main.Achievements.GetCondition("THE_CAVALRY", "Equip").Complete();
|
||||
if ((context == 10 || context == 11) && item.wingSlot > (sbyte) 0)
|
||||
Main.Achievements.GetCondition("HEAD_IN_THE_CLOUDS", "Equip").Complete();
|
||||
if (context == 8 && player.armor[0].stack > 0 && player.armor[1].stack > 0 && player.armor[2].stack > 0)
|
||||
Main.Achievements.GetCondition("MATCHING_ATTIRE", "Equip").Complete();
|
||||
if (context == 9 && player.armor[10].stack > 0 && player.armor[11].stack > 0 && player.armor[12].stack > 0)
|
||||
Main.Achievements.GetCondition("FASHION_STATEMENT", "Equip").Complete();
|
||||
if (context != 12)
|
||||
return;
|
||||
for (int index = 0; index < player.extraAccessorySlots + 3 + 5; ++index)
|
||||
{
|
||||
if (player.dye[index].type < 1 || player.dye[index].stack < 1)
|
||||
return;
|
||||
}
|
||||
for (int index = 0; index < player.miscDyes.Length; ++index)
|
||||
{
|
||||
if (player.miscDyes[index].type < 1 || player.miscDyes[index].stack < 1)
|
||||
return;
|
||||
}
|
||||
Main.Achievements.GetCondition("DYE_HARD", "Equip").Complete();
|
||||
}
|
||||
|
||||
public static void HandleSpecialEvent(Player player, int eventID)
|
||||
{
|
||||
if (player.whoAmI != Main.myPlayer)
|
||||
return;
|
||||
switch (eventID)
|
||||
{
|
||||
case 1:
|
||||
Main.Achievements.GetCondition("STAR_POWER", "Use").Complete();
|
||||
if (player.statLifeMax != 500 || player.statManaMax != 200)
|
||||
break;
|
||||
Main.Achievements.GetCondition("TOPPED_OFF", "Use").Complete();
|
||||
break;
|
||||
case 2:
|
||||
Main.Achievements.GetCondition("GET_A_LIFE", "Use").Complete();
|
||||
if (player.statLifeMax != 500 || player.statManaMax != 200)
|
||||
break;
|
||||
Main.Achievements.GetCondition("TOPPED_OFF", "Use").Complete();
|
||||
break;
|
||||
case 3:
|
||||
Main.Achievements.GetCondition("NOT_THE_BEES", "Use").Complete();
|
||||
break;
|
||||
case 4:
|
||||
Main.Achievements.GetCondition("WATCH_YOUR_STEP", "Hit").Complete();
|
||||
break;
|
||||
case 5:
|
||||
Main.Achievements.GetCondition("RAINBOWS_AND_UNICORNS", "Use").Complete();
|
||||
break;
|
||||
case 6:
|
||||
Main.Achievements.GetCondition("YOU_AND_WHAT_ARMY", "Spawn").Complete();
|
||||
break;
|
||||
case 7:
|
||||
Main.Achievements.GetCondition("THROWING_LINES", "Use").Complete();
|
||||
break;
|
||||
case 8:
|
||||
Main.Achievements.GetCondition("LUCKY_BREAK", "Hit").Complete();
|
||||
break;
|
||||
case 9:
|
||||
Main.Achievements.GetCondition("VEHICULAR_MANSLAUGHTER", "Hit").Complete();
|
||||
break;
|
||||
case 10:
|
||||
Main.Achievements.GetCondition("ROCK_BOTTOM", "Reach").Complete();
|
||||
break;
|
||||
case 11:
|
||||
Main.Achievements.GetCondition("INTO_ORBIT", "Reach").Complete();
|
||||
break;
|
||||
case 12:
|
||||
Main.Achievements.GetCondition("WHERES_MY_HONEY", "Reach").Complete();
|
||||
break;
|
||||
case 13:
|
||||
Main.Achievements.GetCondition("JEEPERS_CREEPERS", "Reach").Complete();
|
||||
break;
|
||||
case 14:
|
||||
Main.Achievements.GetCondition("ITS_GETTING_HOT_IN_HERE", "Reach").Complete();
|
||||
break;
|
||||
case 15:
|
||||
Main.Achievements.GetCondition("FUNKYTOWN", "Reach").Complete();
|
||||
break;
|
||||
case 16:
|
||||
Main.Achievements.GetCondition("I_AM_LOOT", "Peek").Complete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void HandleNurseService(int coinsSpent) => ((CustomFloatCondition) Main.Achievements.GetCondition("FREQUENT_FLYER", "Pay")).Value += (float) coinsSpent;
|
||||
|
||||
public static void HandleAnglerService()
|
||||
{
|
||||
Main.Achievements.GetCondition("SERVANT_IN_TRAINING", "Finish").Complete();
|
||||
++((CustomIntCondition) Main.Achievements.GetCondition("GOOD_LITTLE_SLAVE", "Finish")).Value;
|
||||
++((CustomIntCondition) Main.Achievements.GetCondition("TROUT_MONKEY", "Finish")).Value;
|
||||
++((CustomIntCondition) Main.Achievements.GetCondition("FAST_AND_FISHIOUS", "Finish")).Value;
|
||||
++((CustomIntCondition) Main.Achievements.GetCondition("SUPREME_HELPER_MINION", "Finish")).Value;
|
||||
}
|
||||
|
||||
public static void HandleRunning(float pixelsMoved) => ((CustomFloatCondition) Main.Achievements.GetCondition("MARATHON_MEDALIST", "Move")).Value += pixelsMoved;
|
||||
|
||||
public static void HandleMining() => ++((CustomIntCondition) Main.Achievements.GetCondition("BULLDOZER", "Pick")).Value;
|
||||
|
||||
public static void CheckMechaMayhem(int justKilled = -1)
|
||||
{
|
||||
if (!AchievementsHelper.mayhemOK)
|
||||
{
|
||||
if (!NPC.AnyNPCs((int) sbyte.MaxValue) || !NPC.AnyNPCs(134) || !NPC.AnyNPCs(126) || !NPC.AnyNPCs(125))
|
||||
return;
|
||||
AchievementsHelper.mayhemOK = true;
|
||||
AchievementsHelper.mayhem1down = false;
|
||||
AchievementsHelper.mayhem2down = false;
|
||||
AchievementsHelper.mayhem3down = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (justKilled == 125 || justKilled == 126)
|
||||
AchievementsHelper.mayhem1down = true;
|
||||
else if (!NPC.AnyNPCs(125) && !NPC.AnyNPCs(126) && !AchievementsHelper.mayhem1down)
|
||||
{
|
||||
AchievementsHelper.mayhemOK = false;
|
||||
return;
|
||||
}
|
||||
if (justKilled == 134)
|
||||
AchievementsHelper.mayhem2down = true;
|
||||
else if (!NPC.AnyNPCs(134) && !AchievementsHelper.mayhem2down)
|
||||
{
|
||||
AchievementsHelper.mayhemOK = false;
|
||||
return;
|
||||
}
|
||||
if (justKilled == (int) sbyte.MaxValue)
|
||||
AchievementsHelper.mayhem3down = true;
|
||||
else if (!NPC.AnyNPCs((int) sbyte.MaxValue) && !AchievementsHelper.mayhem3down)
|
||||
{
|
||||
AchievementsHelper.mayhemOK = false;
|
||||
return;
|
||||
}
|
||||
if (!AchievementsHelper.mayhem1down || !AchievementsHelper.mayhem2down || !AchievementsHelper.mayhem3down)
|
||||
return;
|
||||
AchievementsHelper.NotifyProgressionEvent(21);
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void ItemPickupEvent(Player player, short itemId, int count);
|
||||
|
||||
public delegate void ItemCraftEvent(short itemId, int count);
|
||||
|
||||
public delegate void TileDestroyedEvent(Player player, ushort tileId);
|
||||
|
||||
public delegate void NPCKilledEvent(Player player, short npcId);
|
||||
|
||||
public delegate void ProgressionEventEvent(int eventID);
|
||||
}
|
||||
}
|
20
GameContent/Achievements/CustomFlagCondition.cs
Normal file
20
GameContent/Achievements/CustomFlagCondition.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomFlagCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class CustomFlagCondition : AchievementCondition
|
||||
{
|
||||
private CustomFlagCondition(string name)
|
||||
: base(name)
|
||||
{
|
||||
}
|
||||
|
||||
public static AchievementCondition Create(string name) => (AchievementCondition) new CustomFlagCondition(name);
|
||||
}
|
||||
}
|
60
GameContent/Achievements/CustomFloatCondition.cs
Normal file
60
GameContent/Achievements/CustomFloatCondition.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomFloatCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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);
|
||||
}
|
||||
}
|
60
GameContent/Achievements/CustomIntCondition.cs
Normal file
60
GameContent/Achievements/CustomIntCondition.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomIntCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// 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 CustomIntCondition : AchievementCondition
|
||||
{
|
||||
[JsonProperty("Value")]
|
||||
private int _value;
|
||||
private int _maxValue;
|
||||
|
||||
public int Value
|
||||
{
|
||||
get => this._value;
|
||||
set
|
||||
{
|
||||
int newValue = Utils.Clamp<int>(value, 0, this._maxValue);
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<int>) this._tracker).SetValue(newValue);
|
||||
this._value = newValue;
|
||||
if (this._value != this._maxValue)
|
||||
return;
|
||||
this.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private CustomIntCondition(string name, int maxValue)
|
||||
: base(name)
|
||||
{
|
||||
this._maxValue = maxValue;
|
||||
this._value = 0;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
this._value = 0;
|
||||
base.Clear();
|
||||
}
|
||||
|
||||
public override void Load(JObject state)
|
||||
{
|
||||
base.Load(state);
|
||||
this._value = JToken.op_Explicit(state["Value"]);
|
||||
if (this._tracker == null)
|
||||
return;
|
||||
((AchievementTracker<int>) this._tracker).SetValue(this._value, false);
|
||||
}
|
||||
|
||||
protected override IAchievementTracker CreateAchievementTracker() => (IAchievementTracker) new ConditionIntTracker(this._maxValue);
|
||||
|
||||
public static AchievementCondition Create(string name, int maxValue) => (AchievementCondition) new CustomIntCondition(name, maxValue);
|
||||
}
|
||||
}
|
68
GameContent/Achievements/ItemCraftCondition.cs
Normal file
68
GameContent/Achievements/ItemCraftCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.ItemCraftCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class ItemCraftCondition : AchievementCondition
|
||||
{
|
||||
private const string Identifier = "ITEM_PICKUP";
|
||||
private static Dictionary<short, List<ItemCraftCondition>> _listeners = new Dictionary<short, List<ItemCraftCondition>>();
|
||||
private static bool _isListenerHooked = false;
|
||||
private short[] _itemIds;
|
||||
|
||||
private ItemCraftCondition(short itemId)
|
||||
: base("ITEM_PICKUP_" + (object) itemId)
|
||||
{
|
||||
this._itemIds = new short[1]{ itemId };
|
||||
ItemCraftCondition.ListenForCraft(this);
|
||||
}
|
||||
|
||||
private ItemCraftCondition(short[] itemIds)
|
||||
: base("ITEM_PICKUP_" + (object) itemIds[0])
|
||||
{
|
||||
this._itemIds = itemIds;
|
||||
ItemCraftCondition.ListenForCraft(this);
|
||||
}
|
||||
|
||||
private static void ListenForCraft(ItemCraftCondition condition)
|
||||
{
|
||||
if (!ItemCraftCondition._isListenerHooked)
|
||||
{
|
||||
AchievementsHelper.OnItemCraft += new AchievementsHelper.ItemCraftEvent(ItemCraftCondition.ItemCraftListener);
|
||||
ItemCraftCondition._isListenerHooked = true;
|
||||
}
|
||||
for (int index = 0; index < condition._itemIds.Length; ++index)
|
||||
{
|
||||
if (!ItemCraftCondition._listeners.ContainsKey(condition._itemIds[index]))
|
||||
ItemCraftCondition._listeners[condition._itemIds[index]] = new List<ItemCraftCondition>();
|
||||
ItemCraftCondition._listeners[condition._itemIds[index]].Add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ItemCraftListener(short itemId, int count)
|
||||
{
|
||||
if (!ItemCraftCondition._listeners.ContainsKey(itemId))
|
||||
return;
|
||||
foreach (AchievementCondition achievementCondition in ItemCraftCondition._listeners[itemId])
|
||||
achievementCondition.Complete();
|
||||
}
|
||||
|
||||
public static AchievementCondition Create(params short[] items) => (AchievementCondition) new ItemCraftCondition(items);
|
||||
|
||||
public static AchievementCondition Create(short item) => (AchievementCondition) new ItemCraftCondition(item);
|
||||
|
||||
public static AchievementCondition[] CreateMany(params short[] items)
|
||||
{
|
||||
AchievementCondition[] achievementConditionArray = new AchievementCondition[items.Length];
|
||||
for (int index = 0; index < items.Length; ++index)
|
||||
achievementConditionArray[index] = (AchievementCondition) new ItemCraftCondition(items[index]);
|
||||
return achievementConditionArray;
|
||||
}
|
||||
}
|
||||
}
|
68
GameContent/Achievements/ItemPickupCondition.cs
Normal file
68
GameContent/Achievements/ItemPickupCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.ItemPickupCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class ItemPickupCondition : AchievementCondition
|
||||
{
|
||||
private const string Identifier = "ITEM_PICKUP";
|
||||
private static Dictionary<short, List<ItemPickupCondition>> _listeners = new Dictionary<short, List<ItemPickupCondition>>();
|
||||
private static bool _isListenerHooked = false;
|
||||
private short[] _itemIds;
|
||||
|
||||
private ItemPickupCondition(short itemId)
|
||||
: base("ITEM_PICKUP_" + (object) itemId)
|
||||
{
|
||||
this._itemIds = new short[1]{ itemId };
|
||||
ItemPickupCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private ItemPickupCondition(short[] itemIds)
|
||||
: base("ITEM_PICKUP_" + (object) itemIds[0])
|
||||
{
|
||||
this._itemIds = itemIds;
|
||||
ItemPickupCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private static void ListenForPickup(ItemPickupCondition condition)
|
||||
{
|
||||
if (!ItemPickupCondition._isListenerHooked)
|
||||
{
|
||||
AchievementsHelper.OnItemPickup += new AchievementsHelper.ItemPickupEvent(ItemPickupCondition.ItemPickupListener);
|
||||
ItemPickupCondition._isListenerHooked = true;
|
||||
}
|
||||
for (int index = 0; index < condition._itemIds.Length; ++index)
|
||||
{
|
||||
if (!ItemPickupCondition._listeners.ContainsKey(condition._itemIds[index]))
|
||||
ItemPickupCondition._listeners[condition._itemIds[index]] = new List<ItemPickupCondition>();
|
||||
ItemPickupCondition._listeners[condition._itemIds[index]].Add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ItemPickupListener(Player player, short itemId, int count)
|
||||
{
|
||||
if (player.whoAmI != Main.myPlayer || !ItemPickupCondition._listeners.ContainsKey(itemId))
|
||||
return;
|
||||
foreach (AchievementCondition achievementCondition in ItemPickupCondition._listeners[itemId])
|
||||
achievementCondition.Complete();
|
||||
}
|
||||
|
||||
public static AchievementCondition Create(params short[] items) => (AchievementCondition) new ItemPickupCondition(items);
|
||||
|
||||
public static AchievementCondition Create(short item) => (AchievementCondition) new ItemPickupCondition(item);
|
||||
|
||||
public static AchievementCondition[] CreateMany(params short[] items)
|
||||
{
|
||||
AchievementCondition[] achievementConditionArray = new AchievementCondition[items.Length];
|
||||
for (int index = 0; index < items.Length; ++index)
|
||||
achievementConditionArray[index] = (AchievementCondition) new ItemPickupCondition(items[index]);
|
||||
return achievementConditionArray;
|
||||
}
|
||||
}
|
||||
}
|
68
GameContent/Achievements/NPCKilledCondition.cs
Normal file
68
GameContent/Achievements/NPCKilledCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.NPCKilledCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class NPCKilledCondition : AchievementCondition
|
||||
{
|
||||
private const string Identifier = "NPC_KILLED";
|
||||
private static Dictionary<short, List<NPCKilledCondition>> _listeners = new Dictionary<short, List<NPCKilledCondition>>();
|
||||
private static bool _isListenerHooked = false;
|
||||
private short[] _npcIds;
|
||||
|
||||
private NPCKilledCondition(short npcId)
|
||||
: base("NPC_KILLED_" + (object) npcId)
|
||||
{
|
||||
this._npcIds = new short[1]{ npcId };
|
||||
NPCKilledCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private NPCKilledCondition(short[] npcIds)
|
||||
: base("NPC_KILLED_" + (object) npcIds[0])
|
||||
{
|
||||
this._npcIds = npcIds;
|
||||
NPCKilledCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private static void ListenForPickup(NPCKilledCondition condition)
|
||||
{
|
||||
if (!NPCKilledCondition._isListenerHooked)
|
||||
{
|
||||
AchievementsHelper.OnNPCKilled += new AchievementsHelper.NPCKilledEvent(NPCKilledCondition.NPCKilledListener);
|
||||
NPCKilledCondition._isListenerHooked = true;
|
||||
}
|
||||
for (int index = 0; index < condition._npcIds.Length; ++index)
|
||||
{
|
||||
if (!NPCKilledCondition._listeners.ContainsKey(condition._npcIds[index]))
|
||||
NPCKilledCondition._listeners[condition._npcIds[index]] = new List<NPCKilledCondition>();
|
||||
NPCKilledCondition._listeners[condition._npcIds[index]].Add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
private static void NPCKilledListener(Player player, short npcId)
|
||||
{
|
||||
if (player.whoAmI != Main.myPlayer || !NPCKilledCondition._listeners.ContainsKey(npcId))
|
||||
return;
|
||||
foreach (AchievementCondition achievementCondition in NPCKilledCondition._listeners[npcId])
|
||||
achievementCondition.Complete();
|
||||
}
|
||||
|
||||
public static AchievementCondition Create(params short[] npcIds) => (AchievementCondition) new NPCKilledCondition(npcIds);
|
||||
|
||||
public static AchievementCondition Create(short npcId) => (AchievementCondition) new NPCKilledCondition(npcId);
|
||||
|
||||
public static AchievementCondition[] CreateMany(params short[] npcs)
|
||||
{
|
||||
AchievementCondition[] achievementConditionArray = new AchievementCondition[npcs.Length];
|
||||
for (int index = 0; index < npcs.Length; ++index)
|
||||
achievementConditionArray[index] = (AchievementCondition) new NPCKilledCondition(npcs[index]);
|
||||
return achievementConditionArray;
|
||||
}
|
||||
}
|
||||
}
|
69
GameContent/Achievements/ProgressionEventCondition.cs
Normal file
69
GameContent/Achievements/ProgressionEventCondition.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.ProgressionEventCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class ProgressionEventCondition : AchievementCondition
|
||||
{
|
||||
private const string Identifier = "PROGRESSION_EVENT";
|
||||
private static Dictionary<int, List<ProgressionEventCondition>> _listeners = new Dictionary<int, List<ProgressionEventCondition>>();
|
||||
private static bool _isListenerHooked = false;
|
||||
private int[] _eventIDs;
|
||||
|
||||
private ProgressionEventCondition(int eventID)
|
||||
: base("PROGRESSION_EVENT_" + (object) eventID)
|
||||
{
|
||||
this._eventIDs = new int[1]{ eventID };
|
||||
ProgressionEventCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private ProgressionEventCondition(int[] eventIDs)
|
||||
: base("PROGRESSION_EVENT_" + (object) eventIDs[0])
|
||||
{
|
||||
this._eventIDs = eventIDs;
|
||||
ProgressionEventCondition.ListenForPickup(this);
|
||||
}
|
||||
|
||||
private static void ListenForPickup(ProgressionEventCondition condition)
|
||||
{
|
||||
if (!ProgressionEventCondition._isListenerHooked)
|
||||
{
|
||||
AchievementsHelper.OnProgressionEvent += new AchievementsHelper.ProgressionEventEvent(ProgressionEventCondition.ProgressionEventListener);
|
||||
ProgressionEventCondition._isListenerHooked = true;
|
||||
}
|
||||
for (int index = 0; index < condition._eventIDs.Length; ++index)
|
||||
{
|
||||
if (!ProgressionEventCondition._listeners.ContainsKey(condition._eventIDs[index]))
|
||||
ProgressionEventCondition._listeners[condition._eventIDs[index]] = new List<ProgressionEventCondition>();
|
||||
ProgressionEventCondition._listeners[condition._eventIDs[index]].Add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ProgressionEventListener(int eventID)
|
||||
{
|
||||
if (!ProgressionEventCondition._listeners.ContainsKey(eventID))
|
||||
return;
|
||||
foreach (AchievementCondition achievementCondition in ProgressionEventCondition._listeners[eventID])
|
||||
achievementCondition.Complete();
|
||||
}
|
||||
|
||||
public static ProgressionEventCondition Create(params int[] eventIDs) => new ProgressionEventCondition(eventIDs);
|
||||
|
||||
public static ProgressionEventCondition Create(int eventID) => new ProgressionEventCondition(eventID);
|
||||
|
||||
public static ProgressionEventCondition[] CreateMany(
|
||||
params int[] eventIDs)
|
||||
{
|
||||
ProgressionEventCondition[] progressionEventConditionArray = new ProgressionEventCondition[eventIDs.Length];
|
||||
for (int index = 0; index < eventIDs.Length; ++index)
|
||||
progressionEventConditionArray[index] = new ProgressionEventCondition(eventIDs[index]);
|
||||
return progressionEventConditionArray;
|
||||
}
|
||||
}
|
||||
}
|
51
GameContent/Achievements/TileDestroyedCondition.cs
Normal file
51
GameContent/Achievements/TileDestroyedCondition.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.TileDestroyedCondition
|
||||
// Assembly: Terraria, Version=1.3.5.3, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 68659D26-2BE6-448F-8663-74FA559E6F08
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class TileDestroyedCondition : AchievementCondition
|
||||
{
|
||||
private const string Identifier = "TILE_DESTROYED";
|
||||
private static Dictionary<ushort, List<TileDestroyedCondition>> _listeners = new Dictionary<ushort, List<TileDestroyedCondition>>();
|
||||
private static bool _isListenerHooked = false;
|
||||
private ushort[] _tileIds;
|
||||
|
||||
private TileDestroyedCondition(ushort[] tileIds)
|
||||
: base("TILE_DESTROYED_" + (object) tileIds[0])
|
||||
{
|
||||
this._tileIds = tileIds;
|
||||
TileDestroyedCondition.ListenForDestruction(this);
|
||||
}
|
||||
|
||||
private static void ListenForDestruction(TileDestroyedCondition condition)
|
||||
{
|
||||
if (!TileDestroyedCondition._isListenerHooked)
|
||||
{
|
||||
AchievementsHelper.OnTileDestroyed += new AchievementsHelper.TileDestroyedEvent(TileDestroyedCondition.TileDestroyedListener);
|
||||
TileDestroyedCondition._isListenerHooked = true;
|
||||
}
|
||||
for (int index = 0; index < condition._tileIds.Length; ++index)
|
||||
{
|
||||
if (!TileDestroyedCondition._listeners.ContainsKey(condition._tileIds[index]))
|
||||
TileDestroyedCondition._listeners[condition._tileIds[index]] = new List<TileDestroyedCondition>();
|
||||
TileDestroyedCondition._listeners[condition._tileIds[index]].Add(condition);
|
||||
}
|
||||
}
|
||||
|
||||
private static void TileDestroyedListener(Player player, ushort tileId)
|
||||
{
|
||||
if (player.whoAmI != Main.myPlayer || !TileDestroyedCondition._listeners.ContainsKey(tileId))
|
||||
return;
|
||||
foreach (AchievementCondition achievementCondition in TileDestroyedCondition._listeners[tileId])
|
||||
achievementCondition.Complete();
|
||||
}
|
||||
|
||||
public static AchievementCondition Create(params ushort[] tileIds) => (AchievementCondition) new TileDestroyedCondition(tileIds);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue