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);
|
||||
}
|
||||
}
|
67
GameContent/Biomes/CampsiteBiome.cs
Normal file
67
GameContent/Biomes/CampsiteBiome.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CampsiteBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class CampsiteBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Ref<int> count1 = new Ref<int>(0);
|
||||
Ref<int> count2 = new Ref<int>(0);
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1)));
|
||||
if (count1.Value < count2.Value - 5)
|
||||
return false;
|
||||
int radius = GenBase._random.Next(6, 10);
|
||||
int num1 = GenBase._random.Next(5);
|
||||
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2)))
|
||||
return false;
|
||||
ShapeData data = new ShapeData();
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Slime(radius), Actions.Chain(new Modifiers.Blotches(num1, num1, num1, 1).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 53
|
||||
}), (GenAction) new Actions.SetTile((ushort) 397, true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte) 16)));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(), (GenAction) new Actions.SetLiquid(value: (byte) 0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new byte[1]), (GenAction) new Actions.PlaceWall((byte) 16)));
|
||||
Point result;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result))
|
||||
return false;
|
||||
int j = result.Y - 1;
|
||||
bool flag = GenBase._random.Next() % 2 == 0;
|
||||
if (GenBase._random.Next() % 10 != 0)
|
||||
{
|
||||
int num2 = GenBase._random.Next(1, 4);
|
||||
int num3 = flag ? 4 : -(radius >> 1);
|
||||
for (int index1 = 0; index1 < num2; ++index1)
|
||||
{
|
||||
int num4 = GenBase._random.Next(1, 3);
|
||||
for (int index2 = 0; index2 < num4; ++index2)
|
||||
WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 331);
|
||||
}
|
||||
}
|
||||
int num5 = (radius - 3) * (flag ? -1 : 1);
|
||||
if (GenBase._random.Next() % 10 != 0)
|
||||
WorldGen.PlaceTile(origin.X + num5, j, 186);
|
||||
if (GenBase._random.Next() % 10 != 0)
|
||||
{
|
||||
WorldGen.PlaceTile(origin.X, j, 215, true);
|
||||
if (GenBase._tiles[origin.X, j].active() && GenBase._tiles[origin.X, j].type == (ushort) 215)
|
||||
{
|
||||
GenBase._tiles[origin.X, j].frameY += (short) 36;
|
||||
GenBase._tiles[origin.X - 1, j].frameY += (short) 36;
|
||||
GenBase._tiles[origin.X + 1, j].frameY += (short) 36;
|
||||
GenBase._tiles[origin.X, j - 1].frameY += (short) 36;
|
||||
GenBase._tiles[origin.X - 1, j - 1].frameY += (short) 36;
|
||||
GenBase._tiles[origin.X + 1, j - 1].frameY += (short) 36;
|
||||
}
|
||||
}
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
699
GameContent/Biomes/CaveHouseBiome.cs
Normal file
699
GameContent/Biomes/CaveHouseBiome.cs
Normal file
|
@ -0,0 +1,699 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouseBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.ID;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class CaveHouseBiome : MicroBiome
|
||||
{
|
||||
private const int VERTICAL_EXIT_WIDTH = 3;
|
||||
private static readonly bool[] _blacklistedTiles = TileID.Sets.Factory.CreateBoolSet(true, 225, 41, 43, 44, 226, 203, 112, 25, 151);
|
||||
private int _sharpenerCount;
|
||||
private int _extractinatorCount;
|
||||
|
||||
private Microsoft.Xna.Framework.Rectangle GetRoom(Point origin)
|
||||
{
|
||||
Point result1;
|
||||
bool flag1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Left(25), (GenCondition) new Conditions.IsSolid()), out result1);
|
||||
Point result2;
|
||||
int num1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Right(25), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;
|
||||
if (!flag1)
|
||||
result1 = new Point(origin.X - 25, origin.Y);
|
||||
if (num1 == 0)
|
||||
result2 = new Point(origin.X + 25, origin.Y);
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, 0, 0);
|
||||
if (origin.X - result1.X > result2.X - origin.X)
|
||||
{
|
||||
rectangle.X = result1.X;
|
||||
rectangle.Width = Utils.Clamp<int>(result2.X - result1.X, 15, 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
rectangle.Width = Utils.Clamp<int>(result2.X - result1.X, 15, 30);
|
||||
rectangle.X = result2.X - rectangle.Width;
|
||||
}
|
||||
Point result3;
|
||||
bool flag2 = WorldUtils.Find(result1, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
|
||||
Point result4;
|
||||
int num2 = WorldUtils.Find(result2, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4) ? 1 : 0;
|
||||
if (!flag2)
|
||||
result3 = new Point(origin.X, origin.Y - 10);
|
||||
if (num2 == 0)
|
||||
result4 = new Point(origin.X, origin.Y - 10);
|
||||
rectangle.Height = Utils.Clamp<int>(Math.Max(origin.Y - result3.Y, origin.Y - result4.Y), 8, 12);
|
||||
rectangle.Y -= rectangle.Height;
|
||||
return rectangle;
|
||||
}
|
||||
|
||||
private float RoomSolidPrecentage(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
float num = (float) (room.Width * room.Height);
|
||||
Ref<int> count = new Ref<int>(0);
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Count(count)));
|
||||
return (float) count.Value / num;
|
||||
}
|
||||
|
||||
private bool FindVerticalExit(Microsoft.Xna.Framework.Rectangle wall, bool isUp, out int exitX)
|
||||
{
|
||||
Point result;
|
||||
int num = WorldUtils.Find(new Point(wall.X + wall.Width - 3, wall.Y + (isUp ? -5 : 0)), Searches.Chain((GenSearch) new Searches.Left(wall.Width - 3), new Conditions.IsSolid().Not().AreaOr(3, 5)), out result) ? 1 : 0;
|
||||
exitX = result.X;
|
||||
return num != 0;
|
||||
}
|
||||
|
||||
private bool FindSideExit(Microsoft.Xna.Framework.Rectangle wall, bool isLeft, out int exitY)
|
||||
{
|
||||
Point result;
|
||||
int num = WorldUtils.Find(new Point(wall.X + (isLeft ? -4 : 0), wall.Y + wall.Height - 3), Searches.Chain((GenSearch) new Searches.Up(wall.Height - 3), new Conditions.IsSolid().Not().AreaOr(4, 3)), out result) ? 1 : 0;
|
||||
exitY = result.Y;
|
||||
return num != 0;
|
||||
}
|
||||
|
||||
private int SortBiomeResults(
|
||||
Tuple<CaveHouseBiome.BuildData, int> item1,
|
||||
Tuple<CaveHouseBiome.BuildData, int> item2)
|
||||
{
|
||||
return item2.Item2.CompareTo(item1.Item2);
|
||||
}
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Point result1;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin)
|
||||
return false;
|
||||
Microsoft.Xna.Framework.Rectangle room1 = this.GetRoom(result1);
|
||||
Microsoft.Xna.Framework.Rectangle room2 = this.GetRoom(new Point(room1.Center.X, room1.Y + 1));
|
||||
Microsoft.Xna.Framework.Rectangle room3 = this.GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
|
||||
room3.Y = room1.Y + room1.Height - 1;
|
||||
float num1 = this.RoomSolidPrecentage(room2);
|
||||
float num2 = this.RoomSolidPrecentage(room3);
|
||||
room1.Y += 3;
|
||||
room2.Y += 3;
|
||||
room3.Y += 3;
|
||||
List<Microsoft.Xna.Framework.Rectangle> rectangleList1 = new List<Microsoft.Xna.Framework.Rectangle>();
|
||||
if ((double) GenBase._random.NextFloat() > (double) num1 + 0.200000002980232)
|
||||
rectangleList1.Add(room2);
|
||||
else
|
||||
room2 = room1;
|
||||
rectangleList1.Add(room1);
|
||||
if ((double) GenBase._random.NextFloat() > (double) num2 + 0.200000002980232)
|
||||
rectangleList1.Add(room3);
|
||||
else
|
||||
room3 = room1;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
|
||||
return false;
|
||||
}
|
||||
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), (GenShape) new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12]
|
||||
{
|
||||
(ushort) 0,
|
||||
(ushort) 59,
|
||||
(ushort) 147,
|
||||
(ushort) 1,
|
||||
(ushort) 161,
|
||||
(ushort) 53,
|
||||
(ushort) 396,
|
||||
(ushort) 397,
|
||||
(ushort) 368,
|
||||
(ushort) 367,
|
||||
(ushort) 60,
|
||||
(ushort) 70
|
||||
}).Output(resultsOutput));
|
||||
List<Tuple<CaveHouseBiome.BuildData, int>> tupleList1 = new List<Tuple<CaveHouseBiome.BuildData, int>>();
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1]));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 60] * 10));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 70] * 10));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, resultsOutput[(ushort) 147] + resultsOutput[(ushort) 161]));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, resultsOutput[(ushort) 397] + resultsOutput[(ushort) 396] + resultsOutput[(ushort) 53]));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, resultsOutput[(ushort) 368]));
|
||||
tupleList1.Add(Tuple.Create<CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, resultsOutput[(ushort) 367]));
|
||||
tupleList1.Sort(new Comparison<Tuple<CaveHouseBiome.BuildData, int>>(this.SortBiomeResults));
|
||||
CaveHouseBiome.BuildData buildData = tupleList1[0].Item1;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
|
||||
{
|
||||
if (buildData != CaveHouseBiome.BuildData.Granite)
|
||||
{
|
||||
if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out Point _))
|
||||
return false;
|
||||
}
|
||||
if (!structures.CanPlace(area, CaveHouseBiome._blacklistedTiles, 5))
|
||||
return false;
|
||||
}
|
||||
int val1_1 = room1.X;
|
||||
int val1_2 = room1.X + room1.Width - 1;
|
||||
List<Microsoft.Xna.Framework.Rectangle> rectangleList2 = new List<Microsoft.Xna.Framework.Rectangle>();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
val1_1 = Math.Min(val1_1, rectangle.X);
|
||||
val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
|
||||
}
|
||||
int num3 = 6;
|
||||
while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
|
||||
--num3;
|
||||
for (int x = val1_1; x <= val1_2; x += num3)
|
||||
{
|
||||
for (int index1 = 0; index1 < rectangleList1.Count; ++index1)
|
||||
{
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = rectangleList1[index1];
|
||||
if (x >= rectangle.X && x < rectangle.X + rectangle.Width)
|
||||
{
|
||||
int y = rectangle.Y + rectangle.Height;
|
||||
int num4 = 50;
|
||||
for (int index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
|
||||
{
|
||||
if (x >= rectangleList1[index2].X && x < rectangleList1[index2].X + rectangleList1[index2].Width)
|
||||
num4 = Math.Min(num4, rectangleList1[index2].Y - y);
|
||||
}
|
||||
if (num4 > 0)
|
||||
{
|
||||
Point result2;
|
||||
bool flag = WorldUtils.Find(new Point(x, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2);
|
||||
if (num4 < 50)
|
||||
{
|
||||
flag = true;
|
||||
result2 = new Point(x, y + num4);
|
||||
}
|
||||
if (flag)
|
||||
rectangleList2.Add(new Microsoft.Xna.Framework.Rectangle(x, y, 1, result2.Y - y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Point> pointList1 = new List<Point>();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int exitY;
|
||||
if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY))
|
||||
pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
|
||||
if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY))
|
||||
pointList1.Add(new Point(rectangle.X, exitY));
|
||||
}
|
||||
List<Tuple<Point, Point>> tupleList2 = new List<Tuple<Point, Point>>();
|
||||
for (int index = 1; index < rectangleList1.Count; ++index)
|
||||
{
|
||||
Microsoft.Xna.Framework.Rectangle rectangle1 = rectangleList1[index];
|
||||
Microsoft.Xna.Framework.Rectangle rectangle2 = rectangleList1[index - 1];
|
||||
if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
|
||||
tupleList2.Add(new Tuple<Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1)));
|
||||
else
|
||||
tupleList2.Add(new Tuple<Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
|
||||
}
|
||||
List<Point> pointList2 = new List<Point>();
|
||||
int exitX;
|
||||
if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX))
|
||||
pointList2.Add(new Point(exitX, room2.Y));
|
||||
if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX))
|
||||
pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
|
||||
foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
|
||||
{
|
||||
WorldUtils.Gen(new Point(area.X, area.Y), (GenShape) new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), (GenShape) new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall)));
|
||||
structures.AddStructure(area, 8);
|
||||
}
|
||||
foreach (Tuple<Point, Point> tuple in tupleList2)
|
||||
{
|
||||
Point origin1 = tuple.Item1;
|
||||
Point point = tuple.Item2;
|
||||
int num5 = point.X > origin1.X ? 1 : -1;
|
||||
ShapeData data = new ShapeData();
|
||||
for (int y = 0; y < point.Y - origin1.Y; ++y)
|
||||
data.Add(num5 * (y + 1), y);
|
||||
WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num5 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(new Point(origin1.X + (num5 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall), (GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
|
||||
}
|
||||
foreach (Point origin2 in pointList1)
|
||||
{
|
||||
WorldUtils.Gen(origin2, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
|
||||
WorldGen.PlaceTile(origin2.X, origin2.Y, 10, true, true, style: buildData.DoorStyle);
|
||||
}
|
||||
foreach (Point origin3 in pointList2)
|
||||
{
|
||||
Shapes.Rectangle rectangle = new Shapes.Rectangle(3, 1);
|
||||
GenAction action = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort) 19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true));
|
||||
WorldUtils.Gen(origin3, (GenShape) rectangle, action);
|
||||
}
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList2)
|
||||
{
|
||||
if (rectangle.Height > 1 && GenBase._tiles[rectangle.X, rectangle.Y - 1].type != (ushort) 19)
|
||||
{
|
||||
WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), (GenShape) new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort) 124), (GenAction) new Actions.SetFrames(true)));
|
||||
Tile tile = GenBase._tiles[rectangle.X, rectangle.Y + rectangle.Height];
|
||||
tile.slope((byte) 0);
|
||||
tile.halfBrick(false);
|
||||
}
|
||||
}
|
||||
Point[] pointArray = new Point[7]
|
||||
{
|
||||
new Point(14, buildData.TableStyle),
|
||||
new Point(16, 0),
|
||||
new Point(18, buildData.WorkbenchStyle),
|
||||
new Point(86, 0),
|
||||
new Point(87, buildData.PianoStyle),
|
||||
new Point(94, 0),
|
||||
new Point(101, buildData.BookcaseStyle)
|
||||
};
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int num6 = rectangle.Width / 8;
|
||||
int num7 = rectangle.Width / (num6 + 1);
|
||||
int num8 = GenBase._random.Next(2);
|
||||
for (int index3 = 0; index3 < num6; ++index3)
|
||||
{
|
||||
int num9 = (index3 + 1) * num7 + rectangle.X;
|
||||
switch (index3 + num8 % 2)
|
||||
{
|
||||
case 0:
|
||||
int num10 = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
|
||||
Vector2 vector2 = WorldGen.randHousePicture();
|
||||
int x = (int) vector2.X;
|
||||
int y = (int) vector2.Y;
|
||||
if (!WorldGen.nearPicture(num9, num10))
|
||||
{
|
||||
WorldGen.PlaceTile(num9, num10, x, true, style: y);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
int j = rectangle.Y + 1;
|
||||
WorldGen.PlaceTile(num9, j, 34, true, style: GenBase._random.Next(6));
|
||||
for (int index4 = -1; index4 < 2; ++index4)
|
||||
{
|
||||
for (int index5 = 0; index5 < 3; ++index5)
|
||||
GenBase._tiles[index4 + num9, index5 + j].frameX += (short) 54;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
int num11 = rectangle.Width / 8 + 3;
|
||||
WorldGen.SetupStatueList();
|
||||
for (; num11 > 0; --num11)
|
||||
{
|
||||
int num12 = GenBase._random.Next(rectangle.Width - 3) + 1 + rectangle.X;
|
||||
int num13 = rectangle.Y + rectangle.Height - 2;
|
||||
switch (GenBase._random.Next(4))
|
||||
{
|
||||
case 0:
|
||||
WorldGen.PlaceSmallPile(num12, num13, GenBase._random.Next(31, 34), 1);
|
||||
break;
|
||||
case 1:
|
||||
WorldGen.PlaceTile(num12, num13, 186, true, style: GenBase._random.Next(22, 26));
|
||||
break;
|
||||
case 2:
|
||||
int index = GenBase._random.Next(2, WorldGen.statueList.Length);
|
||||
WorldGen.PlaceTile(num12, num13, (int) WorldGen.statueList[index].X, true, style: ((int) WorldGen.statueList[index].Y));
|
||||
if (WorldGen.StatuesWithTraps.Contains(index))
|
||||
{
|
||||
WorldGen.PlaceStatueTrap(num12, num13);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Point point = Utils.SelectRandom<Point>(GenBase._random, pointArray);
|
||||
WorldGen.PlaceTile(num12, num13, point.X, true, style: point.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room4 in rectangleList1)
|
||||
buildData.ProcessRoom(room4);
|
||||
bool flag1 = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int j = rectangle.Height - 1 + rectangle.Y;
|
||||
int Style = j > (int) Main.worldSurface ? buildData.ChestStyle : 0;
|
||||
int num14 = 0;
|
||||
while (num14 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, Style: Style)))
|
||||
++num14;
|
||||
if (!flag1)
|
||||
{
|
||||
int i = rectangle.X + 2;
|
||||
while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, Style: Style)))
|
||||
++i;
|
||||
if (flag1)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!flag1)
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int j = rectangle.Y - 1;
|
||||
int Style = j > (int) Main.worldSurface ? buildData.ChestStyle : 0;
|
||||
int num15 = 0;
|
||||
while (num15 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, Style: Style)))
|
||||
++num15;
|
||||
if (!flag1)
|
||||
{
|
||||
int i = rectangle.X + 2;
|
||||
while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, Style: Style)))
|
||||
++i;
|
||||
if (flag1)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag1)
|
||||
{
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
int i = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
|
||||
int num16 = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
|
||||
int num17 = num16 > (int) Main.worldSurface ? buildData.ChestStyle : 0;
|
||||
int j = num16;
|
||||
int Style = num17;
|
||||
if (WorldGen.AddBuriedChest(i, j, Style: Style))
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
|
||||
{
|
||||
bool flag2 = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int j = rectangle.Height - 2 + rectangle.Y;
|
||||
for (int index = 0; index < 10; ++index)
|
||||
{
|
||||
int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
|
||||
WorldGen.PlaceTile(i, j, 377, true, true);
|
||||
if (flag2 = GenBase._tiles[i, j].active() && GenBase._tiles[i, j].type == (ushort) 377)
|
||||
break;
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
int i = rectangle.X + 2;
|
||||
while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true)))
|
||||
++i;
|
||||
if (flag2)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (flag2)
|
||||
++this._sharpenerCount;
|
||||
}
|
||||
if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
|
||||
{
|
||||
bool flag3 = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
|
||||
{
|
||||
int j = rectangle.Height - 2 + rectangle.Y;
|
||||
for (int index = 0; index < 10; ++index)
|
||||
{
|
||||
int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
|
||||
WorldGen.PlaceTile(i, j, 219, true, true);
|
||||
if (flag3 = GenBase._tiles[i, j].active() && GenBase._tiles[i, j].type == (ushort) 219)
|
||||
break;
|
||||
}
|
||||
if (!flag3)
|
||||
{
|
||||
int i = rectangle.X + 2;
|
||||
while (i <= rectangle.X + rectangle.Width - 2 && !(flag3 = WorldGen.PlaceTile(i, j, 219, true, true)))
|
||||
++i;
|
||||
if (flag3)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (flag3)
|
||||
++this._extractinatorCount;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._sharpenerCount = 0;
|
||||
this._extractinatorCount = 0;
|
||||
}
|
||||
|
||||
internal static void AgeDefaultRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
for (int index = 0; index < room.Width * room.Height / 16; ++index)
|
||||
WorldUtils.Gen(new Point(GenBase._random.Next(1, room.Width - 1) + room.X, GenBase._random.Next(1, room.Height - 1) + room.Y), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.Blotches(chance: 2.0), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetTile((ushort) 51, true)));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.OnlyWalls(new byte[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Default.Wall
|
||||
}), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((byte) 2)));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.949999988079071), (GenAction) new Modifiers.OnlyTiles(new ushort[3]
|
||||
{
|
||||
(ushort) 30,
|
||||
(ushort) 321,
|
||||
(ushort) 158
|
||||
}), (GenAction) new Actions.ClearTile(true)));
|
||||
}
|
||||
|
||||
internal static void AgeSnowRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Snow.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 161, true), (GenAction) new Modifiers.Dither(0.8), (GenAction) new Actions.SetTile((ushort) 147, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 161
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 161
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(chance: 0.8), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((byte) 40)));
|
||||
}
|
||||
|
||||
internal static void AgeDesertRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.Blotches(chance: 0.200000002980232), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Desert.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 396, true), (GenAction) new Modifiers.Dither(), (GenAction) new Actions.SetTile((ushort) 397, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
|
||||
{
|
||||
(ushort) 397,
|
||||
(ushort) 396
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
|
||||
{
|
||||
(ushort) 397,
|
||||
(ushort) 396
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.OnlyWalls(new byte[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Desert.Wall
|
||||
}), (GenAction) new Actions.PlaceWall((byte) 216)));
|
||||
}
|
||||
|
||||
internal static void AgeGraniteRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Granite.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 368, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 368
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 368
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 180)));
|
||||
}
|
||||
|
||||
internal static void AgeMarbleRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Marble.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 367, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 367
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 367
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionStalagtite()));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 178)));
|
||||
}
|
||||
|
||||
internal static void AgeMushroomRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.699999988079071), (GenAction) new Modifiers.Blotches(chance: 0.5), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Mushroom.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 70, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 70
|
||||
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new Actions.SetTile((ushort) 71)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 70
|
||||
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new Actions.SetTile((ushort) 71)));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.ClearWall()));
|
||||
}
|
||||
|
||||
internal static void AgeJungleRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.600000023841858), (GenAction) new Modifiers.Blotches(chance: 0.600000023841858), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
CaveHouseBiome.BuildData.Jungle.Tile
|
||||
}), (GenAction) new Actions.SetTile((ushort) 60, true), (GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Actions.SetTile((ushort) 59, true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 60
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, room.Height, 62)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + room.Height - 1), (GenShape) new Shapes.Rectangle(room.Width - 2, 1), Actions.Chain((GenAction) new Modifiers.Dither(), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 60
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, room.Height, 62)));
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Modifiers.Dither(0.850000023841858), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.PlaceWall((byte) 64)));
|
||||
}
|
||||
|
||||
private class BuildData
|
||||
{
|
||||
public static CaveHouseBiome.BuildData Snow = CaveHouseBiome.BuildData.CreateSnowData();
|
||||
public static CaveHouseBiome.BuildData Jungle = CaveHouseBiome.BuildData.CreateJungleData();
|
||||
public static CaveHouseBiome.BuildData Default = CaveHouseBiome.BuildData.CreateDefaultData();
|
||||
public static CaveHouseBiome.BuildData Granite = CaveHouseBiome.BuildData.CreateGraniteData();
|
||||
public static CaveHouseBiome.BuildData Marble = CaveHouseBiome.BuildData.CreateMarbleData();
|
||||
public static CaveHouseBiome.BuildData Mushroom = CaveHouseBiome.BuildData.CreateMushroomData();
|
||||
public static CaveHouseBiome.BuildData Desert = CaveHouseBiome.BuildData.CreateDesertData();
|
||||
public ushort Tile;
|
||||
public byte Wall;
|
||||
public int PlatformStyle;
|
||||
public int DoorStyle;
|
||||
public int TableStyle;
|
||||
public int WorkbenchStyle;
|
||||
public int PianoStyle;
|
||||
public int BookcaseStyle;
|
||||
public int ChairStyle;
|
||||
public int ChestStyle;
|
||||
public CaveHouseBiome.BuildData.ProcessRoomMethod ProcessRoom;
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateSnowData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 321,
|
||||
Wall = 149,
|
||||
DoorStyle = 30,
|
||||
PlatformStyle = 19,
|
||||
TableStyle = 28,
|
||||
WorkbenchStyle = 23,
|
||||
PianoStyle = 23,
|
||||
BookcaseStyle = 25,
|
||||
ChairStyle = 30,
|
||||
ChestStyle = 11,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeSnowRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateDesertData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 396,
|
||||
Wall = 187,
|
||||
PlatformStyle = 0,
|
||||
DoorStyle = 0,
|
||||
TableStyle = 0,
|
||||
WorkbenchStyle = 0,
|
||||
PianoStyle = 0,
|
||||
BookcaseStyle = 0,
|
||||
ChairStyle = 0,
|
||||
ChestStyle = 1,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeDesertRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateJungleData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 158,
|
||||
Wall = 42,
|
||||
PlatformStyle = 2,
|
||||
DoorStyle = 2,
|
||||
TableStyle = 2,
|
||||
WorkbenchStyle = 2,
|
||||
PianoStyle = 2,
|
||||
BookcaseStyle = 12,
|
||||
ChairStyle = 3,
|
||||
ChestStyle = 8,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeJungleRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateGraniteData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 369,
|
||||
Wall = 181,
|
||||
PlatformStyle = 28,
|
||||
DoorStyle = 34,
|
||||
TableStyle = 33,
|
||||
WorkbenchStyle = 29,
|
||||
PianoStyle = 28,
|
||||
BookcaseStyle = 30,
|
||||
ChairStyle = 34,
|
||||
ChestStyle = 50,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeGraniteRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateMarbleData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 357,
|
||||
Wall = 179,
|
||||
PlatformStyle = 29,
|
||||
DoorStyle = 35,
|
||||
TableStyle = 34,
|
||||
WorkbenchStyle = 30,
|
||||
PianoStyle = 29,
|
||||
BookcaseStyle = 31,
|
||||
ChairStyle = 35,
|
||||
ChestStyle = 51,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMarbleRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateMushroomData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 190,
|
||||
Wall = 74,
|
||||
PlatformStyle = 18,
|
||||
DoorStyle = 6,
|
||||
TableStyle = 27,
|
||||
WorkbenchStyle = 7,
|
||||
PianoStyle = 22,
|
||||
BookcaseStyle = 24,
|
||||
ChairStyle = 9,
|
||||
ChestStyle = 32,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeMushroomRoom)
|
||||
};
|
||||
|
||||
public static CaveHouseBiome.BuildData CreateDefaultData() => new CaveHouseBiome.BuildData()
|
||||
{
|
||||
Tile = 30,
|
||||
Wall = 27,
|
||||
PlatformStyle = 0,
|
||||
DoorStyle = 0,
|
||||
TableStyle = 0,
|
||||
WorkbenchStyle = 0,
|
||||
PianoStyle = 0,
|
||||
BookcaseStyle = 0,
|
||||
ChairStyle = 0,
|
||||
ChestStyle = 1,
|
||||
ProcessRoom = new CaveHouseBiome.BuildData.ProcessRoomMethod(CaveHouseBiome.AgeDefaultRoom)
|
||||
};
|
||||
|
||||
public delegate void ProcessRoomMethod(Microsoft.Xna.Framework.Rectangle room);
|
||||
}
|
||||
}
|
||||
}
|
55
GameContent/Biomes/CorruptionPitBiome.cs
Normal file
55
GameContent/Biomes/CorruptionPitBiome.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CorruptionPitBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.ID;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class CorruptionPitBiome : MicroBiome
|
||||
{
|
||||
public static bool[] ValidTiles = TileID.Sets.Factory.CreateBoolSet(true, 21, 31, 26);
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == (byte) 3)
|
||||
return false;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(100), (GenCondition) new Conditions.IsSolid()), out origin))
|
||||
return false;
|
||||
if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain((GenSearch) new Searches.Down(5), new Conditions.IsTile(new ushort[1]
|
||||
{
|
||||
(ushort) 25
|
||||
}).AreaAnd(8, 1)), out Point _))
|
||||
return false;
|
||||
ShapeData data1 = new ShapeData();
|
||||
ShapeData shapeData1 = new ShapeData();
|
||||
ShapeData shapeData2 = new ShapeData();
|
||||
for (int index = 0; index < 6; ++index)
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3).Output(data1)));
|
||||
for (int index = 0; index < 6; ++index)
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3).Output(shapeData1)));
|
||||
for (int index = 0; index < 6; ++index)
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain((GenAction) new Modifiers.Offset(0, (int) (7.5 * (double) index) - 10), new Modifiers.Blotches(3).Output(shapeData2)));
|
||||
ShapeData data2 = new ShapeData(shapeData1);
|
||||
shapeData1.Subtract(shapeData2, origin, origin);
|
||||
data2.Subtract(shapeData1, origin, origin);
|
||||
Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2);
|
||||
if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
|
||||
return false;
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort) 25, true), (GenAction) new Actions.PlaceWall((byte) 3)));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), (GenAction) new Actions.SetTile((ushort) 0, true));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData2), (GenAction) new Actions.ClearTile(true));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), Actions.Chain((GenAction) new Modifiers.IsTouchingAir(true), (GenAction) new Modifiers.NotTouching(false, new ushort[1]
|
||||
{
|
||||
(ushort) 25
|
||||
}), (GenAction) new Actions.SetTile((ushort) 23, true)));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data2), (GenAction) new Actions.PlaceWall((byte) 69));
|
||||
structures.AddStructure(bounds, 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
460
GameContent/Biomes/DesertBiome.cs
Normal file
460
GameContent/Biomes/DesertBiome.cs
Normal file
|
@ -0,0 +1,460 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.DesertBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class DesertBiome : MicroBiome
|
||||
{
|
||||
private void PlaceSand(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
|
||||
{
|
||||
int num1 = (int) ((double) scale.X * (double) clusters.Width);
|
||||
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
|
||||
int num3 = 5;
|
||||
int val1 = start.Y + (num2 >> 1);
|
||||
float num4 = 0.0f;
|
||||
short[] numArray = new short[num1 + num3 * 2];
|
||||
for (int index = -num3; index < num1 + num3; ++index)
|
||||
{
|
||||
for (int y = 150; y < val1; ++y)
|
||||
{
|
||||
if (WorldGen.SolidOrSlopedTile(index + start.X, y))
|
||||
{
|
||||
num4 += (float) (y - 1);
|
||||
numArray[index + num3] = (short) (y - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
float num5 = num4 / (float) (num1 + num3 * 2);
|
||||
int num6 = 0;
|
||||
for (int index1 = -num3; index1 < num1 + num3; ++index1)
|
||||
{
|
||||
float num7 = MathHelper.Clamp((float) ((double) Math.Abs((float) (index1 + num3) / (float) (num1 + num3 * 2)) * 2.0 - 1.0), -1f, 1f);
|
||||
if (index1 % 3 == 0)
|
||||
num6 = Utils.Clamp<int>(num6 + GenBase._random.Next(-1, 2), -10, 10);
|
||||
float num8 = (float) Math.Sqrt(1.0 - (double) num7 * (double) num7 * (double) num7 * (double) num7);
|
||||
int val2_1 = val1 - (int) ((double) num8 * (double) ((float) val1 - num5)) + num6;
|
||||
int val2_2 = val1 - (int) ((double) ((float) val1 - num5) * ((double) num8 - 0.150000005960464 / Math.Sqrt(Math.Max(0.01, (double) Math.Abs(8f * num7) - 0.1)) + 0.25));
|
||||
int num9 = Math.Min(val1, val2_2);
|
||||
if ((double) Math.Abs(num7) < 0.800000011920929)
|
||||
{
|
||||
float num10 = Utils.SmoothStep(0.5f, 0.8f, Math.Abs(num7));
|
||||
float num11 = num10 * num10 * num10;
|
||||
int num12 = Math.Min(10 + (int) ((double) num5 - (double) num11 * 20.0) + num6, val2_1);
|
||||
int num13 = 50;
|
||||
for (int index2 = num13; (double) index2 < (double) num5; ++index2)
|
||||
{
|
||||
int index3 = index1 + start.X;
|
||||
if (GenBase._tiles[index3, index2].active() && (GenBase._tiles[index3, index2].type == (ushort) 189 || GenBase._tiles[index3, index2].type == (ushort) 196))
|
||||
num13 = index2 + 5;
|
||||
}
|
||||
for (int index4 = num13; index4 < num12; ++index4)
|
||||
{
|
||||
int index5 = index1 + start.X;
|
||||
int index6 = index4;
|
||||
GenBase._tiles[index5, index6].active(false);
|
||||
GenBase._tiles[index5, index6].wall = (byte) 0;
|
||||
}
|
||||
numArray[index1 + num3] = (short) num12;
|
||||
}
|
||||
for (int index7 = val1 - 1; index7 >= val2_1; --index7)
|
||||
{
|
||||
int i = index1 + start.X;
|
||||
int j = index7;
|
||||
Tile tile1 = GenBase._tiles[i, j];
|
||||
tile1.liquid = (byte) 0;
|
||||
Tile tile2 = GenBase._tiles[i, j + 1];
|
||||
Tile tile3 = GenBase._tiles[i, j + 2];
|
||||
tile1.type = !WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3) ? (ushort) 397 : (ushort) 53;
|
||||
if (index7 > val2_1 + 5)
|
||||
tile1.wall = (byte) 187;
|
||||
tile1.active(true);
|
||||
if (tile1.wall != (byte) 187)
|
||||
tile1.wall = (byte) 0;
|
||||
if (index7 < num9)
|
||||
{
|
||||
if (index7 > val2_1 + 5)
|
||||
tile1.wall = (byte) 187;
|
||||
tile1.active(false);
|
||||
}
|
||||
WorldGen.SquareWallFrame(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceClusters(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
|
||||
{
|
||||
int num1 = (int) ((double) scale.X * (double) clusters.Width);
|
||||
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
|
||||
Vector2 vector2_1 = new Vector2((float) num1, (float) num2);
|
||||
Vector2 vector2_2 = new Vector2((float) clusters.Width, (float) clusters.Height);
|
||||
for (int index1 = -20; index1 < num1 + 20; ++index1)
|
||||
{
|
||||
for (int index2 = -20; index2 < num2 + 20; ++index2)
|
||||
{
|
||||
float num3 = 0.0f;
|
||||
int num4 = -1;
|
||||
float num5 = 0.0f;
|
||||
int x = index1 + start.X;
|
||||
int y = index2 + start.Y;
|
||||
Vector2 vector2_3 = new Vector2((float) index1, (float) index2) / vector2_1 * vector2_2;
|
||||
float num6 = (new Vector2((float) index1, (float) index2) / vector2_1 * 2f - Vector2.One).Length();
|
||||
for (int index3 = 0; index3 < clusters.Count; ++index3)
|
||||
{
|
||||
DesertBiome.Cluster cluster = clusters[index3];
|
||||
if ((double) Math.Abs(cluster[0].Position.X - vector2_3.X) <= 10.0 && (double) Math.Abs(cluster[0].Position.Y - vector2_3.Y) <= 10.0)
|
||||
{
|
||||
float num7 = 0.0f;
|
||||
foreach (DesertBiome.Hub hub in (List<DesertBiome.Hub>) cluster)
|
||||
num7 += 1f / Vector2.DistanceSquared(hub.Position, vector2_3);
|
||||
if ((double) num7 > (double) num3)
|
||||
{
|
||||
if ((double) num3 > (double) num5)
|
||||
num5 = num3;
|
||||
num3 = num7;
|
||||
num4 = index3;
|
||||
}
|
||||
else if ((double) num7 > (double) num5)
|
||||
num5 = num7;
|
||||
}
|
||||
}
|
||||
float num8 = num3 + num5;
|
||||
Tile tile = GenBase._tiles[x, y];
|
||||
bool flag = (double) num6 >= 0.800000011920929;
|
||||
if ((double) num8 > 3.5)
|
||||
{
|
||||
tile.ClearEverything();
|
||||
tile.wall = (byte) 187;
|
||||
tile.liquid = (byte) 0;
|
||||
if (num4 % 15 == 2)
|
||||
{
|
||||
tile.ResetToType((ushort) 404);
|
||||
tile.wall = (byte) 187;
|
||||
tile.active(true);
|
||||
}
|
||||
Tile.SmoothSlope(x, y);
|
||||
}
|
||||
else if ((double) num8 > 1.79999995231628)
|
||||
{
|
||||
tile.wall = (byte) 187;
|
||||
if (!flag || tile.active())
|
||||
{
|
||||
tile.ResetToType((ushort) 396);
|
||||
tile.wall = (byte) 187;
|
||||
tile.active(true);
|
||||
Tile.SmoothSlope(x, y);
|
||||
}
|
||||
tile.liquid = (byte) 0;
|
||||
}
|
||||
else if ((double) num8 > 0.699999988079071 || !flag)
|
||||
{
|
||||
if (!flag || tile.active())
|
||||
{
|
||||
tile.ResetToType((ushort) 397);
|
||||
tile.active(true);
|
||||
Tile.SmoothSlope(x, y);
|
||||
}
|
||||
tile.liquid = (byte) 0;
|
||||
tile.wall = (byte) 216;
|
||||
}
|
||||
else if ((double) num8 > 0.25)
|
||||
{
|
||||
float num9 = (float) (((double) num8 - 0.25) / 0.449999988079071);
|
||||
if ((double) GenBase._random.NextFloat() < (double) num9)
|
||||
{
|
||||
if (tile.active())
|
||||
{
|
||||
tile.ResetToType((ushort) 397);
|
||||
tile.active(true);
|
||||
Tile.SmoothSlope(x, y);
|
||||
tile.wall = (byte) 216;
|
||||
}
|
||||
tile.liquid = (byte) 0;
|
||||
tile.wall = (byte) 187;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddTileVariance(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
|
||||
{
|
||||
int num1 = (int) ((double) scale.X * (double) clusters.Width);
|
||||
int num2 = (int) ((double) scale.Y * (double) clusters.Height);
|
||||
for (int index1 = -20; index1 < num1 + 20; ++index1)
|
||||
{
|
||||
for (int index2 = -20; index2 < num2 + 20; ++index2)
|
||||
{
|
||||
int index3 = index1 + start.X;
|
||||
int index4 = index2 + start.Y;
|
||||
Tile tile1 = GenBase._tiles[index3, index4];
|
||||
Tile tile2 = GenBase._tiles[index3, index4 + 1];
|
||||
Tile tile3 = GenBase._tiles[index3, index4 + 2];
|
||||
if (tile1.type == (ushort) 53 && (!WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3)))
|
||||
tile1.type = (ushort) 397;
|
||||
}
|
||||
}
|
||||
for (int index5 = -20; index5 < num1 + 20; ++index5)
|
||||
{
|
||||
for (int index6 = -20; index6 < num2 + 20; ++index6)
|
||||
{
|
||||
int i = index5 + start.X;
|
||||
int index7 = index6 + start.Y;
|
||||
Tile tile = GenBase._tiles[i, index7];
|
||||
if (tile.active() && tile.type == (ushort) 396)
|
||||
{
|
||||
bool flag1 = true;
|
||||
for (int index8 = -1; index8 >= -3; --index8)
|
||||
{
|
||||
if (GenBase._tiles[i, index7 + index8].active())
|
||||
{
|
||||
flag1 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool flag2 = true;
|
||||
for (int index9 = 1; index9 <= 3; ++index9)
|
||||
{
|
||||
if (GenBase._tiles[i, index7 + index9].active())
|
||||
{
|
||||
flag2 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag1 ^ flag2 && GenBase._random.Next(5) == 0)
|
||||
WorldGen.PlaceTile(i, index7 + (flag1 ? -1 : 1), 165, true, true);
|
||||
else if (flag1 && GenBase._random.Next(5) == 0)
|
||||
WorldGen.PlaceTile(i, index7 - 1, 187, true, true, style: (29 + GenBase._random.Next(6)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool FindStart(
|
||||
Point origin,
|
||||
Vector2 scale,
|
||||
int xHubCount,
|
||||
int yHubCount,
|
||||
out Point start)
|
||||
{
|
||||
start = new Point(0, 0);
|
||||
int width = (int) ((double) scale.X * (double) xHubCount);
|
||||
int height = (int) ((double) scale.Y * (double) yHubCount);
|
||||
origin.X -= width >> 1;
|
||||
int y = 220;
|
||||
label_10:
|
||||
for (int index = -20; index < width + 20; ++index)
|
||||
{
|
||||
for (int j = 220; j < Main.maxTilesY; ++j)
|
||||
{
|
||||
if (WorldGen.SolidTile(index + origin.X, j))
|
||||
{
|
||||
switch (GenBase._tiles[index + origin.X, j].type)
|
||||
{
|
||||
case 59:
|
||||
case 60:
|
||||
return false;
|
||||
default:
|
||||
if (j > y)
|
||||
{
|
||||
y = j;
|
||||
goto label_10;
|
||||
}
|
||||
else
|
||||
goto label_10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WorldGen.UndergroundDesertLocation = new Microsoft.Xna.Framework.Rectangle(origin.X, y, width, height);
|
||||
start = new Point(origin.X, y);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
float num1 = (float) Main.maxTilesX / 4200f;
|
||||
int num2 = (int) (80.0 * (double) num1);
|
||||
int num3 = (int) (((double) GenBase._random.NextFloat() + 1.0) * 80.0 * (double) num1);
|
||||
Vector2 scale = new Vector2(4f, 2f);
|
||||
Point start;
|
||||
if (!this.FindStart(origin, scale, num2, num3, out start))
|
||||
return false;
|
||||
DesertBiome.ClusterGroup clusters = new DesertBiome.ClusterGroup();
|
||||
clusters.Generate(num2, num3);
|
||||
this.PlaceSand(clusters, start, scale);
|
||||
this.PlaceClusters(clusters, start, scale);
|
||||
this.AddTileVariance(clusters, start, scale);
|
||||
int num4 = (int) ((double) scale.X * (double) clusters.Width);
|
||||
int num5 = (int) ((double) scale.Y * (double) clusters.Height);
|
||||
for (int index1 = -20; index1 < num4 + 20; ++index1)
|
||||
{
|
||||
for (int index2 = -20; index2 < num5 + 20; ++index2)
|
||||
{
|
||||
if (index1 + start.X > 0 && index1 + start.X < Main.maxTilesX - 1 && index2 + start.Y > 0 && index2 + start.Y < Main.maxTilesY - 1)
|
||||
{
|
||||
WorldGen.SquareWallFrame(index1 + start.X, index2 + start.Y);
|
||||
WorldUtils.TileFrame(index1 + start.X, index2 + start.Y, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private struct Hub
|
||||
{
|
||||
public Vector2 Position;
|
||||
|
||||
public Hub(Vector2 position) => this.Position = position;
|
||||
|
||||
public Hub(float x, float y) => this.Position = new Vector2(x, y);
|
||||
}
|
||||
|
||||
private class Cluster : List<DesertBiome.Hub>
|
||||
{
|
||||
}
|
||||
|
||||
private class ClusterGroup : List<DesertBiome.Cluster>
|
||||
{
|
||||
public int Width;
|
||||
public int Height;
|
||||
|
||||
private void SearchForCluster(
|
||||
bool[,] hubMap,
|
||||
List<Point> pointCluster,
|
||||
int x,
|
||||
int y,
|
||||
int level = 2)
|
||||
{
|
||||
pointCluster.Add(new Point(x, y));
|
||||
hubMap[x, y] = false;
|
||||
--level;
|
||||
if (level == -1)
|
||||
return;
|
||||
if (x > 0 && hubMap[x - 1, y])
|
||||
this.SearchForCluster(hubMap, pointCluster, x - 1, y, level);
|
||||
if (x < hubMap.GetLength(0) - 1 && hubMap[x + 1, y])
|
||||
this.SearchForCluster(hubMap, pointCluster, x + 1, y, level);
|
||||
if (y > 0 && hubMap[x, y - 1])
|
||||
this.SearchForCluster(hubMap, pointCluster, x, y - 1, level);
|
||||
if (y >= hubMap.GetLength(1) - 1 || !hubMap[x, y + 1])
|
||||
return;
|
||||
this.SearchForCluster(hubMap, pointCluster, x, y + 1, level);
|
||||
}
|
||||
|
||||
private void AttemptClaim(
|
||||
int x,
|
||||
int y,
|
||||
int[,] clusterIndexMap,
|
||||
List<List<Point>> pointClusters,
|
||||
int index)
|
||||
{
|
||||
int clusterIndex = clusterIndexMap[x, y];
|
||||
if (clusterIndex == -1 || clusterIndex == index)
|
||||
return;
|
||||
int num = WorldGen.genRand.Next(2) == 0 ? -1 : index;
|
||||
foreach (Point point in pointClusters[clusterIndex])
|
||||
clusterIndexMap[point.X, point.Y] = num;
|
||||
}
|
||||
|
||||
public void Generate(int width, int height)
|
||||
{
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
this.Clear();
|
||||
bool[,] hubMap = new bool[width, height];
|
||||
int num1 = (width >> 1) - 1;
|
||||
int y1 = (height >> 1) - 1;
|
||||
int num2 = (num1 + 1) * (num1 + 1);
|
||||
Point point1 = new Point(num1, y1);
|
||||
for (int index1 = point1.Y - y1; index1 <= point1.Y + y1; ++index1)
|
||||
{
|
||||
float num3 = (float) num1 / (float) y1 * (float) (index1 - point1.Y);
|
||||
int num4 = Math.Min(num1, (int) Math.Sqrt((double) num2 - (double) num3 * (double) num3));
|
||||
for (int index2 = point1.X - num4; index2 <= point1.X + num4; ++index2)
|
||||
hubMap[index2, index1] = WorldGen.genRand.Next(2) == 0;
|
||||
}
|
||||
List<List<Point>> pointClusters = new List<List<Point>>();
|
||||
for (int x = 0; x < hubMap.GetLength(0); ++x)
|
||||
{
|
||||
for (int y2 = 0; y2 < hubMap.GetLength(1); ++y2)
|
||||
{
|
||||
if (hubMap[x, y2] && WorldGen.genRand.Next(2) == 0)
|
||||
{
|
||||
List<Point> pointCluster = new List<Point>();
|
||||
this.SearchForCluster(hubMap, pointCluster, x, y2);
|
||||
if (pointCluster.Count > 2)
|
||||
pointClusters.Add(pointCluster);
|
||||
}
|
||||
}
|
||||
}
|
||||
int[,] clusterIndexMap = new int[hubMap.GetLength(0), hubMap.GetLength(1)];
|
||||
for (int index3 = 0; index3 < clusterIndexMap.GetLength(0); ++index3)
|
||||
{
|
||||
for (int index4 = 0; index4 < clusterIndexMap.GetLength(1); ++index4)
|
||||
clusterIndexMap[index3, index4] = -1;
|
||||
}
|
||||
for (int index = 0; index < pointClusters.Count; ++index)
|
||||
{
|
||||
foreach (Point point2 in pointClusters[index])
|
||||
clusterIndexMap[point2.X, point2.Y] = index;
|
||||
}
|
||||
for (int index5 = 0; index5 < pointClusters.Count; ++index5)
|
||||
{
|
||||
foreach (Point point3 in pointClusters[index5])
|
||||
{
|
||||
int x = point3.X;
|
||||
int y3 = point3.Y;
|
||||
if (clusterIndexMap[x, y3] != -1)
|
||||
{
|
||||
int index6 = clusterIndexMap[x, y3];
|
||||
if (x > 0)
|
||||
this.AttemptClaim(x - 1, y3, clusterIndexMap, pointClusters, index6);
|
||||
if (x < clusterIndexMap.GetLength(0) - 1)
|
||||
this.AttemptClaim(x + 1, y3, clusterIndexMap, pointClusters, index6);
|
||||
if (y3 > 0)
|
||||
this.AttemptClaim(x, y3 - 1, clusterIndexMap, pointClusters, index6);
|
||||
if (y3 < clusterIndexMap.GetLength(1) - 1)
|
||||
this.AttemptClaim(x, y3 + 1, clusterIndexMap, pointClusters, index6);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (List<Point> pointList in pointClusters)
|
||||
pointList.Clear();
|
||||
for (int x = 0; x < clusterIndexMap.GetLength(0); ++x)
|
||||
{
|
||||
for (int y4 = 0; y4 < clusterIndexMap.GetLength(1); ++y4)
|
||||
{
|
||||
if (clusterIndexMap[x, y4] != -1)
|
||||
pointClusters[clusterIndexMap[x, y4]].Add(new Point(x, y4));
|
||||
}
|
||||
}
|
||||
foreach (List<Point> pointList in pointClusters)
|
||||
{
|
||||
if (pointList.Count < 4)
|
||||
pointList.Clear();
|
||||
}
|
||||
foreach (List<Point> pointList in pointClusters)
|
||||
{
|
||||
DesertBiome.Cluster cluster = new DesertBiome.Cluster();
|
||||
if (pointList.Count > 0)
|
||||
{
|
||||
foreach (Point point4 in pointList)
|
||||
cluster.Add(new DesertBiome.Hub((float) point4.X + (float) (((double) WorldGen.genRand.NextFloat() - 0.5) * 0.5), (float) point4.Y + (float) (((double) WorldGen.genRand.NextFloat() - 0.5) * 0.5)));
|
||||
this.Add(cluster);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
68
GameContent/Biomes/EnchantedSwordBiome.cs
Normal file
68
GameContent/Biomes/EnchantedSwordBiome.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.EnchantedSwordBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class EnchantedSwordBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
|
||||
WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[2]
|
||||
{
|
||||
(ushort) 0,
|
||||
(ushort) 1
|
||||
}).Output(resultsOutput));
|
||||
if (resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1] < 1250)
|
||||
return false;
|
||||
Point result;
|
||||
bool flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);
|
||||
if (WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(origin.Y - result.Y), (GenCondition) new Conditions.IsTile(new ushort[1]
|
||||
{
|
||||
(ushort) 53
|
||||
})), out Point _) || !flag)
|
||||
return false;
|
||||
result.Y += 50;
|
||||
ShapeData data1 = new ShapeData();
|
||||
ShapeData shapeData = new ShapeData();
|
||||
Point point1 = new Point(origin.X, origin.Y + 20);
|
||||
Point point2 = new Point(origin.X, origin.Y + 30);
|
||||
float xScale = (float) (0.800000011920929 + (double) GenBase._random.NextFloat() * 0.5);
|
||||
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(point1.X - (int) (20.0 * (double) xScale), point1.Y - 20, (int) (40.0 * (double) xScale), 40)) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), 2))
|
||||
return false;
|
||||
WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(chance: 0.4), new Actions.ClearTile(true).Output(data1)));
|
||||
WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort) 0), new Actions.SetFrames(true).Output(shapeData)));
|
||||
data1.Subtract(shapeData, point1, point2);
|
||||
WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort) 2), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid()));
|
||||
WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((byte) 68), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 2
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5)));
|
||||
ShapeData data2 = new ShapeData();
|
||||
WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(chance: 0.2), new Actions.ClearTile().Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 53
|
||||
}), new Actions.SetTile((ushort) 397).Output(data2)));
|
||||
WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
|
||||
if (GenBase._random.Next(3) == 0)
|
||||
WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, style: 17);
|
||||
else
|
||||
WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, style: 15);
|
||||
WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 2
|
||||
}), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int) (20.0 * (double) xScale), point1.Y - 20, (int) (40.0 * (double) xScale), 40), 4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
228
GameContent/Biomes/GraniteBiome.cs
Normal file
228
GameContent/Biomes/GraniteBiome.cs
Normal file
|
@ -0,0 +1,228 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.GraniteBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class GraniteBiome : MicroBiome
|
||||
{
|
||||
private const int MAX_MAGMA_ITERATIONS = 300;
|
||||
private static GraniteBiome.Magma[,] _sourceMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
private static GraniteBiome.Magma[,] _targetMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (GenBase._tiles[origin.X, origin.Y].active())
|
||||
return false;
|
||||
int length1 = GraniteBiome._sourceMagmaMap.GetLength(0);
|
||||
int length2 = GraniteBiome._sourceMagmaMap.GetLength(1);
|
||||
int index1 = length1 / 2;
|
||||
int index2 = length2 / 2;
|
||||
origin.X -= index1;
|
||||
origin.Y -= index2;
|
||||
for (int index3 = 0; index3 < length1; ++index3)
|
||||
{
|
||||
for (int index4 = 0; index4 < length2; ++index4)
|
||||
{
|
||||
int i = index3 + origin.X;
|
||||
int j = index4 + origin.Y;
|
||||
GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
|
||||
GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4];
|
||||
}
|
||||
}
|
||||
int max1 = index1;
|
||||
int min1 = index1;
|
||||
int max2 = index2;
|
||||
int min2 = index2;
|
||||
for (int index5 = 0; index5 < 300; ++index5)
|
||||
{
|
||||
for (int index6 = max1; index6 <= min1; ++index6)
|
||||
{
|
||||
for (int index7 = max2; index7 <= min2; ++index7)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index6, index7];
|
||||
if (sourceMagma1.IsActive)
|
||||
{
|
||||
float num1 = 0.0f;
|
||||
Vector2 zero = Vector2.Zero;
|
||||
for (int index8 = -1; index8 <= 1; ++index8)
|
||||
{
|
||||
for (int index9 = -1; index9 <= 1; ++index9)
|
||||
{
|
||||
if (index8 != 0 || index9 != 0)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((float) index8, (float) index9);
|
||||
vector2.Normalize();
|
||||
GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index6 + index8, index7 + index9];
|
||||
if ((double) sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive)
|
||||
{
|
||||
if (index8 == -1)
|
||||
max1 = Utils.Clamp<int>(index6 + index8, 1, max1);
|
||||
else
|
||||
min1 = Utils.Clamp<int>(index6 + index8, min1, length1 - 2);
|
||||
if (index9 == -1)
|
||||
max2 = Utils.Clamp<int>(index7 + index9, 1, max2);
|
||||
else
|
||||
min2 = Utils.Clamp<int>(index7 + index9, min2, length2 - 2);
|
||||
GraniteBiome._targetMagmaMap[index6 + index8, index7 + index9] = sourceMagma2.ToFlow();
|
||||
}
|
||||
float pressure = sourceMagma2.Pressure;
|
||||
num1 += pressure;
|
||||
zero += pressure * vector2;
|
||||
}
|
||||
}
|
||||
}
|
||||
float num2 = num1 / 8f;
|
||||
if ((double) num2 > (double) sourceMagma1.Resistance)
|
||||
{
|
||||
float num3 = zero.Length() / 8f;
|
||||
float pressure = Math.Max(0.0f, (float) ((double) Math.Max(num2 - num3 - sourceMagma1.Pressure, 0.0f) + (double) num3 + (double) sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance);
|
||||
GraniteBiome._targetMagmaMap[index6, index7] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index5 < 2)
|
||||
GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f);
|
||||
Utils.Swap<GraniteBiome.Magma[,]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
|
||||
}
|
||||
bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30;
|
||||
bool flag2 = false;
|
||||
for (int index10 = -50; index10 < 50 && !flag2; ++index10)
|
||||
{
|
||||
for (int index11 = -50; index11 < 50 && !flag2; ++index11)
|
||||
{
|
||||
if (GenBase._tiles[origin.X + index1 + index10, origin.Y + index2 + index11].active())
|
||||
{
|
||||
switch (GenBase._tiles[origin.X + index1 + index10, origin.Y + index2 + index11].type)
|
||||
{
|
||||
case 147:
|
||||
case 161:
|
||||
case 162:
|
||||
case 163:
|
||||
case 200:
|
||||
flag1 = false;
|
||||
flag2 = true;
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index12 = max1; index12 <= min1; ++index12)
|
||||
{
|
||||
for (int index13 = max2; index13 <= min2; ++index13)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index12, index13];
|
||||
if (sourceMagma.IsActive)
|
||||
{
|
||||
Tile tile = GenBase._tiles[origin.X + index12, origin.Y + index13];
|
||||
if ((double) Math.Max(1f - Math.Max(0.0f, (float) (Math.Sin((double) (origin.Y + index13) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float) (0.200000002980232 + 0.5 / Math.Sqrt((double) Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index12, origin.Y + index13) ? 0.0 : 0.5))
|
||||
{
|
||||
if (TileID.Sets.Ore[(int) tile.type])
|
||||
tile.ResetToType(tile.type);
|
||||
else
|
||||
tile.ResetToType((ushort) 368);
|
||||
tile.wall = (byte) 180;
|
||||
}
|
||||
else if ((double) sourceMagma.Resistance < 0.00999999977648258)
|
||||
{
|
||||
WorldUtils.ClearTile(origin.X + index12, origin.Y + index13);
|
||||
tile.wall = (byte) 180;
|
||||
}
|
||||
if (tile.liquid > (byte) 0 & flag1)
|
||||
tile.liquidType(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Point16> point16List = new List<Point16>();
|
||||
for (int index14 = max1; index14 <= min1; ++index14)
|
||||
{
|
||||
for (int index15 = max2; index15 <= min2; ++index15)
|
||||
{
|
||||
if (GraniteBiome._sourceMagmaMap[index14, index15].IsActive)
|
||||
{
|
||||
int num4 = 0;
|
||||
int num5 = index14 + origin.X;
|
||||
int num6 = index15 + origin.Y;
|
||||
if (WorldGen.SolidTile(num5, num6))
|
||||
{
|
||||
for (int index16 = -1; index16 <= 1; ++index16)
|
||||
{
|
||||
for (int index17 = -1; index17 <= 1; ++index17)
|
||||
{
|
||||
if (WorldGen.SolidTile(num5 + index16, num6 + index17))
|
||||
++num4;
|
||||
}
|
||||
}
|
||||
if (num4 < 3)
|
||||
point16List.Add(new Point16(num5, num6));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Point16 point16 in point16List)
|
||||
{
|
||||
int x = (int) point16.X;
|
||||
int y = (int) point16.Y;
|
||||
WorldUtils.ClearTile(x, y, true);
|
||||
GenBase._tiles[x, y].wall = (byte) 180;
|
||||
}
|
||||
point16List.Clear();
|
||||
for (int index18 = max1; index18 <= min1; ++index18)
|
||||
{
|
||||
for (int index19 = max2; index19 <= min2; ++index19)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index18, index19];
|
||||
int index20 = index18 + origin.X;
|
||||
int index21 = index19 + origin.Y;
|
||||
if (sourceMagma.IsActive)
|
||||
{
|
||||
WorldUtils.TileFrame(index20, index21);
|
||||
WorldGen.SquareWallFrame(index20, index21);
|
||||
if (GenBase._random.Next(8) == 0 && GenBase._tiles[index20, index21].active())
|
||||
{
|
||||
if (!GenBase._tiles[index20, index21 + 1].active())
|
||||
WorldGen.PlaceTight(index20, index21 + 1);
|
||||
if (!GenBase._tiles[index20, index21 - 1].active())
|
||||
WorldGen.PlaceTight(index20, index21 - 1);
|
||||
}
|
||||
if (GenBase._random.Next(2) == 0)
|
||||
Tile.SmoothSlope(index20, index21);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private struct Magma
|
||||
{
|
||||
public readonly float Pressure;
|
||||
public readonly float Resistance;
|
||||
public readonly bool IsActive;
|
||||
|
||||
private Magma(float pressure, float resistance, bool active)
|
||||
{
|
||||
this.Pressure = pressure;
|
||||
this.Resistance = resistance;
|
||||
this.IsActive = active;
|
||||
}
|
||||
|
||||
public GraniteBiome.Magma ToFlow() => new GraniteBiome.Magma(this.Pressure, this.Resistance, true);
|
||||
|
||||
public static GraniteBiome.Magma CreateFlow(float pressure, float resistance = 0.0f) => new GraniteBiome.Magma(pressure, resistance, true);
|
||||
|
||||
public static GraniteBiome.Magma CreateEmpty(float resistance = 0.0f) => new GraniteBiome.Magma(0.0f, resistance, false);
|
||||
}
|
||||
}
|
||||
}
|
161
GameContent/Biomes/HiveBiome.cs
Normal file
161
GameContent/Biomes/HiveBiome.cs
Normal file
|
@ -0,0 +1,161 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.HiveBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class HiveBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Ref<int> count1 = new Ref<int>(0);
|
||||
Ref<int> count2 = new Ref<int>(0);
|
||||
Ref<int> count3 = new Ref<int>(0);
|
||||
Ref<int> count4 = new Ref<int>(0);
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(15), Actions.Chain((GenAction) new Actions.Scanner(count3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
|
||||
{
|
||||
(ushort) 60,
|
||||
(ushort) 59
|
||||
}), (GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 60
|
||||
}), (GenAction) new Actions.Scanner(count4)));
|
||||
if ((double) count2.Value / (double) count1.Value < 0.75 || count4.Value < 2 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100)))
|
||||
return false;
|
||||
int x1 = origin.X;
|
||||
int y1 = origin.Y;
|
||||
int num1 = 150;
|
||||
for (int index1 = x1 - num1; index1 < x1 + num1; index1 += 10)
|
||||
{
|
||||
if (index1 > 0 && index1 <= Main.maxTilesX - 1)
|
||||
{
|
||||
for (int index2 = y1 - num1; index2 < y1 + num1; index2 += 10)
|
||||
{
|
||||
if (index2 > 0 && index2 <= Main.maxTilesY - 1 && (Main.tile[index1, index2].active() && Main.tile[index1, index2].type == (ushort) 226 || Main.tile[index1, index2].wall == (byte) 87 || Main.tile[index1, index2].wall == (byte) 3 || Main.tile[index1, index2].wall == (byte) 83))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
int x2 = origin.X;
|
||||
int y2 = origin.Y;
|
||||
int index3 = 0;
|
||||
int[] numArray1 = new int[10];
|
||||
int[] numArray2 = new int[10];
|
||||
Vector2 vector2_1 = new Vector2((float) x2, (float) y2);
|
||||
Vector2 vector2_2 = vector2_1;
|
||||
int num2 = WorldGen.genRand.Next(2, 5);
|
||||
for (int index4 = 0; index4 < num2; ++index4)
|
||||
{
|
||||
int num3 = WorldGen.genRand.Next(2, 5);
|
||||
for (int index5 = 0; index5 < num3; ++index5)
|
||||
vector2_2 = WorldGen.Hive((int) vector2_1.X, (int) vector2_1.Y);
|
||||
vector2_1 = vector2_2;
|
||||
numArray1[index3] = (int) vector2_1.X;
|
||||
numArray2[index3] = (int) vector2_1.Y;
|
||||
++index3;
|
||||
}
|
||||
for (int index6 = 0; index6 < index3; ++index6)
|
||||
{
|
||||
int index7 = numArray1[index6];
|
||||
int index8 = numArray2[index6];
|
||||
bool flag = false;
|
||||
int num4 = 1;
|
||||
if (WorldGen.genRand.Next(2) == 0)
|
||||
num4 = -1;
|
||||
while (index7 > 10 && index7 < Main.maxTilesX - 10 && index8 > 10 && index8 < Main.maxTilesY - 10 && (!Main.tile[index7, index8].active() || !Main.tile[index7, index8 + 1].active() || !Main.tile[index7 + 1, index8].active() || !Main.tile[index7 + 1, index8 + 1].active()))
|
||||
{
|
||||
index7 += num4;
|
||||
if (Math.Abs(index7 - numArray1[index6]) > 50)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
int i = index7 + num4;
|
||||
for (int index9 = i - 1; index9 <= i + 2; ++index9)
|
||||
{
|
||||
for (int index10 = index8 - 1; index10 <= index8 + 2; ++index10)
|
||||
{
|
||||
if (index9 < 10 || index9 > Main.maxTilesX - 10)
|
||||
flag = true;
|
||||
else if (Main.tile[index9, index10].active() && Main.tile[index9, index10].type != (ushort) 225)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
for (int index11 = i - 1; index11 <= i + 2; ++index11)
|
||||
{
|
||||
for (int index12 = index8 - 1; index12 <= index8 + 2; ++index12)
|
||||
{
|
||||
if (index11 >= i && index11 <= i + 1 && index12 >= index8 && index12 <= index8 + 1)
|
||||
{
|
||||
Main.tile[index11, index12].active(false);
|
||||
Main.tile[index11, index12].liquid = byte.MaxValue;
|
||||
Main.tile[index11, index12].honey(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[index11, index12].active(true);
|
||||
Main.tile[index11, index12].type = (ushort) 225;
|
||||
}
|
||||
}
|
||||
}
|
||||
int num5 = num4 * -1;
|
||||
int j = index8 + 1;
|
||||
int num6 = 0;
|
||||
while ((num6 < 4 || WorldGen.SolidTile(i, j)) && i > 10 && i < Main.maxTilesX - 10)
|
||||
{
|
||||
++num6;
|
||||
i += num5;
|
||||
if (WorldGen.SolidTile(i, j))
|
||||
{
|
||||
WorldGen.PoundTile(i, j);
|
||||
if (!Main.tile[i, j + 1].active())
|
||||
{
|
||||
Main.tile[i, j + 1].active(true);
|
||||
Main.tile[i, j + 1].type = (ushort) 225;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp<int>((int) vector2_1.X, 5, Main.maxTilesX - 5);
|
||||
WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp<int>((int) vector2_1.Y, 5, Main.maxTilesY - 5);
|
||||
++WorldGen.numLarva;
|
||||
int x3 = (int) vector2_1.X;
|
||||
int y3 = (int) vector2_1.Y;
|
||||
for (int index13 = x3 - 1; index13 <= x3 + 1 && index13 > 0 && index13 < Main.maxTilesX; ++index13)
|
||||
{
|
||||
for (int index14 = y3 - 2; index14 <= y3 + 1 && index14 > 0 && index14 < Main.maxTilesY; ++index14)
|
||||
{
|
||||
if (index14 != y3 + 1)
|
||||
{
|
||||
Main.tile[index13, index14].active(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[index13, index14].active(true);
|
||||
Main.tile[index13, index14].type = (ushort) 225;
|
||||
Main.tile[index13, index14].slope((byte) 0);
|
||||
Main.tile[index13, index14].halfBrick(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
34
GameContent/Biomes/HoneyPatchBiome.cs
Normal file
34
GameContent/Biomes/HoneyPatchBiome.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.HoneyPatchBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class HoneyPatchBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y))
|
||||
return false;
|
||||
Point result;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result))
|
||||
return false;
|
||||
result.Y += 2;
|
||||
Ref<int> count = new Ref<int>(0);
|
||||
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count)));
|
||||
if (count.Value < 20 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16)))
|
||||
return false;
|
||||
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort) 229, true)));
|
||||
ShapeData data = new ShapeData();
|
||||
WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2)));
|
||||
WorldUtils.Gen(new Point(result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort) 59, true)));
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
92
GameContent/Biomes/MahoganyTreeBiome.cs
Normal file
92
GameContent/Biomes/MahoganyTreeBiome.cs
Normal file
|
@ -0,0 +1,92 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.MahoganyTreeBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class MahoganyTreeBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Point result1;
|
||||
if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain((GenSearch) new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out result1))
|
||||
return false;
|
||||
Point result2;
|
||||
if (!WorldUtils.Find(new Point(result1.X, result1.Y - 5), Searches.Chain((GenSearch) new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out result2) || result1.Y - 5 - result2.Y > 60 || result1.Y - result2.Y < 30 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 60, 60, 90)))
|
||||
return false;
|
||||
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
|
||||
WorldUtils.Gen(new Point(result1.X - 25, result1.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4]
|
||||
{
|
||||
(ushort) 0,
|
||||
(ushort) 59,
|
||||
(ushort) 147,
|
||||
(ushort) 1
|
||||
}).Output(resultsOutput));
|
||||
int num1 = resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1];
|
||||
int num2 = resultsOutput[(ushort) 59];
|
||||
if (resultsOutput[(ushort) 147] > num2 || num1 > num2 || num2 < 50)
|
||||
return false;
|
||||
int num3 = (result1.Y - result2.Y - 9) / 5;
|
||||
int num4 = num3 * 5;
|
||||
int num5 = 0;
|
||||
double num6 = GenBase._random.NextDouble() + 1.0;
|
||||
double num7 = GenBase._random.NextDouble() + 2.0;
|
||||
if (GenBase._random.Next(2) == 0)
|
||||
num7 = -num7;
|
||||
for (int index = 0; index < num3; ++index)
|
||||
{
|
||||
int num8 = (int) (Math.Sin((double) (index + 1) / 12.0 * num6 * 3.14159274101257) * num7);
|
||||
int num9 = num8 < num5 ? num8 - num5 : 0;
|
||||
WorldUtils.Gen(new Point(result1.X + num5 + num9, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain((GenAction) new Actions.RemoveWall(), (GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames()));
|
||||
WorldUtils.Gen(new Point(result1.X + num5 + num9 + 2, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte) 78)));
|
||||
WorldUtils.Gen(new Point(result1.X + num5 + 2, result1.Y - index * 5), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((byte) 78)));
|
||||
num5 = num8;
|
||||
}
|
||||
int num10 = 6;
|
||||
if (num7 < 0.0)
|
||||
num10 = 0;
|
||||
List<Point> endpoints = new List<Point>();
|
||||
for (int index = 0; index < 2; ++index)
|
||||
{
|
||||
double num11 = ((double) index + 1.0) / 3.0;
|
||||
int num12 = num10 + (int) (Math.Sin((double) num3 * num11 / 12.0 * num6 * 3.14159274101257) * num7);
|
||||
double angle = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232;
|
||||
if (num10 == 0)
|
||||
angle -= 1.57079637050629;
|
||||
WorldUtils.Gen(new Point(result1.X + num12, result1.Y - (int) ((double) (num3 * 5) * num11)), (GenShape) new ShapeBranch(angle, (double) GenBase._random.Next(12, 16)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
|
||||
num10 = 6 - num10;
|
||||
}
|
||||
int num13 = (int) (Math.Sin((double) num3 / 12.0 * num6 * 3.14159274101257) * num7);
|
||||
WorldUtils.Gen(new Point(result1.X + 6 + num13, result1.Y - num4), (GenShape) new ShapeBranch(-0.685398185253143, (double) GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(new Point(result1.X + num13, result1.Y - num4), (GenShape) new ShapeBranch(-2.45619449615479, (double) GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort) 383), (GenAction) new Actions.SetFrames(true)));
|
||||
foreach (Point origin1 in endpoints)
|
||||
{
|
||||
Shapes.Circle circle = new Shapes.Circle(4);
|
||||
GenAction action = Actions.Chain((GenAction) new Modifiers.Blotches(4, 2, 0.3), (GenAction) new Modifiers.SkipTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 383
|
||||
}), (GenAction) new Modifiers.SkipWalls(new byte[1]
|
||||
{
|
||||
(byte) 78
|
||||
}), (GenAction) new Actions.SetTile((ushort) 384), (GenAction) new Actions.SetFrames(true));
|
||||
WorldUtils.Gen(origin1, (GenShape) circle, action);
|
||||
}
|
||||
for (int index = 0; index < 4; ++index)
|
||||
{
|
||||
float angle = (float) ((double) index / 3.0 * 2.0 + 0.570749998092651);
|
||||
WorldUtils.Gen(result1, (GenShape) new ShapeRoot(angle, (float) GenBase._random.Next(40, 60)), (GenAction) new Actions.SetTile((ushort) 383, true));
|
||||
}
|
||||
WorldGen.AddBuriedChest(result1.X + 3, result1.Y - 1, GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem(), Style: 10);
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 30, 60, 60));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
193
GameContent/Biomes/MarbleBiome.cs
Normal file
193
GameContent/Biomes/MarbleBiome.cs
Normal file
|
@ -0,0 +1,193 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.MarbleBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.ID;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class MarbleBiome : MicroBiome
|
||||
{
|
||||
private const int SCALE = 3;
|
||||
private MarbleBiome.Slab[,] _slabs;
|
||||
|
||||
private void SmoothSlope(int x, int y)
|
||||
{
|
||||
MarbleBiome.Slab slab = this._slabs[x, y];
|
||||
if (!slab.IsSolid)
|
||||
return;
|
||||
int num = this._slabs[x, y - 1].IsSolid ? 1 : 0;
|
||||
bool isSolid1 = this._slabs[x, y + 1].IsSolid;
|
||||
bool isSolid2 = this._slabs[x - 1, y].IsSolid;
|
||||
bool isSolid3 = this._slabs[x + 1, y].IsSolid;
|
||||
switch ((num != 0 ? 1 : 0) << 3 | (isSolid1 ? 1 : 0) << 2 | (isSolid2 ? 1 : 0) << 1 | (isSolid3 ? 1 : 0))
|
||||
{
|
||||
case 4:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.HalfBrick));
|
||||
break;
|
||||
case 5:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.BottomRightFilled));
|
||||
break;
|
||||
case 6:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.BottomLeftFilled));
|
||||
break;
|
||||
case 9:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.TopRightFilled));
|
||||
break;
|
||||
case 10:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.TopLeftFilled));
|
||||
break;
|
||||
default:
|
||||
this._slabs[x, y] = slab.WithState(new MarbleBiome.SlabState(MarbleBiome.SlabStates.Solid));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceSlab(MarbleBiome.Slab slab, int originX, int originY, int scale)
|
||||
{
|
||||
for (int x = 0; x < scale; ++x)
|
||||
{
|
||||
for (int y = 0; y < scale; ++y)
|
||||
{
|
||||
Tile tile = GenBase._tiles[originX + x, originY + y];
|
||||
if (TileID.Sets.Ore[(int) tile.type])
|
||||
tile.ResetToType(tile.type);
|
||||
else
|
||||
tile.ResetToType((ushort) 367);
|
||||
bool active = slab.State(x, y, scale);
|
||||
tile.active(active);
|
||||
if (slab.HasWall)
|
||||
tile.wall = (byte) 178;
|
||||
WorldUtils.TileFrame(originX + x, originY + y, true);
|
||||
WorldGen.SquareWallFrame(originX + x, originY + y);
|
||||
Tile.SmoothSlope(originX + x, originY + y);
|
||||
if (WorldGen.SolidTile(originX + x, originY + y - 1) && GenBase._random.Next(4) == 0)
|
||||
WorldGen.PlaceTight(originX + x, originY + y);
|
||||
if (WorldGen.SolidTile(originX + x, originY + y) && GenBase._random.Next(4) == 0)
|
||||
WorldGen.PlaceTight(originX + x, originY + y - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsGroupSolid(int x, int y, int scale)
|
||||
{
|
||||
int num = 0;
|
||||
for (int index1 = 0; index1 < scale; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < scale; ++index2)
|
||||
{
|
||||
if (WorldGen.SolidOrSlopedTile(x + index1, y + index2))
|
||||
++num;
|
||||
}
|
||||
}
|
||||
return num > scale / 4 * 3;
|
||||
}
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (this._slabs == null)
|
||||
this._slabs = new MarbleBiome.Slab[56, 26];
|
||||
int num1 = GenBase._random.Next(80, 150) / 3;
|
||||
int num2 = GenBase._random.Next(40, 60) / 3;
|
||||
int num3 = (num2 * 3 - GenBase._random.Next(20, 30)) / 3;
|
||||
origin.X -= num1 * 3 / 2;
|
||||
origin.Y -= num2 * 3 / 2;
|
||||
for (int index1 = -1; index1 < num1 + 1; ++index1)
|
||||
{
|
||||
float num4 = (float) ((double) (index1 - num1 / 2) / (double) num1 + 0.5);
|
||||
int num5 = (int) ((0.5 - (double) Math.Abs(num4 - 0.5f)) * 5.0) - 2;
|
||||
for (int index2 = -1; index2 < num2 + 1; ++index2)
|
||||
{
|
||||
bool hasWall = true;
|
||||
bool flag1 = false;
|
||||
bool flag2 = this.IsGroupSolid(index1 * 3 + origin.X, index2 * 3 + origin.Y, 3);
|
||||
int num6 = Math.Abs(index2 - num2 / 2) - num3 / 4 + num5;
|
||||
if (num6 > 3)
|
||||
{
|
||||
flag1 = flag2;
|
||||
hasWall = false;
|
||||
}
|
||||
else if (num6 > 0)
|
||||
{
|
||||
flag1 = index2 - num2 / 2 > 0 | flag2;
|
||||
hasWall = index2 - num2 / 2 < 0 || num6 <= 2;
|
||||
}
|
||||
else if (num6 == 0)
|
||||
flag1 = GenBase._random.Next(2) == 0 && index2 - num2 / 2 > 0 | flag2;
|
||||
if ((double) Math.Abs(num4 - 0.5f) > 0.349999994039536 + (double) GenBase._random.NextFloat() * 0.100000001490116 && !flag2)
|
||||
{
|
||||
hasWall = false;
|
||||
flag1 = false;
|
||||
}
|
||||
this._slabs[index1 + 1, index2 + 1] = MarbleBiome.Slab.Create(flag1 ? new MarbleBiome.SlabState(MarbleBiome.SlabStates.Solid) : new MarbleBiome.SlabState(MarbleBiome.SlabStates.Empty), hasWall);
|
||||
}
|
||||
}
|
||||
for (int index3 = 0; index3 < num1; ++index3)
|
||||
{
|
||||
for (int index4 = 0; index4 < num2; ++index4)
|
||||
this.SmoothSlope(index3 + 1, index4 + 1);
|
||||
}
|
||||
int num7 = num1 / 2;
|
||||
int val1 = num2 / 2;
|
||||
int num8 = (val1 + 1) * (val1 + 1);
|
||||
float num9 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
|
||||
float num10 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
|
||||
float num11 = (float) ((double) GenBase._random.NextFloat() * 2.0 - 1.0);
|
||||
float num12 = 0.0f;
|
||||
for (int index5 = 0; index5 <= num1; ++index5)
|
||||
{
|
||||
float num13 = (float) val1 / (float) num7 * (float) (index5 - num7);
|
||||
int num14 = Math.Min(val1, (int) Math.Sqrt((double) Math.Max(0.0f, (float) num8 - num13 * num13)));
|
||||
if (index5 < num1 / 2)
|
||||
num12 += MathHelper.Lerp(num9, num10, (float) index5 / (float) (num1 / 2));
|
||||
else
|
||||
num12 += MathHelper.Lerp(num10, num11, (float) ((double) index5 / (double) (num1 / 2) - 1.0));
|
||||
for (int index6 = val1 - num14; index6 <= val1 + num14; ++index6)
|
||||
this.PlaceSlab(this._slabs[index5 + 1, index6 + 1], index5 * 3 + origin.X, index6 * 3 + origin.Y + (int) num12, 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private delegate bool SlabState(int x, int y, int scale);
|
||||
|
||||
private class SlabStates
|
||||
{
|
||||
public static bool Empty(int x, int y, int scale) => false;
|
||||
|
||||
public static bool Solid(int x, int y, int scale) => true;
|
||||
|
||||
public static bool HalfBrick(int x, int y, int scale) => y >= scale / 2;
|
||||
|
||||
public static bool BottomRightFilled(int x, int y, int scale) => x >= scale - y;
|
||||
|
||||
public static bool BottomLeftFilled(int x, int y, int scale) => x < y;
|
||||
|
||||
public static bool TopRightFilled(int x, int y, int scale) => x > y;
|
||||
|
||||
public static bool TopLeftFilled(int x, int y, int scale) => x < scale - y;
|
||||
}
|
||||
|
||||
private struct Slab
|
||||
{
|
||||
public readonly MarbleBiome.SlabState State;
|
||||
public readonly bool HasWall;
|
||||
|
||||
public bool IsSolid => this.State != new MarbleBiome.SlabState(MarbleBiome.SlabStates.Empty);
|
||||
|
||||
private Slab(MarbleBiome.SlabState state, bool hasWall)
|
||||
{
|
||||
this.State = state;
|
||||
this.HasWall = hasWall;
|
||||
}
|
||||
|
||||
public MarbleBiome.Slab WithState(MarbleBiome.SlabState state) => new MarbleBiome.Slab(state, this.HasWall);
|
||||
|
||||
public static MarbleBiome.Slab Create(MarbleBiome.SlabState state, bool hasWall) => new MarbleBiome.Slab(state, hasWall);
|
||||
}
|
||||
}
|
||||
}
|
68
GameContent/Biomes/MiningExplosivesBiome.cs
Normal file
68
GameContent/Biomes/MiningExplosivesBiome.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.MiningExplosivesBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class MiningExplosivesBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (WorldGen.SolidTile(origin.X, origin.Y))
|
||||
return false;
|
||||
ushort type = Utils.SelectRandom<ushort>(GenBase._random, WorldGen.goldBar == 19 ? (ushort) 8 : (ushort) 169, WorldGen.silverBar == 21 ? (ushort) 9 : (ushort) 168, WorldGen.ironBar == 22 ? (ushort) 6 : (ushort) 167, WorldGen.copperBar == 20 ? (ushort) 7 : (ushort) 166);
|
||||
double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
|
||||
return false;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
|
||||
return false;
|
||||
ShapeData shapeData = new ShapeData();
|
||||
Ref<int> count1 = new Ref<int>(0);
|
||||
Ref<int> count2 = new Ref<int>(0);
|
||||
WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float) num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
|
||||
if (count2.Value < count1.Value / 2)
|
||||
return false;
|
||||
Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
|
||||
if (!structures.CanPlace(area))
|
||||
return false;
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true));
|
||||
WorldUtils.Gen(new Point(origin.X - (int) (num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Actions.ClearTile(true)));
|
||||
Point result1;
|
||||
int num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0);
|
||||
int num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
|
||||
Point result2;
|
||||
int num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;
|
||||
if ((num2 & num4) == 0)
|
||||
return false;
|
||||
--result1.Y;
|
||||
--result2.Y;
|
||||
Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1];
|
||||
tile1.slope((byte) 0);
|
||||
tile1.halfBrick(false);
|
||||
for (int index = -1; index <= 1; ++index)
|
||||
{
|
||||
WorldUtils.ClearTile(result2.X + index, result2.Y);
|
||||
Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1];
|
||||
if (!WorldGen.SolidOrSlopedTile(tile2))
|
||||
{
|
||||
tile2.ResetToType((ushort) 1);
|
||||
tile2.active(true);
|
||||
}
|
||||
tile2.slope((byte) 0);
|
||||
tile2.halfBrick(false);
|
||||
WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true);
|
||||
}
|
||||
WorldGen.PlaceTile(result1.X, result1.Y, 141);
|
||||
WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true);
|
||||
WorldUtils.WireLine(result1, result2);
|
||||
structures.AddStructure(area, 5);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/Biomes/ThinIceBiome.cs
Normal file
48
GameContent/Biomes/ThinIceBiome.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.ThinIceBiome
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class ThinIceBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
|
||||
WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4]
|
||||
{
|
||||
(ushort) 0,
|
||||
(ushort) 59,
|
||||
(ushort) 147,
|
||||
(ushort) 1
|
||||
}).Output(resultsOutput));
|
||||
int num1 = resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1];
|
||||
int num2 = resultsOutput[(ushort) 59];
|
||||
int num3 = resultsOutput[(ushort) 147];
|
||||
if (num3 <= num2 || num3 <= num1)
|
||||
return false;
|
||||
int num4 = 0;
|
||||
for (int radius = GenBase._random.Next(10, 15); radius > 5; --radius)
|
||||
{
|
||||
int num5 = GenBase._random.Next(-5, 5);
|
||||
WorldUtils.Gen(new Point(origin.X + num5, origin.Y + num4), (GenShape) new Shapes.Circle(radius), Actions.Chain((GenAction) new Modifiers.Blotches(4), (GenAction) new Modifiers.OnlyTiles(new ushort[5]
|
||||
{
|
||||
(ushort) 147,
|
||||
(ushort) 161,
|
||||
(ushort) 224,
|
||||
(ushort) 0,
|
||||
(ushort) 1
|
||||
}), (GenAction) new Actions.SetTile((ushort) 162, true)));
|
||||
WorldUtils.Gen(new Point(origin.X + num5, origin.Y + num4), (GenShape) new Shapes.Circle(radius), Actions.Chain((GenAction) new Modifiers.Blotches(4), (GenAction) new Modifiers.HasLiquid(), (GenAction) new Actions.SetTile((ushort) 162, true), (GenAction) new Actions.SetLiquid(value: (byte) 0)));
|
||||
num4 += radius - 2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
23
GameContent/ChildSafety.cs
Normal file
23
GameContent/ChildSafety.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.ChildSafety
|
||||
// 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.ID;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class ChildSafety
|
||||
{
|
||||
private static SetFactory factoryDust = new SetFactory(275);
|
||||
private static SetFactory factoryGore = new SetFactory(1087);
|
||||
private static readonly bool[] SafeGore = ChildSafety.factoryGore.CreateBoolSet(11, 12, 13, 16, 17, 42, 53, 44, 51, 52, 53, 54, 55, 56, 57, 61, 62, 63, 67, 68, 69, 99, 106, 120, 130, 131, 147, 148, 149, 150, 156, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 213, 217, 218, 219, 220, 221, 222, 257, 265, 266, 267, 268, 269, 276, 277, 278, 279, 280, 281, 282, 314, 321, 322, 326, 331, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 375, 376, 377, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 435, 436, 437, 521, 522, 523, 525, 526, 527, 542, 570, 571, 572, 580, 581, 582, 603, 604, 605, 606, 610, 611, 612, 613, 614, 615, 616, 617, 618, 639, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 734, 728, 729, 730, 731, 732, 733, 825, 826, 827, 848, 849, 850, 851, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 892, 893, 898, 899, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926);
|
||||
private static readonly bool[] SafeDust = ChildSafety.factoryDust.CreateBoolSet(true, 5, 227, 273);
|
||||
public static bool Disabled = true;
|
||||
|
||||
public static bool DangerousGore(int id) => !ChildSafety.SafeGore[id];
|
||||
|
||||
public static bool DangerousDust(int id) => !ChildSafety.SafeDust[id];
|
||||
}
|
||||
}
|
39
GameContent/Dyes/LegacyHairShaderData.cs
Normal file
39
GameContent/Dyes/LegacyHairShaderData.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Dyes.LegacyHairShaderData
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Dyes
|
||||
{
|
||||
public class LegacyHairShaderData : HairShaderData
|
||||
{
|
||||
private LegacyHairShaderData.ColorProcessingMethod _colorProcessor;
|
||||
|
||||
public LegacyHairShaderData()
|
||||
: base((Ref<Effect>) null, (string) null)
|
||||
{
|
||||
this._shaderDisabled = true;
|
||||
}
|
||||
|
||||
public override Color GetColor(Player player, Color lightColor)
|
||||
{
|
||||
bool lighting = true;
|
||||
Color color = this._colorProcessor(player, player.hairColor, ref lighting);
|
||||
return lighting ? new Color(color.ToVector4() * lightColor.ToVector4()) : color;
|
||||
}
|
||||
|
||||
public LegacyHairShaderData UseLegacyMethod(
|
||||
LegacyHairShaderData.ColorProcessingMethod colorProcessor)
|
||||
{
|
||||
this._colorProcessor = colorProcessor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public delegate Color ColorProcessingMethod(Player player, Color color, ref bool lighting);
|
||||
}
|
||||
}
|
67
GameContent/Dyes/ReflectiveArmorShaderData.cs
Normal file
67
GameContent/Dyes/ReflectiveArmorShaderData.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Dyes.ReflectiveArmorShaderData
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Dyes
|
||||
{
|
||||
public class ReflectiveArmorShaderData : ArmorShaderData
|
||||
{
|
||||
public ReflectiveArmorShaderData(Ref<Effect> shader, string passName)
|
||||
: base(shader, passName)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Apply(Entity entity, DrawData? drawData)
|
||||
{
|
||||
if (entity == null)
|
||||
{
|
||||
this.Shader.Parameters["uLightSource"].SetValue(Vector3.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
float num1 = 0.0f;
|
||||
if (drawData.HasValue)
|
||||
num1 = drawData.Value.rotation;
|
||||
Vector2 position = entity.position;
|
||||
float width = (float) entity.width;
|
||||
float height = (float) entity.height;
|
||||
Vector2 vector2_1 = new Vector2(width, height) * 0.1f;
|
||||
Vector2 vector2_2 = position + vector2_1;
|
||||
float x = width * 0.8f;
|
||||
float y = height * 0.8f;
|
||||
Vector3 subLight1 = Lighting.GetSubLight(vector2_2 + new Vector2(x * 0.5f, 0.0f));
|
||||
Vector3 subLight2 = Lighting.GetSubLight(vector2_2 + new Vector2(0.0f, y * 0.5f));
|
||||
Vector3 subLight3 = Lighting.GetSubLight(vector2_2 + new Vector2(x, y * 0.5f));
|
||||
Vector3 subLight4 = Lighting.GetSubLight(vector2_2 + new Vector2(x * 0.5f, y));
|
||||
float num2 = subLight1.X + subLight1.Y + subLight1.Z;
|
||||
float num3 = subLight2.X + subLight2.Y + subLight2.Z;
|
||||
float num4 = subLight3.X + subLight3.Y + subLight3.Z;
|
||||
float num5 = subLight4.X + subLight4.Y + subLight4.Z;
|
||||
Vector2 spinningpoint = new Vector2(num4 - num3, num5 - num2);
|
||||
if ((double) spinningpoint.Length() > 1.0)
|
||||
{
|
||||
float num6 = 1f;
|
||||
spinningpoint /= num6;
|
||||
}
|
||||
if (entity.direction == -1)
|
||||
spinningpoint.X *= -1f;
|
||||
spinningpoint = spinningpoint.RotatedBy(-(double) num1);
|
||||
Vector3 vector3 = new Vector3(spinningpoint, (float) (1.0 - ((double) spinningpoint.X * (double) spinningpoint.X + (double) spinningpoint.Y * (double) spinningpoint.Y)));
|
||||
vector3.X *= 2f;
|
||||
vector3.Y -= 0.15f;
|
||||
vector3.Y *= 2f;
|
||||
vector3.Normalize();
|
||||
vector3.Z *= 0.6f;
|
||||
this.Shader.Parameters["uLightSource"].SetValue(vector3);
|
||||
}
|
||||
base.Apply(entity, drawData);
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Dyes/TeamArmorShaderData.cs
Normal file
49
GameContent/Dyes/TeamArmorShaderData.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Dyes.TeamArmorShaderData
|
||||
// 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 Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Dyes
|
||||
{
|
||||
public class TeamArmorShaderData : ArmorShaderData
|
||||
{
|
||||
private static bool isInitialized;
|
||||
private static ArmorShaderData[] dustShaderData;
|
||||
|
||||
public TeamArmorShaderData(Ref<Effect> shader, string passName)
|
||||
: base(shader, passName)
|
||||
{
|
||||
if (TeamArmorShaderData.isInitialized)
|
||||
return;
|
||||
TeamArmorShaderData.isInitialized = true;
|
||||
TeamArmorShaderData.dustShaderData = new ArmorShaderData[Main.teamColor.Length];
|
||||
for (int index = 1; index < Main.teamColor.Length; ++index)
|
||||
TeamArmorShaderData.dustShaderData[index] = new ArmorShaderData(shader, passName).UseColor(Main.teamColor[index]);
|
||||
TeamArmorShaderData.dustShaderData[0] = new ArmorShaderData(shader, "Default");
|
||||
}
|
||||
|
||||
public override void Apply(Entity entity, DrawData? drawData)
|
||||
{
|
||||
if (!(entity is Player player) || player.team == 0)
|
||||
{
|
||||
TeamArmorShaderData.dustShaderData[0].Apply((Entity) player, drawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.UseColor(Main.teamColor[player.team]);
|
||||
base.Apply((Entity) player, drawData);
|
||||
}
|
||||
}
|
||||
|
||||
public override ArmorShaderData GetSecondaryShader(Entity entity)
|
||||
{
|
||||
Player player = entity as Player;
|
||||
return TeamArmorShaderData.dustShaderData[player.team];
|
||||
}
|
||||
}
|
||||
}
|
149
GameContent/Events/BirthdayParty.cs
Normal file
149
GameContent/Events/BirthdayParty.cs
Normal file
|
@ -0,0 +1,149 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.BirthdayParty
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class BirthdayParty
|
||||
{
|
||||
public static bool ManualParty = false;
|
||||
public static bool GenuineParty = false;
|
||||
public static int PartyDaysOnCooldown = 0;
|
||||
public static List<int> CelebratingNPCs = new List<int>();
|
||||
private static bool _wasCelebrating = false;
|
||||
|
||||
public static bool PartyIsUp => BirthdayParty.GenuineParty || BirthdayParty.ManualParty;
|
||||
|
||||
public static void CheckMorning() => BirthdayParty.NaturalAttempt();
|
||||
|
||||
public static void CheckNight()
|
||||
{
|
||||
bool flag = false;
|
||||
if (BirthdayParty.GenuineParty)
|
||||
{
|
||||
flag = true;
|
||||
BirthdayParty.GenuineParty = false;
|
||||
BirthdayParty.CelebratingNPCs.Clear();
|
||||
}
|
||||
if (BirthdayParty.ManualParty)
|
||||
{
|
||||
flag = true;
|
||||
BirthdayParty.ManualParty = false;
|
||||
}
|
||||
if (!flag)
|
||||
return;
|
||||
Color color = new Color((int) byte.MaxValue, 0, 160);
|
||||
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color);
|
||||
}
|
||||
|
||||
private static void NaturalAttempt()
|
||||
{
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
if (BirthdayParty.PartyDaysOnCooldown > 0)
|
||||
{
|
||||
--BirthdayParty.PartyDaysOnCooldown;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.rand.Next(10) != 0)
|
||||
return;
|
||||
List<NPC> source = new List<NPC>();
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
NPC npc = Main.npc[index];
|
||||
if (npc.active && npc.townNPC && npc.type != 37 && npc.type != 453 && npc.aiStyle != 0)
|
||||
source.Add(npc);
|
||||
}
|
||||
if (source.Count < 5)
|
||||
return;
|
||||
BirthdayParty.GenuineParty = true;
|
||||
BirthdayParty.PartyDaysOnCooldown = Main.rand.Next(5, 11);
|
||||
BirthdayParty.CelebratingNPCs.Clear();
|
||||
List<int> intList = new List<int>();
|
||||
int num = 1;
|
||||
if (Main.rand.Next(5) == 0 && source.Count > 12)
|
||||
num = 3;
|
||||
else if (Main.rand.Next(3) == 0)
|
||||
num = 2;
|
||||
List<NPC> list = source.OrderBy<NPC, int>((Func<NPC, int>) (i => Main.rand.Next())).ToList<NPC>();
|
||||
for (int index = 0; index < num; ++index)
|
||||
intList.Add(index);
|
||||
for (int index = 0; index < intList.Count; ++index)
|
||||
BirthdayParty.CelebratingNPCs.Add(list[intList[index]].whoAmI);
|
||||
Color color = new Color((int) byte.MaxValue, 0, 160);
|
||||
if (BirthdayParty.CelebratingNPCs.Count == 3)
|
||||
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_3", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[1]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[2]].GetGivenOrTypeNetName()), color);
|
||||
else if (BirthdayParty.CelebratingNPCs.Count == 2)
|
||||
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_2", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName(), (object) Main.npc[BirthdayParty.CelebratingNPCs[1]].GetGivenOrTypeNetName()), color);
|
||||
else
|
||||
WorldGen.BroadcastText(NetworkText.FromKey("Game.BirthdayParty_1", (object) Main.npc[BirthdayParty.CelebratingNPCs[0]].GetGivenOrTypeNetName()), color);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ToggleManualParty()
|
||||
{
|
||||
int num1 = BirthdayParty.PartyIsUp ? 1 : 0;
|
||||
if (Main.netMode != 1)
|
||||
BirthdayParty.ManualParty = !BirthdayParty.ManualParty;
|
||||
else
|
||||
NetMessage.SendData(111);
|
||||
int num2 = BirthdayParty.PartyIsUp ? 1 : 0;
|
||||
if (num1 == num2 || Main.netMode != 2)
|
||||
return;
|
||||
NetMessage.SendData(7);
|
||||
}
|
||||
|
||||
public static void WorldClear()
|
||||
{
|
||||
BirthdayParty.ManualParty = false;
|
||||
BirthdayParty.GenuineParty = false;
|
||||
BirthdayParty.PartyDaysOnCooldown = 0;
|
||||
BirthdayParty.CelebratingNPCs.Clear();
|
||||
BirthdayParty._wasCelebrating = false;
|
||||
}
|
||||
|
||||
public static void UpdateTime()
|
||||
{
|
||||
if (BirthdayParty._wasCelebrating != BirthdayParty.PartyIsUp)
|
||||
{
|
||||
if (Main.netMode != 2)
|
||||
{
|
||||
if (BirthdayParty.PartyIsUp)
|
||||
SkyManager.Instance.Activate("Party", new Vector2());
|
||||
else
|
||||
SkyManager.Instance.Deactivate("Party");
|
||||
}
|
||||
if (Main.netMode != 1 && BirthdayParty.CelebratingNPCs.Count > 0)
|
||||
{
|
||||
for (int index = 0; index < BirthdayParty.CelebratingNPCs.Count; ++index)
|
||||
{
|
||||
NPC npc = Main.npc[BirthdayParty.CelebratingNPCs[index]];
|
||||
if (!npc.active || !npc.townNPC || npc.type == 37 || npc.type == 453 || npc.aiStyle == 0)
|
||||
BirthdayParty.CelebratingNPCs.RemoveAt(index);
|
||||
}
|
||||
if (BirthdayParty.CelebratingNPCs.Count == 0)
|
||||
{
|
||||
BirthdayParty.GenuineParty = false;
|
||||
if (!BirthdayParty.ManualParty)
|
||||
{
|
||||
Color color = new Color((int) byte.MaxValue, 0, 160);
|
||||
WorldGen.BroadcastText(NetworkText.FromKey(Lang.misc[99].Key), color);
|
||||
NetMessage.SendData(7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BirthdayParty._wasCelebrating = BirthdayParty.PartyIsUp;
|
||||
}
|
||||
}
|
||||
}
|
90
GameContent/Events/CultistRitual.cs
Normal file
90
GameContent/Events/CultistRitual.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.CultistRitual
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class CultistRitual
|
||||
{
|
||||
public const int delayStart = 86400;
|
||||
public const int respawnDelay = 43200;
|
||||
private const int timePerCultist = 3600;
|
||||
private const int recheckStart = 600;
|
||||
public static int delay;
|
||||
public static int recheck;
|
||||
|
||||
public static void UpdateTime()
|
||||
{
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
CultistRitual.delay -= Main.dayRate;
|
||||
if (CultistRitual.delay < 0)
|
||||
CultistRitual.delay = 0;
|
||||
CultistRitual.recheck -= Main.dayRate;
|
||||
if (CultistRitual.recheck < 0)
|
||||
CultistRitual.recheck = 0;
|
||||
if (CultistRitual.delay != 0 || CultistRitual.recheck != 0)
|
||||
return;
|
||||
CultistRitual.recheck = 600;
|
||||
if (NPC.AnyDanger())
|
||||
CultistRitual.recheck *= 6;
|
||||
else
|
||||
CultistRitual.TrySpawning(Main.dungeonX, Main.dungeonY);
|
||||
}
|
||||
|
||||
public static void CultistSlain() => CultistRitual.delay -= 3600;
|
||||
|
||||
public static void TabletDestroyed() => CultistRitual.delay = 43200;
|
||||
|
||||
public static void TrySpawning(int x, int y)
|
||||
{
|
||||
if (WorldGen.PlayerLOS(x - 6, y) || WorldGen.PlayerLOS(x + 6, y) || !CultistRitual.CheckRitual(x, y))
|
||||
return;
|
||||
NPC.NewNPC(x * 16 + 8, (y - 4) * 16 - 8, 437);
|
||||
}
|
||||
|
||||
private static bool CheckRitual(int x, int y)
|
||||
{
|
||||
if (CultistRitual.delay != 0 || !Main.hardMode || !NPC.downedGolemBoss || !NPC.downedBoss3 || y < 7 || WorldGen.SolidTile(Main.tile[x, y - 7]) || NPC.AnyNPCs(437))
|
||||
return false;
|
||||
Vector2 Center = new Vector2((float) (x * 16 + 8), (float) (y * 16 - 64 - 8 - 27));
|
||||
Point[] pointArray = (Point[]) null;
|
||||
ref Point[] local = ref pointArray;
|
||||
return CultistRitual.CheckFloor(Center, out local);
|
||||
}
|
||||
|
||||
public static bool CheckFloor(Vector2 Center, out Point[] spawnPoints)
|
||||
{
|
||||
Point[] pointArray = new Point[4];
|
||||
int num1 = 0;
|
||||
Point tileCoordinates = Center.ToTileCoordinates();
|
||||
for (int index1 = -5; index1 <= 5; index1 += 2)
|
||||
{
|
||||
if (index1 != -1 && index1 != 1)
|
||||
{
|
||||
for (int index2 = -5; index2 < 12; ++index2)
|
||||
{
|
||||
int num2 = tileCoordinates.X + index1 * 2;
|
||||
int num3 = tileCoordinates.Y + index2;
|
||||
if (WorldGen.SolidTile(num2, num3) && !Collision.SolidTiles(num2 - 1, num2 + 1, num3 - 3, num3 - 1))
|
||||
{
|
||||
pointArray[num1++] = new Point(num2, num3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num1 != 4)
|
||||
{
|
||||
spawnPoints = (Point[]) null;
|
||||
return false;
|
||||
}
|
||||
spawnPoints = pointArray;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
1684
GameContent/Events/DD2Event.cs
Normal file
1684
GameContent/Events/DD2Event.cs
Normal file
File diff suppressed because it is too large
Load diff
220
GameContent/Events/MoonlordDeathDrama.cs
Normal file
220
GameContent/Events/MoonlordDeathDrama.cs
Normal file
|
@ -0,0 +1,220 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.MoonlordDeathDrama
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class MoonlordDeathDrama
|
||||
{
|
||||
private static List<MoonlordDeathDrama.MoonlordPiece> _pieces = new List<MoonlordDeathDrama.MoonlordPiece>();
|
||||
private static List<MoonlordDeathDrama.MoonlordExplosion> _explosions = new List<MoonlordDeathDrama.MoonlordExplosion>();
|
||||
private static List<Vector2> _lightSources = new List<Vector2>();
|
||||
private static float whitening = 0.0f;
|
||||
private static float requestedLight = 0.0f;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
for (int index = 0; index < MoonlordDeathDrama._pieces.Count; ++index)
|
||||
{
|
||||
MoonlordDeathDrama.MoonlordPiece piece = MoonlordDeathDrama._pieces[index];
|
||||
piece.Update();
|
||||
if (piece.Dead)
|
||||
{
|
||||
MoonlordDeathDrama._pieces.Remove(piece);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < MoonlordDeathDrama._explosions.Count; ++index)
|
||||
{
|
||||
MoonlordDeathDrama.MoonlordExplosion explosion = MoonlordDeathDrama._explosions[index];
|
||||
explosion.Update();
|
||||
if (explosion.Dead)
|
||||
{
|
||||
MoonlordDeathDrama._explosions.Remove(explosion);
|
||||
--index;
|
||||
}
|
||||
}
|
||||
bool flag = false;
|
||||
for (int index = 0; index < MoonlordDeathDrama._lightSources.Count; ++index)
|
||||
{
|
||||
if ((double) Main.player[Main.myPlayer].Distance(MoonlordDeathDrama._lightSources[index]) < 2000.0)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
MoonlordDeathDrama._lightSources.Clear();
|
||||
if (!flag)
|
||||
MoonlordDeathDrama.requestedLight = 0.0f;
|
||||
if ((double) MoonlordDeathDrama.requestedLight != (double) MoonlordDeathDrama.whitening)
|
||||
{
|
||||
if ((double) Math.Abs(MoonlordDeathDrama.requestedLight - MoonlordDeathDrama.whitening) < 0.0199999995529652)
|
||||
MoonlordDeathDrama.whitening = MoonlordDeathDrama.requestedLight;
|
||||
else
|
||||
MoonlordDeathDrama.whitening += (float) Math.Sign(MoonlordDeathDrama.requestedLight - MoonlordDeathDrama.whitening) * 0.02f;
|
||||
}
|
||||
MoonlordDeathDrama.requestedLight = 0.0f;
|
||||
}
|
||||
|
||||
public static void DrawPieces(SpriteBatch spriteBatch)
|
||||
{
|
||||
Rectangle playerScreen = Utils.CenteredRectangle(Main.screenPosition + new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f, new Vector2((float) (Main.screenWidth + 1000), (float) (Main.screenHeight + 1000)));
|
||||
for (int index = 0; index < MoonlordDeathDrama._pieces.Count; ++index)
|
||||
{
|
||||
if (MoonlordDeathDrama._pieces[index].InDrawRange(playerScreen))
|
||||
MoonlordDeathDrama._pieces[index].Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawExplosions(SpriteBatch spriteBatch)
|
||||
{
|
||||
Rectangle playerScreen = Utils.CenteredRectangle(Main.screenPosition + new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f, new Vector2((float) (Main.screenWidth + 1000), (float) (Main.screenHeight + 1000)));
|
||||
for (int index = 0; index < MoonlordDeathDrama._explosions.Count; ++index)
|
||||
{
|
||||
if (MoonlordDeathDrama._explosions[index].InDrawRange(playerScreen))
|
||||
MoonlordDeathDrama._explosions[index].Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawWhite(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((double) MoonlordDeathDrama.whitening == 0.0)
|
||||
return;
|
||||
Color color = Color.White * MoonlordDeathDrama.whitening;
|
||||
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
}
|
||||
|
||||
public static void ThrowPieces(Vector2 MoonlordCoreCenter, int DramaSeed)
|
||||
{
|
||||
UnifiedRandom r = new UnifiedRandom(DramaSeed);
|
||||
Vector2 vector2_1 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
|
||||
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Spine"), new Vector2(64f, 150f), MoonlordCoreCenter + new Vector2(0.0f, 50f), vector2_1 * 6f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
|
||||
Vector2 vector2_2 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
|
||||
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Shoulder"), new Vector2(40f, 120f), MoonlordCoreCenter + new Vector2(50f, -120f), vector2_2 * 10f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
|
||||
Vector2 vector2_3 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
|
||||
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Torso"), new Vector2(192f, 252f), MoonlordCoreCenter, vector2_3 * 8f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
|
||||
Vector2 vector2_4 = Vector2.UnitY.RotatedBy((double) r.NextFloat() * 1.57079637050629 - 0.785398185253143 + 3.14159274101257);
|
||||
MoonlordDeathDrama._pieces.Add(new MoonlordDeathDrama.MoonlordPiece(TextureManager.Load("Images/Misc/MoonExplosion/Head"), new Vector2(138f, 185f), MoonlordCoreCenter - new Vector2(0.0f, 200f), vector2_4 * 12f, 0.0f, (float) ((double) r.NextFloat() * 0.100000001490116 - 0.0500000007450581)));
|
||||
}
|
||||
|
||||
public static void AddExplosion(Vector2 spot) => MoonlordDeathDrama._explosions.Add(new MoonlordDeathDrama.MoonlordExplosion(TextureManager.Load("Images/Misc/MoonExplosion/Explosion"), spot, Main.rand.Next(2, 4)));
|
||||
|
||||
public static void RequestLight(float light, Vector2 spot)
|
||||
{
|
||||
MoonlordDeathDrama._lightSources.Add(spot);
|
||||
if ((double) light > 1.0)
|
||||
light = 1f;
|
||||
if ((double) MoonlordDeathDrama.requestedLight >= (double) light)
|
||||
return;
|
||||
MoonlordDeathDrama.requestedLight = light;
|
||||
}
|
||||
|
||||
public class MoonlordPiece
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private Vector2 _position;
|
||||
private Vector2 _velocity;
|
||||
private Vector2 _origin;
|
||||
private float _rotation;
|
||||
private float _rotationVelocity;
|
||||
|
||||
public MoonlordPiece(
|
||||
Texture2D pieceTexture,
|
||||
Vector2 textureOrigin,
|
||||
Vector2 centerPos,
|
||||
Vector2 velocity,
|
||||
float rot,
|
||||
float angularVelocity)
|
||||
{
|
||||
this._texture = pieceTexture;
|
||||
this._origin = textureOrigin;
|
||||
this._position = centerPos;
|
||||
this._velocity = velocity;
|
||||
this._rotation = rot;
|
||||
this._rotationVelocity = angularVelocity;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
this._velocity.Y += 0.3f;
|
||||
this._rotation += this._rotationVelocity;
|
||||
this._rotationVelocity *= 0.99f;
|
||||
this._position += this._velocity;
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch sp)
|
||||
{
|
||||
Color light = this.GetLight();
|
||||
sp.Draw(this._texture, this._position - Main.screenPosition, new Rectangle?(), light, this._rotation, this._origin, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public bool Dead => (double) this._position.Y > (double) (Main.maxTilesY * 16) - 480.0 || (double) this._position.X < 480.0 || (double) this._position.X >= (double) (Main.maxTilesX * 16) - 480.0;
|
||||
|
||||
public bool InDrawRange(Rectangle playerScreen) => playerScreen.Contains(this._position.ToPoint());
|
||||
|
||||
public Color GetLight()
|
||||
{
|
||||
Vector3 zero = Vector3.Zero;
|
||||
float num1 = 0.0f;
|
||||
int num2 = 5;
|
||||
Point tileCoordinates = this._position.ToTileCoordinates();
|
||||
for (int x = tileCoordinates.X - num2; x <= tileCoordinates.X + num2; ++x)
|
||||
{
|
||||
for (int y = tileCoordinates.Y - num2; y <= tileCoordinates.Y + num2; ++y)
|
||||
{
|
||||
zero += Lighting.GetColor(x, y).ToVector3();
|
||||
++num1;
|
||||
}
|
||||
}
|
||||
return (double) num1 == 0.0 ? Color.White : new Color(zero / num1);
|
||||
}
|
||||
}
|
||||
|
||||
public class MoonlordExplosion
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private Vector2 _position;
|
||||
private Vector2 _origin;
|
||||
private Rectangle _frame;
|
||||
private int _frameCounter;
|
||||
private int _frameSpeed;
|
||||
|
||||
public MoonlordExplosion(Texture2D pieceTexture, Vector2 centerPos, int frameSpeed)
|
||||
{
|
||||
this._texture = pieceTexture;
|
||||
this._position = centerPos;
|
||||
this._frameSpeed = frameSpeed;
|
||||
this._frameCounter = 0;
|
||||
this._frame = this._texture.Frame(verticalFrames: 7);
|
||||
this._origin = this._frame.Size() / 2f;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
++this._frameCounter;
|
||||
this._frame = this._texture.Frame(verticalFrames: 7, frameY: (this._frameCounter / this._frameSpeed));
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch sp)
|
||||
{
|
||||
Color light = this.GetLight();
|
||||
sp.Draw(this._texture, this._position - Main.screenPosition, new Rectangle?(this._frame), light, 0.0f, this._origin, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public bool Dead => (double) this._position.Y > (double) (Main.maxTilesY * 16) - 480.0 || (double) this._position.X < 480.0 || (double) this._position.X >= (double) (Main.maxTilesX * 16) - 480.0 || this._frameCounter >= this._frameSpeed * 7;
|
||||
|
||||
public bool InDrawRange(Rectangle playerScreen) => playerScreen.Contains(this._position.ToPoint());
|
||||
|
||||
public Color GetLight() => new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, (int) sbyte.MaxValue);
|
||||
}
|
||||
}
|
||||
}
|
202
GameContent/Events/Sandstorm.cs
Normal file
202
GameContent/Events/Sandstorm.cs
Normal file
|
@ -0,0 +1,202 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.Sandstorm
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class Sandstorm
|
||||
{
|
||||
public static bool Happening;
|
||||
public static int TimeLeft;
|
||||
public static float Severity;
|
||||
public static float IntendedSeverity;
|
||||
private static bool _effectsUp;
|
||||
|
||||
public static void WorldClear() => Sandstorm.Happening = false;
|
||||
|
||||
public static void UpdateTime()
|
||||
{
|
||||
if (Main.netMode != 1)
|
||||
{
|
||||
if (Sandstorm.Happening)
|
||||
{
|
||||
if (Sandstorm.TimeLeft > 86400)
|
||||
Sandstorm.TimeLeft = 0;
|
||||
Sandstorm.TimeLeft -= Main.dayRate;
|
||||
if (Sandstorm.TimeLeft <= 0)
|
||||
Sandstorm.StopSandstorm();
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = (int) ((double) Main.windSpeed * 100.0);
|
||||
for (int index = 0; index < Main.dayRate; ++index)
|
||||
{
|
||||
if (Main.rand.Next(777600) == 0)
|
||||
Sandstorm.StartSandstorm();
|
||||
else if ((Main.numClouds < 40 || Math.Abs(num) > 50) && Main.rand.Next(518400) == 0)
|
||||
Sandstorm.StartSandstorm();
|
||||
}
|
||||
}
|
||||
if (Main.rand.Next(18000) == 0)
|
||||
Sandstorm.ChangeSeverityIntentions();
|
||||
}
|
||||
Sandstorm.UpdateSeverity();
|
||||
}
|
||||
|
||||
private static void ChangeSeverityIntentions()
|
||||
{
|
||||
Sandstorm.IntendedSeverity = !Sandstorm.Happening ? (Main.rand.Next(3) != 0 ? Main.rand.NextFloat() * 0.3f : 0.0f) : 0.4f + Main.rand.NextFloat();
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
NetMessage.SendData(7);
|
||||
}
|
||||
|
||||
private static void UpdateSeverity()
|
||||
{
|
||||
int num1 = Math.Sign(Sandstorm.IntendedSeverity - Sandstorm.Severity);
|
||||
Sandstorm.Severity = MathHelper.Clamp(Sandstorm.Severity + 3f / 1000f * (float) num1, 0.0f, 1f);
|
||||
int num2 = Math.Sign(Sandstorm.IntendedSeverity - Sandstorm.Severity);
|
||||
if (num1 == num2)
|
||||
return;
|
||||
Sandstorm.Severity = Sandstorm.IntendedSeverity;
|
||||
}
|
||||
|
||||
private static void StartSandstorm()
|
||||
{
|
||||
Sandstorm.Happening = true;
|
||||
Sandstorm.TimeLeft = (int) (3600.0 * (8.0 + (double) Main.rand.NextFloat() * 16.0));
|
||||
Sandstorm.ChangeSeverityIntentions();
|
||||
}
|
||||
|
||||
private static void StopSandstorm()
|
||||
{
|
||||
Sandstorm.Happening = false;
|
||||
Sandstorm.TimeLeft = 0;
|
||||
Sandstorm.ChangeSeverityIntentions();
|
||||
}
|
||||
|
||||
public static void HandleEffectAndSky(bool toState)
|
||||
{
|
||||
if (toState == Sandstorm._effectsUp)
|
||||
return;
|
||||
Sandstorm._effectsUp = toState;
|
||||
Vector2 center = Main.player[Main.myPlayer].Center;
|
||||
if (Sandstorm._effectsUp)
|
||||
{
|
||||
SkyManager.Instance.Activate(nameof (Sandstorm), center);
|
||||
Filters.Scene.Activate(nameof (Sandstorm), center);
|
||||
Overlays.Scene.Activate(nameof (Sandstorm), center);
|
||||
}
|
||||
else
|
||||
{
|
||||
SkyManager.Instance.Deactivate(nameof (Sandstorm));
|
||||
Filters.Scene.Deactivate(nameof (Sandstorm));
|
||||
Overlays.Scene.Deactivate(nameof (Sandstorm));
|
||||
}
|
||||
}
|
||||
|
||||
public static void EmitDust()
|
||||
{
|
||||
if (Main.gamePaused)
|
||||
return;
|
||||
int sandTiles = Main.sandTiles;
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
bool flag = Sandstorm.Happening && player.ZoneSandstorm && (Main.bgStyle == 2 || Main.bgStyle == 5) && Main.bgDelay < 50;
|
||||
Sandstorm.HandleEffectAndSky(flag && Main.UseStormEffects);
|
||||
if (sandTiles < 100 || (double) player.position.Y > Main.worldSurface * 16.0 || player.ZoneBeach)
|
||||
return;
|
||||
int maxValue1 = 1;
|
||||
if (!flag || Main.rand.Next(maxValue1) != 0)
|
||||
return;
|
||||
int num1 = Math.Sign(Main.windSpeed);
|
||||
float amount = Math.Abs(Main.windSpeed);
|
||||
if ((double) amount < 0.00999999977648258)
|
||||
return;
|
||||
float num2 = (float) num1 * MathHelper.Lerp(0.9f, 1f, amount);
|
||||
float num3 = 2000f / (float) sandTiles;
|
||||
float num4 = MathHelper.Clamp(3f / num3, 0.77f, 1f);
|
||||
int num5 = (int) num3;
|
||||
int num6 = (int) (1000.0 * (double) ((float) Main.screenWidth / (float) Main.maxScreenW));
|
||||
float num7 = 20f * Sandstorm.Severity;
|
||||
float num8 = (float) ((double) num6 * ((double) Main.gfxQuality * 0.5 + 0.5) + (double) num6 * 0.100000001490116) - (float) Dust.SandStormCount;
|
||||
if ((double) num8 <= 0.0)
|
||||
return;
|
||||
float num9 = (float) Main.screenWidth + 1000f;
|
||||
float screenHeight = (float) Main.screenHeight;
|
||||
Vector2 vector2 = Main.screenPosition + player.velocity;
|
||||
WeightedRandom<Color> weightedRandom = new WeightedRandom<Color>();
|
||||
weightedRandom.Add(new Color(200, 160, 20, 180), (double) (Main.screenTileCounts[53] + Main.screenTileCounts[396] + Main.screenTileCounts[397]));
|
||||
weightedRandom.Add(new Color(103, 98, 122, 180), (double) (Main.screenTileCounts[112] + Main.screenTileCounts[400] + Main.screenTileCounts[398]));
|
||||
weightedRandom.Add(new Color(135, 43, 34, 180), (double) (Main.screenTileCounts[234] + Main.screenTileCounts[401] + Main.screenTileCounts[399]));
|
||||
weightedRandom.Add(new Color(213, 196, 197, 180), (double) (Main.screenTileCounts[116] + Main.screenTileCounts[403] + Main.screenTileCounts[402]));
|
||||
float num10 = MathHelper.Lerp(0.2f, 0.35f, Sandstorm.Severity);
|
||||
float num11 = MathHelper.Lerp(0.5f, 0.7f, Sandstorm.Severity);
|
||||
int maxValue2 = (int) MathHelper.Lerp(1f, 10f, (float) (((double) num4 - 0.769999980926514) / 0.230000019073486));
|
||||
for (int index1 = 0; (double) index1 < (double) num7; ++index1)
|
||||
{
|
||||
if (Main.rand.Next(num5 / 4) == 0)
|
||||
{
|
||||
Vector2 Position = new Vector2((float) ((double) Main.rand.NextFloat() * (double) num9 - 500.0), Main.rand.NextFloat() * -50f);
|
||||
if (Main.rand.Next(3) == 0 && num1 == 1)
|
||||
Position.X = (float) (Main.rand.Next(500) - 500);
|
||||
else if (Main.rand.Next(3) == 0 && num1 == -1)
|
||||
Position.X = (float) (Main.rand.Next(500) + Main.screenWidth);
|
||||
if ((double) Position.X < 0.0 || (double) Position.X > (double) Main.screenWidth)
|
||||
Position.Y += (float) ((double) Main.rand.NextFloat() * (double) screenHeight * 0.899999976158142);
|
||||
Position += vector2;
|
||||
int index2 = (int) Position.X / 16;
|
||||
int index3 = (int) Position.Y / 16;
|
||||
if (Main.tile[index2, index3] != null && Main.tile[index2, index3].wall == (byte) 0)
|
||||
{
|
||||
for (int index4 = 0; index4 < 1; ++index4)
|
||||
{
|
||||
Dust dust = Main.dust[Dust.NewDust(Position, 10, 10, 268)];
|
||||
dust.velocity.Y = (float) (2.0 + (double) Main.rand.NextFloat() * 0.200000002980232);
|
||||
dust.velocity.Y *= dust.scale;
|
||||
dust.velocity.Y *= 0.35f;
|
||||
dust.velocity.X = (float) ((double) num2 * 5.0 + (double) Main.rand.NextFloat() * 1.0);
|
||||
dust.velocity.X += (float) ((double) num2 * (double) num11 * 20.0);
|
||||
dust.fadeIn += num11 * 0.2f;
|
||||
dust.velocity *= (float) (1.0 + (double) num10 * 0.5);
|
||||
dust.color = (Color) weightedRandom;
|
||||
dust.velocity *= 1f + num10;
|
||||
dust.velocity *= num4;
|
||||
dust.scale = 0.9f;
|
||||
--num8;
|
||||
if ((double) num8 > 0.0)
|
||||
{
|
||||
if (Main.rand.Next(maxValue2) != 0)
|
||||
{
|
||||
--index4;
|
||||
Position += Utils.RandomVector2(Main.rand, -10f, 10f) + dust.velocity * -1.1f;
|
||||
int x = (int) Position.X / 16;
|
||||
int y = (int) Position.Y / 16;
|
||||
if (WorldGen.InWorld(x, y, 10) && Main.tile[x, y] != null)
|
||||
{
|
||||
int wall = (int) Main.tile[x, y].wall;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if ((double) num8 <= 0.0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawGrains(SpriteBatch spriteBatch)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/Events/ScreenDarkness.cs
Normal file
48
GameContent/Events/ScreenDarkness.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.ScreenDarkness
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class ScreenDarkness
|
||||
{
|
||||
public static float screenObstruction;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
float num = 0.0f;
|
||||
float amount = 0.1f;
|
||||
Vector2 mountedCenter = Main.player[Main.myPlayer].MountedCenter;
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].type == 370 && (double) Main.npc[index].Distance(mountedCenter) < 3000.0 && ((double) Main.npc[index].ai[0] >= 10.0 || (double) Main.npc[index].ai[0] == 9.0 && (double) Main.npc[index].ai[2] > 120.0))
|
||||
{
|
||||
num = 0.95f;
|
||||
amount = 0.03f;
|
||||
}
|
||||
}
|
||||
ScreenDarkness.screenObstruction = MathHelper.Lerp(ScreenDarkness.screenObstruction, num, amount);
|
||||
}
|
||||
|
||||
public static void DrawBack(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((double) ScreenDarkness.screenObstruction == 0.0)
|
||||
return;
|
||||
Color color = Color.Black * ScreenDarkness.screenObstruction;
|
||||
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
}
|
||||
|
||||
public static void DrawFront(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((double) ScreenDarkness.screenObstruction == 0.0)
|
||||
return;
|
||||
Color color = new Color(0, 0, 120) * ScreenDarkness.screenObstruction * 0.3f;
|
||||
spriteBatch.Draw(Main.magicPixel, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Events/ScreenObstruction.cs
Normal file
49
GameContent/Events/ScreenObstruction.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Events.ScreenObstruction
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Terraria.GameContent.Events
|
||||
{
|
||||
public class ScreenObstruction
|
||||
{
|
||||
public static float screenObstruction;
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
float num = 0.0f;
|
||||
float amount = 0.1f;
|
||||
if (Main.player[Main.myPlayer].headcovered)
|
||||
{
|
||||
num = 0.95f;
|
||||
amount = 0.3f;
|
||||
}
|
||||
ScreenObstruction.screenObstruction = MathHelper.Lerp(ScreenObstruction.screenObstruction, num, amount);
|
||||
}
|
||||
|
||||
public static void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if ((double) ScreenObstruction.screenObstruction == 0.0)
|
||||
return;
|
||||
Color color = Color.Black * ScreenObstruction.screenObstruction;
|
||||
int width = Main.extraTexture[49].Width;
|
||||
int num = 10;
|
||||
Rectangle rect = Main.player[Main.myPlayer].getRect();
|
||||
rect.Inflate((width - rect.Width) / 2, (width - rect.Height) / 2 + num / 2);
|
||||
rect.Offset(-(int) Main.screenPosition.X, -(int) Main.screenPosition.Y + (int) Main.player[Main.myPlayer].gfxOffY - num);
|
||||
Rectangle destinationRectangle1 = Rectangle.Union(new Rectangle(0, 0, 1, 1), new Rectangle(rect.Right - 1, rect.Top - 1, 1, 1));
|
||||
Rectangle destinationRectangle2 = Rectangle.Union(new Rectangle(Main.screenWidth - 1, 0, 1, 1), new Rectangle(rect.Right, rect.Bottom - 1, 1, 1));
|
||||
Rectangle destinationRectangle3 = Rectangle.Union(new Rectangle(Main.screenWidth - 1, Main.screenHeight - 1, 1, 1), new Rectangle(rect.Left, rect.Bottom, 1, 1));
|
||||
Rectangle destinationRectangle4 = Rectangle.Union(new Rectangle(0, Main.screenHeight - 1, 1, 1), new Rectangle(rect.Left - 1, rect.Top, 1, 1));
|
||||
spriteBatch.Draw(Main.magicPixel, destinationRectangle1, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
spriteBatch.Draw(Main.magicPixel, destinationRectangle2, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
spriteBatch.Draw(Main.magicPixel, destinationRectangle3, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
spriteBatch.Draw(Main.magicPixel, destinationRectangle4, new Rectangle?(new Rectangle(0, 0, 1, 1)), color);
|
||||
spriteBatch.Draw(Main.extraTexture[49], rect, color);
|
||||
}
|
||||
}
|
||||
}
|
31
GameContent/FixExploitManEaters.cs
Normal file
31
GameContent/FixExploitManEaters.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.FixExploitManEaters
|
||||
// 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;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public static class FixExploitManEaters
|
||||
{
|
||||
private static List<int> _indexesProtected = new List<int>();
|
||||
|
||||
public static void Update() => FixExploitManEaters._indexesProtected.Clear();
|
||||
|
||||
public static void ProtectSpot(int x, int y)
|
||||
{
|
||||
int num = (x & (int) ushort.MaxValue) << 16 | y & (int) ushort.MaxValue;
|
||||
if (FixExploitManEaters._indexesProtected.Contains(num))
|
||||
return;
|
||||
FixExploitManEaters._indexesProtected.Add(num);
|
||||
}
|
||||
|
||||
public static bool SpotProtected(int x, int y)
|
||||
{
|
||||
int num = (x & (int) ushort.MaxValue) << 16 | y & (int) ushort.MaxValue;
|
||||
return FixExploitManEaters._indexesProtected.Contains(num);
|
||||
}
|
||||
}
|
||||
}
|
22
GameContent/Generation/ActionGrass.cs
Normal file
22
GameContent/Generation/ActionGrass.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionGrass
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ActionGrass : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
if (GenBase._tiles[x, y].active() || GenBase._tiles[x, y - 1].active())
|
||||
return false;
|
||||
WorldGen.PlaceTile(x, y, (int) Utils.SelectRandom<ushort>(GenBase._random, (ushort) 3, (ushort) 73), true);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
26
GameContent/Generation/ActionPlaceStatue.cs
Normal file
26
GameContent/Generation/ActionPlaceStatue.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionPlaceStatue
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ActionPlaceStatue : GenAction
|
||||
{
|
||||
private int _statueIndex;
|
||||
|
||||
public ActionPlaceStatue(int index = -1) => this._statueIndex = index;
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
Point16 point16 = this._statueIndex != -1 ? WorldGen.statueList[this._statueIndex] : WorldGen.statueList[GenBase._random.Next(2, WorldGen.statueList.Length)];
|
||||
WorldGen.PlaceTile(x, y, (int) point16.X, true, style: ((int) point16.Y));
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
20
GameContent/Generation/ActionStalagtite.cs
Normal file
20
GameContent/Generation/ActionStalagtite.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionStalagtite
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ActionStalagtite : GenAction
|
||||
{
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
WorldGen.PlaceTight(x, y);
|
||||
return this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
37
GameContent/Generation/ActionVines.cs
Normal file
37
GameContent/Generation/ActionVines.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ActionVines
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ActionVines : GenAction
|
||||
{
|
||||
private int _minLength;
|
||||
private int _maxLength;
|
||||
private int _vineId;
|
||||
|
||||
public ActionVines(int minLength = 6, int maxLength = 10, int vineId = 52)
|
||||
{
|
||||
this._minLength = minLength;
|
||||
this._maxLength = maxLength;
|
||||
this._vineId = vineId;
|
||||
}
|
||||
|
||||
public override bool Apply(Point origin, int x, int y, params object[] args)
|
||||
{
|
||||
int num1 = GenBase._random.Next(this._minLength, this._maxLength + 1);
|
||||
int num2;
|
||||
for (num2 = 0; num2 < num1 && !GenBase._tiles[x, y + num2].active(); ++num2)
|
||||
{
|
||||
GenBase._tiles[x, y + num2].type = (ushort) this._vineId;
|
||||
GenBase._tiles[x, y + num2].active(true);
|
||||
}
|
||||
return num2 > 0 && this.UnitApply(origin, x, y, args);
|
||||
}
|
||||
}
|
||||
}
|
54
GameContent/Generation/PassLegacy.cs
Normal file
54
GameContent/Generation/PassLegacy.cs
Normal file
|
@ -0,0 +1,54 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.PassLegacy
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class PassLegacy : GenPass
|
||||
{
|
||||
private static Dictionary<string, float> _weightMap = PassLegacy.GenerateWeightMap();
|
||||
private WorldGenLegacyMethod _method;
|
||||
|
||||
private static Dictionary<string, float> GenerateWeightMap()
|
||||
{
|
||||
Dictionary<string, float> dictionary = new Dictionary<string, float>();
|
||||
char[] chArray1 = new char[1]{ ',' };
|
||||
foreach (string str in "Reset:1.794,Terrain:233.6416,Tunnels:4.6075,Sand:256.211,Mount Caves:28.2501,Dirt Wall Backgrounds:91.1031,Rocks In Dirt:568.933,Dirt In Rocks:612.0777,Clay:99.0829,Small Holes:1080.6658,Dirt Layer Caves:97.6719,Rock Layer Caves:978.5062,Surface Caves:13.8707,Slush Check:40.0098,Grass:14.2435,Jungle:2404.0004,Marble:644.4756,Granite:7445.4057,Mud Caves To Grass:13289.4058,Full Desert:1977.3443,Floating Islands:430.9967,Mushroom Patches:305.0517,Mud To Dirt:135.7024,Silt:76.367,Shinies:106.5187,Webs:22.2261,Underworld:5202.7952,Lakes:12.458,Dungeon:273.1042,Corruption:100.9735,Slush:24.1356,Mud Caves To Grass:8.4174,Beaches:4.4018,Gems:289.1701,Gravitating Sand:207.9566,Clean Up Dirt:459.6188,Pyramids:0.4286,Dirt Rock Wall Runner:18.2315,Living Trees:11.9772,Wood Tree Walls:61.6,Altars:18.7726,Wet Jungle:10.5711,Remove Water From Sand:11.0268,Jungle Temple:140.1556,Hives:2144.6166,Jungle Chests:1.3979,Smooth World:2242.1054,Settle Liquids:4844.7201,Waterfalls:1868.306,Ice:80.3287,Wall Variety:2390.3296,Traps:42.6118,Life Crystals:2.0239,Statues:15.5157,Buried Chests:591.4215,Surface Chests:9.5181,Jungle Chests Placement:1.8203,Water Chests:5.5477,Spider Caves:4979.7116,Gem Caves:41.1786,Moss:2116.5164,Temple:6.6512,Ice Walls:7890.5261,Jungle Trees:230.5412,Floating Island Houses:2.299,Quick Cleanup:417.1482,Pots:515.7405,Hellforge:5.3522,Spreading Grass:47.0313,Piles:160.8168,Moss:11.8533,Spawn Point:0.2951,Grass Wall:293.7116,Guide:4.4433,Sunflowers:4.6765,Planting Trees:203.2509,Herbs:86.5444,Dye Plants:178.949,Webs And Honey:336.4474,Weeds:137.5676,Mud Caves To Grass:179.8629,Jungle Plants:606.4348,Vines:264.2856,Flowers:0.8461,Mushrooms:0.4203,Stalac:347.0403,Gems In Ice Biome:5.491,Random Gems:9.3797,Moss Grass:267.3524,Muds Walls In Jungle:34.8689,Larva:0.6675,Tile Cleanup:675.7305,Lihzahrd Altars:0.2615,Micro Biomes:2734.7864,Final Cleanup:648.6878".Split(chArray1))
|
||||
{
|
||||
char[] chArray2 = new char[1]{ ':' };
|
||||
string[] strArray = str.Split(chArray2);
|
||||
dictionary[strArray[0]] = float.Parse(strArray[1], NumberStyles.AllowDecimalPoint, (IFormatProvider) CultureInfo.InvariantCulture);
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public PassLegacy(string name, WorldGenLegacyMethod method)
|
||||
: base(name, PassLegacy.GetWeight(name))
|
||||
{
|
||||
this._method = method;
|
||||
}
|
||||
|
||||
public PassLegacy(string name, WorldGenLegacyMethod method, float weight)
|
||||
: base(name, weight)
|
||||
{
|
||||
this._method = method;
|
||||
}
|
||||
|
||||
private static float GetWeight(string name)
|
||||
{
|
||||
float num;
|
||||
if (!PassLegacy._weightMap.TryGetValue(name, out num))
|
||||
num = 1f;
|
||||
return num;
|
||||
}
|
||||
|
||||
public override void Apply(GenerationProgress progress) => this._method(progress);
|
||||
}
|
||||
}
|
69
GameContent/Generation/ShapeBranch.cs
Normal file
69
GameContent/Generation/ShapeBranch.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeBranch
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ShapeBranch : GenShape
|
||||
{
|
||||
private Point _offset;
|
||||
private List<Point> _endPoints;
|
||||
|
||||
public ShapeBranch() => this._offset = new Point(10, -5);
|
||||
|
||||
public ShapeBranch(Point offset) => this._offset = offset;
|
||||
|
||||
public ShapeBranch(double angle, double distance) => this._offset = new Point((int) (Math.Cos(angle) * distance), (int) (Math.Sin(angle) * distance));
|
||||
|
||||
private bool PerformSegment(Point origin, GenAction action, Point start, Point end, int size)
|
||||
{
|
||||
size = Math.Max(1, size);
|
||||
for (int index1 = -(size >> 1); index1 < size - (size >> 1); ++index1)
|
||||
{
|
||||
for (int index2 = -(size >> 1); index2 < size - (size >> 1); ++index2)
|
||||
{
|
||||
if (!Utils.PlotLine(new Point(start.X + index1, start.Y + index2), end, (Utils.PerLinePoint) ((tileX, tileY) => this.UnitApply(action, origin, tileX, tileY) || !this._quitOnFail), false))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
float num1 = new Vector2((float) this._offset.X, (float) this._offset.Y).Length();
|
||||
int size = (int) ((double) num1 / 6.0);
|
||||
if (this._endPoints != null)
|
||||
this._endPoints.Add(new Point(origin.X + this._offset.X, origin.Y + this._offset.Y));
|
||||
if (!this.PerformSegment(origin, action, origin, new Point(origin.X + this._offset.X, origin.Y + this._offset.Y), size))
|
||||
return false;
|
||||
int num2 = (int) ((double) num1 / 8.0);
|
||||
for (int index = 0; index < num2; ++index)
|
||||
{
|
||||
float num3 = (float) (((double) index + 1.0) / ((double) num2 + 1.0));
|
||||
Point point1 = new Point((int) ((double) num3 * (double) this._offset.X), (int) ((double) num3 * (double) this._offset.Y));
|
||||
Vector2 spinningpoint = new Vector2((float) (this._offset.X - point1.X), (float) (this._offset.Y - point1.Y));
|
||||
spinningpoint = spinningpoint.RotatedBy((GenBase._random.NextDouble() * 0.5 + 1.0) * (GenBase._random.Next(2) == 0 ? -1.0 : 1.0)) * 0.75f;
|
||||
Point point2 = new Point((int) spinningpoint.X + point1.X, (int) spinningpoint.Y + point1.Y);
|
||||
if (this._endPoints != null)
|
||||
this._endPoints.Add(new Point(point2.X + origin.X, point2.Y + origin.Y));
|
||||
if (!this.PerformSegment(origin, action, new Point(point1.X + origin.X, point1.Y + origin.Y), new Point(point2.X + origin.X, point2.Y + origin.Y), size - 1))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShapeBranch OutputEndpoints(List<Point> endpoints)
|
||||
{
|
||||
this._endPoints = endpoints;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
55
GameContent/Generation/ShapeFloodFill.cs
Normal file
55
GameContent/Generation/ShapeFloodFill.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeFloodFill
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ShapeFloodFill : GenShape
|
||||
{
|
||||
private int _maximumActions;
|
||||
|
||||
public ShapeFloodFill(int maximumActions = 100) => this._maximumActions = maximumActions;
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
Queue<Point> pointQueue = new Queue<Point>();
|
||||
HashSet<Point16> point16Set = new HashSet<Point16>();
|
||||
pointQueue.Enqueue(origin);
|
||||
int maximumActions = this._maximumActions;
|
||||
while (pointQueue.Count > 0 && maximumActions > 0)
|
||||
{
|
||||
Point point = pointQueue.Dequeue();
|
||||
if (!point16Set.Contains(new Point16(point.X, point.Y)) && this.UnitApply(action, origin, point.X, point.Y))
|
||||
{
|
||||
point16Set.Add(new Point16(point));
|
||||
--maximumActions;
|
||||
if (point.X + 1 < Main.maxTilesX - 1)
|
||||
pointQueue.Enqueue(new Point(point.X + 1, point.Y));
|
||||
if (point.X - 1 >= 1)
|
||||
pointQueue.Enqueue(new Point(point.X - 1, point.Y));
|
||||
if (point.Y + 1 < Main.maxTilesY - 1)
|
||||
pointQueue.Enqueue(new Point(point.X, point.Y + 1));
|
||||
if (point.Y - 1 >= 1)
|
||||
pointQueue.Enqueue(new Point(point.X, point.Y - 1));
|
||||
}
|
||||
}
|
||||
while (pointQueue.Count > 0)
|
||||
{
|
||||
Point point = pointQueue.Dequeue();
|
||||
if (!point16Set.Contains(new Point16(point.X, point.Y)))
|
||||
{
|
||||
pointQueue.Enqueue(point);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pointQueue.Count == 0;
|
||||
}
|
||||
}
|
||||
}
|
59
GameContent/Generation/ShapeRoot.cs
Normal file
59
GameContent/Generation/ShapeRoot.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeRoot
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ShapeRoot : GenShape
|
||||
{
|
||||
private float _angle;
|
||||
private float _startingSize;
|
||||
private float _endingSize;
|
||||
private float _distance;
|
||||
|
||||
public ShapeRoot(float angle, float distance = 10f, float startingSize = 4f, float endingSize = 1f)
|
||||
{
|
||||
this._angle = angle;
|
||||
this._distance = distance;
|
||||
this._startingSize = startingSize;
|
||||
this._endingSize = endingSize;
|
||||
}
|
||||
|
||||
private bool DoRoot(
|
||||
Point origin,
|
||||
GenAction action,
|
||||
float angle,
|
||||
float distance,
|
||||
float startingSize)
|
||||
{
|
||||
float x = (float) origin.X;
|
||||
float y = (float) origin.Y;
|
||||
for (float num1 = 0.0f; (double) num1 < (double) distance * 0.850000023841858; ++num1)
|
||||
{
|
||||
float amount = num1 / distance;
|
||||
float num2 = MathHelper.Lerp(startingSize, this._endingSize, amount);
|
||||
x += (float) Math.Cos((double) angle);
|
||||
y += (float) Math.Sin((double) angle);
|
||||
angle += (float) ((double) GenBase._random.NextFloat() - 0.5 + (double) GenBase._random.NextFloat() * ((double) this._angle - 1.57079637050629) * 0.100000001490116 * (1.0 - (double) amount));
|
||||
angle = (float) ((double) angle * 0.400000005960464 + 0.449999988079071 * (double) MathHelper.Clamp(angle, this._angle - (float) (2.0 * (1.0 - 0.5 * (double) amount)), this._angle + (float) (2.0 * (1.0 - 0.5 * (double) amount))) + (double) MathHelper.Lerp(this._angle, 1.570796f, amount) * 0.150000005960464);
|
||||
for (int index1 = 0; index1 < (int) num2; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < (int) num2; ++index2)
|
||||
{
|
||||
if (!this.UnitApply(action, origin, (int) x + index1, (int) y + index2) && this._quitOnFail)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action) => this.DoRoot(origin, action, this._angle, this._distance, this._startingSize);
|
||||
}
|
||||
}
|
62
GameContent/Generation/ShapeRunner.cs
Normal file
62
GameContent/Generation/ShapeRunner.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.ShapeRunner
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class ShapeRunner : GenShape
|
||||
{
|
||||
private float _startStrength;
|
||||
private int _steps;
|
||||
private Vector2 _startVelocity;
|
||||
|
||||
public ShapeRunner(float strength, int steps, Vector2 velocity)
|
||||
{
|
||||
this._startStrength = strength;
|
||||
this._steps = steps;
|
||||
this._startVelocity = velocity;
|
||||
}
|
||||
|
||||
public override bool Perform(Point origin, GenAction action)
|
||||
{
|
||||
float num1 = (float) this._steps;
|
||||
float steps = (float) this._steps;
|
||||
double num2 = (double) this._startStrength;
|
||||
Vector2 vector2_1 = new Vector2((float) origin.X, (float) origin.Y);
|
||||
Vector2 vector2_2 = this._startVelocity == Vector2.Zero ? Utils.RandomVector2(GenBase._random, -1f, 1f) : this._startVelocity;
|
||||
while ((double) num1 > 0.0 && num2 > 0.0)
|
||||
{
|
||||
num2 = (double) this._startStrength * ((double) num1 / (double) steps);
|
||||
float num3 = num1 - 1f;
|
||||
int num4 = Math.Max(1, (int) ((double) vector2_1.X - num2 * 0.5));
|
||||
int num5 = Math.Max(1, (int) ((double) vector2_1.Y - num2 * 0.5));
|
||||
int num6 = Math.Min(GenBase._worldWidth, (int) ((double) vector2_1.X + num2 * 0.5));
|
||||
int num7 = Math.Min(GenBase._worldHeight, (int) ((double) vector2_1.Y + num2 * 0.5));
|
||||
for (int x = num4; x < num6; ++x)
|
||||
{
|
||||
for (int y = num5; y < num7; ++y)
|
||||
{
|
||||
if ((double) Math.Abs((float) x - vector2_1.X) + (double) Math.Abs((float) y - vector2_1.Y) < num2 * 0.5 * (1.0 + (double) GenBase._random.Next(-10, 11) * 0.015))
|
||||
this.UnitApply(action, origin, x, y);
|
||||
}
|
||||
}
|
||||
int num8 = (int) (num2 / 50.0) + 1;
|
||||
num1 = num3 - (float) num8;
|
||||
vector2_1 += vector2_2;
|
||||
for (int index = 0; index < num8; ++index)
|
||||
{
|
||||
vector2_1 += vector2_2;
|
||||
vector2_2 += Utils.RandomVector2(GenBase._random, -0.5f, 0.5f);
|
||||
}
|
||||
vector2_2 = Vector2.Clamp(vector2_2 + Utils.RandomVector2(GenBase._random, -0.5f, 0.5f), -Vector2.One, Vector2.One);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
279
GameContent/Generation/TrackGenerator.cs
Normal file
279
GameContent/Generation/TrackGenerator.cs
Normal file
|
@ -0,0 +1,279 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.TrackGenerator
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.ID;
|
||||
using Terraria.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public class TrackGenerator
|
||||
{
|
||||
private static readonly byte[] INVALID_WALLS = new byte[13]
|
||||
{
|
||||
(byte) 7,
|
||||
(byte) 94,
|
||||
(byte) 95,
|
||||
(byte) 8,
|
||||
(byte) 98,
|
||||
(byte) 99,
|
||||
(byte) 9,
|
||||
(byte) 96,
|
||||
(byte) 97,
|
||||
(byte) 3,
|
||||
(byte) 83,
|
||||
(byte) 87,
|
||||
(byte) 86
|
||||
};
|
||||
private const int TOTAL_TILE_IGNORES = 150;
|
||||
private const int PLAYER_HEIGHT = 6;
|
||||
private const int MAX_RETRIES = 400;
|
||||
private const int MAX_SMOOTH_DISTANCE = 15;
|
||||
private const int MAX_ITERATIONS = 1000000;
|
||||
private TrackGenerator.TrackHistory[] _historyCache = new TrackGenerator.TrackHistory[2048];
|
||||
|
||||
public void Generate(int trackCount, int minimumLength)
|
||||
{
|
||||
int num = trackCount;
|
||||
while (num > 0)
|
||||
{
|
||||
int x = WorldGen.genRand.Next(150, Main.maxTilesX - 150);
|
||||
int y = WorldGen.genRand.Next((int) Main.worldSurface + 25, Main.maxTilesY - 200);
|
||||
if (this.IsLocationEmpty(x, y))
|
||||
{
|
||||
while (this.IsLocationEmpty(x, y + 1))
|
||||
++y;
|
||||
if (this.FindPath(x, y, minimumLength))
|
||||
--num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLocationEmpty(int x, int y)
|
||||
{
|
||||
if (y > Main.maxTilesY - 200 || x < 0 || y < (int) Main.worldSurface || x > Main.maxTilesX - 5)
|
||||
return false;
|
||||
for (int index = 0; index < 6; ++index)
|
||||
{
|
||||
if (WorldGen.SolidTile(x, y - index))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool CanTrackBePlaced(int x, int y)
|
||||
{
|
||||
if (y > Main.maxTilesY - 200 || x < 0 || y < (int) Main.worldSurface || x > Main.maxTilesX - 5)
|
||||
return false;
|
||||
byte wall = Main.tile[x, y].wall;
|
||||
for (int index = 0; index < TrackGenerator.INVALID_WALLS.Length; ++index)
|
||||
{
|
||||
if ((int) wall == (int) TrackGenerator.INVALID_WALLS[index])
|
||||
return false;
|
||||
}
|
||||
for (int index = -1; index <= 1; ++index)
|
||||
{
|
||||
if (Main.tile[x + index, y].active() && (Main.tile[x + index, y].type == (ushort) 314 || !TileID.Sets.GeneralPlacementTiles[(int) Main.tile[x + index, y].type]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SmoothTrack(TrackGenerator.TrackHistory[] history, int length)
|
||||
{
|
||||
int val2 = length - 1;
|
||||
bool flag = false;
|
||||
for (int index1 = length - 1; index1 >= 0; --index1)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
val2 = Math.Min(index1 + 15, val2);
|
||||
if ((int) history[index1].Y >= (int) history[val2].Y)
|
||||
{
|
||||
for (int index2 = index1 + 1; (int) history[index2].Y > (int) history[index1].Y; ++index2)
|
||||
history[index2].Y = history[index1].Y;
|
||||
if ((int) history[index1].Y == (int) history[val2].Y)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
else if ((int) history[index1].Y > (int) history[val2].Y)
|
||||
flag = true;
|
||||
else
|
||||
val2 = index1;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FindPath(int x, int y, int minimumLength, bool debugMode = false)
|
||||
{
|
||||
TrackGenerator.TrackHistory[] historyCache = this._historyCache;
|
||||
int index1 = 0;
|
||||
Tile[,] tile = Main.tile;
|
||||
bool flag1 = true;
|
||||
int num1 = WorldGen.genRand.Next(2) == 0 ? 1 : -1;
|
||||
if (debugMode)
|
||||
num1 = Main.player[Main.myPlayer].direction;
|
||||
int yDirection = 1;
|
||||
int length = 0;
|
||||
int num2 = 400;
|
||||
bool flag2 = false;
|
||||
int num3 = 150;
|
||||
int num4 = 0;
|
||||
for (int index2 = 1000000; index2 > 0 & flag1 && index1 < historyCache.Length - 1; ++index1)
|
||||
{
|
||||
--index2;
|
||||
historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection);
|
||||
bool flag3 = false;
|
||||
int num5 = 1;
|
||||
if (index1 > minimumLength >> 1)
|
||||
num5 = -1;
|
||||
else if (index1 > (minimumLength >> 1) - 5)
|
||||
num5 = 0;
|
||||
if (flag2)
|
||||
{
|
||||
int num6 = 0;
|
||||
int num7 = num3;
|
||||
bool flag4 = false;
|
||||
for (int index3 = Math.Min(1, yDirection + 1); index3 >= Math.Max(-1, yDirection - 1); --index3)
|
||||
{
|
||||
int num8;
|
||||
for (num8 = 0; num8 <= num3; ++num8)
|
||||
{
|
||||
if (this.IsLocationEmpty(x + (num8 + 1) * num1, y + (num8 + 1) * index3 * num5))
|
||||
{
|
||||
flag4 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num8 < num7)
|
||||
{
|
||||
num7 = num8;
|
||||
num6 = index3;
|
||||
}
|
||||
}
|
||||
if (flag4)
|
||||
{
|
||||
yDirection = num6;
|
||||
for (int index4 = 0; index4 < num7 - 1; ++index4)
|
||||
{
|
||||
++index1;
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection);
|
||||
num4 = index1;
|
||||
}
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
length = index1 + 1;
|
||||
flag2 = false;
|
||||
}
|
||||
num3 -= num7;
|
||||
if (num3 < 0)
|
||||
flag1 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index5 = Math.Min(1, yDirection + 1); index5 >= Math.Max(-1, yDirection - 1); --index5)
|
||||
{
|
||||
if (this.IsLocationEmpty(x + num1, y + index5 * num5))
|
||||
{
|
||||
yDirection = index5;
|
||||
flag3 = true;
|
||||
x += num1;
|
||||
y += yDirection * num5;
|
||||
length = index1 + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag3)
|
||||
{
|
||||
while (index1 > num4 && y == (int) historyCache[index1].Y)
|
||||
--index1;
|
||||
x = (int) historyCache[index1].X;
|
||||
y = (int) historyCache[index1].Y;
|
||||
yDirection = (int) historyCache[index1].YDirection - 1;
|
||||
--num2;
|
||||
if (num2 <= 0)
|
||||
{
|
||||
index1 = length;
|
||||
x = (int) historyCache[index1].X;
|
||||
y = (int) historyCache[index1].Y;
|
||||
yDirection = (int) historyCache[index1].YDirection;
|
||||
flag2 = true;
|
||||
num2 = 200;
|
||||
}
|
||||
--index1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(length > minimumLength | debugMode))
|
||||
return false;
|
||||
this.SmoothTrack(historyCache, length);
|
||||
if (!debugMode)
|
||||
{
|
||||
for (int index6 = 0; index6 < length; ++index6)
|
||||
{
|
||||
for (int index7 = -1; index7 < 7; ++index7)
|
||||
{
|
||||
if (!this.CanTrackBePlaced((int) historyCache[index6].X, (int) historyCache[index6].Y - index7))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index8 = 0; index8 < length; ++index8)
|
||||
{
|
||||
TrackGenerator.TrackHistory trackHistory = historyCache[index8];
|
||||
for (int index9 = 0; index9 < 6; ++index9)
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y - index9].active(false);
|
||||
}
|
||||
for (int index10 = 0; index10 < length; ++index10)
|
||||
{
|
||||
TrackGenerator.TrackHistory trackHistory = historyCache[index10];
|
||||
Tile.SmoothSlope((int) trackHistory.X, (int) trackHistory.Y + 1);
|
||||
Tile.SmoothSlope((int) trackHistory.X, (int) trackHistory.Y - 6);
|
||||
bool wire = Main.tile[(int) trackHistory.X, (int) trackHistory.Y].wire();
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y].ResetToType((ushort) 314);
|
||||
Main.tile[(int) trackHistory.X, (int) trackHistory.Y].wire(wire);
|
||||
if (index10 != 0)
|
||||
{
|
||||
for (int index11 = 0; index11 < 6; ++index11)
|
||||
WorldUtils.TileFrame((int) historyCache[index10 - 1].X, (int) historyCache[index10 - 1].Y - index11, true);
|
||||
if (index10 == length - 1)
|
||||
{
|
||||
for (int index12 = 0; index12 < 6; ++index12)
|
||||
WorldUtils.TileFrame((int) trackHistory.X, (int) trackHistory.Y - index12, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Run(int trackCount = 30, int minimumLength = 250) => new TrackGenerator().Generate(trackCount, minimumLength);
|
||||
|
||||
public static void Run(Point start) => new TrackGenerator().FindPath(start.X, start.Y, 250, true);
|
||||
|
||||
private struct TrackHistory
|
||||
{
|
||||
public short X;
|
||||
public short Y;
|
||||
public byte YDirection;
|
||||
|
||||
public TrackHistory(int x, int y, int yDirection)
|
||||
{
|
||||
this.X = (short) x;
|
||||
this.Y = (short) y;
|
||||
this.YDirection = (byte) yDirection;
|
||||
}
|
||||
|
||||
public TrackHistory(short x, short y, byte yDirection)
|
||||
{
|
||||
this.X = x;
|
||||
this.Y = y;
|
||||
this.YDirection = yDirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
GameContent/Generation/WorldGenLegacyMethod.cs
Normal file
12
GameContent/Generation/WorldGenLegacyMethod.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Generation.WorldGenLegacyMethod
|
||||
// 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.World.Generation;
|
||||
|
||||
namespace Terraria.GameContent.Generation
|
||||
{
|
||||
public delegate void WorldGenLegacyMethod(GenerationProgress progress);
|
||||
}
|
589
GameContent/Liquid/LiquidRenderer.cs
Normal file
589
GameContent/Liquid/LiquidRenderer.cs
Normal file
|
@ -0,0 +1,589 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Liquid.LiquidRenderer
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Liquid
|
||||
{
|
||||
public class LiquidRenderer
|
||||
{
|
||||
private const int ANIMATION_FRAME_COUNT = 16;
|
||||
private const int CACHE_PADDING = 2;
|
||||
private const int CACHE_PADDING_2 = 4;
|
||||
private static readonly int[] WATERFALL_LENGTH = new int[3]
|
||||
{
|
||||
10,
|
||||
3,
|
||||
2
|
||||
};
|
||||
private static readonly float[] DEFAULT_OPACITY = new float[3]
|
||||
{
|
||||
0.6f,
|
||||
0.95f,
|
||||
0.95f
|
||||
};
|
||||
private static readonly byte[] WAVE_MASK_STRENGTH = new byte[5]
|
||||
{
|
||||
(byte) 0,
|
||||
(byte) 0,
|
||||
(byte) 0,
|
||||
byte.MaxValue,
|
||||
(byte) 0
|
||||
};
|
||||
private static readonly byte[] VISCOSITY_MASK = new byte[5]
|
||||
{
|
||||
(byte) 0,
|
||||
(byte) 200,
|
||||
(byte) 240,
|
||||
(byte) 0,
|
||||
(byte) 0
|
||||
};
|
||||
public const float MIN_LIQUID_SIZE = 0.25f;
|
||||
public static LiquidRenderer Instance = new LiquidRenderer();
|
||||
private Tile[,] _tiles = Main.tile;
|
||||
private Texture2D[] _liquidTextures = new Texture2D[12];
|
||||
private LiquidRenderer.LiquidCache[] _cache = new LiquidRenderer.LiquidCache[1];
|
||||
private LiquidRenderer.LiquidDrawCache[] _drawCache = new LiquidRenderer.LiquidDrawCache[1];
|
||||
private int _animationFrame;
|
||||
private Rectangle _drawArea = new Rectangle(0, 0, 1, 1);
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Color[] _waveMask = new Color[1];
|
||||
private float _frameState;
|
||||
|
||||
public event Action<Color[], Rectangle> WaveFilters;
|
||||
|
||||
public LiquidRenderer()
|
||||
{
|
||||
for (int index = 0; index < this._liquidTextures.Length; ++index)
|
||||
this._liquidTextures[index] = TextureManager.Load("Images/Misc/water_" + (object) index);
|
||||
}
|
||||
|
||||
private unsafe void InternalPrepareDraw(Rectangle drawArea)
|
||||
{
|
||||
Rectangle rectangle = new Rectangle(drawArea.X - 2, drawArea.Y - 2, drawArea.Width + 4, drawArea.Height + 4);
|
||||
this._drawArea = drawArea;
|
||||
if (this._cache.Length < rectangle.Width * rectangle.Height + 1)
|
||||
this._cache = new LiquidRenderer.LiquidCache[rectangle.Width * rectangle.Height + 1];
|
||||
if (this._drawCache.Length < drawArea.Width * drawArea.Height + 1)
|
||||
this._drawCache = new LiquidRenderer.LiquidDrawCache[drawArea.Width * drawArea.Height + 1];
|
||||
if (this._waveMask.Length < drawArea.Width * drawArea.Height)
|
||||
this._waveMask = new Color[drawArea.Width * drawArea.Height];
|
||||
fixed (LiquidRenderer.LiquidCache* liquidCachePtr1 = &this._cache[1])
|
||||
{
|
||||
int num1 = rectangle.Height * 2 + 2;
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr2 = liquidCachePtr1;
|
||||
for (int x = rectangle.X; x < rectangle.X + rectangle.Width; ++x)
|
||||
{
|
||||
for (int y = rectangle.Y; y < rectangle.Y + rectangle.Height; ++y)
|
||||
{
|
||||
Tile tile = this._tiles[x, y] ?? new Tile();
|
||||
liquidCachePtr2->LiquidLevel = (float) tile.liquid / (float) byte.MaxValue;
|
||||
liquidCachePtr2->IsHalfBrick = tile.halfBrick() && liquidCachePtr2[-1].HasLiquid;
|
||||
liquidCachePtr2->IsSolid = WorldGen.SolidOrSlopedTile(tile) && !liquidCachePtr2->IsHalfBrick;
|
||||
liquidCachePtr2->HasLiquid = tile.liquid > (byte) 0;
|
||||
liquidCachePtr2->VisibleLiquidLevel = 0.0f;
|
||||
liquidCachePtr2->HasWall = tile.wall > (byte) 0;
|
||||
liquidCachePtr2->Type = tile.liquidType();
|
||||
if (liquidCachePtr2->IsHalfBrick && !liquidCachePtr2->HasLiquid)
|
||||
liquidCachePtr2->Type = liquidCachePtr2[-1].Type;
|
||||
++liquidCachePtr2;
|
||||
}
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr3 = liquidCachePtr1 + num1;
|
||||
for (int index1 = 2; index1 < rectangle.Width - 2; ++index1)
|
||||
{
|
||||
for (int index2 = 2; index2 < rectangle.Height - 2; ++index2)
|
||||
{
|
||||
float val1 = 0.0f;
|
||||
float num2;
|
||||
if (liquidCachePtr3->IsHalfBrick && liquidCachePtr3[-1].HasLiquid)
|
||||
num2 = 1f;
|
||||
else if (!liquidCachePtr3->HasLiquid)
|
||||
{
|
||||
LiquidRenderer.LiquidCache liquidCache1 = liquidCachePtr3[-rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache2 = liquidCachePtr3[rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache3 = liquidCachePtr3[-1];
|
||||
LiquidRenderer.LiquidCache liquidCache4 = liquidCachePtr3[1];
|
||||
if (liquidCache1.HasLiquid && liquidCache2.HasLiquid && (int) liquidCache1.Type == (int) liquidCache2.Type)
|
||||
{
|
||||
val1 = liquidCache1.LiquidLevel + liquidCache2.LiquidLevel;
|
||||
liquidCachePtr3->Type = liquidCache1.Type;
|
||||
}
|
||||
if (liquidCache3.HasLiquid && liquidCache4.HasLiquid && (int) liquidCache3.Type == (int) liquidCache4.Type)
|
||||
{
|
||||
val1 = Math.Max(val1, liquidCache3.LiquidLevel + liquidCache4.LiquidLevel);
|
||||
liquidCachePtr3->Type = liquidCache3.Type;
|
||||
}
|
||||
num2 = val1 * 0.5f;
|
||||
}
|
||||
else
|
||||
num2 = liquidCachePtr3->LiquidLevel;
|
||||
liquidCachePtr3->VisibleLiquidLevel = num2;
|
||||
liquidCachePtr3->HasVisibleLiquid = (double) num2 != 0.0;
|
||||
++liquidCachePtr3;
|
||||
}
|
||||
liquidCachePtr3 += 4;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr4 = liquidCachePtr1;
|
||||
for (int index3 = 0; index3 < rectangle.Width; ++index3)
|
||||
{
|
||||
for (int index4 = 0; index4 < rectangle.Height - 10; ++index4)
|
||||
{
|
||||
if (liquidCachePtr4->HasVisibleLiquid && !liquidCachePtr4->IsSolid)
|
||||
{
|
||||
liquidCachePtr4->Opacity = 1f;
|
||||
liquidCachePtr4->VisibleType = liquidCachePtr4->Type;
|
||||
float num3 = 1f / (float) (LiquidRenderer.WATERFALL_LENGTH[(int) liquidCachePtr4->Type] + 1);
|
||||
float num4 = 1f;
|
||||
for (int index5 = 1; index5 <= LiquidRenderer.WATERFALL_LENGTH[(int) liquidCachePtr4->Type]; ++index5)
|
||||
{
|
||||
num4 -= num3;
|
||||
if (!liquidCachePtr4[index5].IsSolid)
|
||||
{
|
||||
liquidCachePtr4[index5].VisibleLiquidLevel = Math.Max(liquidCachePtr4[index5].VisibleLiquidLevel, liquidCachePtr4->VisibleLiquidLevel * num4);
|
||||
liquidCachePtr4[index5].Opacity = num4;
|
||||
liquidCachePtr4[index5].VisibleType = liquidCachePtr4->Type;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (liquidCachePtr4->IsSolid)
|
||||
{
|
||||
liquidCachePtr4->VisibleLiquidLevel = 1f;
|
||||
liquidCachePtr4->HasVisibleLiquid = false;
|
||||
}
|
||||
else
|
||||
liquidCachePtr4->HasVisibleLiquid = (double) liquidCachePtr4->VisibleLiquidLevel != 0.0;
|
||||
++liquidCachePtr4;
|
||||
}
|
||||
liquidCachePtr4 += 10;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr5 = liquidCachePtr1 + num1;
|
||||
for (int index6 = 2; index6 < rectangle.Width - 2; ++index6)
|
||||
{
|
||||
for (int index7 = 2; index7 < rectangle.Height - 2; ++index7)
|
||||
{
|
||||
if (!liquidCachePtr5->HasVisibleLiquid || liquidCachePtr5->IsSolid)
|
||||
{
|
||||
liquidCachePtr5->HasLeftEdge = false;
|
||||
liquidCachePtr5->HasTopEdge = false;
|
||||
liquidCachePtr5->HasRightEdge = false;
|
||||
liquidCachePtr5->HasBottomEdge = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LiquidRenderer.LiquidCache liquidCache5 = liquidCachePtr5[-1];
|
||||
LiquidRenderer.LiquidCache liquidCache6 = liquidCachePtr5[1];
|
||||
LiquidRenderer.LiquidCache liquidCache7 = liquidCachePtr5[-rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache8 = liquidCachePtr5[rectangle.Height];
|
||||
float num5 = 0.0f;
|
||||
float num6 = 1f;
|
||||
float num7 = 0.0f;
|
||||
float num8 = 1f;
|
||||
float visibleLiquidLevel = liquidCachePtr5->VisibleLiquidLevel;
|
||||
if (!liquidCache5.HasVisibleLiquid)
|
||||
num7 += liquidCache6.VisibleLiquidLevel * (1f - visibleLiquidLevel);
|
||||
if (!liquidCache6.HasVisibleLiquid && !liquidCache6.IsSolid && !liquidCache6.IsHalfBrick)
|
||||
num8 -= liquidCache5.VisibleLiquidLevel * (1f - visibleLiquidLevel);
|
||||
if (!liquidCache7.HasVisibleLiquid && !liquidCache7.IsSolid && !liquidCache7.IsHalfBrick)
|
||||
num5 += liquidCache8.VisibleLiquidLevel * (1f - visibleLiquidLevel);
|
||||
if (!liquidCache8.HasVisibleLiquid && !liquidCache8.IsSolid && !liquidCache8.IsHalfBrick)
|
||||
num6 -= liquidCache7.VisibleLiquidLevel * (1f - visibleLiquidLevel);
|
||||
liquidCachePtr5->LeftWall = num5;
|
||||
liquidCachePtr5->RightWall = num6;
|
||||
liquidCachePtr5->BottomWall = num8;
|
||||
liquidCachePtr5->TopWall = num7;
|
||||
Point zero = Point.Zero;
|
||||
liquidCachePtr5->HasTopEdge = !liquidCache5.HasVisibleLiquid && !liquidCache5.IsSolid || (double) num7 != 0.0;
|
||||
liquidCachePtr5->HasBottomEdge = !liquidCache6.HasVisibleLiquid && !liquidCache6.IsSolid || (double) num8 != 1.0;
|
||||
liquidCachePtr5->HasLeftEdge = !liquidCache7.HasVisibleLiquid && !liquidCache7.IsSolid || (double) num5 != 0.0;
|
||||
liquidCachePtr5->HasRightEdge = !liquidCache8.HasVisibleLiquid && !liquidCache8.IsSolid || (double) num6 != 1.0;
|
||||
if (!liquidCachePtr5->HasLeftEdge)
|
||||
{
|
||||
if (liquidCachePtr5->HasRightEdge)
|
||||
zero.X += 32;
|
||||
else
|
||||
zero.X += 16;
|
||||
}
|
||||
if (liquidCachePtr5->HasLeftEdge && liquidCachePtr5->HasRightEdge)
|
||||
{
|
||||
zero.X = 16;
|
||||
zero.Y += 32;
|
||||
if (liquidCachePtr5->HasTopEdge)
|
||||
zero.Y = 16;
|
||||
}
|
||||
else if (!liquidCachePtr5->HasTopEdge)
|
||||
{
|
||||
if (!liquidCachePtr5->HasLeftEdge && !liquidCachePtr5->HasRightEdge)
|
||||
zero.Y += 48;
|
||||
else
|
||||
zero.Y += 16;
|
||||
}
|
||||
if (zero.Y == 16 && liquidCachePtr5->HasLeftEdge ^ liquidCachePtr5->HasRightEdge && (index7 + rectangle.Y) % 2 == 0)
|
||||
zero.Y += 16;
|
||||
liquidCachePtr5->FrameOffset = zero;
|
||||
}
|
||||
++liquidCachePtr5;
|
||||
}
|
||||
liquidCachePtr5 += 4;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr6 = liquidCachePtr1 + num1;
|
||||
for (int index8 = 2; index8 < rectangle.Width - 2; ++index8)
|
||||
{
|
||||
for (int index9 = 2; index9 < rectangle.Height - 2; ++index9)
|
||||
{
|
||||
if (liquidCachePtr6->HasVisibleLiquid)
|
||||
{
|
||||
LiquidRenderer.LiquidCache liquidCache9 = liquidCachePtr6[-1];
|
||||
LiquidRenderer.LiquidCache liquidCache10 = liquidCachePtr6[1];
|
||||
LiquidRenderer.LiquidCache liquidCache11 = liquidCachePtr6[-rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache12 = liquidCachePtr6[rectangle.Height];
|
||||
liquidCachePtr6->VisibleLeftWall = liquidCachePtr6->LeftWall;
|
||||
liquidCachePtr6->VisibleRightWall = liquidCachePtr6->RightWall;
|
||||
liquidCachePtr6->VisibleTopWall = liquidCachePtr6->TopWall;
|
||||
liquidCachePtr6->VisibleBottomWall = liquidCachePtr6->BottomWall;
|
||||
if (liquidCache9.HasVisibleLiquid && liquidCache10.HasVisibleLiquid)
|
||||
{
|
||||
if (liquidCachePtr6->HasLeftEdge)
|
||||
liquidCachePtr6->VisibleLeftWall = (float) (((double) liquidCachePtr6->LeftWall * 2.0 + (double) liquidCache9.LeftWall + (double) liquidCache10.LeftWall) * 0.25);
|
||||
if (liquidCachePtr6->HasRightEdge)
|
||||
liquidCachePtr6->VisibleRightWall = (float) (((double) liquidCachePtr6->RightWall * 2.0 + (double) liquidCache9.RightWall + (double) liquidCache10.RightWall) * 0.25);
|
||||
}
|
||||
if (liquidCache11.HasVisibleLiquid && liquidCache12.HasVisibleLiquid)
|
||||
{
|
||||
if (liquidCachePtr6->HasTopEdge)
|
||||
liquidCachePtr6->VisibleTopWall = (float) (((double) liquidCachePtr6->TopWall * 2.0 + (double) liquidCache11.TopWall + (double) liquidCache12.TopWall) * 0.25);
|
||||
if (liquidCachePtr6->HasBottomEdge)
|
||||
liquidCachePtr6->VisibleBottomWall = (float) (((double) liquidCachePtr6->BottomWall * 2.0 + (double) liquidCache11.BottomWall + (double) liquidCache12.BottomWall) * 0.25);
|
||||
}
|
||||
}
|
||||
++liquidCachePtr6;
|
||||
}
|
||||
liquidCachePtr6 += 4;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr7 = liquidCachePtr1 + num1;
|
||||
for (int index10 = 2; index10 < rectangle.Width - 2; ++index10)
|
||||
{
|
||||
for (int index11 = 2; index11 < rectangle.Height - 2; ++index11)
|
||||
{
|
||||
if (liquidCachePtr7->HasLiquid)
|
||||
{
|
||||
LiquidRenderer.LiquidCache liquidCache13 = liquidCachePtr7[-1];
|
||||
LiquidRenderer.LiquidCache liquidCache14 = liquidCachePtr7[1];
|
||||
LiquidRenderer.LiquidCache liquidCache15 = liquidCachePtr7[-rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache16 = liquidCachePtr7[rectangle.Height];
|
||||
if (liquidCachePtr7->HasTopEdge && !liquidCachePtr7->HasBottomEdge && liquidCachePtr7->HasLeftEdge ^ liquidCachePtr7->HasRightEdge)
|
||||
{
|
||||
if (liquidCachePtr7->HasRightEdge)
|
||||
{
|
||||
liquidCachePtr7->VisibleRightWall = liquidCache14.VisibleRightWall;
|
||||
liquidCachePtr7->VisibleTopWall = liquidCache15.VisibleTopWall;
|
||||
}
|
||||
else
|
||||
{
|
||||
liquidCachePtr7->VisibleLeftWall = liquidCache14.VisibleLeftWall;
|
||||
liquidCachePtr7->VisibleTopWall = liquidCache16.VisibleTopWall;
|
||||
}
|
||||
}
|
||||
else if (liquidCache14.FrameOffset.X == 16 && liquidCache14.FrameOffset.Y == 32)
|
||||
{
|
||||
if ((double) liquidCachePtr7->VisibleLeftWall > 0.5)
|
||||
{
|
||||
liquidCachePtr7->VisibleLeftWall = 0.0f;
|
||||
liquidCachePtr7->FrameOffset = new Point(0, 0);
|
||||
}
|
||||
else if ((double) liquidCachePtr7->VisibleRightWall < 0.5)
|
||||
{
|
||||
liquidCachePtr7->VisibleRightWall = 1f;
|
||||
liquidCachePtr7->FrameOffset = new Point(32, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
++liquidCachePtr7;
|
||||
}
|
||||
liquidCachePtr7 += 4;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr8 = liquidCachePtr1 + num1;
|
||||
for (int index12 = 2; index12 < rectangle.Width - 2; ++index12)
|
||||
{
|
||||
for (int index13 = 2; index13 < rectangle.Height - 2; ++index13)
|
||||
{
|
||||
if (liquidCachePtr8->HasLiquid)
|
||||
{
|
||||
LiquidRenderer.LiquidCache liquidCache17 = liquidCachePtr8[-1];
|
||||
LiquidRenderer.LiquidCache liquidCache18 = liquidCachePtr8[1];
|
||||
LiquidRenderer.LiquidCache liquidCache19 = liquidCachePtr8[-rectangle.Height];
|
||||
LiquidRenderer.LiquidCache liquidCache20 = liquidCachePtr8[rectangle.Height];
|
||||
if (!liquidCachePtr8->HasBottomEdge && !liquidCachePtr8->HasLeftEdge && !liquidCachePtr8->HasTopEdge && !liquidCachePtr8->HasRightEdge)
|
||||
{
|
||||
if (liquidCache19.HasTopEdge && liquidCache17.HasLeftEdge)
|
||||
{
|
||||
liquidCachePtr8->FrameOffset.X = Math.Max(4, (int) (16.0 - (double) liquidCache17.VisibleLeftWall * 16.0)) - 4;
|
||||
liquidCachePtr8->FrameOffset.Y = 48 + Math.Max(4, (int) (16.0 - (double) liquidCache19.VisibleTopWall * 16.0)) - 4;
|
||||
liquidCachePtr8->VisibleLeftWall = 0.0f;
|
||||
liquidCachePtr8->VisibleTopWall = 0.0f;
|
||||
liquidCachePtr8->VisibleRightWall = 1f;
|
||||
liquidCachePtr8->VisibleBottomWall = 1f;
|
||||
}
|
||||
else if (liquidCache20.HasTopEdge && liquidCache17.HasRightEdge)
|
||||
{
|
||||
liquidCachePtr8->FrameOffset.X = 32 - Math.Min(16, (int) ((double) liquidCache17.VisibleRightWall * 16.0) - 4);
|
||||
liquidCachePtr8->FrameOffset.Y = 48 + Math.Max(4, (int) (16.0 - (double) liquidCache20.VisibleTopWall * 16.0)) - 4;
|
||||
liquidCachePtr8->VisibleLeftWall = 0.0f;
|
||||
liquidCachePtr8->VisibleTopWall = 0.0f;
|
||||
liquidCachePtr8->VisibleRightWall = 1f;
|
||||
liquidCachePtr8->VisibleBottomWall = 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
++liquidCachePtr8;
|
||||
}
|
||||
liquidCachePtr8 += 4;
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr9 = liquidCachePtr1 + num1;
|
||||
fixed (LiquidRenderer.LiquidDrawCache* liquidDrawCachePtr1 = &this._drawCache[0])
|
||||
fixed (Color* colorPtr1 = &this._waveMask[0])
|
||||
{
|
||||
LiquidRenderer.LiquidDrawCache* liquidDrawCachePtr2 = liquidDrawCachePtr1;
|
||||
Color* colorPtr2 = colorPtr1;
|
||||
for (int index14 = 2; index14 < rectangle.Width - 2; ++index14)
|
||||
{
|
||||
for (int index15 = 2; index15 < rectangle.Height - 2; ++index15)
|
||||
{
|
||||
if (liquidCachePtr9->HasVisibleLiquid)
|
||||
{
|
||||
float num9 = Math.Min(0.75f, liquidCachePtr9->VisibleLeftWall);
|
||||
float num10 = Math.Max(0.25f, liquidCachePtr9->VisibleRightWall);
|
||||
float num11 = Math.Min(0.75f, liquidCachePtr9->VisibleTopWall);
|
||||
float num12 = Math.Max(0.25f, liquidCachePtr9->VisibleBottomWall);
|
||||
if (liquidCachePtr9->IsHalfBrick && (double) num12 > 0.5)
|
||||
num12 = 0.5f;
|
||||
liquidDrawCachePtr2->IsVisible = liquidCachePtr9->HasWall || !liquidCachePtr9->IsHalfBrick || !liquidCachePtr9->HasLiquid;
|
||||
liquidDrawCachePtr2->SourceRectangle = new Rectangle((int) (16.0 - (double) num10 * 16.0) + liquidCachePtr9->FrameOffset.X, (int) (16.0 - (double) num12 * 16.0) + liquidCachePtr9->FrameOffset.Y, (int) Math.Ceiling(((double) num10 - (double) num9) * 16.0), (int) Math.Ceiling(((double) num12 - (double) num11) * 16.0));
|
||||
liquidDrawCachePtr2->IsSurfaceLiquid = liquidCachePtr9->FrameOffset.X == 16 && liquidCachePtr9->FrameOffset.Y == 0 && (double) (index15 + rectangle.Y) > Main.worldSurface - 40.0;
|
||||
liquidDrawCachePtr2->Opacity = liquidCachePtr9->Opacity;
|
||||
liquidDrawCachePtr2->LiquidOffset = new Vector2((float) Math.Floor((double) num9 * 16.0), (float) Math.Floor((double) num11 * 16.0));
|
||||
liquidDrawCachePtr2->Type = liquidCachePtr9->VisibleType;
|
||||
liquidDrawCachePtr2->HasWall = liquidCachePtr9->HasWall;
|
||||
byte num13 = LiquidRenderer.WAVE_MASK_STRENGTH[(int) liquidCachePtr9->VisibleType];
|
||||
byte num14 = (byte) ((uint) num13 >> 1);
|
||||
colorPtr2->R = num14;
|
||||
colorPtr2->G = num14;
|
||||
colorPtr2->B = LiquidRenderer.VISCOSITY_MASK[(int) liquidCachePtr9->VisibleType];
|
||||
colorPtr2->A = num13;
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr10 = liquidCachePtr9 - 1;
|
||||
if (index15 != 2 && !liquidCachePtr10->HasVisibleLiquid && !liquidCachePtr10->IsSolid && !liquidCachePtr10->IsHalfBrick)
|
||||
*(colorPtr2 - 1) = *colorPtr2;
|
||||
}
|
||||
else
|
||||
{
|
||||
liquidDrawCachePtr2->IsVisible = false;
|
||||
int index16 = liquidCachePtr9->IsSolid || liquidCachePtr9->IsHalfBrick ? 3 : 4;
|
||||
byte num15 = LiquidRenderer.WAVE_MASK_STRENGTH[index16];
|
||||
byte num16 = (byte) ((uint) num15 >> 1);
|
||||
colorPtr2->R = num16;
|
||||
colorPtr2->G = num16;
|
||||
colorPtr2->B = LiquidRenderer.VISCOSITY_MASK[index16];
|
||||
colorPtr2->A = num15;
|
||||
}
|
||||
++liquidCachePtr9;
|
||||
++liquidDrawCachePtr2;
|
||||
++colorPtr2;
|
||||
}
|
||||
liquidCachePtr9 += 4;
|
||||
}
|
||||
}
|
||||
LiquidRenderer.LiquidCache* liquidCachePtr11 = liquidCachePtr1;
|
||||
for (int x = rectangle.X; x < rectangle.X + rectangle.Width; ++x)
|
||||
{
|
||||
for (int y = rectangle.Y; y < rectangle.Y + rectangle.Height; ++y)
|
||||
{
|
||||
if (liquidCachePtr11->VisibleType == (byte) 1 && liquidCachePtr11->HasVisibleLiquid && Dust.lavaBubbles < 200)
|
||||
{
|
||||
if (this._random.Next(700) == 0)
|
||||
Dust.NewDust(new Vector2((float) (x * 16), (float) (y * 16)), 16, 16, 35, newColor: Color.White);
|
||||
if (this._random.Next(350) == 0)
|
||||
{
|
||||
int index = Dust.NewDust(new Vector2((float) (x * 16), (float) (y * 16)), 16, 8, 35, Alpha: 50, newColor: Color.White, Scale: 1.5f);
|
||||
Main.dust[index].velocity *= 0.8f;
|
||||
Main.dust[index].velocity.X *= 2f;
|
||||
Main.dust[index].velocity.Y -= (float) this._random.Next(1, 7) * 0.1f;
|
||||
if (this._random.Next(10) == 0)
|
||||
Main.dust[index].velocity.Y *= (float) this._random.Next(2, 5);
|
||||
Main.dust[index].noGravity = true;
|
||||
}
|
||||
}
|
||||
++liquidCachePtr11;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.WaveFilters == null)
|
||||
return;
|
||||
this.WaveFilters(this._waveMask, this.GetCachedDrawArea());
|
||||
}
|
||||
|
||||
private unsafe void InternalDraw(
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 drawOffset,
|
||||
int waterStyle,
|
||||
float globalAlpha,
|
||||
bool isBackgroundDraw)
|
||||
{
|
||||
Rectangle drawArea = this._drawArea;
|
||||
Main.tileBatch.Begin();
|
||||
fixed (LiquidRenderer.LiquidDrawCache* liquidDrawCachePtr1 = &this._drawCache[0])
|
||||
{
|
||||
LiquidRenderer.LiquidDrawCache* liquidDrawCachePtr2 = liquidDrawCachePtr1;
|
||||
for (int x = drawArea.X; x < drawArea.X + drawArea.Width; ++x)
|
||||
{
|
||||
for (int y = drawArea.Y; y < drawArea.Y + drawArea.Height; ++y)
|
||||
{
|
||||
if (liquidDrawCachePtr2->IsVisible)
|
||||
{
|
||||
Rectangle sourceRectangle = liquidDrawCachePtr2->SourceRectangle;
|
||||
if (liquidDrawCachePtr2->IsSurfaceLiquid)
|
||||
sourceRectangle.Y = 1280;
|
||||
else
|
||||
sourceRectangle.Y += this._animationFrame * 80;
|
||||
Vector2 liquidOffset = liquidDrawCachePtr2->LiquidOffset;
|
||||
float val2 = liquidDrawCachePtr2->Opacity * (isBackgroundDraw ? 1f : LiquidRenderer.DEFAULT_OPACITY[(int) liquidDrawCachePtr2->Type]);
|
||||
int index = (int) liquidDrawCachePtr2->Type;
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
index = waterStyle;
|
||||
val2 *= isBackgroundDraw ? 1f : globalAlpha;
|
||||
break;
|
||||
case 2:
|
||||
index = 11;
|
||||
break;
|
||||
}
|
||||
float num = Math.Min(1f, val2);
|
||||
VertexColors vertices;
|
||||
Lighting.GetColor4Slice_New(x, y, out vertices);
|
||||
vertices.BottomLeftColor *= num;
|
||||
vertices.BottomRightColor *= num;
|
||||
vertices.TopLeftColor *= num;
|
||||
vertices.TopRightColor *= num;
|
||||
Main.tileBatch.Draw(this._liquidTextures[index], new Vector2((float) (x << 4), (float) (y << 4)) + drawOffset + liquidOffset, new Rectangle?(sourceRectangle), vertices, Vector2.Zero, 1f, SpriteEffects.None);
|
||||
}
|
||||
++liquidDrawCachePtr2;
|
||||
}
|
||||
}
|
||||
}
|
||||
Main.tileBatch.End();
|
||||
}
|
||||
|
||||
public bool HasFullWater(int x, int y)
|
||||
{
|
||||
x -= this._drawArea.X;
|
||||
y -= this._drawArea.Y;
|
||||
int index = x * this._drawArea.Height + y;
|
||||
if (index < 0 || index >= this._drawCache.Length)
|
||||
return true;
|
||||
return this._drawCache[index].IsVisible && !this._drawCache[index].IsSurfaceLiquid;
|
||||
}
|
||||
|
||||
public float GetVisibleLiquid(int x, int y)
|
||||
{
|
||||
x -= this._drawArea.X;
|
||||
y -= this._drawArea.Y;
|
||||
if (x < 0 || x >= this._drawArea.Width || y < 0 || y >= this._drawArea.Height)
|
||||
return 0.0f;
|
||||
int index = (x + 2) * (this._drawArea.Height + 4) + y + 2;
|
||||
return !this._cache[index].HasVisibleLiquid ? 0.0f : this._cache[index].VisibleLiquidLevel;
|
||||
}
|
||||
|
||||
public void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
float val2 = MathHelper.Clamp(Main.windSpeed * 80f, -20f, 20f);
|
||||
this._frameState += ((double) val2 >= 0.0 ? Math.Max(10f, val2) : Math.Min(-10f, val2)) * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._frameState < 0.0)
|
||||
this._frameState += 16f;
|
||||
this._frameState %= 16f;
|
||||
this._animationFrame = (int) this._frameState;
|
||||
}
|
||||
|
||||
public void PrepareDraw(Rectangle drawArea) => this.InternalPrepareDraw(drawArea);
|
||||
|
||||
public void SetWaveMaskData(ref Texture2D texture)
|
||||
{
|
||||
if (texture == null || texture.Width < this._drawArea.Height || texture.Height < this._drawArea.Width)
|
||||
{
|
||||
Console.WriteLine("WaveMaskData texture recreated. {0}x{1}", (object) this._drawArea.Height, (object) this._drawArea.Width);
|
||||
if (texture != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
texture.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
texture = new Texture2D(Main.instance.GraphicsDevice, this._drawArea.Height, this._drawArea.Width, false, SurfaceFormat.Color);
|
||||
}
|
||||
texture.SetData<Color>(0, new Rectangle?(new Rectangle(0, 0, this._drawArea.Height, this._drawArea.Width)), this._waveMask, 0, this._drawArea.Width * this._drawArea.Height);
|
||||
}
|
||||
|
||||
public Rectangle GetCachedDrawArea() => this._drawArea;
|
||||
|
||||
public void Draw(
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 drawOffset,
|
||||
int waterStyle,
|
||||
float alpha,
|
||||
bool isBackgroundDraw)
|
||||
{
|
||||
this.InternalDraw(spriteBatch, drawOffset, waterStyle, alpha, isBackgroundDraw);
|
||||
}
|
||||
|
||||
private struct LiquidCache
|
||||
{
|
||||
public float LiquidLevel;
|
||||
public float VisibleLiquidLevel;
|
||||
public float Opacity;
|
||||
public bool IsSolid;
|
||||
public bool IsHalfBrick;
|
||||
public bool HasLiquid;
|
||||
public bool HasVisibleLiquid;
|
||||
public bool HasWall;
|
||||
public Point FrameOffset;
|
||||
public bool HasLeftEdge;
|
||||
public bool HasRightEdge;
|
||||
public bool HasTopEdge;
|
||||
public bool HasBottomEdge;
|
||||
public float LeftWall;
|
||||
public float RightWall;
|
||||
public float BottomWall;
|
||||
public float TopWall;
|
||||
public float VisibleLeftWall;
|
||||
public float VisibleRightWall;
|
||||
public float VisibleBottomWall;
|
||||
public float VisibleTopWall;
|
||||
public byte Type;
|
||||
public byte VisibleType;
|
||||
}
|
||||
|
||||
private struct LiquidDrawCache
|
||||
{
|
||||
public Rectangle SourceRectangle;
|
||||
public Vector2 LiquidOffset;
|
||||
public bool IsVisible;
|
||||
public float Opacity;
|
||||
public byte Type;
|
||||
public bool IsSurfaceLiquid;
|
||||
public bool HasWall;
|
||||
}
|
||||
}
|
||||
}
|
50
GameContent/NetModules/NetLiquidModule.cs
Normal file
50
GameContent/NetModules/NetLiquidModule.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetLiquidModule
|
||||
// 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 System.IO;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetLiquidModule : NetModule
|
||||
{
|
||||
public static NetPacket Serialize(HashSet<int> changes)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetLiquidModule>(changes.Count * 6 + 2);
|
||||
packet.Writer.Write((ushort) changes.Count);
|
||||
foreach (int change in changes)
|
||||
{
|
||||
int index1 = change >> 16 & (int) ushort.MaxValue;
|
||||
int index2 = change & (int) ushort.MaxValue;
|
||||
packet.Writer.Write(change);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquid);
|
||||
packet.Writer.Write(Main.tile[index1, index2].liquidType());
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int userId)
|
||||
{
|
||||
int num1 = (int) reader.ReadUInt16();
|
||||
for (int index1 = 0; index1 < num1; ++index1)
|
||||
{
|
||||
int num2 = reader.ReadInt32();
|
||||
byte num3 = reader.ReadByte();
|
||||
byte num4 = reader.ReadByte();
|
||||
int index2 = num2 >> 16 & (int) ushort.MaxValue;
|
||||
int index3 = num2 & (int) ushort.MaxValue;
|
||||
Tile tile = Main.tile[index2, index3];
|
||||
if (tile != null)
|
||||
{
|
||||
tile.liquid = num3;
|
||||
tile.liquidType((int) num4);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
65
GameContent/NetModules/NetTextModule.cs
Normal file
65
GameContent/NetModules/NetTextModule.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.NetModules.NetTextModule
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
using Terraria.Chat;
|
||||
using Terraria.GameContent.UI.Chat;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Net;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.NetModules
|
||||
{
|
||||
public class NetTextModule : NetModule
|
||||
{
|
||||
public static NetPacket SerializeClientMessage(ChatMessage message)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTextModule>(message.GetMaxSerializedSize());
|
||||
message.Serialize(packet.Writer);
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static NetPacket SerializeServerMessage(NetworkText text, Color color) => NetTextModule.SerializeServerMessage(text, color, byte.MaxValue);
|
||||
|
||||
public static NetPacket SerializeServerMessage(
|
||||
NetworkText text,
|
||||
Color color,
|
||||
byte authorId)
|
||||
{
|
||||
NetPacket packet = NetModule.CreatePacket<NetTextModule>(1 + text.GetMaxSerializedSize() + 3);
|
||||
packet.Writer.Write(authorId);
|
||||
text.Serialize(packet.Writer);
|
||||
packet.Writer.WriteRGB(color);
|
||||
return packet;
|
||||
}
|
||||
|
||||
private bool DeserializeAsClient(BinaryReader reader, int senderPlayerId)
|
||||
{
|
||||
byte num = reader.ReadByte();
|
||||
string str = NetworkText.Deserialize(reader).ToString();
|
||||
Color c = reader.ReadRGB();
|
||||
if (num < byte.MaxValue)
|
||||
{
|
||||
Main.player[(int) num].chatOverhead.NewMessage(str, Main.chatLength / 2);
|
||||
str = NameTagHandler.GenerateTag(Main.player[(int) num].name) + " " + str;
|
||||
}
|
||||
Main.NewTextMultiline(str, c: c);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool DeserializeAsServer(BinaryReader reader, int senderPlayerId)
|
||||
{
|
||||
ChatMessage message = ChatMessage.Deserialize(reader);
|
||||
ChatManager.Commands.ProcessReceivedMessage(message, senderPlayerId);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void BroadcastRawMessage(ChatMessage message, byte author, Color messageColor) => NetManager.Instance.Broadcast(NetTextModule.SerializeServerMessage(NetworkText.FromLiteral(message.Text), messageColor));
|
||||
|
||||
public override bool Deserialize(BinaryReader reader, int senderPlayerId) => this.DeserializeAsClient(reader, senderPlayerId);
|
||||
}
|
||||
}
|
488
GameContent/PortalHelper.cs
Normal file
488
GameContent/PortalHelper.cs
Normal file
|
@ -0,0 +1,488 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.PortalHelper
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class PortalHelper
|
||||
{
|
||||
public const int PORTALS_PER_PERSON = 2;
|
||||
private static int[,] FoundPortals = new int[256, 2];
|
||||
private static int[] PortalCooldownForPlayers = new int[256];
|
||||
private static int[] PortalCooldownForNPCs = new int[200];
|
||||
private static readonly Vector2[] EDGES = new Vector2[4]
|
||||
{
|
||||
new Vector2(0.0f, 1f),
|
||||
new Vector2(0.0f, -1f),
|
||||
new Vector2(1f, 0.0f),
|
||||
new Vector2(-1f, 0.0f)
|
||||
};
|
||||
private static readonly Vector2[] SLOPE_EDGES = new Vector2[4]
|
||||
{
|
||||
new Vector2(1f, -1f),
|
||||
new Vector2(-1f, -1f),
|
||||
new Vector2(1f, 1f),
|
||||
new Vector2(-1f, 1f)
|
||||
};
|
||||
private static readonly Point[] SLOPE_OFFSETS = new Point[4]
|
||||
{
|
||||
new Point(1, -1),
|
||||
new Point(-1, -1),
|
||||
new Point(1, 1),
|
||||
new Point(-1, 1)
|
||||
};
|
||||
|
||||
static PortalHelper()
|
||||
{
|
||||
for (int index = 0; index < PortalHelper.SLOPE_EDGES.Length; ++index)
|
||||
PortalHelper.SLOPE_EDGES[index].Normalize();
|
||||
for (int index = 0; index < PortalHelper.FoundPortals.GetLength(0); ++index)
|
||||
{
|
||||
PortalHelper.FoundPortals[index, 0] = -1;
|
||||
PortalHelper.FoundPortals[index, 1] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdatePortalPoints()
|
||||
{
|
||||
for (int index = 0; index < PortalHelper.FoundPortals.GetLength(0); ++index)
|
||||
{
|
||||
PortalHelper.FoundPortals[index, 0] = -1;
|
||||
PortalHelper.FoundPortals[index, 1] = -1;
|
||||
}
|
||||
for (int index = 0; index < PortalHelper.PortalCooldownForPlayers.Length; ++index)
|
||||
{
|
||||
if (PortalHelper.PortalCooldownForPlayers[index] > 0)
|
||||
--PortalHelper.PortalCooldownForPlayers[index];
|
||||
}
|
||||
for (int index = 0; index < PortalHelper.PortalCooldownForNPCs.Length; ++index)
|
||||
{
|
||||
if (PortalHelper.PortalCooldownForNPCs[index] > 0)
|
||||
--PortalHelper.PortalCooldownForNPCs[index];
|
||||
}
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
Projectile projectile = Main.projectile[index];
|
||||
if (projectile.active && projectile.type == 602 && (double) projectile.ai[1] >= 0.0 && (double) projectile.ai[1] <= 1.0 && projectile.owner >= 0 && projectile.owner <= (int) byte.MaxValue)
|
||||
PortalHelper.FoundPortals[projectile.owner, (int) projectile.ai[1]] = index;
|
||||
}
|
||||
}
|
||||
|
||||
public static void TryGoingThroughPortals(Entity ent)
|
||||
{
|
||||
float collisionPoint = 0.0f;
|
||||
Vector2 velocity = ent.velocity;
|
||||
int width = ent.width;
|
||||
int height = ent.height;
|
||||
int gravDir = 1;
|
||||
if (ent is Player)
|
||||
gravDir = (int) ((Player) ent).gravDir;
|
||||
for (int index1 = 0; index1 < PortalHelper.FoundPortals.GetLength(0); ++index1)
|
||||
{
|
||||
if (PortalHelper.FoundPortals[index1, 0] != -1 && PortalHelper.FoundPortals[index1, 1] != -1 && (!(ent is Player) || index1 < PortalHelper.PortalCooldownForPlayers.Length && PortalHelper.PortalCooldownForPlayers[index1] <= 0) && (!(ent is NPC) || index1 < PortalHelper.PortalCooldownForNPCs.Length && PortalHelper.PortalCooldownForNPCs[index1] <= 0))
|
||||
{
|
||||
for (int index2 = 0; index2 < 2; ++index2)
|
||||
{
|
||||
Projectile projectile1 = Main.projectile[PortalHelper.FoundPortals[index1, index2]];
|
||||
Vector2 start;
|
||||
Vector2 end;
|
||||
PortalHelper.GetPortalEdges(projectile1.Center, projectile1.ai[0], out start, out end);
|
||||
if (Collision.CheckAABBvLineCollision(ent.position + ent.velocity, ent.Size, start, end, 2f, ref collisionPoint))
|
||||
{
|
||||
Projectile projectile2 = Main.projectile[PortalHelper.FoundPortals[index1, 1 - index2]];
|
||||
float num1 = ent.Hitbox.Distance(projectile1.Center);
|
||||
int bonusX;
|
||||
int bonusY;
|
||||
Vector2 newPos = PortalHelper.GetPortalOutingPoint(ent.Size, projectile2.Center, projectile2.ai[0], out bonusX, out bonusY) + Vector2.Normalize(new Vector2((float) bonusX, (float) bonusY)) * num1;
|
||||
Vector2 Velocity1 = Vector2.UnitX * 16f;
|
||||
if (!(Collision.TileCollision(newPos - Velocity1, Velocity1, width, height, true, true, gravDir) != Velocity1))
|
||||
{
|
||||
Vector2 Velocity2 = -Vector2.UnitX * 16f;
|
||||
if (!(Collision.TileCollision(newPos - Velocity2, Velocity2, width, height, true, true, gravDir) != Velocity2))
|
||||
{
|
||||
Vector2 Velocity3 = Vector2.UnitY * 16f;
|
||||
if (!(Collision.TileCollision(newPos - Velocity3, Velocity3, width, height, true, true, gravDir) != Velocity3))
|
||||
{
|
||||
Vector2 Velocity4 = -Vector2.UnitY * 16f;
|
||||
if (!(Collision.TileCollision(newPos - Velocity4, Velocity4, width, height, true, true, gravDir) != Velocity4))
|
||||
{
|
||||
float num2 = 0.1f;
|
||||
if (bonusY == -gravDir)
|
||||
num2 = 0.1f;
|
||||
if (ent.velocity == Vector2.Zero)
|
||||
ent.velocity = (projectile1.ai[0] - 1.570796f).ToRotationVector2() * num2;
|
||||
if ((double) ent.velocity.Length() < (double) num2)
|
||||
{
|
||||
ent.velocity.Normalize();
|
||||
ent.velocity *= num2;
|
||||
}
|
||||
Vector2 vec = Vector2.Normalize(new Vector2((float) bonusX, (float) bonusY));
|
||||
if (vec.HasNaNs() || vec == Vector2.Zero)
|
||||
vec = Vector2.UnitX * (float) ent.direction;
|
||||
ent.velocity = vec * ent.velocity.Length();
|
||||
if (bonusY == -gravDir && Math.Sign(ent.velocity.Y) != -gravDir || (double) Math.Abs(ent.velocity.Y) < 0.100000001490116)
|
||||
ent.velocity.Y = (float) -gravDir * 0.1f;
|
||||
int extraInfo = (int) ((double) (projectile2.owner * 2) + (double) projectile2.ai[1]);
|
||||
int num3 = extraInfo + (extraInfo % 2 == 0 ? 1 : -1);
|
||||
switch (ent)
|
||||
{
|
||||
case Player _:
|
||||
Player player = (Player) ent;
|
||||
player.lastPortalColorIndex = num3;
|
||||
player.Teleport(newPos, 4, extraInfo);
|
||||
if (Main.netMode == 1)
|
||||
{
|
||||
NetMessage.SendData(96, number: player.whoAmI, number2: newPos.X, number3: newPos.Y, number4: ((float) extraInfo));
|
||||
NetMessage.SendData(13, number: player.whoAmI);
|
||||
}
|
||||
PortalHelper.PortalCooldownForPlayers[index1] = 10;
|
||||
return;
|
||||
case NPC _:
|
||||
NPC npc = (NPC) ent;
|
||||
npc.lastPortalColorIndex = num3;
|
||||
npc.Teleport(newPos, 4, extraInfo);
|
||||
if (Main.netMode == 1)
|
||||
{
|
||||
NetMessage.SendData(100, number: npc.whoAmI, number2: newPos.X, number3: newPos.Y, number4: ((float) extraInfo));
|
||||
NetMessage.SendData(23, number: npc.whoAmI);
|
||||
}
|
||||
PortalHelper.PortalCooldownForPlayers[index1] = 10;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int TryPlacingPortal(
|
||||
Projectile theBolt,
|
||||
Vector2 velocity,
|
||||
Vector2 theCrashVelocity)
|
||||
{
|
||||
Vector2 vector2_1 = velocity / velocity.Length();
|
||||
Point tileCoordinates = PortalHelper.FindCollision(theBolt.position, theBolt.position + velocity + vector2_1 * 32f).ToTileCoordinates();
|
||||
Tile tile = Main.tile[tileCoordinates.X, tileCoordinates.Y];
|
||||
Vector2 vector2_2 = new Vector2((float) (tileCoordinates.X * 16 + 8), (float) (tileCoordinates.Y * 16 + 8));
|
||||
if (!WorldGen.SolidOrSlopedTile(tile))
|
||||
return -1;
|
||||
int num = (int) tile.slope();
|
||||
bool flag = tile.halfBrick();
|
||||
for (int index = 0; index < (flag ? 2 : PortalHelper.EDGES.Length); ++index)
|
||||
{
|
||||
Point bestPosition;
|
||||
if ((double) Vector2.Dot(PortalHelper.EDGES[index], vector2_1) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, (int) PortalHelper.EDGES[index].Y, (int) -(double) PortalHelper.EDGES[index].X, out bestPosition))
|
||||
return PortalHelper.AddPortal(new Vector2((float) (bestPosition.X * 16 + 8), (float) (bestPosition.Y * 16 + 8)) - PortalHelper.EDGES[index] * (flag ? 0.0f : 8f), (float) Math.Atan2((double) PortalHelper.EDGES[index].Y, (double) PortalHelper.EDGES[index].X) + 1.570796f, (int) theBolt.ai[0], theBolt.direction);
|
||||
}
|
||||
if (num != 0)
|
||||
{
|
||||
Vector2 vector2_3 = PortalHelper.SLOPE_EDGES[num - 1];
|
||||
Point bestPosition;
|
||||
if ((double) Vector2.Dot(vector2_3, -vector2_1) > 0.0 && PortalHelper.FindValidLine(tileCoordinates, -PortalHelper.SLOPE_OFFSETS[num - 1].Y, PortalHelper.SLOPE_OFFSETS[num - 1].X, out bestPosition))
|
||||
return PortalHelper.AddPortal(new Vector2((float) (bestPosition.X * 16 + 8), (float) (bestPosition.Y * 16 + 8)), (float) Math.Atan2((double) vector2_3.Y, (double) vector2_3.X) - 1.570796f, (int) theBolt.ai[0], theBolt.direction);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static bool FindValidLine(
|
||||
Point position,
|
||||
int xOffset,
|
||||
int yOffset,
|
||||
out Point bestPosition)
|
||||
{
|
||||
bestPosition = position;
|
||||
if (PortalHelper.IsValidLine(position, xOffset, yOffset))
|
||||
return true;
|
||||
Point position1 = new Point(position.X - xOffset, position.Y - yOffset);
|
||||
if (PortalHelper.IsValidLine(position1, xOffset, yOffset))
|
||||
{
|
||||
bestPosition = position1;
|
||||
return true;
|
||||
}
|
||||
Point position2 = new Point(position.X + xOffset, position.Y + yOffset);
|
||||
if (!PortalHelper.IsValidLine(position2, xOffset, yOffset))
|
||||
return false;
|
||||
bestPosition = position2;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsValidLine(Point position, int xOffset, int yOffset)
|
||||
{
|
||||
Tile tile1 = Main.tile[position.X, position.Y];
|
||||
Tile tile2 = Main.tile[position.X - xOffset, position.Y - yOffset];
|
||||
Tile tile3 = Main.tile[position.X + xOffset, position.Y + yOffset];
|
||||
return !PortalHelper.BlockPortals(Main.tile[position.X + yOffset, position.Y - xOffset]) && !PortalHelper.BlockPortals(Main.tile[position.X + yOffset - xOffset, position.Y - xOffset - yOffset]) && !PortalHelper.BlockPortals(Main.tile[position.X + yOffset + xOffset, position.Y - xOffset + yOffset]) && WorldGen.SolidOrSlopedTile(tile1) && WorldGen.SolidOrSlopedTile(tile2) && WorldGen.SolidOrSlopedTile(tile3) && tile2.HasSameSlope(tile1) && tile3.HasSameSlope(tile1);
|
||||
}
|
||||
|
||||
private static bool BlockPortals(Tile t) => t.active() && !Main.tileCut[(int) t.type] && !TileID.Sets.BreakableWhenPlacing[(int) t.type] && Main.tileSolid[(int) t.type];
|
||||
|
||||
private static Vector2 FindCollision(Vector2 startPosition, Vector2 stopPosition)
|
||||
{
|
||||
int lastX = 0;
|
||||
int lastY = 0;
|
||||
Utils.PlotLine(startPosition.ToTileCoordinates(), stopPosition.ToTileCoordinates(), (Utils.PerLinePoint) ((x, y) =>
|
||||
{
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
return !WorldGen.SolidOrSlopedTile(x, y);
|
||||
}), false);
|
||||
return new Vector2((float) lastX * 16f, (float) lastY * 16f);
|
||||
}
|
||||
|
||||
private static int AddPortal(Vector2 position, float angle, int form, int direction)
|
||||
{
|
||||
if (!PortalHelper.SupportedTilesAreFine(position, angle))
|
||||
return -1;
|
||||
PortalHelper.RemoveMyOldPortal(form);
|
||||
PortalHelper.RemoveIntersectingPortals(position, angle);
|
||||
int index = Projectile.NewProjectile(position.X, position.Y, 0.0f, 0.0f, 602, 0, 0.0f, Main.myPlayer, angle, (float) form);
|
||||
Main.projectile[index].direction = direction;
|
||||
Main.projectile[index].netUpdate = true;
|
||||
return index;
|
||||
}
|
||||
|
||||
private static void RemoveMyOldPortal(int form)
|
||||
{
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
Projectile projectile = Main.projectile[index];
|
||||
if (projectile.active && projectile.type == 602 && projectile.owner == Main.myPlayer && (double) projectile.ai[1] == (double) form)
|
||||
{
|
||||
projectile.Kill();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void RemoveIntersectingPortals(Vector2 position, float angle)
|
||||
{
|
||||
Vector2 start1;
|
||||
Vector2 end1;
|
||||
PortalHelper.GetPortalEdges(position, angle, out start1, out end1);
|
||||
for (int number = 0; number < 1000; ++number)
|
||||
{
|
||||
Projectile projectile = Main.projectile[number];
|
||||
if (projectile.active && projectile.type == 602)
|
||||
{
|
||||
Vector2 start2;
|
||||
Vector2 end2;
|
||||
PortalHelper.GetPortalEdges(projectile.Center, projectile.ai[0], out start2, out end2);
|
||||
if (Collision.CheckLinevLine(start1, end1, start2, end2).Length != 0)
|
||||
{
|
||||
if (projectile.owner != Main.myPlayer && Main.netMode != 2)
|
||||
NetMessage.SendData(95, number: number);
|
||||
projectile.Kill();
|
||||
if (Main.netMode == 2)
|
||||
NetMessage.SendData(29, number: projectile.whoAmI, number2: ((float) projectile.owner));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Color GetPortalColor(int colorIndex) => PortalHelper.GetPortalColor(colorIndex / 2, colorIndex % 2);
|
||||
|
||||
public static Color GetPortalColor(int player, int portal)
|
||||
{
|
||||
Color white = Color.White;
|
||||
Color color;
|
||||
if (Main.netMode == 0)
|
||||
{
|
||||
color = portal != 0 ? Main.hslToRgb(0.52f, 1f, 0.6f) : Main.hslToRgb(0.12f, 1f, 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
float num = 0.08f;
|
||||
color = Main.hslToRgb((float) ((0.5 + (double) player * ((double) num * 2.0) + (double) portal * (double) num) % 1.0), 1f, 0.5f);
|
||||
}
|
||||
color.A = (byte) 66;
|
||||
return color;
|
||||
}
|
||||
|
||||
private static void GetPortalEdges(
|
||||
Vector2 position,
|
||||
float angle,
|
||||
out Vector2 start,
|
||||
out Vector2 end)
|
||||
{
|
||||
Vector2 rotationVector2 = angle.ToRotationVector2();
|
||||
start = position + rotationVector2 * -22f;
|
||||
end = position + rotationVector2 * 22f;
|
||||
}
|
||||
|
||||
private static Vector2 GetPortalOutingPoint(
|
||||
Vector2 objectSize,
|
||||
Vector2 portalPosition,
|
||||
float portalAngle,
|
||||
out int bonusX,
|
||||
out int bonusY)
|
||||
{
|
||||
int num = (int) Math.Round((double) MathHelper.WrapAngle(portalAngle) / 0.785398185253143);
|
||||
switch (num)
|
||||
{
|
||||
case -3:
|
||||
case 3:
|
||||
bonusX = num == -3 ? 1 : -1;
|
||||
bonusY = -1;
|
||||
return portalPosition + new Vector2(num == -3 ? 0.0f : -objectSize.X, -objectSize.Y);
|
||||
case -2:
|
||||
case 2:
|
||||
bonusX = num == 2 ? -1 : 1;
|
||||
bonusY = 0;
|
||||
return portalPosition + new Vector2(num == 2 ? -objectSize.X : 0.0f, (float) (-(double) objectSize.Y / 2.0));
|
||||
case -1:
|
||||
case 1:
|
||||
bonusX = num == -1 ? 1 : -1;
|
||||
bonusY = 1;
|
||||
return portalPosition + new Vector2(num == -1 ? 0.0f : -objectSize.X, 0.0f);
|
||||
case 0:
|
||||
case 4:
|
||||
bonusX = 0;
|
||||
bonusY = num == 0 ? 1 : -1;
|
||||
return portalPosition + new Vector2((float) (-(double) objectSize.X / 2.0), num == 0 ? 0.0f : -objectSize.Y);
|
||||
default:
|
||||
Main.NewText("Broken portal! (over4s = " + (object) num + ")");
|
||||
bonusX = 0;
|
||||
bonusY = 0;
|
||||
return portalPosition;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SyncPortalsOnPlayerJoin(
|
||||
int plr,
|
||||
int fluff,
|
||||
List<Point> dontInclude,
|
||||
out List<Point> portals,
|
||||
out List<Point> portalCenters)
|
||||
{
|
||||
portals = new List<Point>();
|
||||
portalCenters = new List<Point>();
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
Projectile projectile = Main.projectile[index];
|
||||
if (projectile.active && (projectile.type == 602 || projectile.type == 601))
|
||||
{
|
||||
Vector2 center = projectile.Center;
|
||||
int sectionX = Netplay.GetSectionX((int) ((double) center.X / 16.0));
|
||||
int sectionY = Netplay.GetSectionY((int) ((double) center.Y / 16.0));
|
||||
for (int x = sectionX - fluff; x < sectionX + fluff + 1; ++x)
|
||||
{
|
||||
for (int y = sectionY - fluff; y < sectionY + fluff + 1; ++y)
|
||||
{
|
||||
if (x >= 0 && x < Main.maxSectionsX && y >= 0 && y < Main.maxSectionsY && !Netplay.Clients[plr].TileSections[x, y] && !dontInclude.Contains(new Point(x, y)))
|
||||
{
|
||||
portals.Add(new Point(x, y));
|
||||
if (!portalCenters.Contains(new Point(sectionX, sectionY)))
|
||||
portalCenters.Add(new Point(sectionX, sectionY));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SyncPortalSections(Vector2 portalPosition, int fluff)
|
||||
{
|
||||
for (int playerIndex = 0; playerIndex < (int) byte.MaxValue; ++playerIndex)
|
||||
{
|
||||
if (Main.player[playerIndex].active)
|
||||
RemoteClient.CheckSection(playerIndex, portalPosition, fluff);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SupportedTilesAreFine(Vector2 portalCenter, float portalAngle)
|
||||
{
|
||||
Point tileCoordinates = portalCenter.ToTileCoordinates();
|
||||
int num1 = (int) Math.Round((double) MathHelper.WrapAngle(portalAngle) / 0.785398185253143);
|
||||
int num2;
|
||||
int num3;
|
||||
switch (num1)
|
||||
{
|
||||
case -3:
|
||||
case 3:
|
||||
num2 = num1 == -3 ? 1 : -1;
|
||||
num3 = -1;
|
||||
break;
|
||||
case -2:
|
||||
case 2:
|
||||
num2 = num1 == 2 ? -1 : 1;
|
||||
num3 = 0;
|
||||
break;
|
||||
case -1:
|
||||
case 1:
|
||||
num2 = num1 == -1 ? 1 : -1;
|
||||
num3 = 1;
|
||||
break;
|
||||
case 0:
|
||||
case 4:
|
||||
num2 = 0;
|
||||
num3 = num1 == 0 ? 1 : -1;
|
||||
break;
|
||||
default:
|
||||
Main.NewText("Broken portal! (over4s = " + (object) num1 + " , " + (object) portalAngle + ")");
|
||||
return false;
|
||||
}
|
||||
if (num2 != 0 && num3 != 0)
|
||||
{
|
||||
int num4 = 3;
|
||||
if (num2 == -1 && num3 == 1)
|
||||
num4 = 5;
|
||||
if (num2 == 1 && num3 == -1)
|
||||
num4 = 2;
|
||||
if (num2 == 1 && num3 == 1)
|
||||
num4 = 4;
|
||||
int slope = num4 - 1;
|
||||
return PortalHelper.SupportedSlope(tileCoordinates.X, tileCoordinates.Y, slope) && PortalHelper.SupportedSlope(tileCoordinates.X + num2, tileCoordinates.Y - num3, slope) && PortalHelper.SupportedSlope(tileCoordinates.X - num2, tileCoordinates.Y + num3, slope);
|
||||
}
|
||||
switch (num2)
|
||||
{
|
||||
case 0:
|
||||
switch (num3)
|
||||
{
|
||||
case 0:
|
||||
return true;
|
||||
case 1:
|
||||
--tileCoordinates.Y;
|
||||
break;
|
||||
}
|
||||
if (PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X + 1, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X - 1, tileCoordinates.Y))
|
||||
return true;
|
||||
return PortalHelper.SupportedHalfbrick(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedHalfbrick(tileCoordinates.X + 1, tileCoordinates.Y) && PortalHelper.SupportedHalfbrick(tileCoordinates.X - 1, tileCoordinates.Y);
|
||||
case 1:
|
||||
--tileCoordinates.X;
|
||||
break;
|
||||
}
|
||||
return PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y) && PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y - 1) && PortalHelper.SupportedNormal(tileCoordinates.X, tileCoordinates.Y + 1);
|
||||
}
|
||||
|
||||
private static bool SupportedSlope(int x, int y, int slope)
|
||||
{
|
||||
Tile tile = Main.tile[x, y];
|
||||
return tile != null && tile.nactive() && !Main.tileCut[(int) tile.type] && !TileID.Sets.BreakableWhenPlacing[(int) tile.type] && Main.tileSolid[(int) tile.type] && (int) tile.slope() == slope;
|
||||
}
|
||||
|
||||
private static bool SupportedHalfbrick(int x, int y)
|
||||
{
|
||||
Tile tile = Main.tile[x, y];
|
||||
return tile != null && tile.nactive() && !Main.tileCut[(int) tile.type] && !TileID.Sets.BreakableWhenPlacing[(int) tile.type] && Main.tileSolid[(int) tile.type] && tile.halfBrick();
|
||||
}
|
||||
|
||||
private static bool SupportedNormal(int x, int y)
|
||||
{
|
||||
Tile tile = Main.tile[x, y];
|
||||
return tile != null && tile.nactive() && !Main.tileCut[(int) tile.type] && !TileID.Sets.BreakableWhenPlacing[(int) tile.type] && Main.tileSolid[(int) tile.type] && !TileID.Sets.NotReallySolid[(int) tile.type] && !tile.halfBrick() && tile.slope() == (byte) 0;
|
||||
}
|
||||
}
|
||||
}
|
142
GameContent/PressurePlateHelper.cs
Normal file
142
GameContent/PressurePlateHelper.cs
Normal file
|
@ -0,0 +1,142 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.PressurePlateHelper
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class PressurePlateHelper
|
||||
{
|
||||
public static Dictionary<Point, bool[]> PressurePlatesPressed = new Dictionary<Point, bool[]>();
|
||||
public static bool NeedsFirstUpdate = false;
|
||||
private static Vector2[] PlayerLastPosition = new Vector2[(int) byte.MaxValue];
|
||||
private static Rectangle pressurePlateBounds = new Rectangle(0, 0, 16, 10);
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (!PressurePlateHelper.NeedsFirstUpdate)
|
||||
return;
|
||||
foreach (Point key in PressurePlateHelper.PressurePlatesPressed.Keys)
|
||||
PressurePlateHelper.PokeLocation(key);
|
||||
PressurePlateHelper.PressurePlatesPressed.Clear();
|
||||
PressurePlateHelper.NeedsFirstUpdate = false;
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
PressurePlateHelper.PressurePlatesPressed.Clear();
|
||||
for (int index = 0; index < PressurePlateHelper.PlayerLastPosition.Length; ++index)
|
||||
PressurePlateHelper.PlayerLastPosition[index] = Vector2.Zero;
|
||||
}
|
||||
|
||||
public static void ResetPlayer(int player)
|
||||
{
|
||||
foreach (bool[] flagArray in PressurePlateHelper.PressurePlatesPressed.Values)
|
||||
flagArray[player] = false;
|
||||
}
|
||||
|
||||
public static void UpdatePlayerPosition(Player player)
|
||||
{
|
||||
Point p = new Point(1, 1);
|
||||
Vector2 vector2 = p.ToVector2();
|
||||
List<Point> tilesIn1 = Collision.GetTilesIn(PressurePlateHelper.PlayerLastPosition[player.whoAmI] + vector2, PressurePlateHelper.PlayerLastPosition[player.whoAmI] + player.Size - vector2 * 2f);
|
||||
List<Point> tilesIn2 = Collision.GetTilesIn(player.TopLeft + vector2, player.BottomRight - vector2 * 2f);
|
||||
Rectangle hitbox1 = player.Hitbox;
|
||||
Rectangle hitbox2 = player.Hitbox;
|
||||
hitbox1.Inflate(-p.X, -p.Y);
|
||||
hitbox2.Inflate(-p.X, -p.Y);
|
||||
hitbox2.X = (int) PressurePlateHelper.PlayerLastPosition[player.whoAmI].X;
|
||||
hitbox2.Y = (int) PressurePlateHelper.PlayerLastPosition[player.whoAmI].Y;
|
||||
for (int index = 0; index < tilesIn1.Count; ++index)
|
||||
{
|
||||
Point location = tilesIn1[index];
|
||||
Tile tile = Main.tile[location.X, location.Y];
|
||||
if (tile.active() && tile.type == (ushort) 428)
|
||||
{
|
||||
PressurePlateHelper.pressurePlateBounds.X = location.X * 16;
|
||||
PressurePlateHelper.pressurePlateBounds.Y = location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
|
||||
if (!hitbox1.Intersects(PressurePlateHelper.pressurePlateBounds) && !tilesIn2.Contains(location))
|
||||
PressurePlateHelper.MoveAwayFrom(location, player.whoAmI);
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < tilesIn2.Count; ++index)
|
||||
{
|
||||
Point location = tilesIn2[index];
|
||||
Tile tile = Main.tile[location.X, location.Y];
|
||||
if (tile.active() && tile.type == (ushort) 428)
|
||||
{
|
||||
PressurePlateHelper.pressurePlateBounds.X = location.X * 16;
|
||||
PressurePlateHelper.pressurePlateBounds.Y = location.Y * 16 + 16 - PressurePlateHelper.pressurePlateBounds.Height;
|
||||
if (hitbox1.Intersects(PressurePlateHelper.pressurePlateBounds) && (!tilesIn1.Contains(location) || !hitbox2.Intersects(PressurePlateHelper.pressurePlateBounds)))
|
||||
PressurePlateHelper.MoveInto(location, player.whoAmI);
|
||||
}
|
||||
}
|
||||
PressurePlateHelper.PlayerLastPosition[player.whoAmI] = player.position;
|
||||
}
|
||||
|
||||
public static void DestroyPlate(Point location)
|
||||
{
|
||||
if (!PressurePlateHelper.PressurePlatesPressed.TryGetValue(location, out bool[] _))
|
||||
return;
|
||||
PressurePlateHelper.PressurePlatesPressed.Remove(location);
|
||||
PressurePlateHelper.PokeLocation(location);
|
||||
}
|
||||
|
||||
private static void UpdatePlatePosition(Point location, int player, bool onIt)
|
||||
{
|
||||
if (onIt)
|
||||
PressurePlateHelper.MoveInto(location, player);
|
||||
else
|
||||
PressurePlateHelper.MoveAwayFrom(location, player);
|
||||
}
|
||||
|
||||
private static void MoveInto(Point location, int player)
|
||||
{
|
||||
bool[] flagArray;
|
||||
if (PressurePlateHelper.PressurePlatesPressed.TryGetValue(location, out flagArray))
|
||||
{
|
||||
flagArray[player] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
PressurePlateHelper.PressurePlatesPressed[location] = new bool[(int) byte.MaxValue];
|
||||
PressurePlateHelper.PressurePlatesPressed[location][player] = true;
|
||||
PressurePlateHelper.PokeLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
private static void MoveAwayFrom(Point location, int player)
|
||||
{
|
||||
bool[] flagArray;
|
||||
if (!PressurePlateHelper.PressurePlatesPressed.TryGetValue(location, out flagArray))
|
||||
return;
|
||||
flagArray[player] = false;
|
||||
bool flag = false;
|
||||
for (int index = 0; index < flagArray.Length; ++index)
|
||||
{
|
||||
if (flagArray[index])
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
return;
|
||||
PressurePlateHelper.PressurePlatesPressed.Remove(location);
|
||||
PressurePlateHelper.PokeLocation(location);
|
||||
}
|
||||
|
||||
private static void PokeLocation(Point location)
|
||||
{
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
Wiring.blockPlayerTeleportationForOneIteration = true;
|
||||
Wiring.HitSwitch(location.X, location.Y);
|
||||
NetMessage.SendData(59, number: location.X, number2: ((float) location.Y));
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/Shaders/BlizzardShaderData.cs
Normal file
48
GameContent/Shaders/BlizzardShaderData.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.BlizzardShaderData
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public class BlizzardShaderData : ScreenShaderData
|
||||
{
|
||||
private Vector2 _texturePosition = Vector2.Zero;
|
||||
private float windSpeed = 0.1f;
|
||||
|
||||
public BlizzardShaderData(string passName)
|
||||
: base(passName)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
float num = Main.windSpeed;
|
||||
if ((double) num >= 0.0 && (double) num <= 0.100000001490116)
|
||||
num = 0.1f;
|
||||
else if ((double) num <= 0.0 && (double) num >= -0.100000001490116)
|
||||
num = -0.1f;
|
||||
this.windSpeed = (float) ((double) num * 0.0500000007450581 + (double) this.windSpeed * 0.949999988079071);
|
||||
Vector2 direction = new Vector2(-this.windSpeed, -1f) * new Vector2(10f, 2f);
|
||||
direction.Normalize();
|
||||
direction *= new Vector2(0.8f, 0.6f);
|
||||
if (!Main.gamePaused && Main.hasFocus)
|
||||
this._texturePosition += direction * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
this._texturePosition.X %= 10f;
|
||||
this._texturePosition.Y %= 10f;
|
||||
this.UseDirection(direction);
|
||||
this.UseTargetPosition(this._texturePosition);
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
this.UseTargetPosition(this._texturePosition);
|
||||
base.Apply();
|
||||
}
|
||||
}
|
||||
}
|
24
GameContent/Shaders/BloodMoonScreenShaderData.cs
Normal file
24
GameContent/Shaders/BloodMoonScreenShaderData.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.BloodMoonScreenShaderData
|
||||
// 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.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public class BloodMoonScreenShaderData : ScreenShaderData
|
||||
{
|
||||
public BloodMoonScreenShaderData(string passName)
|
||||
: base(passName)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
this.UseOpacity((1f - Utils.SmoothStep((float) Main.worldSurface + 50f, (float) Main.rockLayer + 100f, (float) (((double) Main.screenPosition.Y + (double) (Main.screenHeight / 2)) / 16.0))) * 0.75f);
|
||||
base.Apply();
|
||||
}
|
||||
}
|
||||
}
|
44
GameContent/Shaders/MoonLordScreenShaderData.cs
Normal file
44
GameContent/Shaders/MoonLordScreenShaderData.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.MoonLordScreenShaderData
|
||||
// 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.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public class MoonLordScreenShaderData : ScreenShaderData
|
||||
{
|
||||
private int _moonLordIndex = -1;
|
||||
|
||||
public MoonLordScreenShaderData(string passName)
|
||||
: base(passName)
|
||||
{
|
||||
}
|
||||
|
||||
private void UpdateMoonLordIndex()
|
||||
{
|
||||
if (this._moonLordIndex >= 0 && Main.npc[this._moonLordIndex].active && Main.npc[this._moonLordIndex].type == 398)
|
||||
return;
|
||||
int num = -1;
|
||||
for (int index = 0; index < Main.npc.Length; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].type == 398)
|
||||
{
|
||||
num = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._moonLordIndex = num;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
this.UpdateMoonLordIndex();
|
||||
if (this._moonLordIndex != -1)
|
||||
this.UseTargetPosition(Main.npc[this._moonLordIndex].Center);
|
||||
base.Apply();
|
||||
}
|
||||
}
|
||||
}
|
15
GameContent/Shaders/RippleShape.cs
Normal file
15
GameContent/Shaders/RippleShape.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.RippleShape
|
||||
// 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
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public enum RippleShape
|
||||
{
|
||||
None,
|
||||
Square,
|
||||
Circle,
|
||||
}
|
||||
}
|
40
GameContent/Shaders/SandstormShaderData.cs
Normal file
40
GameContent/Shaders/SandstormShaderData.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.SandstormShaderData
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.Graphics.Shaders;
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public class SandstormShaderData : ScreenShaderData
|
||||
{
|
||||
private Vector2 _texturePosition = Vector2.Zero;
|
||||
|
||||
public SandstormShaderData(string passName)
|
||||
: base(passName)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
Vector2 vector2 = new Vector2(-Main.windSpeed, -1f) * new Vector2(20f, 0.1f);
|
||||
vector2.Normalize();
|
||||
Vector2 direction = vector2 * new Vector2(2f, 0.2f);
|
||||
if (!Main.gamePaused && Main.hasFocus)
|
||||
this._texturePosition += direction * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
this._texturePosition.X %= 10f;
|
||||
this._texturePosition.Y %= 10f;
|
||||
this.UseDirection(direction);
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
this.UseTargetPosition(this._texturePosition);
|
||||
base.Apply();
|
||||
}
|
||||
}
|
||||
}
|
409
GameContent/Shaders/WaterShaderData.cs
Normal file
409
GameContent/Shaders/WaterShaderData.cs
Normal file
|
@ -0,0 +1,409 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Shaders.WaterShaderData
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Liquid;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Shaders;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.Shaders
|
||||
{
|
||||
public class WaterShaderData : ScreenShaderData
|
||||
{
|
||||
private const float DISTORTION_BUFFER_SCALE = 0.25f;
|
||||
private const float WAVE_FRAMERATE = 0.01666667f;
|
||||
private const int MAX_RIPPLES_QUEUED = 200;
|
||||
public bool _useViscosityFilter = true;
|
||||
private RenderTarget2D _distortionTarget;
|
||||
private RenderTarget2D _distortionTargetSwap;
|
||||
private bool _usingRenderTargets;
|
||||
private Vector2 _lastDistortionDrawOffset = Vector2.Zero;
|
||||
private float _progress;
|
||||
private WaterShaderData.Ripple[] _rippleQueue = new WaterShaderData.Ripple[200];
|
||||
private int _rippleQueueCount;
|
||||
private int _lastScreenWidth;
|
||||
private int _lastScreenHeight;
|
||||
public bool _useProjectileWaves = true;
|
||||
private bool _useNPCWaves = true;
|
||||
private bool _usePlayerWaves = true;
|
||||
private bool _useRippleWaves = true;
|
||||
private bool _useCustomWaves = true;
|
||||
private bool _clearNextFrame = true;
|
||||
private Texture2D[] _viscosityMaskChain = new Texture2D[3];
|
||||
private int _activeViscosityMask;
|
||||
private Texture2D _rippleShapeTexture;
|
||||
private bool _isWaveBufferDirty = true;
|
||||
private int _queuedSteps;
|
||||
private const int MAX_QUEUED_STEPS = 2;
|
||||
|
||||
public event Action<TileBatch> OnWaveDraw;
|
||||
|
||||
public WaterShaderData(string passName)
|
||||
: base(passName)
|
||||
{
|
||||
Main.OnRenderTargetsInitialized += new ResolutionChangeEvent(this.InitRenderTargets);
|
||||
Main.OnRenderTargetsReleased += new Action(this.ReleaseRenderTargets);
|
||||
this._rippleShapeTexture = Main.instance.OurLoad<Texture2D>("Images/Misc/Ripples");
|
||||
Main.OnPreDraw += new Action<GameTime>(this.PreDraw);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._useViscosityFilter = Main.WaveQuality >= 3;
|
||||
this._useProjectileWaves = Main.WaveQuality >= 3;
|
||||
this._usePlayerWaves = Main.WaveQuality >= 2;
|
||||
this._useRippleWaves = Main.WaveQuality >= 2;
|
||||
this._useCustomWaves = Main.WaveQuality >= 2;
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
this._progress += (float) (gameTime.ElapsedGameTime.TotalSeconds * (double) this.Intensity * 0.75);
|
||||
this._progress %= 86400f;
|
||||
if (this._useProjectileWaves || this._useRippleWaves || this._useCustomWaves || this._usePlayerWaves)
|
||||
++this._queuedSteps;
|
||||
base.Update(gameTime);
|
||||
}
|
||||
|
||||
private void StepLiquids()
|
||||
{
|
||||
this._isWaveBufferDirty = true;
|
||||
Vector2 vector2_1 = Main.drawToScreen ? Vector2.Zero : new Vector2((float) Main.offScreenRange, (float) Main.offScreenRange);
|
||||
Vector2 vector2_2 = vector2_1 - Main.screenPosition;
|
||||
TileBatch tileBatch = Main.tileBatch;
|
||||
GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
|
||||
graphicsDevice.SetRenderTarget(this._distortionTarget);
|
||||
if (this._clearNextFrame)
|
||||
{
|
||||
graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.0f, 1f));
|
||||
this._clearNextFrame = false;
|
||||
}
|
||||
this.DrawWaves();
|
||||
graphicsDevice.SetRenderTarget(this._distortionTargetSwap);
|
||||
graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.5f, 1f));
|
||||
Main.tileBatch.Begin();
|
||||
Vector2 vector2_3 = vector2_2 * 0.25f;
|
||||
vector2_3.X = (float) Math.Floor((double) vector2_3.X);
|
||||
vector2_3.Y = (float) Math.Floor((double) vector2_3.Y);
|
||||
Vector2 vector2_4 = vector2_3 - this._lastDistortionDrawOffset;
|
||||
this._lastDistortionDrawOffset = vector2_3;
|
||||
tileBatch.Draw((Texture2D) this._distortionTarget, new Vector4(vector2_4.X, vector2_4.Y, (float) this._distortionTarget.Width, (float) this._distortionTarget.Height), new VertexColors(Color.White));
|
||||
GameShaders.Misc["WaterProcessor"].Apply(new DrawData?(new DrawData((Texture2D) this._distortionTarget, Vector2.Zero, Color.White)));
|
||||
tileBatch.End();
|
||||
RenderTarget2D distortionTarget = this._distortionTarget;
|
||||
this._distortionTarget = this._distortionTargetSwap;
|
||||
this._distortionTargetSwap = distortionTarget;
|
||||
if (this._useViscosityFilter)
|
||||
{
|
||||
LiquidRenderer.Instance.SetWaveMaskData(ref this._viscosityMaskChain[this._activeViscosityMask]);
|
||||
tileBatch.Begin();
|
||||
Rectangle cachedDrawArea = LiquidRenderer.Instance.GetCachedDrawArea();
|
||||
Rectangle rectangle = new Rectangle(0, 0, cachedDrawArea.Height, cachedDrawArea.Width);
|
||||
Vector4 vector4 = new Vector4((float) (cachedDrawArea.X + cachedDrawArea.Width), (float) cachedDrawArea.Y, (float) cachedDrawArea.Height, (float) cachedDrawArea.Width) * 16f;
|
||||
vector4.X -= vector2_1.X;
|
||||
vector4.Y -= vector2_1.Y;
|
||||
Vector4 destination = vector4 * 0.25f;
|
||||
destination.X += vector2_3.X;
|
||||
destination.Y += vector2_3.Y;
|
||||
graphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
|
||||
tileBatch.Draw(this._viscosityMaskChain[this._activeViscosityMask], destination, new Rectangle?(rectangle), new VertexColors(Color.White), Vector2.Zero, SpriteEffects.FlipHorizontally, 1.570796f);
|
||||
tileBatch.End();
|
||||
++this._activeViscosityMask;
|
||||
this._activeViscosityMask %= this._viscosityMaskChain.Length;
|
||||
}
|
||||
graphicsDevice.SetRenderTarget((RenderTarget2D) null);
|
||||
}
|
||||
|
||||
private void DrawWaves()
|
||||
{
|
||||
Vector2 screenPosition = Main.screenPosition;
|
||||
Vector2 vector2_1 = -this._lastDistortionDrawOffset / 0.25f + (Main.drawToScreen ? Vector2.Zero : new Vector2((float) Main.offScreenRange, (float) Main.offScreenRange));
|
||||
TileBatch tileBatch = Main.tileBatch;
|
||||
GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
|
||||
Vector2 dimensions1 = new Vector2((float) Main.screenWidth, (float) Main.screenHeight);
|
||||
Vector2 vector2_2 = new Vector2(16f, 16f);
|
||||
tileBatch.Begin();
|
||||
GameShaders.Misc["WaterDistortionObject"].Apply();
|
||||
if (this._useNPCWaves)
|
||||
{
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index] != null && Main.npc[index].active && (Main.npc[index].wet || Main.npc[index].wetCount != (byte) 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Main.npc[index].position - vector2_2, Main.npc[index].Size + vector2_2))
|
||||
{
|
||||
NPC npc = Main.npc[index];
|
||||
Vector2 vector2_3 = npc.Center - vector2_1;
|
||||
Vector2 vector2_4 = npc.velocity.RotatedBy(-(double) npc.rotation) / new Vector2((float) npc.height, (float) npc.width);
|
||||
float num1 = vector2_4.LengthSquared();
|
||||
float num2 = Math.Min((float) ((double) num1 * 0.300000011920929 + 0.699999988079071 * (double) num1 * (1024.0 / (double) (npc.height * npc.width))), 0.08f) + (npc.velocity - npc.oldVelocity).Length() * 0.5f;
|
||||
vector2_4.Normalize();
|
||||
Vector2 velocity = npc.velocity;
|
||||
velocity.Normalize();
|
||||
Vector2 vector2_5 = vector2_3 - velocity * 10f;
|
||||
if (!this._useViscosityFilter && (npc.honeyWet || npc.lavaWet))
|
||||
num2 *= 0.3f;
|
||||
if (npc.wet)
|
||||
tileBatch.Draw(Main.magicPixel, new Vector4(vector2_5.X, vector2_5.Y, (float) npc.width * 2f, (float) npc.height * 2f) * 0.25f, new Rectangle?(), new VertexColors(new Color((float) ((double) vector2_4.X * 0.5 + 0.5), (float) ((double) vector2_4.Y * 0.5 + 0.5), 0.5f * num2)), new Vector2((float) Main.magicPixel.Width / 2f, (float) Main.magicPixel.Height / 2f), SpriteEffects.None, npc.rotation);
|
||||
if (npc.wetCount != (byte) 0)
|
||||
{
|
||||
float num3 = 0.195f * (float) Math.Sqrt((double) npc.velocity.Length());
|
||||
float num4 = 5f;
|
||||
if (!npc.wet)
|
||||
num4 = -20f;
|
||||
this.QueueRipple(npc.Center + velocity * num4, new Color(0.5f, (float) ((npc.wet ? (double) num3 : -(double) num3) * 0.5 + 0.5), 0.0f, 1f) * 0.5f, new Vector2((float) npc.width, (float) npc.height * ((float) npc.wetCount / 9f)) * MathHelper.Clamp(num3 * 10f, 0.0f, 1f), RippleShape.Circle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._usePlayerWaves)
|
||||
{
|
||||
for (int index = 0; index < (int) byte.MaxValue; ++index)
|
||||
{
|
||||
if (Main.player[index] != null && Main.player[index].active && (Main.player[index].wet || Main.player[index].wetCount != (byte) 0) && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, Main.player[index].position - vector2_2, Main.player[index].Size + vector2_2))
|
||||
{
|
||||
Player player = Main.player[index];
|
||||
Vector2 vector2_6 = player.Center - vector2_1;
|
||||
float num5 = 0.05f * (float) Math.Sqrt((double) player.velocity.Length());
|
||||
Vector2 velocity = player.velocity;
|
||||
velocity.Normalize();
|
||||
Vector2 vector2_7 = vector2_6 - velocity * 10f;
|
||||
if (!this._useViscosityFilter && (player.honeyWet || player.lavaWet))
|
||||
num5 *= 0.3f;
|
||||
if (player.wet)
|
||||
tileBatch.Draw(Main.magicPixel, new Vector4(vector2_7.X - (float) ((double) player.width * 2.0 * 0.5), vector2_7.Y - (float) ((double) player.height * 2.0 * 0.5), (float) player.width * 2f, (float) player.height * 2f) * 0.25f, new VertexColors(new Color((float) ((double) velocity.X * 0.5 + 0.5), (float) ((double) velocity.Y * 0.5 + 0.5), 0.5f * num5)));
|
||||
if (player.wetCount != (byte) 0)
|
||||
{
|
||||
float num6 = 5f;
|
||||
if (!player.wet)
|
||||
num6 = -20f;
|
||||
float num7 = num5 * 3f;
|
||||
this.QueueRipple(player.Center + velocity * num6, player.wet ? num7 : -num7, new Vector2((float) player.width, (float) player.height * ((float) player.wetCount / 9f)) * MathHelper.Clamp(num7 * 10f, 0.0f, 1f), RippleShape.Circle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._useProjectileWaves)
|
||||
{
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
Projectile projectile = Main.projectile[index];
|
||||
int num8 = !projectile.wet || projectile.lavaWet ? 0 : (!projectile.honeyWet ? 1 : 0);
|
||||
bool flag1 = projectile.lavaWet;
|
||||
bool flag2 = projectile.honeyWet;
|
||||
bool flag3 = projectile.wet;
|
||||
if (projectile.ignoreWater)
|
||||
flag3 = true;
|
||||
if (((projectile == null || !projectile.active ? 0 : (ProjectileID.Sets.CanDistortWater[projectile.type] ? 1 : 0)) & (flag3 ? 1 : 0)) != 0 && !ProjectileID.Sets.NoLiquidDistortion[projectile.type] && Collision.CheckAABBvAABBCollision(screenPosition, dimensions1, projectile.position - vector2_2, projectile.Size + vector2_2))
|
||||
{
|
||||
if (projectile.ignoreWater)
|
||||
{
|
||||
int num9 = Collision.LavaCollision(projectile.position, projectile.width, projectile.height) ? 1 : 0;
|
||||
flag1 = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
|
||||
flag2 = Collision.honey;
|
||||
int num10 = flag1 ? 1 : 0;
|
||||
if ((num9 | num10 | (flag2 ? 1 : 0)) == 0)
|
||||
continue;
|
||||
}
|
||||
Vector2 vector2_8 = projectile.Center - vector2_1;
|
||||
float num11 = 2f * (float) Math.Sqrt(0.0500000007450581 * (double) projectile.velocity.Length());
|
||||
Vector2 velocity = projectile.velocity;
|
||||
velocity.Normalize();
|
||||
if (!this._useViscosityFilter && flag2 | flag1)
|
||||
num11 *= 0.3f;
|
||||
float z = Math.Max(12f, (float) projectile.width * 0.75f);
|
||||
float w = Math.Max(12f, (float) projectile.height * 0.75f);
|
||||
tileBatch.Draw(Main.magicPixel, new Vector4(vector2_8.X - z * 0.5f, vector2_8.Y - w * 0.5f, z, w) * 0.25f, new VertexColors(new Color((float) ((double) velocity.X * 0.5 + 0.5), (float) ((double) velocity.Y * 0.5 + 0.5), num11 * 0.5f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
tileBatch.End();
|
||||
if (this._useRippleWaves)
|
||||
{
|
||||
tileBatch.Begin();
|
||||
for (int index = 0; index < this._rippleQueueCount; ++index)
|
||||
{
|
||||
Vector2 vector2_9 = this._rippleQueue[index].Position - vector2_1;
|
||||
Vector2 size = this._rippleQueue[index].Size;
|
||||
Rectangle sourceRectangle = this._rippleQueue[index].SourceRectangle;
|
||||
Texture2D rippleShapeTexture = this._rippleShapeTexture;
|
||||
tileBatch.Draw(rippleShapeTexture, new Vector4(vector2_9.X, vector2_9.Y, size.X, size.Y) * 0.25f, new Rectangle?(sourceRectangle), new VertexColors(this._rippleQueue[index].WaveData), new Vector2((float) (sourceRectangle.Width / 2), (float) (sourceRectangle.Height / 2)), SpriteEffects.None, this._rippleQueue[index].Rotation);
|
||||
}
|
||||
tileBatch.End();
|
||||
}
|
||||
this._rippleQueueCount = 0;
|
||||
if (!this._useCustomWaves || this.OnWaveDraw == null)
|
||||
return;
|
||||
tileBatch.Begin();
|
||||
this.OnWaveDraw(tileBatch);
|
||||
tileBatch.End();
|
||||
}
|
||||
|
||||
private void PreDraw(GameTime gameTime)
|
||||
{
|
||||
this.ValidateRenderTargets();
|
||||
if (!this._usingRenderTargets || !Main.IsGraphicsDeviceAvailable)
|
||||
return;
|
||||
if (this._useProjectileWaves || this._useRippleWaves || this._useCustomWaves || this._usePlayerWaves)
|
||||
{
|
||||
for (int index = 0; index < Math.Min(this._queuedSteps, 2); ++index)
|
||||
this.StepLiquids();
|
||||
}
|
||||
else if (this._isWaveBufferDirty || this._clearNextFrame)
|
||||
{
|
||||
GraphicsDevice graphicsDevice = Main.instance.GraphicsDevice;
|
||||
graphicsDevice.SetRenderTarget(this._distortionTarget);
|
||||
graphicsDevice.Clear(new Color(0.5f, 0.5f, 0.0f, 1f));
|
||||
this._clearNextFrame = false;
|
||||
this._isWaveBufferDirty = false;
|
||||
graphicsDevice.SetRenderTarget((RenderTarget2D) null);
|
||||
}
|
||||
this._queuedSteps = 0;
|
||||
}
|
||||
|
||||
public override void Apply()
|
||||
{
|
||||
if (!this._usingRenderTargets || !Main.IsGraphicsDeviceAvailable)
|
||||
return;
|
||||
this.UseProgress(this._progress);
|
||||
Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
|
||||
Vector2 vector2_1 = new Vector2((float) Main.screenWidth, (float) Main.screenHeight) * 0.5f * (Vector2.One - Vector2.One / Main.GameViewMatrix.Zoom);
|
||||
Vector2 vector2_2 = (Main.drawToScreen ? Vector2.Zero : new Vector2((float) Main.offScreenRange, (float) Main.offScreenRange)) - Main.screenPosition - vector2_1;
|
||||
this.UseImage((Texture2D) this._distortionTarget, 1);
|
||||
this.UseImage((Texture2D) Main.waterTarget, 2, SamplerState.PointClamp);
|
||||
this.UseTargetPosition(Main.screenPosition - Main.sceneWaterPos + new Vector2((float) Main.offScreenRange, (float) Main.offScreenRange) + vector2_1);
|
||||
this.UseImageOffset(-(vector2_2 * 0.25f - this._lastDistortionDrawOffset) / new Vector2((float) this._distortionTarget.Width, (float) this._distortionTarget.Height));
|
||||
base.Apply();
|
||||
}
|
||||
|
||||
private void ValidateRenderTargets()
|
||||
{
|
||||
int backBufferWidth = Main.instance.GraphicsDevice.PresentationParameters.BackBufferWidth;
|
||||
int backBufferHeight = Main.instance.GraphicsDevice.PresentationParameters.BackBufferHeight;
|
||||
bool flag = !Main.drawToScreen;
|
||||
if (this._usingRenderTargets && !flag)
|
||||
this.ReleaseRenderTargets();
|
||||
else if (!this._usingRenderTargets & flag)
|
||||
{
|
||||
this.InitRenderTargets(backBufferWidth, backBufferHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(this._usingRenderTargets & flag) || !this._distortionTarget.IsContentLost && !this._distortionTargetSwap.IsContentLost)
|
||||
return;
|
||||
this._clearNextFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitRenderTargets(int width, int height)
|
||||
{
|
||||
this._lastScreenWidth = width;
|
||||
this._lastScreenHeight = height;
|
||||
width = (int) ((double) width * 0.25);
|
||||
height = (int) ((double) height * 0.25);
|
||||
try
|
||||
{
|
||||
this._distortionTarget = new RenderTarget2D(Main.instance.GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
|
||||
this._distortionTargetSwap = new RenderTarget2D(Main.instance.GraphicsDevice, width, height, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
|
||||
this._usingRenderTargets = true;
|
||||
this._clearNextFrame = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Lighting.lightMode = 2;
|
||||
this._usingRenderTargets = false;
|
||||
Console.WriteLine("Failed to create water distortion render targets. " + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseRenderTargets()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this._distortionTarget != null)
|
||||
this._distortionTarget.Dispose();
|
||||
if (this._distortionTargetSwap != null)
|
||||
this._distortionTargetSwap.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error disposing of water distortion render targets. " + ex.ToString());
|
||||
}
|
||||
this._distortionTarget = (RenderTarget2D) null;
|
||||
this._distortionTargetSwap = (RenderTarget2D) null;
|
||||
this._usingRenderTargets = false;
|
||||
}
|
||||
|
||||
public void QueueRipple(Vector2 position, float strength = 1f, RippleShape shape = RippleShape.Square, float rotation = 0.0f)
|
||||
{
|
||||
float g = (float) ((double) strength * 0.5 + 0.5);
|
||||
float num = Math.Min(Math.Abs(strength), 1f);
|
||||
this.QueueRipple(position, new Color(0.5f, g, 0.0f, 1f) * num, new Vector2(4f * Math.Max(Math.Abs(strength), 1f)), shape, rotation);
|
||||
}
|
||||
|
||||
public void QueueRipple(
|
||||
Vector2 position,
|
||||
float strength,
|
||||
Vector2 size,
|
||||
RippleShape shape = RippleShape.Square,
|
||||
float rotation = 0.0f)
|
||||
{
|
||||
float g = (float) ((double) strength * 0.5 + 0.5);
|
||||
float num = Math.Min(Math.Abs(strength), 1f);
|
||||
this.QueueRipple(position, new Color(0.5f, g, 0.0f, 1f) * num, size, shape, rotation);
|
||||
}
|
||||
|
||||
public void QueueRipple(
|
||||
Vector2 position,
|
||||
Color waveData,
|
||||
Vector2 size,
|
||||
RippleShape shape = RippleShape.Square,
|
||||
float rotation = 0.0f)
|
||||
{
|
||||
if (!this._useRippleWaves || Main.drawToScreen)
|
||||
{
|
||||
this._rippleQueueCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._rippleQueueCount >= this._rippleQueue.Length)
|
||||
return;
|
||||
this._rippleQueue[this._rippleQueueCount++] = new WaterShaderData.Ripple(position, waveData, size, shape, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
private struct Ripple
|
||||
{
|
||||
private static readonly Rectangle[] RIPPLE_SHAPE_SOURCE_RECTS = new Rectangle[3]
|
||||
{
|
||||
new Rectangle(0, 0, 0, 0),
|
||||
new Rectangle(1, 1, 62, 62),
|
||||
new Rectangle(1, 65, 62, 62)
|
||||
};
|
||||
public readonly Vector2 Position;
|
||||
public readonly Color WaveData;
|
||||
public readonly Vector2 Size;
|
||||
public readonly RippleShape Shape;
|
||||
public readonly float Rotation;
|
||||
|
||||
public Rectangle SourceRectangle => WaterShaderData.Ripple.RIPPLE_SHAPE_SOURCE_RECTS[(int) this.Shape];
|
||||
|
||||
public Ripple(
|
||||
Vector2 position,
|
||||
Color waveData,
|
||||
Vector2 size,
|
||||
RippleShape shape,
|
||||
float rotation)
|
||||
{
|
||||
this.Position = position;
|
||||
this.WaveData = waveData;
|
||||
this.Size = size;
|
||||
this.Shape = shape;
|
||||
this.Rotation = rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
72
GameContent/Skies/BlizzardSky.cs
Normal file
72
GameContent/Skies/BlizzardSky.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.BlizzardSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class BlizzardSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
private float _opacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
if (this._isLeaving)
|
||||
{
|
||||
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity >= 0.0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
this._opacity = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity <= 1.0)
|
||||
return;
|
||||
this._opacity = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
|
||||
return;
|
||||
float num = Math.Min(1f, Main.cloudAlpha * 2f);
|
||||
Color color = new Color(new Vector4(1f) * Main.bgColor.ToVector4()) * this._opacity * 0.7f * num;
|
||||
spriteBatch.Draw(Main.magicPixel, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
|
||||
}
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._opacity = 0.0f;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
}
|
||||
}
|
277
GameContent/Skies/MartianSky.cs
Normal file
277
GameContent/Skies/MartianSky.cs
Normal file
|
@ -0,0 +1,277 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.MartianSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class MartianSky : CustomSky
|
||||
{
|
||||
private MartianSky.Ufo[] _ufos;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _maxUfos;
|
||||
private bool _active;
|
||||
private bool _leaving;
|
||||
private int _activeUfos;
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
int activeUfos = this._activeUfos;
|
||||
for (int index = 0; index < this._ufos.Length; ++index)
|
||||
{
|
||||
MartianSky.Ufo ufo = this._ufos[index];
|
||||
if (ufo.IsActive)
|
||||
{
|
||||
++ufo.Frame;
|
||||
if (!ufo.Update())
|
||||
{
|
||||
if (!this._leaving)
|
||||
{
|
||||
ufo.AssignNewBehavior();
|
||||
}
|
||||
else
|
||||
{
|
||||
ufo.IsActive = false;
|
||||
--activeUfos;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._ufos[index] = ufo;
|
||||
}
|
||||
if (!this._leaving && activeUfos != this._maxUfos)
|
||||
{
|
||||
this._ufos[activeUfos].IsActive = true;
|
||||
this._ufos[activeUfos++].AssignNewBehavior();
|
||||
}
|
||||
this._active = !this._leaving || (uint) activeUfos > 0U;
|
||||
this._activeUfos = activeUfos;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) Main.screenPosition.Y > 10000.0)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._ufos.Length; ++index)
|
||||
{
|
||||
float depth = this._ufos[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f));
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_2 = new Vector2(1f / this._ufos[index].Depth, 0.9f / this._ufos[index].Depth);
|
||||
Vector2 position = (this._ufos[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
if (this._ufos[index].IsActive && rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
spriteBatch.Draw(this._ufos[index].Texture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), color * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
|
||||
if (this._ufos[index].GlowTexture != null)
|
||||
spriteBatch.Draw(this._ufos[index].GlowTexture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), Color.White * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateUfos()
|
||||
{
|
||||
this._maxUfos = (int) (256.0 * (double) ((float) Main.maxTilesX / 4200f));
|
||||
this._ufos = new MartianSky.Ufo[this._maxUfos];
|
||||
int num1 = this._maxUfos >> 4;
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
double num2 = (double) index / (double) num1;
|
||||
this._ufos[index] = new MartianSky.Ufo(Main.extraTexture[5], (float) (Main.rand.NextDouble() * 4.0 + 6.59999990463257));
|
||||
this._ufos[index].GlowTexture = Main.glowMaskTexture[90];
|
||||
}
|
||||
for (int index = num1; index < this._ufos.Length; ++index)
|
||||
{
|
||||
double num3 = (double) (index - num1) / (double) (this._ufos.Length - num1);
|
||||
this._ufos[index] = new MartianSky.Ufo(Main.extraTexture[6], (float) (Main.rand.NextDouble() * 5.0 + 1.60000002384186));
|
||||
this._ufos[index].Scale = 0.5f;
|
||||
this._ufos[index].GlowTexture = Main.glowMaskTexture[91];
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._activeUfos = 0;
|
||||
this.GenerateUfos();
|
||||
Array.Sort<MartianSky.Ufo>(this._ufos, (Comparison<MartianSky.Ufo>) ((ufo1, ufo2) => ufo2.Depth.CompareTo(ufo1.Depth)));
|
||||
this._active = true;
|
||||
this._leaving = false;
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._leaving = true;
|
||||
|
||||
public override bool IsActive() => this._active;
|
||||
|
||||
public override void Reset() => this._active = false;
|
||||
|
||||
private abstract class IUfoController
|
||||
{
|
||||
public abstract void InitializeUfo(ref MartianSky.Ufo ufo);
|
||||
|
||||
public abstract bool Update(ref MartianSky.Ufo ufo);
|
||||
}
|
||||
|
||||
private class ZipBehavior : MartianSky.IUfoController
|
||||
{
|
||||
private Vector2 _speed;
|
||||
private int _ticks;
|
||||
private int _maxTicks;
|
||||
|
||||
public override void InitializeUfo(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
|
||||
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
|
||||
ufo.Opacity = 0.0f;
|
||||
float num1 = (float) (MartianSky.Ufo.Random.NextDouble() * 5.0 + 10.0);
|
||||
double num2 = MartianSky.Ufo.Random.NextDouble() * 0.600000023841858 - 0.300000011920929;
|
||||
ufo.Rotation = (float) num2;
|
||||
if (MartianSky.Ufo.Random.Next(2) == 0)
|
||||
num2 += 3.14159274101257;
|
||||
this._speed = new Vector2((float) Math.Cos(num2) * num1, (float) Math.Sin(num2) * num1);
|
||||
this._ticks = 0;
|
||||
this._maxTicks = MartianSky.Ufo.Random.Next(400, 500);
|
||||
}
|
||||
|
||||
public override bool Update(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
if (this._ticks < 10)
|
||||
ufo.Opacity += 0.1f;
|
||||
else if (this._ticks > this._maxTicks - 10)
|
||||
ufo.Opacity -= 0.1f;
|
||||
ufo.Position += this._speed;
|
||||
if (this._ticks == this._maxTicks)
|
||||
return false;
|
||||
++this._ticks;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class HoverBehavior : MartianSky.IUfoController
|
||||
{
|
||||
private int _ticks;
|
||||
private int _maxTicks;
|
||||
|
||||
public override void InitializeUfo(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
|
||||
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
|
||||
ufo.Opacity = 0.0f;
|
||||
ufo.Rotation = 0.0f;
|
||||
this._ticks = 0;
|
||||
this._maxTicks = MartianSky.Ufo.Random.Next(120, 240);
|
||||
}
|
||||
|
||||
public override bool Update(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
if (this._ticks < 10)
|
||||
ufo.Opacity += 0.1f;
|
||||
else if (this._ticks > this._maxTicks - 10)
|
||||
ufo.Opacity -= 0.1f;
|
||||
if (this._ticks == this._maxTicks)
|
||||
return false;
|
||||
++this._ticks;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private struct Ufo
|
||||
{
|
||||
private const int MAX_FRAMES = 3;
|
||||
private const int FRAME_RATE = 4;
|
||||
public static UnifiedRandom Random = new UnifiedRandom();
|
||||
private int _frame;
|
||||
private Texture2D _texture;
|
||||
private MartianSky.IUfoController _controller;
|
||||
public Texture2D GlowTexture;
|
||||
public Vector2 Position;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Depth;
|
||||
public float Scale;
|
||||
public float Opacity;
|
||||
public bool IsActive;
|
||||
public float Rotation;
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frame;
|
||||
set => this._frame = value % 12;
|
||||
}
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width;
|
||||
this.FrameHeight = value.Height / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public MartianSky.IUfoController Controller
|
||||
{
|
||||
get => this._controller;
|
||||
set
|
||||
{
|
||||
this._controller = value;
|
||||
value.InitializeUfo(ref this);
|
||||
}
|
||||
}
|
||||
|
||||
public Ufo(Texture2D texture, float depth = 1f)
|
||||
{
|
||||
this._frame = 0;
|
||||
this.Position = Vector2.Zero;
|
||||
this._texture = texture;
|
||||
this.Depth = depth;
|
||||
this.Scale = 1f;
|
||||
this.FrameWidth = texture.Width;
|
||||
this.FrameHeight = texture.Height / 3;
|
||||
this.GlowTexture = (Texture2D) null;
|
||||
this.Opacity = 0.0f;
|
||||
this.Rotation = 0.0f;
|
||||
this.IsActive = false;
|
||||
this._controller = (MartianSky.IUfoController) null;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 4 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
|
||||
public bool Update() => this.Controller.Update(ref this);
|
||||
|
||||
public void AssignNewBehavior()
|
||||
{
|
||||
switch (MartianSky.Ufo.Random.Next(2))
|
||||
{
|
||||
case 0:
|
||||
this.Controller = (MartianSky.IUfoController) new MartianSky.ZipBehavior();
|
||||
break;
|
||||
case 1:
|
||||
this.Controller = (MartianSky.IUfoController) new MartianSky.HoverBehavior();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
79
GameContent/Skies/MoonLordSky.cs
Normal file
79
GameContent/Skies/MoonLordSky.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.MoonLordSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class MoonLordSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private int _moonLordIndex = -1;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
}
|
||||
|
||||
private float GetIntensity()
|
||||
{
|
||||
if (!this.UpdateMoonLordIndex())
|
||||
return 0.0f;
|
||||
float x = 0.0f;
|
||||
if (this._moonLordIndex != -1)
|
||||
x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this._moonLordIndex].Center);
|
||||
return 1f - Utils.SmoothStep(3000f, 6000f, x);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor)
|
||||
{
|
||||
float intensity = this.GetIntensity();
|
||||
return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity));
|
||||
}
|
||||
|
||||
private bool UpdateMoonLordIndex()
|
||||
{
|
||||
if (this._moonLordIndex >= 0 && Main.npc[this._moonLordIndex].active && Main.npc[this._moonLordIndex].type == 398)
|
||||
return true;
|
||||
int num = -1;
|
||||
for (int index = 0; index < Main.npc.Length; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].type == 398)
|
||||
{
|
||||
num = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._moonLordIndex = num;
|
||||
return num != -1;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth < 0.0 || (double) minDepth >= 0.0)
|
||||
return;
|
||||
float intensity = this.GetIntensity();
|
||||
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity);
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => 0.0f;
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args) => this._isActive = true;
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
}
|
||||
}
|
123
GameContent/Skies/NebulaSky.cs
Normal file
123
GameContent/Skies/NebulaSky.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.NebulaSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class NebulaSky : CustomSky
|
||||
{
|
||||
private NebulaSky.LightPillar[] _pillars;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Texture2D _planetTexture;
|
||||
private Texture2D _bgTexture;
|
||||
private Texture2D _beamTexture;
|
||||
private Texture2D[] _rockTextures;
|
||||
private bool _isActive;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = TextureManager.Load("Images/Misc/NebulaSky/Planet");
|
||||
this._bgTexture = TextureManager.Load("Images/Misc/NebulaSky/Background");
|
||||
this._beamTexture = TextureManager.Load("Images/Misc/NebulaSky/Beam");
|
||||
this._rockTextures = new Texture2D[3];
|
||||
for (int index = 0; index < this._rockTextures.Length; ++index)
|
||||
this._rockTextures[index] = TextureManager.Load("Images/Misc/NebulaSky/Rock_" + (object) index);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (this._isActive)
|
||||
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
else
|
||||
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._pillars.Length; ++index)
|
||||
{
|
||||
float depth = this._pillars[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
for (int index1 = num1; index1 < num2; ++index1)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._pillars[index1].Depth, 0.9f / this._pillars[index1].Depth);
|
||||
Vector2 position = (this._pillars[index1].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
float num4 = vector2_4.X * 450f;
|
||||
spriteBatch.Draw(this._beamTexture, position, new Rectangle?(), Color.White * 0.2f * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, new Vector2(num4 / 70f, num4 / 45f), SpriteEffects.None, 0.0f);
|
||||
int index2 = 0;
|
||||
for (float num5 = 0.0f; (double) num5 <= 1.0; num5 += 0.03f)
|
||||
{
|
||||
float num6 = (float) (1.0 - ((double) num5 + (double) Main.GlobalTime * 0.0199999995529652 + Math.Sin((double) index1)) % 1.0);
|
||||
spriteBatch.Draw(this._rockTextures[index2], position + new Vector2((float) (Math.Sin((double) num5 * 1582.0) * ((double) num4 * 0.5) + (double) num4 * 0.5), num6 * 2000f), new Rectangle?(), Color.White * num6 * num3 * this._fadeOpacity, num6 * 20f, new Vector2((float) (this._rockTextures[index2].Width >> 1), (float) (this._rockTextures[index2].Height >> 1)), 0.9f, SpriteEffects.None, 0.0f);
|
||||
index2 = (index2 + 1) % this._rockTextures.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._pillars = new NebulaSky.LightPillar[40];
|
||||
for (int index = 0; index < this._pillars.Length; ++index)
|
||||
{
|
||||
this._pillars[index].Position.X = (float) ((double) index / (double) this._pillars.Length * ((double) Main.maxTilesX * 16.0 + 20000.0) + (double) this._random.NextFloat() * 40.0 - 20.0 - 20000.0);
|
||||
this._pillars[index].Position.Y = (float) ((double) this._random.NextFloat() * 200.0 - 2000.0);
|
||||
this._pillars[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 7.0);
|
||||
}
|
||||
Array.Sort<NebulaSky.LightPillar>(this._pillars, new Comparison<NebulaSky.LightPillar>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(NebulaSky.LightPillar pillar1, NebulaSky.LightPillar pillar2) => pillar2.Depth.CompareTo(pillar1.Depth);
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct LightPillar
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
}
|
||||
}
|
||||
}
|
212
GameContent/Skies/PartySky.cs
Normal file
212
GameContent/Skies/PartySky.cs
Normal file
|
@ -0,0 +1,212 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.PartySky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class PartySky : CustomSky
|
||||
{
|
||||
public static bool MultipleSkyWorkaroundFix;
|
||||
private bool _active;
|
||||
private bool _leaving;
|
||||
private float _opacity;
|
||||
private Texture2D[] _textures;
|
||||
private PartySky.Balloon[] _balloons;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _balloonsDrawing;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._textures = new Texture2D[3];
|
||||
for (int index = 0; index < this._textures.Length; ++index)
|
||||
this._textures[index] = Main.extraTexture[69 + index];
|
||||
this.GenerateBalloons(false);
|
||||
}
|
||||
|
||||
private void GenerateBalloons(bool onlyMissing)
|
||||
{
|
||||
if (!onlyMissing)
|
||||
this._balloons = new PartySky.Balloon[Main.maxTilesY / 4];
|
||||
for (int i = 0; i < this._balloons.Length; ++i)
|
||||
{
|
||||
if (!onlyMissing || !this._balloons[i].Active)
|
||||
{
|
||||
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
|
||||
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
|
||||
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
|
||||
this.ResetBalloon(i);
|
||||
this._balloons[i].Active = true;
|
||||
}
|
||||
}
|
||||
this._balloonsDrawing = this._balloons.Length;
|
||||
}
|
||||
|
||||
public void ResetBalloon(int i)
|
||||
{
|
||||
this._balloons[i].Depth = (float) ((double) i / (double) this._balloons.Length * 1.75 + 1.60000002384186);
|
||||
this._balloons[i].Speed = (float) (-1.5 - 2.5 * this._random.NextDouble());
|
||||
this._balloons[i].Texture = this._textures[this._random.Next(2)];
|
||||
this._balloons[i].Variant = this._random.Next(3);
|
||||
if (this._random.Next(30) != 0)
|
||||
return;
|
||||
this._balloons[i].Texture = this._textures[2];
|
||||
}
|
||||
|
||||
private bool IsNearParty() => (double) Main.player[Main.myPlayer].townNPCs > 0.0 || Main.partyMonoliths > 0;
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (!PartySky.MultipleSkyWorkaroundFix)
|
||||
return;
|
||||
PartySky.MultipleSkyWorkaroundFix = false;
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
this._opacity = Utils.Clamp<float>(this._opacity + (float) this.IsNearParty().ToDirectionInt() * 0.01f, 0.0f, 1f);
|
||||
for (int i = 0; i < this._balloons.Length; ++i)
|
||||
{
|
||||
if (this._balloons[i].Active)
|
||||
{
|
||||
++this._balloons[i].Frame;
|
||||
this._balloons[i].Position.Y += this._balloons[i].Speed;
|
||||
this._balloons[i].Position.X += Main.windSpeed * (3f - this._balloons[i].Speed);
|
||||
if ((double) this._balloons[i].Position.Y < 300.0)
|
||||
{
|
||||
if (!this._leaving)
|
||||
{
|
||||
this.ResetBalloon(i);
|
||||
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) (Main.worldSurface * 16.0 + 1600.0));
|
||||
if (this._random.Next(30) == 0)
|
||||
this._balloons[i].Texture = this._textures[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
this._balloons[i].Active = false;
|
||||
--this._balloonsDrawing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._balloonsDrawing == 0)
|
||||
this._active = false;
|
||||
this._active = true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if (Main.gameMenu && this._active)
|
||||
{
|
||||
this._active = false;
|
||||
this._leaving = false;
|
||||
for (int index = 0; index < this._balloons.Length; ++index)
|
||||
this._balloons[index].Active = false;
|
||||
}
|
||||
if ((double) Main.screenPosition.Y > Main.worldSurface * 16.0 || Main.gameMenu || (double) this._opacity <= 0.0)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._balloons.Length; ++index)
|
||||
{
|
||||
float depth = this._balloons[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
if (this._balloons[index].Active)
|
||||
{
|
||||
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
|
||||
float num3 = 1f;
|
||||
if ((double) this._balloons[index].Depth > 3.0)
|
||||
num3 = 0.6f;
|
||||
else if ((double) this._balloons[index].Depth > 2.5)
|
||||
num3 = 0.7f;
|
||||
else if ((double) this._balloons[index].Depth > 2.0)
|
||||
num3 = 0.8f;
|
||||
else if ((double) this._balloons[index].Depth > 1.5)
|
||||
num3 = 0.9f;
|
||||
float num4 = num3 * 0.9f;
|
||||
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
|
||||
Vector2 vector2_2 = new Vector2(1f / this._balloons[index].Depth, 0.9f / this._balloons[index].Depth);
|
||||
Vector2 position = (this._balloons[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
position.X = (float) (((double) position.X + 500.0) % 4000.0);
|
||||
if ((double) position.X < 0.0)
|
||||
position.X += 4000f;
|
||||
position.X -= 500f;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._balloons[index].Texture, position, new Rectangle?(this._balloons[index].GetSourceRectangle()), color * this._opacity, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
if (this._active)
|
||||
{
|
||||
this._leaving = false;
|
||||
this.GenerateBalloons(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.GenerateBalloons(false);
|
||||
this._active = true;
|
||||
this._leaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._leaving = true;
|
||||
|
||||
public override bool IsActive() => this._active;
|
||||
|
||||
public override void Reset() => this._active = false;
|
||||
|
||||
private struct Balloon
|
||||
{
|
||||
private const int MAX_FRAMES_X = 3;
|
||||
private const int MAX_FRAMES_Y = 3;
|
||||
private const int FRAME_RATE = 14;
|
||||
public int Variant;
|
||||
private Texture2D _texture;
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Speed;
|
||||
public bool Active;
|
||||
private int _frameCounter;
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width / 3;
|
||||
this.FrameHeight = value.Height / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frameCounter;
|
||||
set => this._frameCounter = value % 42;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(this.FrameWidth * this.Variant, this._frameCounter / 14 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
73
GameContent/Skies/SandstormSky.cs
Normal file
73
GameContent/Skies/SandstormSky.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SandstormSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SandstormSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
private float _opacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
if (this._isLeaving)
|
||||
{
|
||||
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity >= 0.0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
this._opacity = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity <= 1.0)
|
||||
return;
|
||||
this._opacity = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
|
||||
return;
|
||||
float num = Math.Min(1f, Sandstorm.Severity * 1.5f);
|
||||
Color color = new Color(new Vector4(0.85f, 0.66f, 0.33f, 1f) * 0.8f * Main.bgColor.ToVector4()) * this._opacity * num;
|
||||
spriteBatch.Draw(Main.magicPixel, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
|
||||
}
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._opacity = 0.0f;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
}
|
||||
}
|
196
GameContent/Skies/SlimeSky.cs
Normal file
196
GameContent/Skies/SlimeSky.cs
Normal file
|
@ -0,0 +1,196 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SlimeSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SlimeSky : CustomSky
|
||||
{
|
||||
private Texture2D[] _textures;
|
||||
private SlimeSky.Slime[] _slimes;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _slimesRemaining;
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._textures = new Texture2D[4];
|
||||
for (int index = 0; index < 4; ++index)
|
||||
this._textures[index] = TextureManager.Load("Images/Misc/Sky_Slime_" + (object) (index + 1));
|
||||
this.GenerateSlimes();
|
||||
}
|
||||
|
||||
private void GenerateSlimes()
|
||||
{
|
||||
this._slimes = new SlimeSky.Slime[Main.maxTilesY / 6];
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
|
||||
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
|
||||
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
|
||||
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
|
||||
this._slimes[index].Texture = this._textures[this._random.Next(2)];
|
||||
if (this._random.Next(60) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[3];
|
||||
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth += 0.5f;
|
||||
}
|
||||
else if (this._random.Next(30) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[2];
|
||||
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
|
||||
}
|
||||
this._slimes[index].Active = true;
|
||||
}
|
||||
this._slimesRemaining = this._slimes.Length;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
if (this._slimes[index].Active)
|
||||
{
|
||||
++this._slimes[index].Frame;
|
||||
this._slimes[index].Position.Y += this._slimes[index].Speed;
|
||||
if ((double) this._slimes[index].Position.Y > Main.worldSurface * 16.0)
|
||||
{
|
||||
if (!this._isLeaving)
|
||||
{
|
||||
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
|
||||
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), -100f);
|
||||
this._slimes[index].Texture = this._textures[this._random.Next(2)];
|
||||
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
|
||||
if (this._random.Next(60) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[3];
|
||||
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth += 0.5f;
|
||||
}
|
||||
else if (this._random.Next(30) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[2];
|
||||
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._slimes[index].Active = false;
|
||||
--this._slimesRemaining;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._slimesRemaining != 0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) Main.screenPosition.Y > 10000.0 || Main.gameMenu)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
float depth = this._slimes[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
if (this._slimes[index].Active)
|
||||
{
|
||||
Color color = new Color(Main.bgColor.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
|
||||
float num3 = 1f;
|
||||
if ((double) this._slimes[index].Depth > 3.0)
|
||||
num3 = 0.6f;
|
||||
else if ((double) this._slimes[index].Depth > 2.5)
|
||||
num3 = 0.7f;
|
||||
else if ((double) this._slimes[index].Depth > 2.0)
|
||||
num3 = 0.8f;
|
||||
else if ((double) this._slimes[index].Depth > 1.5)
|
||||
num3 = 0.9f;
|
||||
float num4 = num3 * 0.8f;
|
||||
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
|
||||
Vector2 vector2_2 = new Vector2(1f / this._slimes[index].Depth, 0.9f / this._slimes[index].Depth);
|
||||
Vector2 position = (this._slimes[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
position.X = (float) (((double) position.X + 500.0) % 4000.0);
|
||||
if ((double) position.X < 0.0)
|
||||
position.X += 4000f;
|
||||
position.X -= 500f;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._slimes[index].Texture, position, new Rectangle?(this._slimes[index].GetSourceRectangle()), color, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this.GenerateSlimes();
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
|
||||
private struct Slime
|
||||
{
|
||||
private const int MAX_FRAMES = 4;
|
||||
private const int FRAME_RATE = 6;
|
||||
private Texture2D _texture;
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Speed;
|
||||
public bool Active;
|
||||
private int _frame;
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width;
|
||||
this.FrameHeight = value.Height / 4;
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frame;
|
||||
set => this._frame = value % 24;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 6 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
126
GameContent/Skies/SolarSky.cs
Normal file
126
GameContent/Skies/SolarSky.cs
Normal file
|
@ -0,0 +1,126 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SolarSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SolarSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Texture2D _planetTexture;
|
||||
private Texture2D _bgTexture;
|
||||
private Texture2D _meteorTexture;
|
||||
private bool _isActive;
|
||||
private SolarSky.Meteor[] _meteors;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = TextureManager.Load("Images/Misc/SolarSky/Planet");
|
||||
this._bgTexture = TextureManager.Load("Images/Misc/SolarSky/Background");
|
||||
this._meteorTexture = TextureManager.Load("Images/Misc/SolarSky/Meteor");
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
float num = 1200f;
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
this._meteors[index].Position.X -= num * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
this._meteors[index].Position.Y += num * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._meteors[index].Position.Y > Main.worldSurface * 16.0)
|
||||
{
|
||||
this._meteors[index].Position.X = this._meteors[index].StartX;
|
||||
this._meteors[index].Position.Y = -10000f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
float depth = this._meteors[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._meteors[index].Depth, 0.9f / this._meteors[index].Depth);
|
||||
Vector2 position = (this._meteors[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
int num4 = this._meteors[index].FrameCounter / 3;
|
||||
this._meteors[index].FrameCounter = (this._meteors[index].FrameCounter + 1) % 12;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._meteorTexture, position, new Rectangle?(new Rectangle(0, num4 * (this._meteorTexture.Height / 4), this._meteorTexture.Width, this._meteorTexture.Height / 4)), Color.White * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f * this._meteors[index].Scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._meteors = new SolarSky.Meteor[150];
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
float num = (float) index / (float) this._meteors.Length;
|
||||
this._meteors[index].Position.X = (float) ((double) num * ((double) Main.maxTilesX * 16.0) + (double) this._random.NextFloat() * 40.0 - 20.0);
|
||||
this._meteors[index].Position.Y = (float) ((double) this._random.NextFloat() * -(Main.worldSurface * 16.0 + 10000.0) - 10000.0);
|
||||
this._meteors[index].Depth = this._random.Next(3) == 0 ? (float) ((double) this._random.NextFloat() * 5.0 + 4.80000019073486) : (float) ((double) this._random.NextFloat() * 3.0 + 1.79999995231628);
|
||||
this._meteors[index].FrameCounter = this._random.Next(12);
|
||||
this._meteors[index].Scale = (float) ((double) this._random.NextFloat() * 0.5 + 1.0);
|
||||
this._meteors[index].StartX = this._meteors[index].Position.X;
|
||||
}
|
||||
Array.Sort<SolarSky.Meteor>(this._meteors, new Comparison<SolarSky.Meteor>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(SolarSky.Meteor meteor1, SolarSky.Meteor meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Meteor
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameCounter;
|
||||
public float Scale;
|
||||
public float StartX;
|
||||
}
|
||||
}
|
||||
}
|
134
GameContent/Skies/StardustSky.cs
Normal file
134
GameContent/Skies/StardustSky.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.StardustSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class StardustSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Texture2D _planetTexture;
|
||||
private Texture2D _bgTexture;
|
||||
private Texture2D[] _starTextures;
|
||||
private bool _isActive;
|
||||
private StardustSky.Star[] _stars;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = TextureManager.Load("Images/Misc/StarDustSky/Planet");
|
||||
this._bgTexture = TextureManager.Load("Images/Misc/StarDustSky/Background");
|
||||
this._starTextures = new Texture2D[2];
|
||||
for (int index = 0; index < this._starTextures.Length; ++index)
|
||||
this._starTextures[index] = TextureManager.Load("Images/Misc/StarDustSky/Star " + (object) index);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (this._isActive)
|
||||
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
else
|
||||
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._stars.Length; ++index)
|
||||
{
|
||||
float depth = this._stars[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._stars[index].Depth, 1.1f / this._stars[index].Depth);
|
||||
Vector2 position = (this._stars[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
float num4 = (float) Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTime + (double) this._stars[index].SinOffset) * this._stars[index].AlphaAmplitude + this._stars[index].AlphaAmplitude;
|
||||
float num5 = (float) (Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTime * 5.0 + (double) this._stars[index].SinOffset) * 0.100000001490116 - 0.100000001490116);
|
||||
float num6 = MathHelper.Clamp(num4, 0.0f, 1f);
|
||||
Texture2D starTexture = this._starTextures[this._stars[index].TextureIndex];
|
||||
spriteBatch.Draw(starTexture, position, new Rectangle?(), Color.White * num3 * num6 * 0.8f * (1f - num5) * this._fadeOpacity, 0.0f, new Vector2((float) (starTexture.Width >> 1), (float) (starTexture.Height >> 1)), (float) (((double) vector2_4.X * 0.5 + 0.5) * ((double) num6 * 0.300000011920929 + 0.699999988079071)), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
int num1 = 200;
|
||||
int num2 = 10;
|
||||
this._stars = new StardustSky.Star[num1 * num2];
|
||||
int index1 = 0;
|
||||
for (int index2 = 0; index2 < num1; ++index2)
|
||||
{
|
||||
float num3 = (float) index2 / (float) num1;
|
||||
for (int index3 = 0; index3 < num2; ++index3)
|
||||
{
|
||||
float num4 = (float) index3 / (float) num2;
|
||||
this._stars[index1].Position.X = (float) ((double) num3 * (double) Main.maxTilesX * 16.0);
|
||||
this._stars[index1].Position.Y = (float) ((double) num4 * (Main.worldSurface * 16.0 + 2000.0) - 1000.0);
|
||||
this._stars[index1].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 1.5);
|
||||
this._stars[index1].TextureIndex = this._random.Next(this._starTextures.Length);
|
||||
this._stars[index1].SinOffset = this._random.NextFloat() * 6.28f;
|
||||
this._stars[index1].AlphaAmplitude = this._random.NextFloat() * 5f;
|
||||
this._stars[index1].AlphaFrequency = this._random.NextFloat() + 1f;
|
||||
++index1;
|
||||
}
|
||||
}
|
||||
Array.Sort<StardustSky.Star>(this._stars, new Comparison<StardustSky.Star>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(StardustSky.Star meteor1, StardustSky.Star meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Star
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int TextureIndex;
|
||||
public float SinOffset;
|
||||
public float AlphaFrequency;
|
||||
public float AlphaAmplitude;
|
||||
}
|
||||
}
|
||||
}
|
122
GameContent/Skies/VortexSky.cs
Normal file
122
GameContent/Skies/VortexSky.cs
Normal file
|
@ -0,0 +1,122 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.VortexSky
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class VortexSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Texture2D _planetTexture;
|
||||
private Texture2D _bgTexture;
|
||||
private Texture2D _boltTexture;
|
||||
private Texture2D _flashTexture;
|
||||
private bool _isActive;
|
||||
private int _ticksUntilNextBolt;
|
||||
private float _fadeOpacity;
|
||||
private VortexSky.Bolt[] _bolts;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = TextureManager.Load("Images/Misc/VortexSky/Planet");
|
||||
this._bgTexture = TextureManager.Load("Images/Misc/VortexSky/Background");
|
||||
this._boltTexture = TextureManager.Load("Images/Misc/VortexSky/Bolt");
|
||||
this._flashTexture = TextureManager.Load("Images/Misc/VortexSky/Flash");
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
if (this._ticksUntilNextBolt <= 0)
|
||||
{
|
||||
this._ticksUntilNextBolt = this._random.Next(1, 5);
|
||||
int index = 0;
|
||||
while (this._bolts[index].IsAlive && index != this._bolts.Length - 1)
|
||||
++index;
|
||||
this._bolts[index].IsAlive = true;
|
||||
this._bolts[index].Position.X = (float) ((double) this._random.NextFloat() * ((double) Main.maxTilesX * 16.0 + 4000.0) - 2000.0);
|
||||
this._bolts[index].Position.Y = this._random.NextFloat() * 500f;
|
||||
this._bolts[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 2.0);
|
||||
this._bolts[index].Life = 30;
|
||||
}
|
||||
--this._ticksUntilNextBolt;
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
{
|
||||
if (this._bolts[index].IsAlive)
|
||||
{
|
||||
--this._bolts[index].Life;
|
||||
if (this._bolts[index].Life <= 0)
|
||||
this._bolts[index].IsAlive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(Main.blackTileTexture, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0)) * this._fadeOpacity);
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width >> 1), (float) (this._planetTexture.Height >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
float num1 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
{
|
||||
if (this._bolts[index].IsAlive && (double) this._bolts[index].Depth > (double) minDepth && (double) this._bolts[index].Depth < (double) maxDepth)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._bolts[index].Depth, 0.9f / this._bolts[index].Depth);
|
||||
Vector2 position = (this._bolts[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
Texture2D texture = this._boltTexture;
|
||||
int life = this._bolts[index].Life;
|
||||
if (life > 26 && life % 2 == 0)
|
||||
texture = this._flashTexture;
|
||||
float num2 = (float) life / 30f;
|
||||
spriteBatch.Draw(texture, position, new Rectangle?(), Color.White * num1 * num2 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
internal override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._bolts = new VortexSky.Bolt[500];
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
this._bolts[index].IsAlive = false;
|
||||
}
|
||||
|
||||
internal override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Bolt
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int Life;
|
||||
public bool IsAlive;
|
||||
}
|
||||
}
|
||||
}
|
113
GameContent/Tile_Entities/TEItemFrame.cs
Normal file
113
GameContent/Tile_Entities/TEItemFrame.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Tile_Entities.TEItemFrame
|
||||
// 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;
|
||||
using System.IO;
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.GameContent.Tile_Entities
|
||||
{
|
||||
public class TEItemFrame : TileEntity
|
||||
{
|
||||
public Item item;
|
||||
|
||||
public static void Initialize() => TileEntity._NetPlaceEntity += new Action<int, int, int>(TEItemFrame.NetPlaceEntity);
|
||||
|
||||
public static void NetPlaceEntity(int x, int y, int type)
|
||||
{
|
||||
if (type != 1 || !TEItemFrame.ValidTile(x, y))
|
||||
return;
|
||||
NetMessage.SendData(86, number: TEItemFrame.Place(x, y), number2: ((float) x), number3: ((float) y));
|
||||
}
|
||||
|
||||
public TEItemFrame() => this.item = new Item();
|
||||
|
||||
public static int Place(int x, int y)
|
||||
{
|
||||
TEItemFrame teItemFrame = new TEItemFrame();
|
||||
teItemFrame.Position = new Point16(x, y);
|
||||
teItemFrame.ID = TileEntity.AssignNewID();
|
||||
teItemFrame.type = (byte) 1;
|
||||
TileEntity.ByID[teItemFrame.ID] = (TileEntity) teItemFrame;
|
||||
TileEntity.ByPosition[teItemFrame.Position] = (TileEntity) teItemFrame;
|
||||
return teItemFrame.ID;
|
||||
}
|
||||
|
||||
public static int Hook_AfterPlacement(int x, int y, int type = 395, int style = 0, int direction = 1)
|
||||
{
|
||||
if (Main.netMode != 1)
|
||||
return TEItemFrame.Place(x, y);
|
||||
NetMessage.SendTileSquare(Main.myPlayer, x, y, 2);
|
||||
NetMessage.SendData(87, number: x, number2: ((float) y), number3: 1f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void Kill(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
if (!TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) || tileEntity.type != (byte) 1)
|
||||
return;
|
||||
TileEntity.ByID.Remove(tileEntity.ID);
|
||||
TileEntity.ByPosition.Remove(new Point16(x, y));
|
||||
}
|
||||
|
||||
public static int Find(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
return TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) && tileEntity.type == (byte) 1 ? tileEntity.ID : -1;
|
||||
}
|
||||
|
||||
public static bool ValidTile(int x, int y) => Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 395 && Main.tile[x, y].frameY == (short) 0 && (int) Main.tile[x, y].frameX % 36 == 0;
|
||||
|
||||
public override void WriteExtraData(BinaryWriter writer, bool networkSend)
|
||||
{
|
||||
writer.Write((short) this.item.netID);
|
||||
writer.Write(this.item.prefix);
|
||||
writer.Write((short) this.item.stack);
|
||||
}
|
||||
|
||||
public override void ReadExtraData(BinaryReader reader, bool networkSend)
|
||||
{
|
||||
this.item = new Item();
|
||||
this.item.netDefaults((int) reader.ReadInt16());
|
||||
this.item.Prefix((int) reader.ReadByte());
|
||||
this.item.stack = (int) reader.ReadInt16();
|
||||
}
|
||||
|
||||
public override string ToString() => this.Position.X.ToString() + "x " + (object) this.Position.Y + "y item: " + this.item.ToString();
|
||||
|
||||
public void DropItem()
|
||||
{
|
||||
if (Main.netMode != 1)
|
||||
Item.NewItem((int) this.Position.X * 16, (int) this.Position.Y * 16, 32, 32, this.item.netID, pfix: ((int) this.item.prefix));
|
||||
this.item = new Item();
|
||||
}
|
||||
|
||||
public static void TryPlacing(int x, int y, int netid, int prefix, int stack)
|
||||
{
|
||||
int key = TEItemFrame.Find(x, y);
|
||||
if (key == -1)
|
||||
{
|
||||
int number = Item.NewItem(x * 16, y * 16, 32, 32, 1);
|
||||
Main.item[number].netDefaults(netid);
|
||||
Main.item[number].Prefix(prefix);
|
||||
Main.item[number].stack = stack;
|
||||
NetMessage.SendData(21, number: number);
|
||||
}
|
||||
else
|
||||
{
|
||||
TEItemFrame teItemFrame = (TEItemFrame) TileEntity.ByID[key];
|
||||
if (teItemFrame.item.stack > 0)
|
||||
teItemFrame.DropItem();
|
||||
teItemFrame.item = new Item();
|
||||
teItemFrame.item.netDefaults(netid);
|
||||
teItemFrame.item.Prefix(prefix);
|
||||
teItemFrame.item.stack = stack;
|
||||
NetMessage.SendData(86, number: teItemFrame.ID, number2: ((float) x), number3: ((float) y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
360
GameContent/Tile_Entities/TELogicSensor.cs
Normal file
360
GameContent/Tile_Entities/TELogicSensor.cs
Normal file
|
@ -0,0 +1,360 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Tile_Entities.TELogicSensor
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.GameContent.Tile_Entities
|
||||
{
|
||||
public class TELogicSensor : TileEntity
|
||||
{
|
||||
private static Dictionary<int, Rectangle> playerBox = new Dictionary<int, Rectangle>();
|
||||
private static List<Tuple<Point16, bool>> tripPoints = new List<Tuple<Point16, bool>>();
|
||||
private static List<int> markedIDsForRemoval = new List<int>();
|
||||
private static bool inUpdateLoop = false;
|
||||
private static bool playerBoxFilled = false;
|
||||
public TELogicSensor.LogicCheckType logicCheck;
|
||||
public bool On;
|
||||
public int CountedData;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
TileEntity._UpdateStart += new Action(TELogicSensor.UpdateStartInternal);
|
||||
TileEntity._UpdateEnd += new Action(TELogicSensor.UpdateEndInternal);
|
||||
TileEntity._NetPlaceEntity += new Action<int, int, int>(TELogicSensor.NetPlaceEntity);
|
||||
}
|
||||
|
||||
public static void NetPlaceEntity(int x, int y, int type)
|
||||
{
|
||||
if (type != 2 || !TELogicSensor.ValidTile(x, y))
|
||||
return;
|
||||
int num = TELogicSensor.Place(x, y);
|
||||
((TELogicSensor) TileEntity.ByID[num]).FigureCheckState();
|
||||
NetMessage.SendData(86, number: num, number2: ((float) x), number3: ((float) y));
|
||||
}
|
||||
|
||||
private static void UpdateStartInternal()
|
||||
{
|
||||
TELogicSensor.inUpdateLoop = true;
|
||||
TELogicSensor.markedIDsForRemoval.Clear();
|
||||
TELogicSensor.playerBox.Clear();
|
||||
TELogicSensor.playerBoxFilled = false;
|
||||
TELogicSensor.FillPlayerHitboxes();
|
||||
}
|
||||
|
||||
private static void FillPlayerHitboxes()
|
||||
{
|
||||
if (TELogicSensor.playerBoxFilled)
|
||||
return;
|
||||
for (int key = 0; key < (int) byte.MaxValue; ++key)
|
||||
{
|
||||
if (Main.player[key].active)
|
||||
TELogicSensor.playerBox[key] = Main.player[key].getRect();
|
||||
}
|
||||
TELogicSensor.playerBoxFilled = true;
|
||||
}
|
||||
|
||||
private static void UpdateEndInternal()
|
||||
{
|
||||
TELogicSensor.inUpdateLoop = false;
|
||||
foreach (Tuple<Point16, bool> tripPoint in TELogicSensor.tripPoints)
|
||||
{
|
||||
Wiring.blockPlayerTeleportationForOneIteration = tripPoint.Item2;
|
||||
Wiring.HitSwitch((int) tripPoint.Item1.X, (int) tripPoint.Item1.Y);
|
||||
}
|
||||
Wiring.blockPlayerTeleportationForOneIteration = false;
|
||||
TELogicSensor.tripPoints.Clear();
|
||||
foreach (int key in TELogicSensor.markedIDsForRemoval)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
if (TileEntity.ByID.TryGetValue(key, out tileEntity) && tileEntity.type == (byte) 2)
|
||||
TileEntity.ByID.Remove(key);
|
||||
TileEntity.ByPosition.Remove(tileEntity.Position);
|
||||
}
|
||||
TELogicSensor.markedIDsForRemoval.Clear();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
bool state = TELogicSensor.GetState((int) this.Position.X, (int) this.Position.Y, this.logicCheck, this);
|
||||
switch (this.logicCheck)
|
||||
{
|
||||
case TELogicSensor.LogicCheckType.Day:
|
||||
case TELogicSensor.LogicCheckType.Night:
|
||||
if (!this.On & state)
|
||||
this.ChangeState(true, true);
|
||||
if (!this.On || state)
|
||||
break;
|
||||
this.ChangeState(false, false);
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.PlayerAbove:
|
||||
case TELogicSensor.LogicCheckType.Water:
|
||||
case TELogicSensor.LogicCheckType.Lava:
|
||||
case TELogicSensor.LogicCheckType.Honey:
|
||||
case TELogicSensor.LogicCheckType.Liquid:
|
||||
if (this.On == state)
|
||||
break;
|
||||
this.ChangeState(state, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeState(bool onState, bool TripWire)
|
||||
{
|
||||
if (onState != this.On && !TELogicSensor.SanityCheck((int) this.Position.X, (int) this.Position.Y))
|
||||
return;
|
||||
Main.tile[(int) this.Position.X, (int) this.Position.Y].frameX = onState ? (short) 18 : (short) 0;
|
||||
this.On = onState;
|
||||
if (Main.netMode == 2)
|
||||
NetMessage.SendTileSquare(-1, (int) this.Position.X, (int) this.Position.Y, 1);
|
||||
if (!TripWire || Main.netMode == 1)
|
||||
return;
|
||||
TELogicSensor.tripPoints.Add(Tuple.Create<Point16, bool>(this.Position, this.logicCheck == TELogicSensor.LogicCheckType.PlayerAbove));
|
||||
}
|
||||
|
||||
public static bool ValidTile(int x, int y) => Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 423 && (int) Main.tile[x, y].frameY % 18 == 0 && (int) Main.tile[x, y].frameX % 18 == 0;
|
||||
|
||||
public TELogicSensor()
|
||||
{
|
||||
this.logicCheck = TELogicSensor.LogicCheckType.None;
|
||||
this.On = false;
|
||||
}
|
||||
|
||||
public static TELogicSensor.LogicCheckType FigureCheckType(
|
||||
int x,
|
||||
int y,
|
||||
out bool on)
|
||||
{
|
||||
on = false;
|
||||
if (!WorldGen.InWorld(x, y))
|
||||
return TELogicSensor.LogicCheckType.None;
|
||||
Tile tile = Main.tile[x, y];
|
||||
if (tile == null)
|
||||
return TELogicSensor.LogicCheckType.None;
|
||||
TELogicSensor.LogicCheckType type = TELogicSensor.LogicCheckType.None;
|
||||
switch ((int) tile.frameY / 18)
|
||||
{
|
||||
case 0:
|
||||
type = TELogicSensor.LogicCheckType.Day;
|
||||
break;
|
||||
case 1:
|
||||
type = TELogicSensor.LogicCheckType.Night;
|
||||
break;
|
||||
case 2:
|
||||
type = TELogicSensor.LogicCheckType.PlayerAbove;
|
||||
break;
|
||||
case 3:
|
||||
type = TELogicSensor.LogicCheckType.Water;
|
||||
break;
|
||||
case 4:
|
||||
type = TELogicSensor.LogicCheckType.Lava;
|
||||
break;
|
||||
case 5:
|
||||
type = TELogicSensor.LogicCheckType.Honey;
|
||||
break;
|
||||
case 6:
|
||||
type = TELogicSensor.LogicCheckType.Liquid;
|
||||
break;
|
||||
}
|
||||
on = TELogicSensor.GetState(x, y, type);
|
||||
return type;
|
||||
}
|
||||
|
||||
public static bool GetState(
|
||||
int x,
|
||||
int y,
|
||||
TELogicSensor.LogicCheckType type,
|
||||
TELogicSensor instance = null)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case TELogicSensor.LogicCheckType.Day:
|
||||
return Main.dayTime;
|
||||
case TELogicSensor.LogicCheckType.Night:
|
||||
return !Main.dayTime;
|
||||
case TELogicSensor.LogicCheckType.PlayerAbove:
|
||||
bool flag1 = false;
|
||||
Rectangle rectangle = new Rectangle(x * 16 - 32 - 1, y * 16 - 160 - 1, 82, 162);
|
||||
foreach (KeyValuePair<int, Rectangle> keyValuePair in TELogicSensor.playerBox)
|
||||
{
|
||||
if (keyValuePair.Value.Intersects(rectangle))
|
||||
{
|
||||
flag1 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag1;
|
||||
case TELogicSensor.LogicCheckType.Water:
|
||||
case TELogicSensor.LogicCheckType.Lava:
|
||||
case TELogicSensor.LogicCheckType.Honey:
|
||||
case TELogicSensor.LogicCheckType.Liquid:
|
||||
if (instance == null)
|
||||
return false;
|
||||
Tile tile = Main.tile[x, y];
|
||||
bool flag2 = true;
|
||||
if (tile == null || tile.liquid == (byte) 0)
|
||||
flag2 = false;
|
||||
if (!tile.lava() && type == TELogicSensor.LogicCheckType.Lava)
|
||||
flag2 = false;
|
||||
if (!tile.honey() && type == TELogicSensor.LogicCheckType.Honey)
|
||||
flag2 = false;
|
||||
if ((tile.honey() || tile.lava()) && type == TELogicSensor.LogicCheckType.Water)
|
||||
flag2 = false;
|
||||
if (!flag2 && instance.On)
|
||||
{
|
||||
if (instance.CountedData == 0)
|
||||
instance.CountedData = 15;
|
||||
else if (instance.CountedData > 0)
|
||||
--instance.CountedData;
|
||||
flag2 = instance.CountedData > 0;
|
||||
}
|
||||
return flag2;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void FigureCheckState()
|
||||
{
|
||||
this.logicCheck = TELogicSensor.FigureCheckType((int) this.Position.X, (int) this.Position.Y, out this.On);
|
||||
TELogicSensor.GetFrame((int) this.Position.X, (int) this.Position.Y, this.logicCheck, this.On);
|
||||
}
|
||||
|
||||
public static void GetFrame(int x, int y, TELogicSensor.LogicCheckType type, bool on)
|
||||
{
|
||||
Main.tile[x, y].frameX = on ? (short) 18 : (short) 0;
|
||||
switch (type)
|
||||
{
|
||||
case TELogicSensor.LogicCheckType.Day:
|
||||
Main.tile[x, y].frameY = (short) 0;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.Night:
|
||||
Main.tile[x, y].frameY = (short) 18;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.PlayerAbove:
|
||||
Main.tile[x, y].frameY = (short) 36;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.Water:
|
||||
Main.tile[x, y].frameY = (short) 54;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.Lava:
|
||||
Main.tile[x, y].frameY = (short) 72;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.Honey:
|
||||
Main.tile[x, y].frameY = (short) 90;
|
||||
break;
|
||||
case TELogicSensor.LogicCheckType.Liquid:
|
||||
Main.tile[x, y].frameY = (short) 108;
|
||||
break;
|
||||
default:
|
||||
Main.tile[x, y].frameY = (short) 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool SanityCheck(int x, int y)
|
||||
{
|
||||
if (Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 423)
|
||||
return true;
|
||||
TELogicSensor.Kill(x, y);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static int Place(int x, int y)
|
||||
{
|
||||
TELogicSensor teLogicSensor = new TELogicSensor();
|
||||
teLogicSensor.Position = new Point16(x, y);
|
||||
teLogicSensor.ID = TileEntity.AssignNewID();
|
||||
teLogicSensor.type = (byte) 2;
|
||||
TileEntity.ByID[teLogicSensor.ID] = (TileEntity) teLogicSensor;
|
||||
TileEntity.ByPosition[teLogicSensor.Position] = (TileEntity) teLogicSensor;
|
||||
return teLogicSensor.ID;
|
||||
}
|
||||
|
||||
public static int Hook_AfterPlacement(int x, int y, int type = 423, int style = 0, int direction = 1)
|
||||
{
|
||||
bool on;
|
||||
TELogicSensor.LogicCheckType type1 = TELogicSensor.FigureCheckType(x, y, out on);
|
||||
TELogicSensor.GetFrame(x, y, type1, on);
|
||||
if (Main.netMode == 1)
|
||||
{
|
||||
NetMessage.SendTileSquare(Main.myPlayer, x, y, 1);
|
||||
NetMessage.SendData(87, number: x, number2: ((float) y), number3: 2f);
|
||||
return -1;
|
||||
}
|
||||
int key = TELogicSensor.Place(x, y);
|
||||
((TELogicSensor) TileEntity.ByID[key]).FigureCheckState();
|
||||
return key;
|
||||
}
|
||||
|
||||
public static void Kill(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
if (!TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) || tileEntity.type != (byte) 2)
|
||||
return;
|
||||
Wiring.blockPlayerTeleportationForOneIteration = ((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.PlayerAbove;
|
||||
if (((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.PlayerAbove && ((TELogicSensor) tileEntity).On)
|
||||
Wiring.HitSwitch((int) tileEntity.Position.X, (int) tileEntity.Position.Y);
|
||||
if (((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.Water && ((TELogicSensor) tileEntity).On)
|
||||
Wiring.HitSwitch((int) tileEntity.Position.X, (int) tileEntity.Position.Y);
|
||||
if (((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.Lava && ((TELogicSensor) tileEntity).On)
|
||||
Wiring.HitSwitch((int) tileEntity.Position.X, (int) tileEntity.Position.Y);
|
||||
if (((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.Honey && ((TELogicSensor) tileEntity).On)
|
||||
Wiring.HitSwitch((int) tileEntity.Position.X, (int) tileEntity.Position.Y);
|
||||
if (((TELogicSensor) tileEntity).logicCheck == TELogicSensor.LogicCheckType.Liquid && ((TELogicSensor) tileEntity).On)
|
||||
Wiring.HitSwitch((int) tileEntity.Position.X, (int) tileEntity.Position.Y);
|
||||
Wiring.blockPlayerTeleportationForOneIteration = false;
|
||||
if (TELogicSensor.inUpdateLoop)
|
||||
{
|
||||
TELogicSensor.markedIDsForRemoval.Add(tileEntity.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntity.ByPosition.Remove(new Point16(x, y));
|
||||
TileEntity.ByID.Remove(tileEntity.ID);
|
||||
}
|
||||
}
|
||||
|
||||
public static int Find(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
return TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) && tileEntity.type == (byte) 2 ? tileEntity.ID : -1;
|
||||
}
|
||||
|
||||
public override void WriteExtraData(BinaryWriter writer, bool networkSend)
|
||||
{
|
||||
if (networkSend)
|
||||
return;
|
||||
writer.Write((byte) this.logicCheck);
|
||||
writer.Write(this.On);
|
||||
}
|
||||
|
||||
public override void ReadExtraData(BinaryReader reader, bool networkSend)
|
||||
{
|
||||
if (networkSend)
|
||||
return;
|
||||
this.logicCheck = (TELogicSensor.LogicCheckType) reader.ReadByte();
|
||||
this.On = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override string ToString() => this.Position.X.ToString() + "x " + (object) this.Position.Y + "y " + (object) this.logicCheck;
|
||||
|
||||
public enum LogicCheckType
|
||||
{
|
||||
None,
|
||||
Day,
|
||||
Night,
|
||||
PlayerAbove,
|
||||
Water,
|
||||
Lava,
|
||||
Honey,
|
||||
Liquid,
|
||||
}
|
||||
}
|
||||
}
|
151
GameContent/Tile_Entities/TETrainingDummy.cs
Normal file
151
GameContent/Tile_Entities/TETrainingDummy.cs
Normal file
|
@ -0,0 +1,151 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Tile_Entities.TETrainingDummy
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.GameContent.Tile_Entities
|
||||
{
|
||||
public class TETrainingDummy : TileEntity
|
||||
{
|
||||
private static Dictionary<int, Rectangle> playerBox = new Dictionary<int, Rectangle>();
|
||||
private static bool playerBoxFilled = false;
|
||||
public int npc;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
TileEntity._UpdateStart += new Action(TETrainingDummy.ClearBoxes);
|
||||
TileEntity._NetPlaceEntity += new Action<int, int, int>(TETrainingDummy.NetPlaceEntity);
|
||||
}
|
||||
|
||||
public static void NetPlaceEntity(int x, int y, int type)
|
||||
{
|
||||
if (type != 0 || !TETrainingDummy.ValidTile(x, y))
|
||||
return;
|
||||
TETrainingDummy.Place(x, y);
|
||||
}
|
||||
|
||||
public static void ClearBoxes()
|
||||
{
|
||||
TETrainingDummy.playerBox.Clear();
|
||||
TETrainingDummy.playerBoxFilled = false;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
Rectangle rectangle = new Rectangle(0, 0, 32, 48);
|
||||
rectangle.Inflate(1600, 1600);
|
||||
int x = rectangle.X;
|
||||
int y = rectangle.Y;
|
||||
if (this.npc != -1)
|
||||
{
|
||||
if (Main.npc[this.npc].active && Main.npc[this.npc].type == 488 && (double) Main.npc[this.npc].ai[0] == (double) this.Position.X && (double) Main.npc[this.npc].ai[1] == (double) this.Position.Y)
|
||||
return;
|
||||
this.Deactivate();
|
||||
}
|
||||
else
|
||||
{
|
||||
TETrainingDummy.FillPlayerHitboxes();
|
||||
rectangle.X = (int) this.Position.X * 16 + x;
|
||||
rectangle.Y = (int) this.Position.Y * 16 + y;
|
||||
bool flag = false;
|
||||
foreach (KeyValuePair<int, Rectangle> keyValuePair in TETrainingDummy.playerBox)
|
||||
{
|
||||
if (keyValuePair.Value.Intersects(rectangle))
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
return;
|
||||
this.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
private static void FillPlayerHitboxes()
|
||||
{
|
||||
if (TETrainingDummy.playerBoxFilled)
|
||||
return;
|
||||
for (int key = 0; key < (int) byte.MaxValue; ++key)
|
||||
{
|
||||
if (Main.player[key].active)
|
||||
TETrainingDummy.playerBox[key] = Main.player[key].getRect();
|
||||
}
|
||||
TETrainingDummy.playerBoxFilled = true;
|
||||
}
|
||||
|
||||
public static bool ValidTile(int x, int y) => Main.tile[x, y].active() && Main.tile[x, y].type == (ushort) 378 && Main.tile[x, y].frameY == (short) 0 && (int) Main.tile[x, y].frameX % 36 == 0;
|
||||
|
||||
public TETrainingDummy() => this.npc = -1;
|
||||
|
||||
public static int Place(int x, int y)
|
||||
{
|
||||
TETrainingDummy teTrainingDummy = new TETrainingDummy();
|
||||
teTrainingDummy.Position = new Point16(x, y);
|
||||
teTrainingDummy.ID = TileEntity.AssignNewID();
|
||||
teTrainingDummy.type = (byte) 0;
|
||||
TileEntity.ByID[teTrainingDummy.ID] = (TileEntity) teTrainingDummy;
|
||||
TileEntity.ByPosition[teTrainingDummy.Position] = (TileEntity) teTrainingDummy;
|
||||
return teTrainingDummy.ID;
|
||||
}
|
||||
|
||||
public static int Hook_AfterPlacement(int x, int y, int type = 378, int style = 0, int direction = 1)
|
||||
{
|
||||
if (Main.netMode != 1)
|
||||
return TETrainingDummy.Place(x - 1, y - 2);
|
||||
NetMessage.SendTileSquare(Main.myPlayer, x - 1, y - 1, 3);
|
||||
NetMessage.SendData(87, number: (x - 1), number2: ((float) (y - 2)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void Kill(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
if (!TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) || tileEntity.type != (byte) 0)
|
||||
return;
|
||||
TileEntity.ByID.Remove(tileEntity.ID);
|
||||
TileEntity.ByPosition.Remove(new Point16(x, y));
|
||||
}
|
||||
|
||||
public static int Find(int x, int y)
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
return TileEntity.ByPosition.TryGetValue(new Point16(x, y), out tileEntity) && tileEntity.type == (byte) 0 ? tileEntity.ID : -1;
|
||||
}
|
||||
|
||||
public override void WriteExtraData(BinaryWriter writer, bool networkSend) => writer.Write((short) this.npc);
|
||||
|
||||
public override void ReadExtraData(BinaryReader reader, bool networkSend) => this.npc = (int) reader.ReadInt16();
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
int index = NPC.NewNPC((int) this.Position.X * 16 + 16, (int) this.Position.Y * 16 + 48, 488, 100);
|
||||
Main.npc[index].ai[0] = (float) this.Position.X;
|
||||
Main.npc[index].ai[1] = (float) this.Position.Y;
|
||||
Main.npc[index].netUpdate = true;
|
||||
this.npc = index;
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
NetMessage.SendData(86, number: this.ID, number2: ((float) this.Position.X), number3: ((float) this.Position.Y));
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
if (this.npc != -1)
|
||||
Main.npc[this.npc].active = false;
|
||||
this.npc = -1;
|
||||
if (Main.netMode == 1)
|
||||
return;
|
||||
NetMessage.SendData(86, number: this.ID, number2: ((float) this.Position.X), number3: ((float) this.Position.Y));
|
||||
}
|
||||
|
||||
public override string ToString() => this.Position.X.ToString() + "x " + (object) this.Position.Y + "y npc: " + (object) this.npc;
|
||||
}
|
||||
}
|
119
GameContent/TownRoomManager.cs
Normal file
119
GameContent/TownRoomManager.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.TownRoomManager
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class TownRoomManager
|
||||
{
|
||||
private List<Tuple<int, Point>> _roomLocationPairs = new List<Tuple<int, Point>>();
|
||||
private bool[] _hasRoom = new bool[580];
|
||||
|
||||
public int FindOccupation(int x, int y) => this.FindOccupation(new Point(x, y));
|
||||
|
||||
public int FindOccupation(Point tilePosition)
|
||||
{
|
||||
foreach (Tuple<int, Point> roomLocationPair in this._roomLocationPairs)
|
||||
{
|
||||
if (roomLocationPair.Item2 == tilePosition)
|
||||
return roomLocationPair.Item1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool HasRoomQuick(int npcID) => this._hasRoom[npcID];
|
||||
|
||||
public bool HasRoom(int npcID, out Point roomPosition)
|
||||
{
|
||||
if (!this._hasRoom[npcID])
|
||||
{
|
||||
roomPosition = new Point(0, 0);
|
||||
return false;
|
||||
}
|
||||
foreach (Tuple<int, Point> roomLocationPair in this._roomLocationPairs)
|
||||
{
|
||||
if (roomLocationPair.Item1 == npcID)
|
||||
{
|
||||
roomPosition = roomLocationPair.Item2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
roomPosition = new Point(0, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetRoom(int npcID, int x, int y)
|
||||
{
|
||||
this._hasRoom[npcID] = true;
|
||||
this.SetRoom(npcID, new Point(x, y));
|
||||
}
|
||||
|
||||
public void SetRoom(int npcID, Point pt)
|
||||
{
|
||||
this._roomLocationPairs.RemoveAll((Predicate<Tuple<int, Point>>) (x => x.Item1 == npcID));
|
||||
this._roomLocationPairs.Add(Tuple.Create<int, Point>(npcID, pt));
|
||||
}
|
||||
|
||||
public void KickOut(NPC n)
|
||||
{
|
||||
this.KickOut(n.type);
|
||||
this._hasRoom[n.type] = false;
|
||||
}
|
||||
|
||||
public void KickOut(int npcType) => this._roomLocationPairs.RemoveAll((Predicate<Tuple<int, Point>>) (x => x.Item1 == npcType));
|
||||
|
||||
public void DisplayRooms()
|
||||
{
|
||||
foreach (Tuple<int, Point> roomLocationPair in this._roomLocationPairs)
|
||||
Dust.QuickDust(roomLocationPair.Item2, Main.hslToRgb((float) ((double) roomLocationPair.Item1 * 0.0500000007450581 % 1.0), 1f, 0.5f));
|
||||
}
|
||||
|
||||
public void Save(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(this._roomLocationPairs.Count);
|
||||
foreach (Tuple<int, Point> roomLocationPair in this._roomLocationPairs)
|
||||
{
|
||||
writer.Write(roomLocationPair.Item1);
|
||||
writer.Write(roomLocationPair.Item2.X);
|
||||
writer.Write(roomLocationPair.Item2.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(BinaryReader reader)
|
||||
{
|
||||
this.Clear();
|
||||
int num = reader.ReadInt32();
|
||||
for (int index1 = 0; index1 < num; ++index1)
|
||||
{
|
||||
int index2 = reader.ReadInt32();
|
||||
Point point = new Point(reader.ReadInt32(), reader.ReadInt32());
|
||||
this._roomLocationPairs.Add(Tuple.Create<int, Point>(index2, point));
|
||||
this._hasRoom[index2] = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
this._roomLocationPairs.Clear();
|
||||
for (int index = 0; index < this._hasRoom.Length; ++index)
|
||||
this._hasRoom[index] = false;
|
||||
}
|
||||
|
||||
public byte GetHouseholdStatus(NPC n)
|
||||
{
|
||||
byte num = 0;
|
||||
if (n.homeless)
|
||||
num = (byte) 1;
|
||||
else if (this.HasRoomQuick(n.type))
|
||||
num = (byte) 2;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
}
|
45
GameContent/UI/Chat/AchievementTagHandler.cs
Normal file
45
GameContent/UI/Chat/AchievementTagHandler.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.AchievementTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class AchievementTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Achievement achievement = Main.Achievements.GetAchievement(text);
|
||||
return achievement == null ? new TextSnippet(text) : (TextSnippet) new AchievementTagHandler.AchievementSnippet(achievement);
|
||||
}
|
||||
|
||||
public static string GenerateTag(Achievement achievement) => "[a:" + achievement.Name + "]";
|
||||
|
||||
private class AchievementSnippet : TextSnippet
|
||||
{
|
||||
private Achievement _achievement;
|
||||
|
||||
public AchievementSnippet(Achievement achievement)
|
||||
: base(achievement.FriendlyName.Value, Color.LightBlue)
|
||||
{
|
||||
this.CheckForHover = true;
|
||||
this._achievement = achievement;
|
||||
}
|
||||
|
||||
public override void OnClick()
|
||||
{
|
||||
IngameOptions.Close();
|
||||
IngameFancyUI.OpenAchievementsAndGoto(this._achievement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
GameContent/UI/Chat/ColorTagHandler.cs
Normal file
29
GameContent/UI/Chat/ColorTagHandler.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.ColorTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ColorTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
TextSnippet textSnippet = new TextSnippet(text);
|
||||
int result;
|
||||
if (!int.TryParse(options, NumberStyles.AllowHexSpecifier, (IFormatProvider) CultureInfo.InvariantCulture, out result))
|
||||
return textSnippet;
|
||||
textSnippet.Color = new Color(result >> 16 & (int) byte.MaxValue, result >> 8 & (int) byte.MaxValue, result & (int) byte.MaxValue);
|
||||
return textSnippet;
|
||||
}
|
||||
}
|
||||
}
|
181
GameContent/UI/Chat/GlyphTagHandler.cs
Normal file
181
GameContent/UI/Chat/GlyphTagHandler.cs
Normal file
|
@ -0,0 +1,181 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.GlyphTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using ReLogic.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class GlyphTagHandler : ITagHandler
|
||||
{
|
||||
private const int GlyphsPerLine = 25;
|
||||
private const int MaxGlyphs = 26;
|
||||
public static float GlyphsScale = 1f;
|
||||
private static Dictionary<string, int> GlyphIndexes = new Dictionary<string, int>()
|
||||
{
|
||||
{
|
||||
Buttons.A.ToString(),
|
||||
0
|
||||
},
|
||||
{
|
||||
Buttons.B.ToString(),
|
||||
1
|
||||
},
|
||||
{
|
||||
Buttons.Back.ToString(),
|
||||
4
|
||||
},
|
||||
{
|
||||
Buttons.DPadDown.ToString(),
|
||||
15
|
||||
},
|
||||
{
|
||||
Buttons.DPadLeft.ToString(),
|
||||
14
|
||||
},
|
||||
{
|
||||
Buttons.DPadRight.ToString(),
|
||||
13
|
||||
},
|
||||
{
|
||||
Buttons.DPadUp.ToString(),
|
||||
16
|
||||
},
|
||||
{
|
||||
Buttons.LeftShoulder.ToString(),
|
||||
6
|
||||
},
|
||||
{
|
||||
Buttons.LeftStick.ToString(),
|
||||
10
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickDown.ToString(),
|
||||
20
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickLeft.ToString(),
|
||||
17
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickRight.ToString(),
|
||||
18
|
||||
},
|
||||
{
|
||||
Buttons.LeftThumbstickUp.ToString(),
|
||||
19
|
||||
},
|
||||
{
|
||||
Buttons.LeftTrigger.ToString(),
|
||||
8
|
||||
},
|
||||
{
|
||||
Buttons.RightShoulder.ToString(),
|
||||
7
|
||||
},
|
||||
{
|
||||
Buttons.RightStick.ToString(),
|
||||
11
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickDown.ToString(),
|
||||
24
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickLeft.ToString(),
|
||||
21
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickRight.ToString(),
|
||||
22
|
||||
},
|
||||
{
|
||||
Buttons.RightThumbstickUp.ToString(),
|
||||
23
|
||||
},
|
||||
{
|
||||
Buttons.RightTrigger.ToString(),
|
||||
9
|
||||
},
|
||||
{
|
||||
Buttons.Start.ToString(),
|
||||
5
|
||||
},
|
||||
{
|
||||
Buttons.X.ToString(),
|
||||
2
|
||||
},
|
||||
{
|
||||
Buttons.Y.ToString(),
|
||||
3
|
||||
},
|
||||
{
|
||||
"LR",
|
||||
25
|
||||
}
|
||||
};
|
||||
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
int result;
|
||||
if (!int.TryParse(text, out result) || result >= 26)
|
||||
return new TextSnippet(text);
|
||||
GlyphTagHandler.GlyphSnippet glyphSnippet = new GlyphTagHandler.GlyphSnippet(result);
|
||||
glyphSnippet.DeleteWhole = true;
|
||||
glyphSnippet.Text = "[g:" + (object) result + "]";
|
||||
return (TextSnippet) glyphSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(int index) => "[g" + ":" + (object) index + "]";
|
||||
|
||||
public static string GenerateTag(string keyname)
|
||||
{
|
||||
int index;
|
||||
return GlyphTagHandler.GlyphIndexes.TryGetValue(keyname, out index) ? GlyphTagHandler.GenerateTag(index) : keyname;
|
||||
}
|
||||
|
||||
private class GlyphSnippet : TextSnippet
|
||||
{
|
||||
private int _glyphIndex;
|
||||
|
||||
public GlyphSnippet(int index)
|
||||
: base()
|
||||
{
|
||||
this._glyphIndex = index;
|
||||
this.Color = Color.White;
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
int frameX = this._glyphIndex;
|
||||
if (this._glyphIndex == 25)
|
||||
frameX = (double) Main.GlobalTime % 0.600000023841858 < 0.300000011920929 ? 17 : 18;
|
||||
Texture2D texture2D = Main.textGlyphTexture[0];
|
||||
spriteBatch.Draw(texture2D, position, new Rectangle?(texture2D.Frame(25, frameX: frameX, frameY: (frameX / 25))), color, 0.0f, Vector2.Zero, GlyphTagHandler.GlyphsScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
size = new Vector2(26f) * GlyphTagHandler.GlyphsScale;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => 26f * GlyphTagHandler.GlyphsScale;
|
||||
}
|
||||
}
|
||||
}
|
133
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
133
GameContent/UI/Chat/ItemTagHandler.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.ItemTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class ItemTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
Item obj = new Item();
|
||||
int result1;
|
||||
if (int.TryParse(text, out result1))
|
||||
obj.netDefaults(result1);
|
||||
if (obj.type <= 0)
|
||||
return new TextSnippet(text);
|
||||
obj.stack = 1;
|
||||
if (options != null)
|
||||
{
|
||||
string[] strArray = options.Split(',');
|
||||
for (int index = 0; index < strArray.Length; ++index)
|
||||
{
|
||||
if (strArray[index].Length != 0)
|
||||
{
|
||||
switch (strArray[index][0])
|
||||
{
|
||||
case 'p':
|
||||
int result2;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result2))
|
||||
{
|
||||
obj.Prefix((int) (byte) Utils.Clamp<int>(result2, 0, 84));
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
case 's':
|
||||
case 'x':
|
||||
int result3;
|
||||
if (int.TryParse(strArray[index].Substring(1), out result3))
|
||||
{
|
||||
obj.stack = Utils.Clamp<int>(result3, 1, obj.maxStack);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
string str = "";
|
||||
if (obj.stack > 1)
|
||||
str = " (" + (object) obj.stack + ")";
|
||||
ItemTagHandler.ItemSnippet itemSnippet = new ItemTagHandler.ItemSnippet(obj);
|
||||
itemSnippet.Text = "[" + obj.AffixName() + str + "]";
|
||||
itemSnippet.CheckForHover = true;
|
||||
itemSnippet.DeleteWhole = true;
|
||||
return (TextSnippet) itemSnippet;
|
||||
}
|
||||
|
||||
public static string GenerateTag(Item I)
|
||||
{
|
||||
string str = "[i";
|
||||
if (I.prefix != (byte) 0)
|
||||
str = str + "/p" + (object) I.prefix;
|
||||
if (I.stack != 1)
|
||||
str = str + "/s" + (object) I.stack;
|
||||
return str + ":" + (object) I.netID + "]";
|
||||
}
|
||||
|
||||
private class ItemSnippet : TextSnippet
|
||||
{
|
||||
private Item _item;
|
||||
|
||||
public ItemSnippet(Item item)
|
||||
: base()
|
||||
{
|
||||
this._item = item;
|
||||
this.Color = ItemRarity.GetColor(item.rare);
|
||||
}
|
||||
|
||||
public override void OnHover()
|
||||
{
|
||||
Main.HoverItem = this._item.Clone();
|
||||
Main.instance.MouseText(this._item.Name, this._item.rare);
|
||||
}
|
||||
|
||||
public override bool UniqueDraw(
|
||||
bool justCheckingString,
|
||||
out Vector2 size,
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position = default (Vector2),
|
||||
Color color = default (Color),
|
||||
float scale = 1f)
|
||||
{
|
||||
float num1 = 1f;
|
||||
float num2 = 1f;
|
||||
if (Main.netMode != 2 && !Main.dedServ)
|
||||
{
|
||||
Texture2D texture2D = Main.itemTexture[this._item.type];
|
||||
Rectangle rectangle = Main.itemAnimations[this._item.type] == null ? texture2D.Frame() : Main.itemAnimations[this._item.type].GetFrame(texture2D);
|
||||
if (rectangle.Height > 32)
|
||||
num2 = 32f / (float) rectangle.Height;
|
||||
}
|
||||
float num3 = num2 * scale;
|
||||
float num4 = num1 * num3;
|
||||
if ((double) num4 > 0.75)
|
||||
num4 = 0.75f;
|
||||
if (!justCheckingString && color != Color.Black)
|
||||
{
|
||||
double inventoryScale = (double) Main.inventoryScale;
|
||||
Main.inventoryScale = scale * num4;
|
||||
ItemSlot.Draw(spriteBatch, ref this._item, 14, position - new Vector2(10f) * scale * num4, Color.White);
|
||||
Main.inventoryScale = (float) inventoryScale;
|
||||
}
|
||||
size = new Vector2(32f) * scale * num4;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override float GetStringLength(DynamicSpriteFont font) => (float) (32.0 * (double) this.Scale * 0.649999976158142);
|
||||
}
|
||||
}
|
||||
}
|
24
GameContent/UI/Chat/NameTagHandler.cs
Normal file
24
GameContent/UI/Chat/NameTagHandler.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.NameTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class NameTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return new TextSnippet("<" + text.Replace("\\[", "[").Replace("\\]", "]") + ">", baseColor);
|
||||
}
|
||||
|
||||
public static string GenerateTag(string name) => "[n:" + name.Replace("[", "\\[").Replace("]", "\\]") + "]";
|
||||
}
|
||||
}
|
37
GameContent/UI/Chat/PlainTagHandler.cs
Normal file
37
GameContent/UI/Chat/PlainTagHandler.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Chat.PlainTagHandler
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Chat
|
||||
{
|
||||
public class PlainTagHandler : ITagHandler
|
||||
{
|
||||
TextSnippet ITagHandler.Parse(
|
||||
string text,
|
||||
Color baseColor,
|
||||
string options)
|
||||
{
|
||||
return (TextSnippet) new PlainTagHandler.PlainSnippet(text);
|
||||
}
|
||||
|
||||
public class PlainSnippet : TextSnippet
|
||||
{
|
||||
public PlainSnippet(string text = "")
|
||||
: base(text)
|
||||
{
|
||||
}
|
||||
|
||||
public PlainSnippet(string text, Color color, float scale = 1f)
|
||||
: base(text, color, scale)
|
||||
{
|
||||
}
|
||||
|
||||
public override Color GetVisibleColor() => this.Color;
|
||||
}
|
||||
}
|
||||
}
|
127
GameContent/UI/CustomCurrencyManager.cs
Normal file
127
GameContent/UI/CustomCurrencyManager.cs
Normal file
|
@ -0,0 +1,127 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencyManager
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencyManager
|
||||
{
|
||||
private static int _nextCurrencyIndex = 0;
|
||||
private static Dictionary<int, CustomCurrencySystem> _currencies = new Dictionary<int, CustomCurrencySystem>();
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CustomCurrencyManager._nextCurrencyIndex = 0;
|
||||
CustomCurrencyID.DefenderMedals = CustomCurrencyManager.RegisterCurrency((CustomCurrencySystem) new CustomCurrencySingleCoin(3817, 999L));
|
||||
}
|
||||
|
||||
public static int RegisterCurrency(CustomCurrencySystem collection)
|
||||
{
|
||||
int nextCurrencyIndex = CustomCurrencyManager._nextCurrencyIndex;
|
||||
++CustomCurrencyManager._nextCurrencyIndex;
|
||||
CustomCurrencyManager._currencies[nextCurrencyIndex] = collection;
|
||||
return nextCurrencyIndex;
|
||||
}
|
||||
|
||||
public static void DrawSavings(
|
||||
SpriteBatch sb,
|
||||
int currencyIndex,
|
||||
float shopx,
|
||||
float shopy,
|
||||
bool horizontal = false)
|
||||
{
|
||||
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
|
||||
Player player = Main.player[Main.myPlayer];
|
||||
bool overFlowing;
|
||||
long num1 = currency.CountCurrency(out overFlowing, player.bank.item);
|
||||
long num2 = currency.CountCurrency(out overFlowing, player.bank2.item);
|
||||
long num3 = currency.CountCurrency(out overFlowing, player.bank3.item);
|
||||
long totalCoins = currency.CombineStacks(out overFlowing, num1, num2, num3);
|
||||
if (totalCoins <= 0L)
|
||||
return;
|
||||
if (num3 > 0L)
|
||||
sb.Draw(Main.itemTexture[3813], Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), Main.itemTexture[3813].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
if (num2 > 0L)
|
||||
sb.Draw(Main.itemTexture[346], Utils.CenteredRectangle(new Vector2(shopx + 80f, shopy + 50f), Main.itemTexture[346].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
if (num1 > 0L)
|
||||
sb.Draw(Main.itemTexture[87], Utils.CenteredRectangle(new Vector2(shopx + 70f, shopy + 60f), Main.itemTexture[87].Size() * 0.65f), new Rectangle?(), Color.White);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontMouseText, Lang.inter[66].Value, shopx, shopy + 40f, Color.White * ((float) Main.mouseTextColor / (float) byte.MaxValue), Color.Black, Vector2.Zero);
|
||||
currency.DrawSavingsMoney(sb, Lang.inter[66].Value, shopx, shopy, totalCoins, horizontal);
|
||||
}
|
||||
|
||||
public static void GetPriceText(
|
||||
int currencyIndex,
|
||||
string[] lines,
|
||||
ref int currentLine,
|
||||
int price)
|
||||
{
|
||||
CustomCurrencyManager._currencies[currencyIndex].GetPriceText(lines, ref currentLine, price);
|
||||
}
|
||||
|
||||
public static bool BuyItem(Player player, int price, int currencyIndex)
|
||||
{
|
||||
CustomCurrencySystem currency = CustomCurrencyManager._currencies[currencyIndex];
|
||||
bool overFlowing;
|
||||
long num1 = currency.CountCurrency(out overFlowing, player.inventory, 58, 57, 56, 55, 54);
|
||||
long num2 = currency.CountCurrency(out overFlowing, player.bank.item);
|
||||
long num3 = currency.CountCurrency(out overFlowing, player.bank2.item);
|
||||
long num4 = currency.CountCurrency(out overFlowing, player.bank3.item);
|
||||
if (currency.CombineStacks(out overFlowing, num1, num2, num3, num4) < (long) price)
|
||||
return false;
|
||||
List<Item[]> objArrayList = new List<Item[]>();
|
||||
Dictionary<int, List<int>> slotsToIgnore = new Dictionary<int, List<int>>();
|
||||
List<Point> pointList1 = new List<Point>();
|
||||
List<Point> slotCoins = new List<Point>();
|
||||
List<Point> pointList2 = new List<Point>();
|
||||
List<Point> pointList3 = new List<Point>();
|
||||
List<Point> pointList4 = new List<Point>();
|
||||
objArrayList.Add(player.inventory);
|
||||
objArrayList.Add(player.bank.item);
|
||||
objArrayList.Add(player.bank2.item);
|
||||
objArrayList.Add(player.bank3.item);
|
||||
for (int key = 0; key < objArrayList.Count; ++key)
|
||||
slotsToIgnore[key] = new List<int>();
|
||||
slotsToIgnore[0] = new List<int>()
|
||||
{
|
||||
58,
|
||||
57,
|
||||
56,
|
||||
55,
|
||||
54
|
||||
};
|
||||
for (int index = 0; index < objArrayList.Count; ++index)
|
||||
{
|
||||
for (int y = 0; y < objArrayList[index].Length; ++y)
|
||||
{
|
||||
if (!slotsToIgnore[index].Contains(y) && currency.Accepts(objArrayList[index][y]))
|
||||
slotCoins.Add(new Point(index, y));
|
||||
}
|
||||
}
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList1, 0);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList2, 1);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList3, 2);
|
||||
CustomCurrencyManager.FindEmptySlots(objArrayList, slotsToIgnore, pointList4, 3);
|
||||
return currency.TryPurchasing(price, objArrayList, slotCoins, pointList1, pointList2, pointList3, pointList4);
|
||||
}
|
||||
|
||||
private static void FindEmptySlots(
|
||||
List<Item[]> inventories,
|
||||
Dictionary<int, List<int>> slotsToIgnore,
|
||||
List<Point> emptySlots,
|
||||
int currentInventoryIndex)
|
||||
{
|
||||
for (int y = inventories[currentInventoryIndex].Length - 1; y >= 0; --y)
|
||||
{
|
||||
if (!slotsToIgnore[currentInventoryIndex].Contains(y) && (inventories[currentInventoryIndex][y].type == 0 || inventories[currentInventoryIndex][y].stack == 0))
|
||||
emptySlots.Add(new Point(currentInventoryIndex, y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
107
GameContent/UI/CustomCurrencySingleCoin.cs
Normal file
107
GameContent/UI/CustomCurrencySingleCoin.cs
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencySingleCoin
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencySingleCoin : CustomCurrencySystem
|
||||
{
|
||||
public float CurrencyDrawScale = 0.8f;
|
||||
public string CurrencyTextKey = "Currency.DefenderMedals";
|
||||
public Color CurrencyTextColor = new Color(240, 100, 120);
|
||||
|
||||
public CustomCurrencySingleCoin(int coinItemID, long currencyCap)
|
||||
{
|
||||
this.Include(coinItemID, 1);
|
||||
this.SetCurrencyCap(currencyCap);
|
||||
}
|
||||
|
||||
public override bool TryPurchasing(
|
||||
int price,
|
||||
List<Item[]> inv,
|
||||
List<Point> slotCoins,
|
||||
List<Point> slotsEmpty,
|
||||
List<Point> slotEmptyBank,
|
||||
List<Point> slotEmptyBank2,
|
||||
List<Point> slotEmptyBank3)
|
||||
{
|
||||
List<Tuple<Point, Item>> cache = this.ItemCacheCreate(inv);
|
||||
int num1 = price;
|
||||
for (int index = 0; index < slotCoins.Count; ++index)
|
||||
{
|
||||
Point slotCoin = slotCoins[index];
|
||||
int num2 = num1;
|
||||
if (inv[slotCoin.X][slotCoin.Y].stack < num2)
|
||||
num2 = inv[slotCoin.X][slotCoin.Y].stack;
|
||||
num1 -= num2;
|
||||
inv[slotCoin.X][slotCoin.Y].stack -= num2;
|
||||
if (inv[slotCoin.X][slotCoin.Y].stack == 0)
|
||||
{
|
||||
switch (slotCoin.X)
|
||||
{
|
||||
case 0:
|
||||
slotsEmpty.Add(slotCoin);
|
||||
break;
|
||||
case 1:
|
||||
slotEmptyBank.Add(slotCoin);
|
||||
break;
|
||||
case 2:
|
||||
slotEmptyBank2.Add(slotCoin);
|
||||
break;
|
||||
case 3:
|
||||
slotEmptyBank3.Add(slotCoin);
|
||||
break;
|
||||
}
|
||||
slotCoins.Remove(slotCoin);
|
||||
--index;
|
||||
}
|
||||
if (num1 == 0)
|
||||
break;
|
||||
}
|
||||
if (num1 == 0)
|
||||
return true;
|
||||
this.ItemCacheRestore(cache, inv);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void DrawSavingsMoney(
|
||||
SpriteBatch sb,
|
||||
string text,
|
||||
float shopx,
|
||||
float shopy,
|
||||
long totalCoins,
|
||||
bool horizontal = false)
|
||||
{
|
||||
int index = this._valuePerUnit.Keys.ElementAt<int>(0);
|
||||
Texture2D texture2D = Main.itemTexture[index];
|
||||
if (horizontal)
|
||||
{
|
||||
Vector2 position = new Vector2((float) ((double) shopx + (double) ChatManager.GetStringSize(Main.fontMouseText, text, Vector2.One).X + 45.0), shopy + 50f);
|
||||
sb.Draw(texture2D, position, new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontItemStack, totalCoins.ToString(), position.X - 11f, position.Y, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = totalCoins > 99L ? -6 : 0;
|
||||
sb.Draw(texture2D, new Vector2(shopx + 11f, shopy + 75f), new Rectangle?(), Color.White, 0.0f, texture2D.Size() / 2f, this.CurrencyDrawScale, SpriteEffects.None, 0.0f);
|
||||
Utils.DrawBorderStringFourWay(sb, Main.fontItemStack, totalCoins.ToString(), shopx + (float) num, shopy + 75f, Color.White, Color.Black, new Vector2(0.3f), 0.75f);
|
||||
}
|
||||
}
|
||||
|
||||
public override void GetPriceText(string[] lines, ref int currentLine, int price)
|
||||
{
|
||||
Color color = this.CurrencyTextColor * ((float) Main.mouseTextColor / (float) byte.MaxValue);
|
||||
lines[currentLine++] = string.Format("[c/{0:X2}{1:X2}{2:X2}:{3} {4} {5}]", (object) color.R, (object) color.G, (object) color.B, (object) Lang.tip[50].Value, (object) price, (object) Language.GetTextValue(this.CurrencyTextKey).ToLower());
|
||||
}
|
||||
}
|
||||
}
|
237
GameContent/UI/CustomCurrencySystem.cs
Normal file
237
GameContent/UI/CustomCurrencySystem.cs
Normal file
|
@ -0,0 +1,237 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.CustomCurrencySystem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class CustomCurrencySystem
|
||||
{
|
||||
protected Dictionary<int, int> _valuePerUnit = new Dictionary<int, int>();
|
||||
private long _currencyCap = 999999999;
|
||||
|
||||
public long CurrencyCap => this._currencyCap;
|
||||
|
||||
public void Include(int coin, int howMuchIsItWorth) => this._valuePerUnit[coin] = howMuchIsItWorth;
|
||||
|
||||
public void SetCurrencyCap(long cap) => this._currencyCap = cap;
|
||||
|
||||
public virtual long CountCurrency(out bool overFlowing, Item[] inv, params int[] ignoreSlots)
|
||||
{
|
||||
List<int> intList = new List<int>((IEnumerable<int>) ignoreSlots);
|
||||
long num1 = 0;
|
||||
for (int index = 0; index < inv.Length; ++index)
|
||||
{
|
||||
if (!intList.Contains(index))
|
||||
{
|
||||
int num2;
|
||||
if (this._valuePerUnit.TryGetValue(inv[index].type, out num2))
|
||||
num1 += (long) (num2 * inv[index].stack);
|
||||
if (num1 >= this.CurrencyCap)
|
||||
{
|
||||
overFlowing = true;
|
||||
return this.CurrencyCap;
|
||||
}
|
||||
}
|
||||
}
|
||||
overFlowing = false;
|
||||
return num1;
|
||||
}
|
||||
|
||||
public virtual long CombineStacks(out bool overFlowing, params long[] coinCounts)
|
||||
{
|
||||
long num = 0;
|
||||
foreach (long coinCount in coinCounts)
|
||||
{
|
||||
num += coinCount;
|
||||
if (num >= this.CurrencyCap)
|
||||
{
|
||||
overFlowing = true;
|
||||
return this.CurrencyCap;
|
||||
}
|
||||
}
|
||||
overFlowing = false;
|
||||
return num;
|
||||
}
|
||||
|
||||
public virtual bool TryPurchasing(
|
||||
int price,
|
||||
List<Item[]> inv,
|
||||
List<Point> slotCoins,
|
||||
List<Point> slotsEmpty,
|
||||
List<Point> slotEmptyBank,
|
||||
List<Point> slotEmptyBank2,
|
||||
List<Point> slotEmptyBank3)
|
||||
{
|
||||
long num1 = (long) price;
|
||||
Dictionary<Point, Item> dictionary = new Dictionary<Point, Item>();
|
||||
bool flag = true;
|
||||
while (num1 > 0L)
|
||||
{
|
||||
long num2 = 1000000;
|
||||
for (int index = 0; index < 4; ++index)
|
||||
{
|
||||
if (num1 >= num2)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (inv[slotCoin.X][slotCoin.Y].type == 74 - index)
|
||||
{
|
||||
long num3 = num1 / num2;
|
||||
dictionary[slotCoin] = inv[slotCoin.X][slotCoin.Y].Clone();
|
||||
if (num3 < (long) inv[slotCoin.X][slotCoin.Y].stack)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].stack -= (int) num3;
|
||||
}
|
||||
else
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
slotsEmpty.Add(slotCoin);
|
||||
}
|
||||
num1 -= num2 * (long) (dictionary[slotCoin].stack - inv[slotCoin.X][slotCoin.Y].stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
num2 /= 100L;
|
||||
}
|
||||
if (num1 > 0L)
|
||||
{
|
||||
if (slotsEmpty.Count > 0)
|
||||
{
|
||||
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
Point point = new Point(-1, -1);
|
||||
for (int index1 = 0; index1 < inv.Count; ++index1)
|
||||
{
|
||||
long num4 = 10000;
|
||||
for (int index2 = 0; index2 < 3; ++index2)
|
||||
{
|
||||
if (num1 >= num4)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 74 - index2 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
|
||||
{
|
||||
List<Point> pointList = slotsEmpty;
|
||||
if (index1 == 1 && slotEmptyBank.Count > 0)
|
||||
pointList = slotEmptyBank;
|
||||
if (index1 == 2 && slotEmptyBank2.Count > 0)
|
||||
pointList = slotEmptyBank2;
|
||||
if (index1 == 3 && slotEmptyBank3.Count > 0)
|
||||
pointList = slotEmptyBank3;
|
||||
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
pointList.Add(slotCoin);
|
||||
}
|
||||
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
|
||||
inv[pointList[0].X][pointList[0].Y].SetDefaults(73 - index2);
|
||||
inv[pointList[0].X][pointList[0].Y].stack = 100;
|
||||
point = pointList[0];
|
||||
pointList.RemoveAt(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (point.X == -1 && point.Y == -1)
|
||||
num4 /= 100L;
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (int index3 = 0; index3 < 2; ++index3)
|
||||
{
|
||||
if (point.X == -1 && point.Y == -1)
|
||||
{
|
||||
foreach (Point slotCoin in slotCoins)
|
||||
{
|
||||
if (slotCoin.X == index1 && inv[slotCoin.X][slotCoin.Y].type == 73 + index3 && inv[slotCoin.X][slotCoin.Y].stack >= 1)
|
||||
{
|
||||
List<Point> pointList = slotsEmpty;
|
||||
if (index1 == 1 && slotEmptyBank.Count > 0)
|
||||
pointList = slotEmptyBank;
|
||||
if (index1 == 2 && slotEmptyBank2.Count > 0)
|
||||
pointList = slotEmptyBank2;
|
||||
if (index1 == 3 && slotEmptyBank3.Count > 0)
|
||||
pointList = slotEmptyBank3;
|
||||
if (--inv[slotCoin.X][slotCoin.Y].stack <= 0)
|
||||
{
|
||||
inv[slotCoin.X][slotCoin.Y].SetDefaults();
|
||||
pointList.Add(slotCoin);
|
||||
}
|
||||
dictionary[pointList[0]] = inv[pointList[0].X][pointList[0].Y].Clone();
|
||||
inv[pointList[0].X][pointList[0].Y].SetDefaults(72 + index3);
|
||||
inv[pointList[0].X][pointList[0].Y].stack = 100;
|
||||
point = pointList[0];
|
||||
pointList.RemoveAt(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (point.X != -1 && point.Y != -1)
|
||||
{
|
||||
slotCoins.Add(point);
|
||||
break;
|
||||
}
|
||||
}
|
||||
slotsEmpty.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank2.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
slotEmptyBank3.Sort(new Comparison<Point>(DelegateMethods.CompareYReverse));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (KeyValuePair<Point, Item> keyValuePair in dictionary)
|
||||
inv[keyValuePair.Key.X][keyValuePair.Key.Y] = keyValuePair.Value.Clone();
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public virtual bool Accepts(Item item) => this._valuePerUnit.ContainsKey(item.type);
|
||||
|
||||
public virtual void DrawSavingsMoney(
|
||||
SpriteBatch sb,
|
||||
string text,
|
||||
float shopx,
|
||||
float shopy,
|
||||
long totalCoins,
|
||||
bool horizontal = false)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void GetPriceText(string[] lines, ref int currentLine, int price)
|
||||
{
|
||||
}
|
||||
|
||||
protected int SortByHighest(Tuple<int, int> valueA, Tuple<int, int> valueB) => valueA.Item2 > valueB.Item2 || valueA.Item2 != valueB.Item2 ? -1 : 0;
|
||||
|
||||
protected List<Tuple<Point, Item>> ItemCacheCreate(List<Item[]> inventories)
|
||||
{
|
||||
List<Tuple<Point, Item>> tupleList = new List<Tuple<Point, Item>>();
|
||||
for (int index = 0; index < inventories.Count; ++index)
|
||||
{
|
||||
for (int y = 0; y < inventories[index].Length; ++y)
|
||||
{
|
||||
Item obj = inventories[index][y];
|
||||
tupleList.Add(new Tuple<Point, Item>(new Point(index, y), obj.DeepClone()));
|
||||
}
|
||||
}
|
||||
return tupleList;
|
||||
}
|
||||
|
||||
protected void ItemCacheRestore(List<Tuple<Point, Item>> cache, List<Item[]> inventories)
|
||||
{
|
||||
foreach (Tuple<Point, Item> tuple in cache)
|
||||
inventories[tuple.Item1.X][tuple.Item1.Y] = tuple.Item2;
|
||||
}
|
||||
}
|
||||
}
|
231
GameContent/UI/Elements/UIAchievementListItem.cs
Normal file
231
GameContent/UI/Elements/UIAchievementListItem.cs
Normal file
|
@ -0,0 +1,231 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIAchievementListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Achievements;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIAchievementListItem : UIPanel
|
||||
{
|
||||
private Achievement _achievement;
|
||||
private UIImageFramed _achievementIcon;
|
||||
private UIImage _achievementIconBorders;
|
||||
private const int _iconSize = 64;
|
||||
private const int _iconSizeWithSpace = 66;
|
||||
private const int _iconsPerRow = 8;
|
||||
private int _iconIndex;
|
||||
private Rectangle _iconFrame;
|
||||
private Rectangle _iconFrameUnlocked;
|
||||
private Rectangle _iconFrameLocked;
|
||||
private Texture2D _innerPanelTopTexture;
|
||||
private Texture2D _innerPanelBottomTexture;
|
||||
private Texture2D _categoryTexture;
|
||||
private bool _locked;
|
||||
private bool _large;
|
||||
|
||||
public UIAchievementListItem(Achievement achievement, bool largeForOtherLanguages)
|
||||
{
|
||||
this._large = largeForOtherLanguages;
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
float num = (float) (16 + this._large.ToInt() * 20);
|
||||
float pixels1 = (float) (this._large.ToInt() * 6);
|
||||
float pixels2 = (float) (this._large.ToInt() * 12);
|
||||
this._achievement = achievement;
|
||||
this.Height.Set(66f + num, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.PaddingTop = 8f;
|
||||
this.PaddingLeft = 9f;
|
||||
int iconIndex = Main.Achievements.GetIconIndex(achievement.Name);
|
||||
this._iconIndex = iconIndex;
|
||||
this._iconFrameUnlocked = new Rectangle(iconIndex % 8 * 66, iconIndex / 8 * 66, 64, 64);
|
||||
this._iconFrameLocked = this._iconFrameUnlocked;
|
||||
this._iconFrameLocked.X += 528;
|
||||
this._iconFrame = this._iconFrameLocked;
|
||||
this.UpdateIconFrame();
|
||||
this._achievementIcon = new UIImageFramed(TextureManager.Load("Images/UI/Achievements"), this._iconFrame);
|
||||
this._achievementIcon.Left.Set(pixels1, 0.0f);
|
||||
this._achievementIcon.Top.Set(pixels2, 0.0f);
|
||||
this.Append((UIElement) this._achievementIcon);
|
||||
this._achievementIconBorders = new UIImage(TextureManager.Load("Images/UI/Achievement_Borders"));
|
||||
this._achievementIconBorders.Left.Set(pixels1 - 4f, 0.0f);
|
||||
this._achievementIconBorders.Top.Set(pixels2 - 4f, 0.0f);
|
||||
this.Append((UIElement) this._achievementIconBorders);
|
||||
this._innerPanelTopTexture = TextureManager.Load("Images/UI/Achievement_InnerPanelTop");
|
||||
this._innerPanelBottomTexture = !this._large ? TextureManager.Load("Images/UI/Achievement_InnerPanelBottom") : TextureManager.Load("Images/UI/Achievement_InnerPanelBottom_Large");
|
||||
this._categoryTexture = TextureManager.Load("Images/UI/Achievement_Categories");
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
int num1 = this._large.ToInt() * 6;
|
||||
Vector2 vector2_1 = new Vector2((float) num1, 0.0f);
|
||||
this._locked = !this._achievement.IsCompleted;
|
||||
this.UpdateIconFrame();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._achievementIconBorders.GetDimensions();
|
||||
Vector2 vector2_2 = new Vector2(dimensions.X + dimensions.Width + 7f, innerDimensions.Y);
|
||||
Tuple<Decimal, Decimal> trackerValues = this.GetTrackerValues();
|
||||
bool flag = false;
|
||||
if ((!(trackerValues.Item1 == 0M) || !(trackerValues.Item2 == 0M)) && this._locked)
|
||||
flag = true;
|
||||
float num2 = (float) ((double) innerDimensions.Width - (double) dimensions.Width + 1.0) - (float) (num1 * 2);
|
||||
Vector2 baseScale1 = new Vector2(0.85f);
|
||||
Vector2 baseScale2 = new Vector2(0.92f);
|
||||
string wrappedText = Main.fontItemStack.CreateWrappedText(this._achievement.Description.Value, (float) (((double) num2 - 20.0) * (1.0 / (double) baseScale2.X)), Language.ActiveCulture.CultureInfo);
|
||||
Vector2 stringSize1 = ChatManager.GetStringSize(Main.fontItemStack, wrappedText, baseScale2, num2);
|
||||
if (!this._large)
|
||||
stringSize1 = ChatManager.GetStringSize(Main.fontItemStack, this._achievement.Description.Value, baseScale2, num2);
|
||||
float num3 = (float) (38.0 + (this._large ? 20.0 : 0.0));
|
||||
if ((double) stringSize1.Y > (double) num3)
|
||||
baseScale2.Y *= num3 / stringSize1.Y;
|
||||
Color baseColor1 = Color.Lerp(this._locked ? Color.Silver : Color.Gold, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color baseColor2 = Color.Lerp(this._locked ? Color.DarkGray : Color.Silver, Color.White, this.IsMouseHovering ? 1f : 0.0f);
|
||||
Color color1 = this.IsMouseHovering ? Color.White : Color.Gray;
|
||||
Vector2 position1 = vector2_2 - Vector2.UnitY * 2f + vector2_1;
|
||||
this.DrawPanelTop(spriteBatch, position1, num2, color1);
|
||||
AchievementCategory category = this._achievement.Category;
|
||||
position1.Y += 2f;
|
||||
position1.X += 4f;
|
||||
spriteBatch.Draw(this._categoryTexture, position1, new Rectangle?(this._categoryTexture.Frame(4, 2, (int) category)), this.IsMouseHovering ? Color.White : Color.Silver, 0.0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0.0f);
|
||||
position1.X += 4f;
|
||||
position1.X += 17f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._achievement.FriendlyName.Value, position1, baseColor1, 0.0f, Vector2.Zero, baseScale1, num2);
|
||||
position1.X -= 17f;
|
||||
Vector2 position2 = vector2_2 + Vector2.UnitY * 27f + vector2_1;
|
||||
this.DrawPanelBottom(spriteBatch, position2, num2, color1);
|
||||
position2.X += 8f;
|
||||
position2.Y += 4f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, wrappedText, position2, baseColor2, 0.0f, Vector2.Zero, baseScale2);
|
||||
if (!flag)
|
||||
return;
|
||||
Vector2 position3 = position1 + Vector2.UnitX * num2 + Vector2.UnitY;
|
||||
string text = ((int) trackerValues.Item1).ToString() + "/" + ((int) trackerValues.Item2).ToString();
|
||||
Vector2 baseScale3 = new Vector2(0.75f);
|
||||
Vector2 stringSize2 = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale3);
|
||||
float progress = (float) (trackerValues.Item1 / trackerValues.Item2);
|
||||
float Width = 80f;
|
||||
Color color2 = new Color(100, (int) byte.MaxValue, 100);
|
||||
if (!this.IsMouseHovering)
|
||||
color2 = Color.Lerp(color2, Color.Black, 0.25f);
|
||||
Color BackColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
if (!this.IsMouseHovering)
|
||||
BackColor = Color.Lerp(BackColor, Color.Black, 0.25f);
|
||||
this.DrawProgressBar(spriteBatch, progress, position3 - Vector2.UnitX * Width * 0.7f, Width, BackColor, color2, color2.MultiplyRGBA(new Color(new Vector4(1f, 1f, 1f, 0.5f))));
|
||||
position3.X -= Width * 1.4f + stringSize2.X;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position3, baseColor1, 0.0f, new Vector2(0.0f, 0.0f), baseScale3, 90f);
|
||||
}
|
||||
|
||||
private void UpdateIconFrame()
|
||||
{
|
||||
this._iconFrame = this._locked ? this._iconFrameLocked : this._iconFrameUnlocked;
|
||||
if (this._achievementIcon == null)
|
||||
return;
|
||||
this._achievementIcon.SetFrame(this._iconFrame);
|
||||
}
|
||||
|
||||
private void DrawPanelTop(SpriteBatch spriteBatch, Vector2 position, float width, Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, position, new Rectangle?(new Rectangle(0, 0, 2, this._innerPanelTopTexture.Height)), color);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, new Vector2(position.X + 2f, position.Y), new Rectangle?(new Rectangle(2, 0, 2, this._innerPanelTopTexture.Height)), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 4.0) / 2.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTopTexture, new Vector2((float) ((double) position.X + (double) width - 2.0), position.Y), new Rectangle?(new Rectangle(4, 0, 2, this._innerPanelTopTexture.Height)), color);
|
||||
}
|
||||
|
||||
private void DrawPanelBottom(
|
||||
SpriteBatch spriteBatch,
|
||||
Vector2 position,
|
||||
float width,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, position, new Rectangle?(new Rectangle(0, 0, 6, this._innerPanelBottomTexture.Height)), color);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, new Vector2(position.X + 6f, position.Y), new Rectangle?(new Rectangle(6, 0, 7, this._innerPanelBottomTexture.Height)), color, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 12.0) / 7.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelBottomTexture, new Vector2((float) ((double) position.X + (double) width - 6.0), position.Y), new Rectangle?(new Rectangle(13, 0, 6, this._innerPanelBottomTexture.Height)), color);
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(46, 60, 119);
|
||||
this.BorderColor = new Color(20, 30, 56);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(26, 40, 89) * 0.8f;
|
||||
this.BorderColor = new Color(13, 20, 44) * 0.8f;
|
||||
}
|
||||
|
||||
public Achievement GetAchievement() => this._achievement;
|
||||
|
||||
private Tuple<Decimal, Decimal> GetTrackerValues()
|
||||
{
|
||||
if (!this._achievement.HasTracker)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
IAchievementTracker tracker = this._achievement.GetTracker();
|
||||
if (tracker.GetTrackerType() == TrackerType.Int)
|
||||
{
|
||||
AchievementTracker<int> achievementTracker = (AchievementTracker<int>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker.Value, (Decimal) achievementTracker.MaxValue);
|
||||
}
|
||||
if (tracker.GetTrackerType() != TrackerType.Float)
|
||||
return Tuple.Create<Decimal, Decimal>(0M, 0M);
|
||||
AchievementTracker<float> achievementTracker1 = (AchievementTracker<float>) tracker;
|
||||
return Tuple.Create<Decimal, Decimal>((Decimal) achievementTracker1.Value, (Decimal) achievementTracker1.MaxValue);
|
||||
}
|
||||
|
||||
private void DrawProgressBar(
|
||||
SpriteBatch spriteBatch,
|
||||
float progress,
|
||||
Vector2 spot,
|
||||
float Width = 169f,
|
||||
Color BackColor = default (Color),
|
||||
Color FillingColor = default (Color),
|
||||
Color BlipColor = default (Color))
|
||||
{
|
||||
if (BlipColor == Color.Transparent)
|
||||
BlipColor = new Color((int) byte.MaxValue, 165, 0, (int) sbyte.MaxValue);
|
||||
if (FillingColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, 241, 51);
|
||||
if (BackColor == Color.Transparent)
|
||||
FillingColor = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue);
|
||||
Texture2D colorBarTexture = Main.colorBarTexture;
|
||||
Texture2D colorBlipTexture = Main.colorBlipTexture;
|
||||
Texture2D magicPixel = Main.magicPixel;
|
||||
float num1 = MathHelper.Clamp(progress, 0.0f, 1f);
|
||||
float num2 = Width * 1f;
|
||||
float y = 8f;
|
||||
float x = num2 / 169f;
|
||||
Vector2 vector2 = spot + Vector2.UnitY * y + Vector2.UnitX * 1f;
|
||||
spriteBatch.Draw(colorBarTexture, spot, new Rectangle?(new Rectangle(5, 0, colorBarTexture.Width - 9, colorBarTexture.Height)), BackColor, 0.0f, new Vector2(84.5f, 0.0f), new Vector2(x, 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(colorBarTexture, spot + new Vector2((float) (-(double) x * 84.5 - 5.0), 0.0f), new Rectangle?(new Rectangle(0, 0, 5, colorBarTexture.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(colorBarTexture, spot + new Vector2(x * 84.5f, 0.0f), new Rectangle?(new Rectangle(colorBarTexture.Width - 4, 0, 4, colorBarTexture.Height)), BackColor, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
Vector2 position = vector2 + Vector2.UnitX * (num1 - 0.5f) * num2;
|
||||
--position.X;
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), FillingColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(num2 * num1, y), SpriteEffects.None, 0.0f);
|
||||
if ((double) progress != 0.0)
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), BlipColor, 0.0f, new Vector2(1f, 0.5f), new Vector2(2f, y), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(magicPixel, position, new Rectangle?(new Rectangle(0, 0, 1, 1)), Color.Black, 0.0f, new Vector2(0.0f, 0.5f), new Vector2(num2 * (1f - num1), y), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UIAchievementListItem achievementListItem))
|
||||
return 0;
|
||||
if (this._achievement.IsCompleted && !achievementListItem._achievement.IsCompleted)
|
||||
return -1;
|
||||
return !this._achievement.IsCompleted && achievementListItem._achievement.IsCompleted ? 1 : this._achievement.Id.CompareTo(achievementListItem._achievement.Id);
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/UI/Elements/UICharacter.cs
Normal file
40
GameContent/UI/Elements/UICharacter.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacter
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacter : UIElement
|
||||
{
|
||||
private Player _player;
|
||||
private Texture2D _texture;
|
||||
private static Item _blankItem = new Item();
|
||||
|
||||
public UICharacter(Player player)
|
||||
{
|
||||
this._player = player;
|
||||
this.Width.Set(59f, 0.0f);
|
||||
this.Height.Set(58f, 0.0f);
|
||||
this._texture = TextureManager.Load("Images/UI/PlayerBackground");
|
||||
this._useImmediateMode = true;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), Color.White);
|
||||
Vector2 vector2 = dimensions.Position() + new Vector2(dimensions.Width * 0.5f - (float) (this._player.width >> 1), dimensions.Height * 0.5f - (float) (this._player.height >> 1));
|
||||
Item obj = this._player.inventory[this._player.selectedItem];
|
||||
this._player.inventory[this._player.selectedItem] = UICharacter._blankItem;
|
||||
Main.instance.DrawPlayer(this._player, vector2 + Main.screenPosition, 0.0f, Vector2.Zero);
|
||||
this._player.inventory[this._player.selectedItem] = obj;
|
||||
}
|
||||
}
|
||||
}
|
271
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
271
GameContent/UI/Elements/UICharacterListItem.cs
Normal file
|
@ -0,0 +1,271 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UICharacterListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UICharacterListItem : UIPanel
|
||||
{
|
||||
private PlayerFileData _data;
|
||||
private Texture2D _dividerTexture;
|
||||
private Texture2D _innerPanelTexture;
|
||||
private UICharacter _playerPanel;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Texture2D _buttonCloudActiveTexture;
|
||||
private Texture2D _buttonCloudInactiveTexture;
|
||||
private Texture2D _buttonFavoriteActiveTexture;
|
||||
private Texture2D _buttonFavoriteInactiveTexture;
|
||||
private Texture2D _buttonPlayTexture;
|
||||
private Texture2D _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UICharacterListItem(PlayerFileData data, int snapPointIndex)
|
||||
{
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
this._dividerTexture = TextureManager.Load("Images/UI/Divider");
|
||||
this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
|
||||
this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
|
||||
this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
|
||||
this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
|
||||
this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
|
||||
this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
|
||||
this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this._data = data;
|
||||
this._playerPanel = new UICharacter(data.Player);
|
||||
this._playerPanel.Left.Set(4f, 0.0f);
|
||||
this._playerPanel.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._playerPanel);
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(4f, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(28f, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(52f, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
|
||||
}
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.HAlign = 1f;
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton4;
|
||||
if (!this._data.IsFavorite)
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(80f, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
|
||||
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
|
||||
uiImageButton4.SetSnapPoint("Delete", snapPointIndex);
|
||||
}
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.PlayerList.Count; ++index)
|
||||
{
|
||||
if (Main.PlayerList[index] == this._data)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Main.selectedPlayer = index;
|
||||
Main.menuMode = 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target || this._data.Player.loadStatus != 0)
|
||||
return;
|
||||
Main.SelectPlayer(this._data);
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this.RemoveChild((UIElement) this._deleteButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this.Append((UIElement) this._deleteButton);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UICharacterListItem characterListItem))
|
||||
return base.CompareTo(obj);
|
||||
if (this.IsFavorite && !characterListItem.IsFavorite)
|
||||
return -1;
|
||||
if (!this.IsFavorite && characterListItem.IsFavorite)
|
||||
return 1;
|
||||
return this._data.Name.CompareTo(characterListItem._data.Name) != 0 ? this._data.Name.CompareTo(characterListItem._data.Name) : this._data.GetFileName().CompareTo(characterListItem._data.GetFileName());
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height)), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._playerPanel.GetDimensions();
|
||||
float x = dimensions.X + dimensions.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x + 6f, dimensions.Y - 2f), Color.White);
|
||||
spriteBatch.Draw(this._dividerTexture, new Vector2(x, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 vector2 = new Vector2(x + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 200f;
|
||||
Vector2 position1 = vector2;
|
||||
this.DrawPanel(spriteBatch, position1, width1);
|
||||
spriteBatch.Draw(Main.heartTexture, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) Main.heartTexture.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statLifeMax.ToString() + " HP", position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
position1.X += 65f;
|
||||
spriteBatch.Draw(Main.manaTexture, position1 + new Vector2(5f, 2f), Color.White);
|
||||
position1.X += 10f + (float) Main.manaTexture.Width;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Player.statManaMax.ToString() + " MP", position1 + new Vector2(0.0f, 3f), Color.White);
|
||||
vector2.X += width1 + 5f;
|
||||
Vector2 position2 = vector2;
|
||||
float width2 = 140f;
|
||||
if (GameCulture.Russian.IsActive)
|
||||
width2 = 180f;
|
||||
this.DrawPanel(spriteBatch, position2, width2);
|
||||
string text1 = "";
|
||||
Color color = Color.White;
|
||||
switch (this._data.Player.difficulty)
|
||||
{
|
||||
case 0:
|
||||
text1 = Language.GetTextValue("UI.Softcore");
|
||||
break;
|
||||
case 1:
|
||||
text1 = Language.GetTextValue("UI.Mediumcore");
|
||||
color = Main.mcColor;
|
||||
break;
|
||||
case 2:
|
||||
text1 = Language.GetTextValue("UI.Hardcore");
|
||||
color = Main.hcColor;
|
||||
break;
|
||||
}
|
||||
Vector2 pos1 = position2 + new Vector2((float) ((double) width2 * 0.5 - (double) Main.fontMouseText.MeasureString(text1).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text1, pos1, color);
|
||||
vector2.X += width2 + 5f;
|
||||
Vector2 position3 = vector2;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position3.X;
|
||||
this.DrawPanel(spriteBatch, position3, width3);
|
||||
TimeSpan playTime = this._data.GetPlayTime();
|
||||
int num = playTime.Days * 24 + playTime.Hours;
|
||||
string text2 = (num < 10 ? (object) "0" : (object) "").ToString() + (object) num + playTime.ToString("\\:mm\\:ss");
|
||||
Vector2 pos2 = position3 + new Vector2((float) ((double) width3 * 0.5 - (double) Main.fontMouseText.MeasureString(text2).X * 0.5), 3f);
|
||||
Utils.DrawBorderString(spriteBatch, text2, pos2, Color.White);
|
||||
}
|
||||
}
|
||||
}
|
119
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
119
GameContent/UI/Elements/UIGenProgressBar.cs
Normal file
|
@ -0,0 +1,119 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIGenProgressBar
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIGenProgressBar : UIElement
|
||||
{
|
||||
private Texture2D _texInnerDirt;
|
||||
private Texture2D _texOuterCrimson;
|
||||
private Texture2D _texOuterCorrupt;
|
||||
private Texture2D _texOuterLower;
|
||||
private float _visualOverallProgress;
|
||||
private float _targetOverallProgress;
|
||||
private float _visualCurrentProgress;
|
||||
private float _targetCurrentProgress;
|
||||
|
||||
public UIGenProgressBar()
|
||||
{
|
||||
if (Main.netMode != 2)
|
||||
{
|
||||
this._texInnerDirt = TextureManager.Load("Images/UI/WorldGen/Outer Dirt");
|
||||
this._texOuterCorrupt = TextureManager.Load("Images/UI/WorldGen/Outer Corrupt");
|
||||
this._texOuterCrimson = TextureManager.Load("Images/UI/WorldGen/Outer Crimson");
|
||||
this._texOuterLower = TextureManager.Load("Images/UI/WorldGen/Outer Lower");
|
||||
}
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Width.Pixels = 612f;
|
||||
this.Height.Pixels = 70f;
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetProgress(float overallProgress, float currentProgress)
|
||||
{
|
||||
this._targetCurrentProgress = currentProgress;
|
||||
this._targetOverallProgress = overallProgress;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._visualOverallProgress = this._targetOverallProgress;
|
||||
this._visualCurrentProgress = this._targetCurrentProgress;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
int completedWidth1 = (int) ((double) this._visualOverallProgress * 504.0);
|
||||
int completedWidth2 = (int) ((double) this._visualCurrentProgress * 504.0);
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Color filled = new Color();
|
||||
filled.PackedValue = WorldGen.crimson ? 4286836223U : 4283888223U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(20f, 40f), 16, completedWidth1, 564, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(48, 48, 48));
|
||||
filled.PackedValue = 4290947159U;
|
||||
this.DrawFilling2(spriteBatch, vector2 + new Vector2(50f, 60f), 8, completedWidth2, 504, filled, Color.Lerp(filled, Color.Black, 0.5f), new Color(33, 33, 33));
|
||||
Rectangle rectangle = this.GetDimensions().ToRectangle();
|
||||
rectangle.X -= 8;
|
||||
spriteBatch.Draw(WorldGen.crimson ? this._texOuterCrimson : this._texOuterCorrupt, rectangle.TopLeft(), Color.White);
|
||||
spriteBatch.Draw(this._texOuterLower, rectangle.TopLeft() + new Vector2(44f, 60f), Color.White);
|
||||
}
|
||||
|
||||
private void DrawFilling(
|
||||
SpriteBatch spritebatch,
|
||||
Texture2D tex,
|
||||
Texture2D texShadow,
|
||||
Vector2 topLeft,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
Vector2 position = topLeft + (float) completedWidth * Vector2.UnitX;
|
||||
int num = completedWidth;
|
||||
Rectangle rectangle = tex.Frame();
|
||||
for (; num > 0; num -= rectangle.Width)
|
||||
{
|
||||
if (rectangle.Width > num)
|
||||
{
|
||||
rectangle.X += rectangle.Width - num;
|
||||
rectangle.Width = num;
|
||||
}
|
||||
spritebatch.Draw(tex, position, new Rectangle?(rectangle), Color.White, 0.0f, new Vector2((float) rectangle.Width, 0.0f), 1f, SpriteEffects.None, 0.0f);
|
||||
position.X -= (float) rectangle.Width;
|
||||
}
|
||||
if (texShadow != null)
|
||||
spritebatch.Draw(texShadow, topLeft, new Rectangle?(new Rectangle(0, 0, completedWidth, texShadow.Height)), Color.White);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, tex.Height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
|
||||
private void DrawFilling2(
|
||||
SpriteBatch spritebatch,
|
||||
Vector2 topLeft,
|
||||
int height,
|
||||
int completedWidth,
|
||||
int totalWidth,
|
||||
Color filled,
|
||||
Color separator,
|
||||
Color empty)
|
||||
{
|
||||
if (completedWidth % 2 != 0)
|
||||
--completedWidth;
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X, (int) topLeft.Y, completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), filled);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth, (int) topLeft.Y, totalWidth - completedWidth, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), empty);
|
||||
spritebatch.Draw(Main.magicPixel, new Rectangle((int) topLeft.X + completedWidth - 2, (int) topLeft.Y, 2, height), new Rectangle?(new Rectangle(0, 0, 1, 1)), separator);
|
||||
}
|
||||
}
|
||||
}
|
45
GameContent/UI/Elements/UIHeader.cs
Normal file
45
GameContent/UI/Elements/UIHeader.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIHeader
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIHeader : UIElement
|
||||
{
|
||||
private string _text;
|
||||
|
||||
public string Text
|
||||
{
|
||||
get => this._text;
|
||||
set
|
||||
{
|
||||
if (!(this._text != value))
|
||||
return;
|
||||
this._text = value;
|
||||
Vector2 vector2 = Main.fontDeathText.MeasureString(this.Text);
|
||||
this.Width.Pixels = vector2.X;
|
||||
this.Height.Pixels = vector2.Y;
|
||||
this.Width.Precent = 0.0f;
|
||||
this.Height.Precent = 0.0f;
|
||||
this.Recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
public UIHeader() => this.Text = "";
|
||||
|
||||
public UIHeader(string text) => this.Text = text;
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
DynamicSpriteFontExtensionMethods.DrawString(spriteBatch, Main.fontDeathText, this.Text, new Vector2(dimensions.X, dimensions.Y), Color.White);
|
||||
}
|
||||
}
|
||||
}
|
38
GameContent/UI/Elements/UIImage.cs
Normal file
38
GameContent/UI/Elements/UIImage.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImage
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImage : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
public float ImageScale = 1f;
|
||||
|
||||
public UIImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position() + this._texture.Size() * (1f - this.ImageScale) / 2f, new Rectangle?(), Color.White, 0.0f, Vector2.Zero, this.ImageScale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
51
GameContent/UI/Elements/UIImageButton.cs
Normal file
51
GameContent/UI/Elements/UIImageButton.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageButton
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageButton : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private float _visibilityActive = 1f;
|
||||
private float _visibilityInactive = 0.4f;
|
||||
|
||||
public UIImageButton(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture)
|
||||
{
|
||||
this._texture = texture;
|
||||
this.Width.Set((float) this._texture.Width, 0.0f);
|
||||
this.Height.Set((float) this._texture.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), Color.White * (this.IsMouseHovering ? this._visibilityActive : this._visibilityInactive));
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
Main.PlaySound(12);
|
||||
}
|
||||
|
||||
public void SetVisibility(float whenActive, float whenInactive)
|
||||
{
|
||||
this._visibilityActive = MathHelper.Clamp(whenActive, 0.0f, 1f);
|
||||
this._visibilityInactive = MathHelper.Clamp(whenInactive, 0.0f, 1f);
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/UI/Elements/UIImageFramed.cs
Normal file
48
GameContent/UI/Elements/UIImageFramed.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIImageFramed
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIImageFramed : UIElement
|
||||
{
|
||||
private Texture2D _texture;
|
||||
private Rectangle _frame;
|
||||
public Color Color = Color.White;
|
||||
|
||||
public UIImageFramed(Texture2D texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetImage(Texture2D texture, Rectangle frame)
|
||||
{
|
||||
this._texture = texture;
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
public void SetFrame(Rectangle frame)
|
||||
{
|
||||
this._frame = frame;
|
||||
this.Width.Set((float) this._frame.Width, 0.0f);
|
||||
this.Height.Set((float) this._frame.Height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(this._texture, dimensions.Position(), new Rectangle?(this._frame), this.Color);
|
||||
}
|
||||
}
|
||||
}
|
202
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
202
GameContent/UI/Elements/UIKeybindingListItem.cs
Normal file
|
@ -0,0 +1,202 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.UI.Chat;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingListItem : UIElement
|
||||
{
|
||||
private InputMode _inputmode;
|
||||
private Color _color;
|
||||
private string _keybind;
|
||||
|
||||
public UIKeybindingListItem(string bind, InputMode mode, Color color)
|
||||
{
|
||||
this._keybind = bind;
|
||||
this._inputmode = mode;
|
||||
this._color = color;
|
||||
this.OnClick += new UIElement.MouseEvent(this.OnClickMethod);
|
||||
}
|
||||
|
||||
public void OnClickMethod(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (!(PlayerInput.ListeningTrigger != this._keybind))
|
||||
return;
|
||||
if (PlayerInput.CurrentProfile.AllowEditting)
|
||||
PlayerInput.ListenFor(this._keybind, this._inputmode);
|
||||
else
|
||||
PlayerInput.ListenFor((string) null, this._inputmode);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = PlayerInput.ListeningTrigger == this._keybind;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(flag ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this.GetFriendlyName(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
string text = this.GenInput(PlayerInput.CurrentProfile.InputModes[this._inputmode].KeyStatus[this._keybind]);
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
text = Lang.menu[195].Value;
|
||||
if (!flag)
|
||||
baseColor = new Color(80, 80, 80);
|
||||
}
|
||||
Vector2 stringSize = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) stringSize.X - 10.0), dimensions.Y + 2f + num1);
|
||||
if (this._inputmode == InputMode.XBoxGamepad || this._inputmode == InputMode.XBoxGamepadUI)
|
||||
position += new Vector2(0.0f, -3f);
|
||||
GlyphTagHandler.GlyphsScale = 0.85f;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
GlyphTagHandler.GlyphsScale = 1f;
|
||||
}
|
||||
|
||||
private string GenInput(List<string> list)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
return "";
|
||||
string str = "";
|
||||
switch (this._inputmode)
|
||||
{
|
||||
case InputMode.Keyboard:
|
||||
case InputMode.KeyboardUI:
|
||||
case InputMode.Mouse:
|
||||
str = list[0];
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + list[index];
|
||||
break;
|
||||
case InputMode.XBoxGamepad:
|
||||
case InputMode.XBoxGamepadUI:
|
||||
str = GlyphTagHandler.GenerateTag(list[0]);
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
str = str + "/" + GlyphTagHandler.GenerateTag(list[index]);
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
private string GetFriendlyName()
|
||||
{
|
||||
switch (this._keybind)
|
||||
{
|
||||
case "Down":
|
||||
return Lang.menu[149].Value;
|
||||
case "DpadRadial1":
|
||||
return Lang.menu[186].Value;
|
||||
case "DpadRadial2":
|
||||
return Lang.menu[187].Value;
|
||||
case "DpadRadial3":
|
||||
return Lang.menu[188].Value;
|
||||
case "DpadRadial4":
|
||||
return Lang.menu[189].Value;
|
||||
case "DpadSnap1":
|
||||
return Lang.menu[191].Value;
|
||||
case "DpadSnap2":
|
||||
return Lang.menu[192].Value;
|
||||
case "DpadSnap3":
|
||||
return Lang.menu[193].Value;
|
||||
case "DpadSnap4":
|
||||
return Lang.menu[194].Value;
|
||||
case "Grapple":
|
||||
return Lang.menu[155].Value;
|
||||
case "Hotbar1":
|
||||
return Lang.menu[176].Value;
|
||||
case "Hotbar10":
|
||||
return Lang.menu[185].Value;
|
||||
case "Hotbar2":
|
||||
return Lang.menu[177].Value;
|
||||
case "Hotbar3":
|
||||
return Lang.menu[178].Value;
|
||||
case "Hotbar4":
|
||||
return Lang.menu[179].Value;
|
||||
case "Hotbar5":
|
||||
return Lang.menu[180].Value;
|
||||
case "Hotbar6":
|
||||
return Lang.menu[181].Value;
|
||||
case "Hotbar7":
|
||||
return Lang.menu[182].Value;
|
||||
case "Hotbar8":
|
||||
return Lang.menu[183].Value;
|
||||
case "Hotbar9":
|
||||
return Lang.menu[184].Value;
|
||||
case "HotbarMinus":
|
||||
return Lang.menu[174].Value;
|
||||
case "HotbarPlus":
|
||||
return Lang.menu[175].Value;
|
||||
case "Inventory":
|
||||
return Lang.menu[154].Value;
|
||||
case "Jump":
|
||||
return Lang.menu[152].Value;
|
||||
case "Left":
|
||||
return Lang.menu[150].Value;
|
||||
case "LockOn":
|
||||
return Lang.menu[231].Value;
|
||||
case "MapAlphaDown":
|
||||
return Lang.menu[170].Value;
|
||||
case "MapAlphaUp":
|
||||
return Lang.menu[171].Value;
|
||||
case "MapFull":
|
||||
return Lang.menu[173].Value;
|
||||
case "MapStyle":
|
||||
return Lang.menu[172].Value;
|
||||
case "MapZoomIn":
|
||||
return Lang.menu[168].Value;
|
||||
case "MapZoomOut":
|
||||
return Lang.menu[169].Value;
|
||||
case "MouseLeft":
|
||||
return Lang.menu[162].Value;
|
||||
case "MouseRight":
|
||||
return Lang.menu[163].Value;
|
||||
case "QuickBuff":
|
||||
return Lang.menu[157].Value;
|
||||
case "QuickHeal":
|
||||
return Lang.menu[159].Value;
|
||||
case "QuickMana":
|
||||
return Lang.menu[156].Value;
|
||||
case "QuickMount":
|
||||
return Lang.menu[158].Value;
|
||||
case "RadialHotbar":
|
||||
return Lang.menu[190].Value;
|
||||
case "RadialQuickbar":
|
||||
return Lang.menu[244].Value;
|
||||
case "Right":
|
||||
return Lang.menu[151].Value;
|
||||
case "SmartCursor":
|
||||
return Lang.menu[161].Value;
|
||||
case "SmartSelect":
|
||||
return Lang.menu[160].Value;
|
||||
case "Throw":
|
||||
return Lang.menu[153].Value;
|
||||
case "Up":
|
||||
return Lang.menu[148].Value;
|
||||
case "ViewZoomIn":
|
||||
return Language.GetTextValue("UI.ZoomIn");
|
||||
case "ViewZoomOut":
|
||||
return Language.GetTextValue("UI.ZoomOut");
|
||||
default:
|
||||
return this._keybind;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
46
GameContent/UI/Elements/UIKeybindingSimpleListItem.cs
Normal file
46
GameContent/UI/Elements/UIKeybindingSimpleListItem.cs
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSimpleListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSimpleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _GetTextFunction;
|
||||
|
||||
public UIKeybindingSimpleListItem(Func<string> getText, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._GetTextFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(this.IsMouseHovering ? Color.White : Color.Silver, Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettings2Panel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
string text = this._GetTextFunction();
|
||||
Vector2 stringSize = ChatManager.GetStringSize(Main.fontItemStack, text, baseScale);
|
||||
position.X = (float) ((double) dimensions.X + (double) dimensions.Width / 2.0 - (double) stringSize.X / 2.0);
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, text, position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
}
|
||||
}
|
||||
}
|
90
GameContent/UI/Elements/UIKeybindingSliderItem.cs
Normal file
90
GameContent/UI/Elements/UIKeybindingSliderItem.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingSliderItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingSliderItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<float> _GetStatusFunction;
|
||||
private Action<float> _SlideKeyboardAction;
|
||||
private Action _SlideGamepadAction;
|
||||
private int _sliderIDInPage;
|
||||
private Texture2D _toggleTexture;
|
||||
|
||||
public UIKeybindingSliderItem(
|
||||
Func<string> getText,
|
||||
Func<float> getStatus,
|
||||
Action<float> setStatusKeyboard,
|
||||
Action setStatusGamepad,
|
||||
int sliderIDInPage,
|
||||
Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = TextureManager.Load("Images/UI/Settings_Toggle");
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._GetStatusFunction = getStatus != null ? getStatus : (Func<float>) (() => 0.0f);
|
||||
this._SlideKeyboardAction = setStatusKeyboard != null ? setStatusKeyboard : (Action<float>) (s => { });
|
||||
this._SlideGamepadAction = setStatusGamepad != null ? setStatusGamepad : (Action) (() => { });
|
||||
this._sliderIDInPage = sliderIDInPage;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
int lockState = 0;
|
||||
IngameOptions.rightHover = -1;
|
||||
if (!Main.mouseLeft)
|
||||
IngameOptions.rightLock = -1;
|
||||
if (IngameOptions.rightLock == this._sliderIDInPage)
|
||||
lockState = 1;
|
||||
else if (IngameOptions.rightLock != -1)
|
||||
lockState = 2;
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2 = new Vector2(dimensions.X, dimensions.Y);
|
||||
bool flag = this.IsMouseHovering;
|
||||
if (lockState == 1)
|
||||
flag = true;
|
||||
if (lockState == 2)
|
||||
flag = false;
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (flag ? Color.White : Color.Silver), Color.White, flag ? 0.5f : 0.0f);
|
||||
Color color = flag ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
Main.colorBarTexture.Frame();
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - 10.0), dimensions.Y + 10f + num1);
|
||||
IngameOptions.valuePosition = position;
|
||||
float num3 = IngameOptions.DrawValueBar(spriteBatch, 1f, this._GetStatusFunction(), lockState);
|
||||
if (IngameOptions.inBar || IngameOptions.rightLock == this._sliderIDInPage)
|
||||
{
|
||||
IngameOptions.rightHover = this._sliderIDInPage;
|
||||
if (PlayerInput.Triggers.Current.MouseLeft && PlayerInput.CurrentProfile.AllowEditting && !PlayerInput.UsingGamepad && IngameOptions.rightLock == this._sliderIDInPage)
|
||||
this._SlideKeyboardAction(num3);
|
||||
}
|
||||
if (IngameOptions.rightHover != -1 && IngameOptions.rightLock == -1)
|
||||
IngameOptions.rightLock = IngameOptions.rightHover;
|
||||
if (!this.IsMouseHovering || !PlayerInput.CurrentProfile.AllowEditting)
|
||||
return;
|
||||
this._SlideGamepadAction();
|
||||
}
|
||||
}
|
||||
}
|
53
GameContent/UI/Elements/UIKeybindingToggleListItem.cs
Normal file
53
GameContent/UI/Elements/UIKeybindingToggleListItem.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIKeybindingToggleListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIKeybindingToggleListItem : UIElement
|
||||
{
|
||||
private Color _color;
|
||||
private Func<string> _TextDisplayFunction;
|
||||
private Func<bool> _IsOnFunction;
|
||||
private Texture2D _toggleTexture;
|
||||
|
||||
public UIKeybindingToggleListItem(Func<string> getText, Func<bool> getStatus, Color color)
|
||||
{
|
||||
this._color = color;
|
||||
this._toggleTexture = TextureManager.Load("Images/UI/Settings_Toggle");
|
||||
this._TextDisplayFunction = getText != null ? getText : (Func<string>) (() => "???");
|
||||
this._IsOnFunction = getStatus != null ? getStatus : (Func<bool>) (() => false);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
float num1 = 6f;
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
float num2 = dimensions.Width + 1f;
|
||||
Vector2 vector2_1 = new Vector2(dimensions.X, dimensions.Y);
|
||||
Vector2 baseScale = new Vector2(0.8f);
|
||||
Color baseColor = Color.Lerp(false ? Color.Gold : (this.IsMouseHovering ? Color.White : Color.Silver), Color.White, this.IsMouseHovering ? 0.5f : 0.0f);
|
||||
Color color = this.IsMouseHovering ? this._color : this._color.MultiplyRGBA(new Color(180, 180, 180));
|
||||
Vector2 position = vector2_1;
|
||||
Utils.DrawSettingsPanel(spriteBatch, position, num2, color);
|
||||
position.X += 8f;
|
||||
position.Y += 2f + num1;
|
||||
ChatManager.DrawColorCodedStringWithShadow(spriteBatch, Main.fontItemStack, this._TextDisplayFunction(), position, baseColor, 0.0f, Vector2.Zero, baseScale, num2);
|
||||
position.X -= 17f;
|
||||
Rectangle rectangle = new Rectangle(this._IsOnFunction() ? (this._toggleTexture.Width - 2) / 2 + 2 : 0, 0, (this._toggleTexture.Width - 2) / 2, this._toggleTexture.Height);
|
||||
Vector2 vector2_2 = new Vector2((float) rectangle.Width, 0.0f);
|
||||
position = new Vector2((float) ((double) dimensions.X + (double) dimensions.Width - (double) vector2_2.X - 10.0), dimensions.Y + 2f + num1);
|
||||
spriteBatch.Draw(this._toggleTexture, position, new Rectangle?(rectangle), Color.White, 0.0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
156
GameContent/UI/Elements/UIList.cs
Normal file
156
GameContent/UI/Elements/UIList.cs
Normal file
|
@ -0,0 +1,156 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIList
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIList : UIElement
|
||||
{
|
||||
protected List<UIElement> _items = new List<UIElement>();
|
||||
protected UIScrollbar _scrollbar;
|
||||
private UIElement _innerList = (UIElement) new UIList.UIInnerList();
|
||||
private float _innerListHeight;
|
||||
public float ListPadding = 5f;
|
||||
|
||||
public int Count => this._items.Count;
|
||||
|
||||
public UIList()
|
||||
{
|
||||
this._innerList.OverflowHidden = false;
|
||||
this._innerList.Width.Set(0.0f, 1f);
|
||||
this._innerList.Height.Set(0.0f, 1f);
|
||||
this.OverflowHidden = true;
|
||||
this.Append(this._innerList);
|
||||
}
|
||||
|
||||
public float GetTotalHeight() => this._innerListHeight;
|
||||
|
||||
public void Goto(UIList.ElementSearchMethod searchMethod)
|
||||
{
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
if (searchMethod(this._items[index]))
|
||||
{
|
||||
this._scrollbar.ViewPosition = this._items[index].Top.Pixels;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Add(UIElement item)
|
||||
{
|
||||
this._items.Add(item);
|
||||
this._innerList.Append(item);
|
||||
this.UpdateOrder();
|
||||
this._innerList.Recalculate();
|
||||
}
|
||||
|
||||
public virtual bool Remove(UIElement item)
|
||||
{
|
||||
this._innerList.RemoveChild(item);
|
||||
this.UpdateOrder();
|
||||
return this._items.Remove(item);
|
||||
}
|
||||
|
||||
public virtual void Clear()
|
||||
{
|
||||
this._innerList.RemoveAllChildren();
|
||||
this._items.Clear();
|
||||
}
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
base.Recalculate();
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public override void ScrollWheel(UIScrollWheelEvent evt)
|
||||
{
|
||||
base.ScrollWheel(evt);
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.ViewPosition -= (float) evt.ScrollWheelValue;
|
||||
}
|
||||
|
||||
public override void RecalculateChildren()
|
||||
{
|
||||
base.RecalculateChildren();
|
||||
float pixels = 0.0f;
|
||||
for (int index = 0; index < this._items.Count; ++index)
|
||||
{
|
||||
this._items[index].Top.Set(pixels, 0.0f);
|
||||
this._items[index].Recalculate();
|
||||
CalculatedStyle outerDimensions = this._items[index].GetOuterDimensions();
|
||||
pixels += outerDimensions.Height + this.ListPadding;
|
||||
}
|
||||
this._innerListHeight = pixels;
|
||||
}
|
||||
|
||||
private void UpdateScrollbar()
|
||||
{
|
||||
if (this._scrollbar == null)
|
||||
return;
|
||||
this._scrollbar.SetView(this.GetInnerDimensions().Height, this._innerListHeight);
|
||||
}
|
||||
|
||||
public void SetScrollbar(UIScrollbar scrollbar)
|
||||
{
|
||||
this._scrollbar = scrollbar;
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public void UpdateOrder()
|
||||
{
|
||||
this._items.Sort(new Comparison<UIElement>(this.SortMethod));
|
||||
this.UpdateScrollbar();
|
||||
}
|
||||
|
||||
public int SortMethod(UIElement item1, UIElement item2) => item1.CompareTo((object) item2);
|
||||
|
||||
public override List<SnapPoint> GetSnapPoints()
|
||||
{
|
||||
List<SnapPoint> snapPointList = new List<SnapPoint>();
|
||||
SnapPoint point;
|
||||
if (this.GetSnapPoint(out point))
|
||||
snapPointList.Add(point);
|
||||
foreach (UIElement uiElement in this._items)
|
||||
snapPointList.AddRange((IEnumerable<SnapPoint>) uiElement.GetSnapPoints());
|
||||
return snapPointList;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._scrollbar != null)
|
||||
this._innerList.Top.Set(-this._scrollbar.GetValue(), 0.0f);
|
||||
this.Recalculate();
|
||||
}
|
||||
|
||||
public delegate bool ElementSearchMethod(UIElement element);
|
||||
|
||||
private class UIInnerList : UIElement
|
||||
{
|
||||
public override bool ContainsPoint(Vector2 point) => true;
|
||||
|
||||
protected override void DrawChildren(SpriteBatch spriteBatch)
|
||||
{
|
||||
Vector2 position1 = this.Parent.GetDimensions().Position();
|
||||
Vector2 dimensions1 = new Vector2(this.Parent.GetDimensions().Width, this.Parent.GetDimensions().Height);
|
||||
foreach (UIElement element in this.Elements)
|
||||
{
|
||||
Vector2 position2 = element.GetDimensions().Position();
|
||||
Vector2 dimensions2 = new Vector2(element.GetDimensions().Width, element.GetDimensions().Height);
|
||||
if (Collision.CheckAABBvAABBCollision(position1, dimensions1, position2, dimensions2))
|
||||
element.Draw(spriteBatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
56
GameContent/UI/Elements/UIPanel.cs
Normal file
56
GameContent/UI/Elements/UIPanel.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIPanel
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIPanel : UIElement
|
||||
{
|
||||
private static int CORNER_SIZE = 12;
|
||||
private static int BAR_SIZE = 4;
|
||||
private static Texture2D _borderTexture;
|
||||
private static Texture2D _backgroundTexture;
|
||||
public Color BorderColor = Color.Black;
|
||||
public Color BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
|
||||
public UIPanel()
|
||||
{
|
||||
if (UIPanel._borderTexture == null)
|
||||
UIPanel._borderTexture = TextureManager.Load("Images/UI/PanelBorder");
|
||||
if (UIPanel._backgroundTexture == null)
|
||||
UIPanel._backgroundTexture = TextureManager.Load("Images/UI/PanelBackground");
|
||||
this.SetPadding((float) UIPanel.CORNER_SIZE);
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Texture2D texture, Color color)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Point point1 = new Point((int) dimensions.X, (int) dimensions.Y);
|
||||
Point point2 = new Point(point1.X + (int) dimensions.Width - UIPanel.CORNER_SIZE, point1.Y + (int) dimensions.Height - UIPanel.CORNER_SIZE);
|
||||
int width = point2.X - point1.X - UIPanel.CORNER_SIZE;
|
||||
int height = point2.Y - point1.Y - UIPanel.CORNER_SIZE;
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(0, 0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, 0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point2.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(0, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point2.Y, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point1.Y, width, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, 0, UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point2.Y, width, UIPanel.CORNER_SIZE), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X, point1.Y + UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, height), new Rectangle?(new Rectangle(0, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point2.X, point1.Y + UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, height), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE + UIPanel.BAR_SIZE, UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(point1.X + UIPanel.CORNER_SIZE, point1.Y + UIPanel.CORNER_SIZE, width, height), new Rectangle?(new Rectangle(UIPanel.CORNER_SIZE, UIPanel.CORNER_SIZE, UIPanel.BAR_SIZE, UIPanel.BAR_SIZE)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this.DrawPanel(spriteBatch, UIPanel._backgroundTexture, this.BackgroundColor);
|
||||
this.DrawPanel(spriteBatch, UIPanel._borderTexture, this.BorderColor);
|
||||
}
|
||||
}
|
||||
}
|
50
GameContent/UI/Elements/UIProgressBar.cs
Normal file
50
GameContent/UI/Elements/UIProgressBar.cs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIProgressBar
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIProgressBar : UIElement
|
||||
{
|
||||
private UIProgressBar.UIInnerProgressBar _progressBar = new UIProgressBar.UIInnerProgressBar();
|
||||
private float _visualProgress;
|
||||
private float _targetProgress;
|
||||
|
||||
public UIProgressBar()
|
||||
{
|
||||
this._progressBar.Height.Precent = 1f;
|
||||
this._progressBar.Recalculate();
|
||||
this.Append((UIElement) this._progressBar);
|
||||
}
|
||||
|
||||
public void SetProgress(float value)
|
||||
{
|
||||
this._targetProgress = value;
|
||||
if ((double) value >= (double) this._visualProgress)
|
||||
return;
|
||||
this._visualProgress = value;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._visualProgress = (float) ((double) this._visualProgress * 0.949999988079071 + 0.0500000007450581 * (double) this._targetProgress);
|
||||
this._progressBar.Width.Precent = this._visualProgress;
|
||||
this._progressBar.Recalculate();
|
||||
}
|
||||
|
||||
private class UIInnerProgressBar : UIElement
|
||||
{
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
spriteBatch.Draw(Main.magicPixel, new Vector2(dimensions.X, dimensions.Y), new Rectangle?(), Color.Blue, 0.0f, Vector2.Zero, new Vector2(dimensions.Width, dimensions.Height / 1000f), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
113
GameContent/UI/Elements/UIScrollbar.cs
Normal file
113
GameContent/UI/Elements/UIScrollbar.cs
Normal file
|
@ -0,0 +1,113 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIScrollbar
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIScrollbar : UIElement
|
||||
{
|
||||
private float _viewPosition;
|
||||
private float _viewSize = 1f;
|
||||
private float _maxViewSize = 20f;
|
||||
private bool _isDragging;
|
||||
private bool _isHoveringOverHandle;
|
||||
private float _dragYOffset;
|
||||
private Texture2D _texture;
|
||||
private Texture2D _innerTexture;
|
||||
|
||||
public float ViewPosition
|
||||
{
|
||||
get => this._viewPosition;
|
||||
set => this._viewPosition = MathHelper.Clamp(value, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
|
||||
public UIScrollbar()
|
||||
{
|
||||
this.Width.Set(20f, 0.0f);
|
||||
this.MaxWidth.Set(20f, 0.0f);
|
||||
this._texture = TextureManager.Load("Images/UI/Scrollbar");
|
||||
this._innerTexture = TextureManager.Load("Images/UI/ScrollbarInner");
|
||||
this.PaddingTop = 5f;
|
||||
this.PaddingBottom = 5f;
|
||||
}
|
||||
|
||||
public void SetView(float viewSize, float maxViewSize)
|
||||
{
|
||||
viewSize = MathHelper.Clamp(viewSize, 0.0f, maxViewSize);
|
||||
this._viewPosition = MathHelper.Clamp(this._viewPosition, 0.0f, maxViewSize - viewSize);
|
||||
this._viewSize = viewSize;
|
||||
this._maxViewSize = maxViewSize;
|
||||
}
|
||||
|
||||
public float GetValue() => this._viewPosition;
|
||||
|
||||
private Rectangle GetHandleRectangle()
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if ((double) this._maxViewSize == 0.0 && (double) this._viewSize == 0.0)
|
||||
{
|
||||
this._viewSize = 1f;
|
||||
this._maxViewSize = 1f;
|
||||
}
|
||||
return new Rectangle((int) innerDimensions.X, (int) ((double) innerDimensions.Y + (double) innerDimensions.Height * ((double) this._viewPosition / (double) this._maxViewSize)) - 3, 20, (int) ((double) innerDimensions.Height * ((double) this._viewSize / (double) this._maxViewSize)) + 7);
|
||||
}
|
||||
|
||||
private void DrawBar(
|
||||
SpriteBatch spriteBatch,
|
||||
Texture2D texture,
|
||||
Rectangle dimensions,
|
||||
Color color)
|
||||
{
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y - 6, dimensions.Width, 6), new Rectangle?(new Rectangle(0, 0, texture.Width, 6)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y, dimensions.Width, dimensions.Height), new Rectangle?(new Rectangle(0, 6, texture.Width, 4)), color);
|
||||
spriteBatch.Draw(texture, new Rectangle(dimensions.X, dimensions.Y + dimensions.Height, dimensions.Width, 6), new Rectangle?(new Rectangle(0, texture.Height - 6, texture.Width, 6)), color);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
if (this._isDragging)
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - this._dragYOffset) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
Vector2 mousePosition = UserInterface.ActiveInstance.MousePosition;
|
||||
int num = this._isHoveringOverHandle ? 1 : 0;
|
||||
this._isHoveringOverHandle = handleRectangle.Contains(new Point((int) mousePosition.X, (int) mousePosition.Y));
|
||||
if (num == 0 && this._isHoveringOverHandle && Main.hasFocus)
|
||||
Main.PlaySound(12);
|
||||
this.DrawBar(spriteBatch, this._texture, dimensions.ToRectangle(), Color.White);
|
||||
this.DrawBar(spriteBatch, this._innerTexture, handleRectangle, Color.White * (this._isDragging || this._isHoveringOverHandle ? 1f : 0.85f));
|
||||
}
|
||||
|
||||
public override void MouseDown(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseDown(evt);
|
||||
if (evt.Target != this)
|
||||
return;
|
||||
Rectangle handleRectangle = this.GetHandleRectangle();
|
||||
if (handleRectangle.Contains(new Point((int) evt.MousePosition.X, (int) evt.MousePosition.Y)))
|
||||
{
|
||||
this._isDragging = true;
|
||||
this._dragYOffset = evt.MousePosition.Y - (float) handleRectangle.Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
this._viewPosition = MathHelper.Clamp((UserInterface.ActiveInstance.MousePosition.Y - innerDimensions.Y - (float) (handleRectangle.Height >> 1)) / innerDimensions.Height * this._maxViewSize, 0.0f, this._maxViewSize - this._viewSize);
|
||||
}
|
||||
}
|
||||
|
||||
public override void MouseUp(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseUp(evt);
|
||||
this._isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
75
GameContent/UI/Elements/UIText.cs
Normal file
75
GameContent/UI/Elements/UIText.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIText
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIText : UIElement
|
||||
{
|
||||
private object _text = (object) "";
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private bool _isLarge;
|
||||
private Color _color = Color.White;
|
||||
|
||||
public string Text => this._text.ToString();
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UIText(string text, float textScale = 1f, bool large = false) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public UIText(LocalizedText text, float textScale = 1f, bool large = false) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.InternalSetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(string text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(LocalizedText text) => this.InternalSetText((object) text, this._textScale, this._isLarge);
|
||||
|
||||
public void SetText(string text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
public void SetText(LocalizedText text, float textScale, bool large) => this.InternalSetText((object) text, textScale, large);
|
||||
|
||||
private void InternalSetText(object text, float textScale, bool large)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this._isLarge = large;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
}
|
||||
}
|
83
GameContent/UI/Elements/UITextBox.cs
Normal file
83
GameContent/UI/Elements/UITextBox.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextBox
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
internal class UITextBox : UITextPanel<string>
|
||||
{
|
||||
private int _cursor;
|
||||
private int _frameCount;
|
||||
private int _maxLength = 20;
|
||||
|
||||
public UITextBox(string text, float textScale = 1f, bool large = false)
|
||||
: base(text, textScale, large)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(string text)
|
||||
{
|
||||
this.SetText(this.Text.Insert(this._cursor, text));
|
||||
this._cursor += text.Length;
|
||||
}
|
||||
|
||||
public override void SetText(string text, float textScale, bool large)
|
||||
{
|
||||
if (text.ToString().Length > this._maxLength)
|
||||
text = text.ToString().Substring(0, this._maxLength);
|
||||
base.SetText(text, textScale, large);
|
||||
this._cursor = Math.Min(this.Text.Length, this._cursor);
|
||||
}
|
||||
|
||||
public void SetTextMaxLength(int maxLength) => this._maxLength = maxLength;
|
||||
|
||||
public void Backspace()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
this.SetText(this.Text.Substring(0, this.Text.Length - 1));
|
||||
}
|
||||
|
||||
public void CursorLeft()
|
||||
{
|
||||
if (this._cursor == 0)
|
||||
return;
|
||||
--this._cursor;
|
||||
}
|
||||
|
||||
public void CursorRight()
|
||||
{
|
||||
if (this._cursor >= this.Text.Length)
|
||||
return;
|
||||
++this._cursor;
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
this._cursor = this.Text.Length;
|
||||
base.DrawSelf(spriteBatch);
|
||||
++this._frameCount;
|
||||
if ((this._frameCount %= 40) > 20)
|
||||
return;
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
Vector2 vector2 = new Vector2((this.IsLarge ? Main.fontDeathText : Main.fontMouseText).MeasureString(this.Text.Substring(0, this._cursor)).X, this.IsLarge ? 32f : 16f) * this.TextScale;
|
||||
if (this.IsLarge)
|
||||
pos.Y -= 8f * this.TextScale;
|
||||
else
|
||||
pos.Y += 2f * this.TextScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this.TextSize.X) * 0.5 + (double) vector2.X - (this.IsLarge ? 8.0 : 4.0) * (double) this.TextScale + 6.0);
|
||||
if (this.IsLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, "|", pos, this.TextColor, this.TextScale);
|
||||
}
|
||||
}
|
||||
}
|
84
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
84
GameContent/UI/Elements/UITextPanel`1.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UITextPanel`1
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UITextPanel<T> : UIPanel
|
||||
{
|
||||
private T _text;
|
||||
private float _textScale = 1f;
|
||||
private Vector2 _textSize = Vector2.Zero;
|
||||
private bool _isLarge;
|
||||
private Color _color = Color.White;
|
||||
private bool _drawPanel = true;
|
||||
|
||||
public bool IsLarge => this._isLarge;
|
||||
|
||||
public bool DrawPanel
|
||||
{
|
||||
get => this._drawPanel;
|
||||
set => this._drawPanel = value;
|
||||
}
|
||||
|
||||
public float TextScale
|
||||
{
|
||||
get => this._textScale;
|
||||
set => this._textScale = value;
|
||||
}
|
||||
|
||||
public Vector2 TextSize => this._textSize;
|
||||
|
||||
public string Text => (object) this._text != null ? this._text.ToString() : "";
|
||||
|
||||
public Color TextColor
|
||||
{
|
||||
get => this._color;
|
||||
set => this._color = value;
|
||||
}
|
||||
|
||||
public UITextPanel(T text, float textScale = 1f, bool large = false) => this.SetText(text, textScale, large);
|
||||
|
||||
public override void Recalculate()
|
||||
{
|
||||
this.SetText(this._text, this._textScale, this._isLarge);
|
||||
base.Recalculate();
|
||||
}
|
||||
|
||||
public void SetText(T text) => this.SetText(text, this._textScale, this._isLarge);
|
||||
|
||||
public virtual void SetText(T text, float textScale, bool large)
|
||||
{
|
||||
Vector2 vector2 = new Vector2((large ? Main.fontDeathText : Main.fontMouseText).MeasureString(text.ToString()).X, large ? 32f : 16f) * textScale;
|
||||
this._text = text;
|
||||
this._textScale = textScale;
|
||||
this._textSize = vector2;
|
||||
this._isLarge = large;
|
||||
this.MinWidth.Set(vector2.X + this.PaddingLeft + this.PaddingRight, 0.0f);
|
||||
this.MinHeight.Set(vector2.Y + this.PaddingTop + this.PaddingBottom, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (this._drawPanel)
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
Vector2 pos = innerDimensions.Position();
|
||||
if (this._isLarge)
|
||||
pos.Y -= 10f * this._textScale * this._textScale;
|
||||
else
|
||||
pos.Y -= 2f * this._textScale;
|
||||
pos.X += (float) (((double) innerDimensions.Width - (double) this._textSize.X) * 0.5);
|
||||
if (this._isLarge)
|
||||
Utils.DrawBorderStringBig(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
else
|
||||
Utils.DrawBorderString(spriteBatch, this.Text, pos, this._color, this._textScale);
|
||||
}
|
||||
}
|
||||
}
|
71
GameContent/UI/Elements/UIToggleImage.cs
Normal file
71
GameContent/UI/Elements/UIToggleImage.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIToggleImage
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIToggleImage : UIElement
|
||||
{
|
||||
private Texture2D _onTexture;
|
||||
private Texture2D _offTexture;
|
||||
private int _drawWidth;
|
||||
private int _drawHeight;
|
||||
private Point _onTextureOffset = Point.Zero;
|
||||
private Point _offTextureOffset = Point.Zero;
|
||||
private bool _isOn;
|
||||
|
||||
public bool IsOn => this._isOn;
|
||||
|
||||
public UIToggleImage(
|
||||
Texture2D texture,
|
||||
int width,
|
||||
int height,
|
||||
Point onTextureOffset,
|
||||
Point offTextureOffset)
|
||||
{
|
||||
this._onTexture = texture;
|
||||
this._offTexture = texture;
|
||||
this._offTextureOffset = offTextureOffset;
|
||||
this._onTextureOffset = onTextureOffset;
|
||||
this._drawWidth = width;
|
||||
this._drawHeight = height;
|
||||
this.Width.Set((float) width, 0.0f);
|
||||
this.Height.Set((float) height, 0.0f);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
CalculatedStyle dimensions = this.GetDimensions();
|
||||
Texture2D texture;
|
||||
Point point;
|
||||
if (this._isOn)
|
||||
{
|
||||
texture = this._onTexture;
|
||||
point = this._onTextureOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = this._offTexture;
|
||||
point = this._offTextureOffset;
|
||||
}
|
||||
Color color = this.IsMouseHovering ? Color.White : Color.Silver;
|
||||
spriteBatch.Draw(texture, new Rectangle((int) dimensions.X, (int) dimensions.Y, this._drawWidth, this._drawHeight), new Rectangle?(new Rectangle(point.X, point.Y, this._drawWidth, this._drawHeight)), color);
|
||||
}
|
||||
|
||||
public override void Click(UIMouseEvent evt)
|
||||
{
|
||||
this.Toggle();
|
||||
base.Click(evt);
|
||||
}
|
||||
|
||||
public void SetState(bool value) => this._isOn = value;
|
||||
|
||||
public void Toggle() => this._isOn = !this._isOn;
|
||||
}
|
||||
}
|
297
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
297
GameContent/UI/Elements/UIWorldListItem.cs
Normal file
|
@ -0,0 +1,297 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.Elements.UIWorldListItem
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.OS;
|
||||
using Terraria.Graphics;
|
||||
using Terraria.IO;
|
||||
using Terraria.Localization;
|
||||
using Terraria.Social;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.UI.Elements
|
||||
{
|
||||
public class UIWorldListItem : UIPanel
|
||||
{
|
||||
private WorldFileData _data;
|
||||
private Texture2D _dividerTexture;
|
||||
private Texture2D _innerPanelTexture;
|
||||
private UIImage _worldIcon;
|
||||
private UIText _buttonLabel;
|
||||
private UIText _deleteButtonLabel;
|
||||
private Texture2D _buttonCloudActiveTexture;
|
||||
private Texture2D _buttonCloudInactiveTexture;
|
||||
private Texture2D _buttonFavoriteActiveTexture;
|
||||
private Texture2D _buttonFavoriteInactiveTexture;
|
||||
private Texture2D _buttonPlayTexture;
|
||||
private Texture2D _buttonSeedTexture;
|
||||
private Texture2D _buttonDeleteTexture;
|
||||
private UIImageButton _deleteButton;
|
||||
|
||||
public bool IsFavorite => this._data.IsFavorite;
|
||||
|
||||
public UIWorldListItem(WorldFileData data, int snapPointIndex)
|
||||
{
|
||||
this._data = data;
|
||||
this.LoadTextures();
|
||||
this.InitializeAppearance();
|
||||
this._worldIcon = new UIImage(this.GetIcon());
|
||||
this._worldIcon.Left.Set(4f, 0.0f);
|
||||
this._worldIcon.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.Append((UIElement) this._worldIcon);
|
||||
float pixels1 = 4f;
|
||||
UIImageButton uiImageButton1 = new UIImageButton(this._buttonPlayTexture);
|
||||
uiImageButton1.VAlign = 1f;
|
||||
uiImageButton1.Left.Set(pixels1, 0.0f);
|
||||
uiImageButton1.OnClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
this.OnDoubleClick += new UIElement.MouseEvent(this.PlayGame);
|
||||
uiImageButton1.OnMouseOver += new UIElement.MouseEvent(this.PlayMouseOver);
|
||||
uiImageButton1.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
this.Append((UIElement) uiImageButton1);
|
||||
float pixels2 = pixels1 + 24f;
|
||||
UIImageButton uiImageButton2 = new UIImageButton(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
uiImageButton2.VAlign = 1f;
|
||||
uiImageButton2.Left.Set(pixels2, 0.0f);
|
||||
uiImageButton2.OnClick += new UIElement.MouseEvent(this.FavoriteButtonClick);
|
||||
uiImageButton2.OnMouseOver += new UIElement.MouseEvent(this.FavoriteMouseOver);
|
||||
uiImageButton2.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton2.SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
this.Append((UIElement) uiImageButton2);
|
||||
float pixels3 = pixels2 + 24f;
|
||||
if (SocialAPI.Cloud != null)
|
||||
{
|
||||
UIImageButton uiImageButton3 = new UIImageButton(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
uiImageButton3.VAlign = 1f;
|
||||
uiImageButton3.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton3.OnClick += new UIElement.MouseEvent(this.CloudButtonClick);
|
||||
uiImageButton3.OnMouseOver += new UIElement.MouseEvent(this.CloudMouseOver);
|
||||
uiImageButton3.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton3.SetSnapPoint("Cloud", snapPointIndex);
|
||||
this.Append((UIElement) uiImageButton3);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
if (Main.UseSeedUI && this._data.WorldGeneratorVersion != 0UL)
|
||||
{
|
||||
UIImageButton uiImageButton4 = new UIImageButton(this._buttonSeedTexture);
|
||||
uiImageButton4.VAlign = 1f;
|
||||
uiImageButton4.Left.Set(pixels3, 0.0f);
|
||||
uiImageButton4.OnClick += new UIElement.MouseEvent(this.SeedButtonClick);
|
||||
uiImageButton4.OnMouseOver += new UIElement.MouseEvent(this.SeedMouseOver);
|
||||
uiImageButton4.OnMouseOut += new UIElement.MouseEvent(this.ButtonMouseOut);
|
||||
uiImageButton4.SetSnapPoint("Seed", snapPointIndex);
|
||||
this.Append((UIElement) uiImageButton4);
|
||||
pixels3 += 24f;
|
||||
}
|
||||
UIImageButton uiImageButton5 = new UIImageButton(this._buttonDeleteTexture);
|
||||
uiImageButton5.VAlign = 1f;
|
||||
uiImageButton5.HAlign = 1f;
|
||||
uiImageButton5.OnClick += new UIElement.MouseEvent(this.DeleteButtonClick);
|
||||
uiImageButton5.OnMouseOver += new UIElement.MouseEvent(this.DeleteMouseOver);
|
||||
uiImageButton5.OnMouseOut += new UIElement.MouseEvent(this.DeleteMouseOut);
|
||||
this._deleteButton = uiImageButton5;
|
||||
if (!this._data.IsFavorite)
|
||||
this.Append((UIElement) uiImageButton5);
|
||||
float pixels4 = pixels3 + 4f;
|
||||
this._buttonLabel = new UIText("");
|
||||
this._buttonLabel.VAlign = 1f;
|
||||
this._buttonLabel.Left.Set(pixels4, 0.0f);
|
||||
this._buttonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._buttonLabel);
|
||||
this._deleteButtonLabel = new UIText("");
|
||||
this._deleteButtonLabel.VAlign = 1f;
|
||||
this._deleteButtonLabel.HAlign = 1f;
|
||||
this._deleteButtonLabel.Left.Set(-30f, 0.0f);
|
||||
this._deleteButtonLabel.Top.Set(-3f, 0.0f);
|
||||
this.Append((UIElement) this._deleteButtonLabel);
|
||||
uiImageButton1.SetSnapPoint("Play", snapPointIndex);
|
||||
uiImageButton2.SetSnapPoint("Favorite", snapPointIndex);
|
||||
uiImageButton5.SetSnapPoint("Delete", snapPointIndex);
|
||||
}
|
||||
|
||||
private void LoadTextures()
|
||||
{
|
||||
this._dividerTexture = TextureManager.Load("Images/UI/Divider");
|
||||
this._innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground");
|
||||
this._buttonCloudActiveTexture = TextureManager.Load("Images/UI/ButtonCloudActive");
|
||||
this._buttonCloudInactiveTexture = TextureManager.Load("Images/UI/ButtonCloudInactive");
|
||||
this._buttonFavoriteActiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteActive");
|
||||
this._buttonFavoriteInactiveTexture = TextureManager.Load("Images/UI/ButtonFavoriteInactive");
|
||||
this._buttonPlayTexture = TextureManager.Load("Images/UI/ButtonPlay");
|
||||
this._buttonSeedTexture = TextureManager.Load("Images/UI/ButtonSeed");
|
||||
this._buttonDeleteTexture = TextureManager.Load("Images/UI/ButtonDelete");
|
||||
}
|
||||
|
||||
private void InitializeAppearance()
|
||||
{
|
||||
this.Height.Set(96f, 0.0f);
|
||||
this.Width.Set(0.0f, 1f);
|
||||
this.SetPadding(6f);
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private Texture2D GetIcon() => TextureManager.Load("Images/UI/Icon" + (this._data.IsHardMode ? "Hallow" : "") + (this._data.HasCorruption ? "Corruption" : "Crimson"));
|
||||
|
||||
private void FavoriteMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsFavorite)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
}
|
||||
|
||||
private void CloudMouseOver(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.Play"));
|
||||
|
||||
private void SeedMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText(Language.GetTextValue("UI.CopySeed", (object) this._data.SeedText));
|
||||
|
||||
private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText(Language.GetTextValue("UI.Delete"));
|
||||
|
||||
private void DeleteMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._deleteButtonLabel.SetText("");
|
||||
|
||||
private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement) => this._buttonLabel.SetText("");
|
||||
|
||||
private void CloudButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (this._data.IsCloudSave)
|
||||
this._data.MoveToLocal();
|
||||
else
|
||||
this._data.MoveToCloud();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsCloudSave ? this._buttonCloudActiveTexture : this._buttonCloudInactiveTexture);
|
||||
if (this._data.IsCloudSave)
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveOffCloud"));
|
||||
else
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.MoveToCloud"));
|
||||
}
|
||||
|
||||
private void DeleteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
for (int index = 0; index < Main.WorldList.Count; ++index)
|
||||
{
|
||||
if (Main.WorldList[index] == this._data)
|
||||
{
|
||||
Main.PlaySound(10);
|
||||
Main.selectedWorld = index;
|
||||
Main.menuMode = 9;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlayGame(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
if (listeningElement != evt.Target)
|
||||
return;
|
||||
this._data.SetAsActive();
|
||||
Main.PlaySound(10);
|
||||
Main.GetInputText("");
|
||||
Main.menuMode = !Main.menuMultiplayer || SocialAPI.Network == null ? (!Main.menuMultiplayer ? 10 : 30) : 889;
|
||||
if (Main.menuMultiplayer)
|
||||
return;
|
||||
WorldGen.playWorld();
|
||||
}
|
||||
|
||||
private void FavoriteButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
this._data.ToggleFavorite();
|
||||
((UIImageButton) evt.Target).SetImage(this._data.IsFavorite ? this._buttonFavoriteActiveTexture : this._buttonFavoriteInactiveTexture);
|
||||
((UIImageButton) evt.Target).SetVisibility(1f, this._data.IsFavorite ? 0.8f : 0.4f);
|
||||
if (this._data.IsFavorite)
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Unfavorite"));
|
||||
this.RemoveChild((UIElement) this._deleteButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.Favorite"));
|
||||
this.Append((UIElement) this._deleteButton);
|
||||
}
|
||||
if (!(this.Parent.Parent is UIList parent))
|
||||
return;
|
||||
parent.UpdateOrder();
|
||||
}
|
||||
|
||||
private void SeedButtonClick(UIMouseEvent evt, UIElement listeningElement)
|
||||
{
|
||||
((Platform) Platform.Current).Clipboard = this._data.SeedText;
|
||||
this._buttonLabel.SetText(Language.GetTextValue("UI.SeedCopied"));
|
||||
}
|
||||
|
||||
public override int CompareTo(object obj)
|
||||
{
|
||||
if (!(obj is UIWorldListItem uiWorldListItem))
|
||||
return base.CompareTo(obj);
|
||||
if (this.IsFavorite && !uiWorldListItem.IsFavorite)
|
||||
return -1;
|
||||
if (!this.IsFavorite && uiWorldListItem.IsFavorite)
|
||||
return 1;
|
||||
return this._data.Name.CompareTo(uiWorldListItem._data.Name) != 0 ? this._data.Name.CompareTo(uiWorldListItem._data.Name) : this._data.GetFileName().CompareTo(uiWorldListItem._data.GetFileName());
|
||||
}
|
||||
|
||||
public override void MouseOver(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOver(evt);
|
||||
this.BackgroundColor = new Color(73, 94, 171);
|
||||
this.BorderColor = new Color(89, 116, 213);
|
||||
}
|
||||
|
||||
public override void MouseOut(UIMouseEvent evt)
|
||||
{
|
||||
base.MouseOut(evt);
|
||||
this.BackgroundColor = new Color(63, 82, 151) * 0.7f;
|
||||
this.BorderColor = new Color(89, 116, 213) * 0.7f;
|
||||
}
|
||||
|
||||
private void DrawPanel(SpriteBatch spriteBatch, Vector2 position, float width)
|
||||
{
|
||||
spriteBatch.Draw(this._innerPanelTexture, position, new Rectangle?(new Rectangle(0, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2(position.X + 8f, position.Y), new Rectangle?(new Rectangle(8, 0, 8, this._innerPanelTexture.Height)), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) width - 16.0) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
spriteBatch.Draw(this._innerPanelTexture, new Vector2((float) ((double) position.X + (double) width - 8.0), position.Y), new Rectangle?(new Rectangle(16, 0, 8, this._innerPanelTexture.Height)), Color.White);
|
||||
}
|
||||
|
||||
protected override void DrawSelf(SpriteBatch spriteBatch)
|
||||
{
|
||||
base.DrawSelf(spriteBatch);
|
||||
CalculatedStyle innerDimensions = this.GetInnerDimensions();
|
||||
CalculatedStyle dimensions = this._worldIcon.GetDimensions();
|
||||
float x1 = dimensions.X + dimensions.Width;
|
||||
Color color = this._data.IsValid ? Color.White : Color.Red;
|
||||
Utils.DrawBorderString(spriteBatch, this._data.Name, new Vector2(x1 + 6f, dimensions.Y - 2f), color);
|
||||
spriteBatch.Draw(this._dividerTexture, new Vector2(x1, innerDimensions.Y + 21f), new Rectangle?(), Color.White, 0.0f, Vector2.Zero, new Vector2((float) (((double) this.GetDimensions().X + (double) this.GetDimensions().Width - (double) x1) / 8.0), 1f), SpriteEffects.None, 0.0f);
|
||||
Vector2 position = new Vector2(x1 + 6f, innerDimensions.Y + 29f);
|
||||
float width1 = 100f;
|
||||
this.DrawPanel(spriteBatch, position, width1);
|
||||
string text = this._data.IsExpertMode ? Language.GetTextValue("UI.Expert") : Language.GetTextValue("UI.Normal");
|
||||
float x2 = Main.fontMouseText.MeasureString(text).X;
|
||||
float x3 = (float) ((double) width1 * 0.5 - (double) x2 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, text, position + new Vector2(x3, 3f), this._data.IsExpertMode ? new Color(217, 143, 244) : Color.White);
|
||||
position.X += width1 + 5f;
|
||||
float width2 = 150f;
|
||||
if (!GameCulture.English.IsActive)
|
||||
width2 += 40f;
|
||||
this.DrawPanel(spriteBatch, position, width2);
|
||||
string textValue1 = Language.GetTextValue("UI.WorldSizeFormat", (object) this._data.WorldSizeName);
|
||||
float x4 = Main.fontMouseText.MeasureString(textValue1).X;
|
||||
float x5 = (float) ((double) width2 * 0.5 - (double) x4 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue1, position + new Vector2(x5, 3f), Color.White);
|
||||
position.X += width2 + 5f;
|
||||
float width3 = innerDimensions.X + innerDimensions.Width - position.X;
|
||||
this.DrawPanel(spriteBatch, position, width3);
|
||||
string textValue2 = Language.GetTextValue("UI.WorldCreatedFormat", !GameCulture.English.IsActive ? (object) this._data.CreationTime.ToShortDateString() : (object) this._data.CreationTime.ToString("d MMMM yyyy"));
|
||||
float x6 = Main.fontMouseText.MeasureString(textValue2).X;
|
||||
float x7 = (float) ((double) width3 * 0.5 - (double) x6 * 0.5);
|
||||
Utils.DrawBorderString(spriteBatch, textValue2, position + new Vector2(x7, 3f), Color.White);
|
||||
position.X += width3 + 5f;
|
||||
}
|
||||
}
|
||||
}
|
800
GameContent/UI/EmoteBubble.cs
Normal file
800
GameContent/UI/EmoteBubble.cs
Normal file
|
@ -0,0 +1,800 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.UI.EmoteBubble
|
||||
// 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 Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.UI
|
||||
{
|
||||
public class EmoteBubble
|
||||
{
|
||||
private static int[] CountNPCs = new int[580];
|
||||
public static Dictionary<int, EmoteBubble> byID = new Dictionary<int, EmoteBubble>();
|
||||
private static List<int> toClean = new List<int>();
|
||||
public static int NextID;
|
||||
public int ID;
|
||||
public WorldUIAnchor anchor;
|
||||
public int lifeTime;
|
||||
public int lifeTimeStart;
|
||||
public int emote;
|
||||
public int metadata;
|
||||
private const int frameSpeed = 8;
|
||||
public int frameCounter;
|
||||
public int frame;
|
||||
|
||||
public static void UpdateAll()
|
||||
{
|
||||
lock (EmoteBubble.byID)
|
||||
{
|
||||
EmoteBubble.toClean.Clear();
|
||||
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
|
||||
{
|
||||
keyValuePair.Value.Update();
|
||||
if (keyValuePair.Value.lifeTime <= 0)
|
||||
EmoteBubble.toClean.Add(keyValuePair.Key);
|
||||
}
|
||||
foreach (int key in EmoteBubble.toClean)
|
||||
EmoteBubble.byID.Remove(key);
|
||||
EmoteBubble.toClean.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawAll(SpriteBatch sb)
|
||||
{
|
||||
lock (EmoteBubble.byID)
|
||||
{
|
||||
foreach (KeyValuePair<int, EmoteBubble> keyValuePair in EmoteBubble.byID)
|
||||
keyValuePair.Value.Draw(sb);
|
||||
}
|
||||
}
|
||||
|
||||
public static Tuple<int, int> SerializeNetAnchor(WorldUIAnchor anch)
|
||||
{
|
||||
if (anch.type != WorldUIAnchor.AnchorType.Entity)
|
||||
return Tuple.Create<int, int>(0, 0);
|
||||
int num = 0;
|
||||
if (anch.entity is NPC)
|
||||
num = 0;
|
||||
else if (anch.entity is Player)
|
||||
num = 1;
|
||||
else if (anch.entity is Projectile)
|
||||
num = 2;
|
||||
return Tuple.Create<int, int>(num, anch.entity.whoAmI);
|
||||
}
|
||||
|
||||
public static WorldUIAnchor DeserializeNetAnchor(int type, int meta)
|
||||
{
|
||||
if (type == 0)
|
||||
return new WorldUIAnchor((Entity) Main.npc[meta]);
|
||||
if (type == 1)
|
||||
return new WorldUIAnchor((Entity) Main.player[meta]);
|
||||
if (type == 2)
|
||||
return new WorldUIAnchor((Entity) Main.projectile[meta]);
|
||||
throw new Exception("How did you end up getting this?");
|
||||
}
|
||||
|
||||
public static int AssignNewID() => EmoteBubble.NextID++;
|
||||
|
||||
public static int NewBubble(int emoticon, WorldUIAnchor bubbleAnchor, int time)
|
||||
{
|
||||
EmoteBubble emoteBubble = new EmoteBubble(emoticon, bubbleAnchor, time)
|
||||
{
|
||||
ID = EmoteBubble.AssignNewID()
|
||||
};
|
||||
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
|
||||
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoticon);
|
||||
}
|
||||
return emoteBubble.ID;
|
||||
}
|
||||
|
||||
public static int NewBubbleNPC(WorldUIAnchor bubbleAnchor, int time, WorldUIAnchor other = null)
|
||||
{
|
||||
EmoteBubble emoteBubble = new EmoteBubble(0, bubbleAnchor, time)
|
||||
{
|
||||
ID = EmoteBubble.AssignNewID()
|
||||
};
|
||||
EmoteBubble.byID[emoteBubble.ID] = emoteBubble;
|
||||
emoteBubble.PickNPCEmote(other);
|
||||
if (Main.netMode == 2)
|
||||
{
|
||||
Tuple<int, int> tuple = EmoteBubble.SerializeNetAnchor(bubbleAnchor);
|
||||
NetMessage.SendData(91, number: emoteBubble.ID, number2: ((float) tuple.Item1), number3: ((float) tuple.Item2), number4: ((float) time), number5: emoteBubble.emote, number6: emoteBubble.metadata);
|
||||
}
|
||||
return emoteBubble.ID;
|
||||
}
|
||||
|
||||
public EmoteBubble(int emotion, WorldUIAnchor bubbleAnchor, int time = 180)
|
||||
{
|
||||
this.anchor = bubbleAnchor;
|
||||
this.emote = emotion;
|
||||
this.lifeTime = time;
|
||||
this.lifeTimeStart = time;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (--this.lifeTime <= 0 || ++this.frameCounter < 8)
|
||||
return;
|
||||
this.frameCounter = 0;
|
||||
if (++this.frame < 2)
|
||||
return;
|
||||
this.frame = 0;
|
||||
}
|
||||
|
||||
private void Draw(SpriteBatch sb)
|
||||
{
|
||||
Texture2D texture2D = Main.extraTexture[48];
|
||||
SpriteEffects effect = SpriteEffects.None;
|
||||
Vector2 vector2 = this.GetPosition(out effect);
|
||||
bool flag = this.lifeTime < 6 || this.lifeTimeStart - this.lifeTime < 6;
|
||||
Rectangle rectangle = texture2D.Frame(8, 33, flag ? 0 : 1);
|
||||
Vector2 origin = new Vector2((float) (rectangle.Width / 2), (float) rectangle.Height);
|
||||
if ((double) Main.player[Main.myPlayer].gravDir == -1.0)
|
||||
{
|
||||
origin.Y = 0.0f;
|
||||
effect |= SpriteEffects.FlipVertically;
|
||||
vector2 = Main.ReverseGravitySupport(vector2);
|
||||
}
|
||||
sb.Draw(texture2D, vector2, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
if (flag)
|
||||
return;
|
||||
if (this.emote >= 0)
|
||||
{
|
||||
if (this.emote == 87)
|
||||
effect = SpriteEffects.None;
|
||||
sb.Draw(texture2D, vector2, new Rectangle?(texture2D.Frame(8, 35, this.emote * 2 % 8 + this.frame, 1 + this.emote / 4)), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.emote != -1)
|
||||
return;
|
||||
Texture2D texture = Main.npcHeadTexture[this.metadata];
|
||||
float scale = 1f;
|
||||
if ((double) texture.Width / 22.0 > 1.0)
|
||||
scale = 22f / (float) texture.Width;
|
||||
if ((double) texture.Height / 16.0 > 1.0 / (double) scale)
|
||||
scale = 16f / (float) texture.Height;
|
||||
sb.Draw(texture, vector2 + new Vector2(effect.HasFlag((Enum) SpriteEffects.FlipHorizontally) ? 1f : -1f, (float) (-rectangle.Height + 3)), new Rectangle?(), Color.White, 0.0f, new Vector2((float) (texture.Width / 2), 0.0f), scale, effect, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 GetPosition(out SpriteEffects effect)
|
||||
{
|
||||
switch (this.anchor.type)
|
||||
{
|
||||
case WorldUIAnchor.AnchorType.Entity:
|
||||
effect = this.anchor.entity.direction == -1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
return this.anchor.entity.Top + new Vector2((float) (-this.anchor.entity.direction * this.anchor.entity.width) * 0.75f, 2f) - Main.screenPosition;
|
||||
case WorldUIAnchor.AnchorType.Tile:
|
||||
effect = SpriteEffects.None;
|
||||
return this.anchor.pos - Main.screenPosition + new Vector2(0.0f, (float) (-(double) this.anchor.size.Y / 2.0));
|
||||
case WorldUIAnchor.AnchorType.Pos:
|
||||
effect = SpriteEffects.None;
|
||||
return this.anchor.pos - Main.screenPosition;
|
||||
default:
|
||||
effect = SpriteEffects.None;
|
||||
return new Vector2((float) Main.screenWidth, (float) Main.screenHeight) / 2f;
|
||||
}
|
||||
}
|
||||
|
||||
public void PickNPCEmote(WorldUIAnchor other = null)
|
||||
{
|
||||
Player plr = Main.player[(int) Player.FindClosest(this.anchor.entity.Center, 0, 0)];
|
||||
List<int> list = new List<int>();
|
||||
bool flag = false;
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].boss)
|
||||
flag = true;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeTownNPCs(list);
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeEmotions(list);
|
||||
if (Main.rand.Next(3) == 0)
|
||||
this.ProbeBiomes(list, plr);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeCritters(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeItems(list, plr);
|
||||
if (Main.rand.Next(5) == 0)
|
||||
this.ProbeBosses(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeDebuffs(list, plr);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeEvents(list);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
this.ProbeWeather(list, plr);
|
||||
this.ProbeExceptions(list, plr, other);
|
||||
}
|
||||
else
|
||||
this.ProbeCombat(list);
|
||||
if (list.Count <= 0)
|
||||
return;
|
||||
this.emote = list[Main.rand.Next(list.Count)];
|
||||
}
|
||||
|
||||
private void ProbeCombat(List<int> list)
|
||||
{
|
||||
list.Add(16);
|
||||
list.Add(1);
|
||||
list.Add(2);
|
||||
list.Add(91);
|
||||
list.Add(93);
|
||||
list.Add(84);
|
||||
list.Add(84);
|
||||
}
|
||||
|
||||
private void ProbeWeather(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) Main.cloudBGActive > 0.0)
|
||||
list.Add(96);
|
||||
if ((double) Main.cloudAlpha > 0.0)
|
||||
{
|
||||
if (!Main.dayTime)
|
||||
list.Add(5);
|
||||
list.Add(4);
|
||||
if (plr.ZoneSnow)
|
||||
list.Add(98);
|
||||
if ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (Main.maxTilesX * 16 - 4000) && (double) plr.position.Y < Main.worldSurface / 16.0)
|
||||
list.Add(97);
|
||||
}
|
||||
else
|
||||
list.Add(95);
|
||||
if (!plr.ZoneHoly)
|
||||
return;
|
||||
list.Add(6);
|
||||
}
|
||||
|
||||
private void ProbeEvents(List<int> list)
|
||||
{
|
||||
if (BirthdayParty.PartyIsUp && Main.rand.Next(3) == 0)
|
||||
list.Add(Utils.SelectRandom<int>(Main.rand, (int) sbyte.MaxValue, 128, 129, 126));
|
||||
if (Main.bloodMoon || !Main.dayTime && Main.rand.Next(4) == 0)
|
||||
list.Add(18);
|
||||
if (Main.eclipse || Main.hardMode && Main.rand.Next(4) == 0)
|
||||
list.Add(19);
|
||||
if ((!Main.dayTime || WorldGen.spawnMeteor) && WorldGen.shadowOrbSmashed)
|
||||
list.Add(99);
|
||||
if (Main.pumpkinMoon || (NPC.downedHalloweenKing || NPC.downedHalloweenTree) && !Main.dayTime)
|
||||
list.Add(20);
|
||||
if (Main.snowMoon || (NPC.downedChristmasIceQueen || NPC.downedChristmasSantank || NPC.downedChristmasTree) && !Main.dayTime)
|
||||
list.Add(21);
|
||||
if (!DD2Event.Ongoing && !DD2Event.DownedInvasionAnyDifficulty)
|
||||
return;
|
||||
list.Add(133);
|
||||
}
|
||||
|
||||
private void ProbeDebuffs(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) plr.Center.Y > (double) (Main.maxTilesY * 16 - 3200) || plr.onFire || ((NPC) this.anchor.entity).onFire || plr.onFire2)
|
||||
list.Add(9);
|
||||
if (Main.rand.Next(2) == 0)
|
||||
list.Add(11);
|
||||
if (plr.poisoned || ((NPC) this.anchor.entity).poisoned || plr.ZoneJungle)
|
||||
list.Add(8);
|
||||
if (plr.inventory[plr.selectedItem].type != 215 && Main.rand.Next(3) != 0)
|
||||
return;
|
||||
list.Add(10);
|
||||
}
|
||||
|
||||
private void ProbeItems(List<int> list, Player plr)
|
||||
{
|
||||
list.Add(7);
|
||||
list.Add(73);
|
||||
list.Add(74);
|
||||
list.Add(75);
|
||||
list.Add(78);
|
||||
list.Add(90);
|
||||
if (plr.statLife >= plr.statLifeMax2 / 2)
|
||||
return;
|
||||
list.Add(84);
|
||||
}
|
||||
|
||||
private void ProbeTownNPCs(List<int> list)
|
||||
{
|
||||
for (int index = 0; index < 580; ++index)
|
||||
EmoteBubble.CountNPCs[index] = 0;
|
||||
for (int index = 0; index < 200; ++index)
|
||||
{
|
||||
if (Main.npc[index].active)
|
||||
++EmoteBubble.CountNPCs[Main.npc[index].type];
|
||||
}
|
||||
int type = ((NPC) this.anchor.entity).type;
|
||||
for (int index = 0; index < 580; ++index)
|
||||
{
|
||||
if (NPCID.Sets.FaceEmote[index] > 0 && EmoteBubble.CountNPCs[index] > 0 && index != type)
|
||||
list.Add(NPCID.Sets.FaceEmote[index]);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProbeBiomes(List<int> list, Player plr)
|
||||
{
|
||||
if ((double) plr.position.Y / 16.0 < Main.worldSurface * 0.45)
|
||||
list.Add(22);
|
||||
else if ((double) plr.position.Y / 16.0 > Main.rockLayer + (double) (Main.maxTilesY / 2) - 100.0)
|
||||
list.Add(31);
|
||||
else if ((double) plr.position.Y / 16.0 > Main.rockLayer)
|
||||
list.Add(30);
|
||||
else if (plr.ZoneHoly)
|
||||
list.Add(27);
|
||||
else if (plr.ZoneCorrupt)
|
||||
list.Add(26);
|
||||
else if (plr.ZoneCrimson)
|
||||
list.Add(25);
|
||||
else if (plr.ZoneJungle)
|
||||
list.Add(24);
|
||||
else if (plr.ZoneSnow)
|
||||
list.Add(32);
|
||||
else if ((double) plr.position.Y / 16.0 < Main.worldSurface && ((double) plr.position.X < 4000.0 || (double) plr.position.X > (double) (16 * (Main.maxTilesX - 250))))
|
||||
list.Add(29);
|
||||
else if (plr.ZoneDesert)
|
||||
list.Add(28);
|
||||
else
|
||||
list.Add(23);
|
||||
}
|
||||
|
||||
private void ProbeCritters(List<int> list)
|
||||
{
|
||||
Vector2 center = this.anchor.entity.Center;
|
||||
float num1 = 1f;
|
||||
float num2 = 1f;
|
||||
if ((double) center.Y < Main.rockLayer * 16.0)
|
||||
num2 = 0.2f;
|
||||
else
|
||||
num1 = 0.2f;
|
||||
if ((double) Main.rand.NextFloat() <= (double) num1)
|
||||
{
|
||||
if (Main.dayTime)
|
||||
{
|
||||
list.Add(13);
|
||||
list.Add(12);
|
||||
list.Add(68);
|
||||
list.Add(62);
|
||||
list.Add(63);
|
||||
list.Add(69);
|
||||
list.Add(70);
|
||||
}
|
||||
if (!Main.dayTime || Main.dayTime && (Main.time < 5400.0 || Main.time > 48600.0))
|
||||
list.Add(61);
|
||||
if (NPC.downedGoblins)
|
||||
list.Add(64);
|
||||
if (NPC.downedFrost)
|
||||
list.Add(66);
|
||||
if (NPC.downedPirates)
|
||||
list.Add(65);
|
||||
if (NPC.downedMartians)
|
||||
list.Add(71);
|
||||
if (WorldGen.crimson)
|
||||
list.Add(67);
|
||||
}
|
||||
if ((double) Main.rand.NextFloat() > (double) num2)
|
||||
return;
|
||||
list.Add(72);
|
||||
list.Add(69);
|
||||
}
|
||||
|
||||
private void ProbeEmotions(List<int> list)
|
||||
{
|
||||
list.Add(0);
|
||||
list.Add(1);
|
||||
list.Add(2);
|
||||
list.Add(3);
|
||||
list.Add(15);
|
||||
list.Add(16);
|
||||
list.Add(17);
|
||||
list.Add(87);
|
||||
list.Add(91);
|
||||
if (!Main.bloodMoon || Main.dayTime)
|
||||
return;
|
||||
int num = Utils.SelectRandom<int>(Main.rand, 16, 1);
|
||||
list.Add(num);
|
||||
list.Add(num);
|
||||
list.Add(num);
|
||||
}
|
||||
|
||||
private void ProbeBosses(List<int> list)
|
||||
{
|
||||
int num = 0;
|
||||
if (!NPC.downedBoss1 && !Main.dayTime || NPC.downedBoss1)
|
||||
num = 1;
|
||||
if (NPC.downedBoss2)
|
||||
num = 2;
|
||||
if (NPC.downedQueenBee || NPC.downedBoss3)
|
||||
num = 3;
|
||||
if (Main.hardMode)
|
||||
num = 4;
|
||||
if (NPC.downedMechBossAny)
|
||||
num = 5;
|
||||
if (NPC.downedPlantBoss)
|
||||
num = 6;
|
||||
if (NPC.downedGolemBoss)
|
||||
num = 7;
|
||||
if (NPC.downedAncientCultist)
|
||||
num = 8;
|
||||
int maxValue = 10;
|
||||
if (NPC.downedMoonlord)
|
||||
maxValue = 1;
|
||||
if (num >= 1 && num <= 2 || num >= 1 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(39);
|
||||
if (WorldGen.crimson)
|
||||
list.Add(41);
|
||||
else
|
||||
list.Add(40);
|
||||
list.Add(51);
|
||||
}
|
||||
if (num >= 2 && num <= 3 || num >= 2 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(42);
|
||||
}
|
||||
if (num >= 4 && num <= 5 || num >= 4 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(44);
|
||||
list.Add(47);
|
||||
list.Add(45);
|
||||
list.Add(46);
|
||||
}
|
||||
if (num >= 5 && num <= 6 || num >= 5 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
if (!NPC.downedMechBoss1)
|
||||
list.Add(47);
|
||||
if (!NPC.downedMechBoss2)
|
||||
list.Add(45);
|
||||
if (!NPC.downedMechBoss3)
|
||||
list.Add(46);
|
||||
list.Add(48);
|
||||
}
|
||||
if (num == 6 || num >= 6 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(48);
|
||||
list.Add(49);
|
||||
list.Add(50);
|
||||
}
|
||||
if (num == 7 || num >= 7 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(49);
|
||||
list.Add(50);
|
||||
list.Add(52);
|
||||
}
|
||||
if (num == 8 || num >= 8 && Main.rand.Next(maxValue) == 0)
|
||||
{
|
||||
list.Add(52);
|
||||
list.Add(53);
|
||||
}
|
||||
if (NPC.downedPirates && Main.expertMode)
|
||||
list.Add(59);
|
||||
if (NPC.downedMartians)
|
||||
list.Add(60);
|
||||
if (NPC.downedChristmasIceQueen)
|
||||
list.Add(57);
|
||||
if (NPC.downedChristmasSantank)
|
||||
list.Add(58);
|
||||
if (NPC.downedChristmasTree)
|
||||
list.Add(56);
|
||||
if (NPC.downedHalloweenKing)
|
||||
list.Add(55);
|
||||
if (!NPC.downedHalloweenTree)
|
||||
return;
|
||||
list.Add(54);
|
||||
}
|
||||
|
||||
private void ProbeExceptions(List<int> list, Player plr, WorldUIAnchor other)
|
||||
{
|
||||
NPC entity = (NPC) this.anchor.entity;
|
||||
if (entity.type == 17)
|
||||
{
|
||||
list.Add(80);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
}
|
||||
else if (entity.type == 18)
|
||||
{
|
||||
list.Add(73);
|
||||
list.Add(73);
|
||||
list.Add(84);
|
||||
list.Add(75);
|
||||
}
|
||||
else if (entity.type == 19)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 22)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else if (other != null && ((NPC) other.entity).type == 22)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(82);
|
||||
list.Add(82);
|
||||
list.Add(85);
|
||||
list.Add(85);
|
||||
list.Add(77);
|
||||
list.Add(93);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 20)
|
||||
{
|
||||
if (list.Contains(121))
|
||||
{
|
||||
list.Add(121);
|
||||
list.Add(121);
|
||||
}
|
||||
list.Add(14);
|
||||
list.Add(14);
|
||||
}
|
||||
else if (entity.type == 22)
|
||||
{
|
||||
if (!Main.bloodMoon)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 19)
|
||||
{
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(93);
|
||||
list.Add(92);
|
||||
}
|
||||
else
|
||||
list.Add(79);
|
||||
}
|
||||
if (!Main.dayTime)
|
||||
{
|
||||
list.Add(16);
|
||||
list.Add(16);
|
||||
list.Add(16);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 37)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(43);
|
||||
list.Add(43);
|
||||
list.Add(72);
|
||||
list.Add(72);
|
||||
}
|
||||
else if (entity.type == 38)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(81);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(77);
|
||||
list.Add(77);
|
||||
list.Add(81);
|
||||
list.Add(81);
|
||||
list.Add(81);
|
||||
list.Add(90);
|
||||
list.Add(90);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 54)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
{
|
||||
list.Add(43);
|
||||
list.Add(72);
|
||||
list.Add(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(111))
|
||||
list.Add(111);
|
||||
list.Add(17);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 107)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 124)
|
||||
{
|
||||
list.Remove(111);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(17);
|
||||
list.Add(17);
|
||||
list.Add(86);
|
||||
list.Add(88);
|
||||
list.Add(88);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(111))
|
||||
{
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
}
|
||||
list.Add(91);
|
||||
list.Add(92);
|
||||
list.Add(91);
|
||||
list.Add(92);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 108)
|
||||
{
|
||||
list.Add(100);
|
||||
list.Add(89);
|
||||
list.Add(11);
|
||||
}
|
||||
if (entity.type == 124)
|
||||
{
|
||||
if (other != null && ((NPC) other.entity).type == 107)
|
||||
{
|
||||
list.Remove(111);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(0);
|
||||
list.Add(17);
|
||||
list.Add(17);
|
||||
list.Add(88);
|
||||
list.Add(88);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (list.Contains(109))
|
||||
{
|
||||
list.Add(109);
|
||||
list.Add(109);
|
||||
list.Add(109);
|
||||
}
|
||||
if (list.Contains(108))
|
||||
{
|
||||
list.Remove(108);
|
||||
if (Main.hardMode)
|
||||
{
|
||||
list.Add(108);
|
||||
list.Add(108);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(106);
|
||||
list.Add(106);
|
||||
}
|
||||
}
|
||||
list.Add(43);
|
||||
list.Add(2);
|
||||
}
|
||||
}
|
||||
else if (entity.type == 142)
|
||||
{
|
||||
list.Add(32);
|
||||
list.Add(66);
|
||||
list.Add(17);
|
||||
list.Add(15);
|
||||
list.Add(15);
|
||||
}
|
||||
else if (entity.type == 160)
|
||||
{
|
||||
list.Add(10);
|
||||
list.Add(89);
|
||||
list.Add(94);
|
||||
list.Add(8);
|
||||
}
|
||||
else if (entity.type == 178)
|
||||
{
|
||||
list.Add(83);
|
||||
list.Add(83);
|
||||
}
|
||||
else if (entity.type == 207)
|
||||
{
|
||||
list.Add(28);
|
||||
list.Add(95);
|
||||
list.Add(93);
|
||||
}
|
||||
else if (entity.type == 208)
|
||||
{
|
||||
list.Add(94);
|
||||
list.Add(17);
|
||||
list.Add(3);
|
||||
list.Add(77);
|
||||
}
|
||||
else if (entity.type == 209)
|
||||
{
|
||||
list.Add(48);
|
||||
list.Add(83);
|
||||
list.Add(5);
|
||||
list.Add(5);
|
||||
}
|
||||
else if (entity.type == 227)
|
||||
{
|
||||
list.Add(63);
|
||||
list.Add(68);
|
||||
}
|
||||
else if (entity.type == 228)
|
||||
{
|
||||
list.Add(24);
|
||||
list.Add(24);
|
||||
list.Add(95);
|
||||
list.Add(8);
|
||||
}
|
||||
else if (entity.type == 229)
|
||||
{
|
||||
list.Add(93);
|
||||
list.Add(9);
|
||||
list.Add(65);
|
||||
list.Add(120);
|
||||
list.Add(59);
|
||||
}
|
||||
else if (entity.type == 353)
|
||||
{
|
||||
if (list.Contains(104))
|
||||
{
|
||||
list.Add(104);
|
||||
list.Add(104);
|
||||
}
|
||||
if (list.Contains(111))
|
||||
{
|
||||
list.Add(111);
|
||||
list.Add(111);
|
||||
}
|
||||
list.Add(67);
|
||||
}
|
||||
else if (entity.type == 368)
|
||||
{
|
||||
list.Add(85);
|
||||
list.Add(7);
|
||||
list.Add(79);
|
||||
}
|
||||
else if (entity.type == 369)
|
||||
{
|
||||
if (Main.bloodMoon)
|
||||
return;
|
||||
list.Add(70);
|
||||
list.Add(70);
|
||||
list.Add(76);
|
||||
list.Add(76);
|
||||
list.Add(79);
|
||||
list.Add(79);
|
||||
if ((double) entity.position.Y >= Main.worldSurface)
|
||||
return;
|
||||
list.Add(29);
|
||||
}
|
||||
else if (entity.type == 453)
|
||||
{
|
||||
list.Add(72);
|
||||
list.Add(69);
|
||||
list.Add(87);
|
||||
list.Add(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entity.type != 441)
|
||||
return;
|
||||
list.Add(100);
|
||||
list.Add(100);
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(1);
|
||||
list.Add(87);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue