Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
74
GameContent/ARenderTargetContentByRequest.cs
Normal file
74
GameContent/ARenderTargetContentByRequest.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.ARenderTargetContentByRequest
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public abstract class ARenderTargetContentByRequest : INeedRenderTargetContent
|
||||
{
|
||||
protected RenderTarget2D _target;
|
||||
protected bool _wasPrepared;
|
||||
private bool _wasRequested;
|
||||
|
||||
public bool IsReady => this._wasPrepared;
|
||||
|
||||
public void Request() => this._wasRequested = true;
|
||||
|
||||
public RenderTarget2D GetTarget() => this._target;
|
||||
|
||||
public void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
|
||||
{
|
||||
this._wasPrepared = false;
|
||||
if (!this._wasRequested)
|
||||
return;
|
||||
this._wasRequested = false;
|
||||
this.HandleUseReqest(device, spriteBatch);
|
||||
}
|
||||
|
||||
protected abstract void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch);
|
||||
|
||||
protected void PrepareARenderTarget_AndListenToEvents(
|
||||
ref RenderTarget2D target,
|
||||
GraphicsDevice device,
|
||||
int neededWidth,
|
||||
int neededHeight,
|
||||
RenderTargetUsage usage)
|
||||
{
|
||||
if (target != null && !target.IsDisposed && target.Width == neededWidth && target.Height == neededHeight)
|
||||
return;
|
||||
if (target != null)
|
||||
{
|
||||
target.ContentLost -= new EventHandler<EventArgs>(this.target_ContentLost);
|
||||
target.Disposing -= new EventHandler<EventArgs>(this.target_Disposing);
|
||||
}
|
||||
target = new RenderTarget2D(device, neededWidth, neededHeight, false, device.PresentationParameters.BackBufferFormat, DepthFormat.None, 0, usage);
|
||||
target.ContentLost += new EventHandler<EventArgs>(this.target_ContentLost);
|
||||
target.Disposing += new EventHandler<EventArgs>(this.target_Disposing);
|
||||
}
|
||||
|
||||
private void target_Disposing(object sender, EventArgs e)
|
||||
{
|
||||
this._wasPrepared = false;
|
||||
this._target = (RenderTarget2D) null;
|
||||
}
|
||||
|
||||
private void target_ContentLost(object sender, EventArgs e) => this._wasPrepared = false;
|
||||
|
||||
protected void PrepareARenderTarget_WithoutListeningToEvents(
|
||||
ref RenderTarget2D target,
|
||||
GraphicsDevice device,
|
||||
int neededWidth,
|
||||
int neededHeight,
|
||||
RenderTargetUsage usage)
|
||||
{
|
||||
if (target != null && !target.IsDisposed && target.Width == neededWidth && target.Height == neededHeight)
|
||||
return;
|
||||
target = new RenderTarget2D(device, neededWidth, neededHeight, false, device.PresentationParameters.BackBufferFormat, DepthFormat.None, 0, usage);
|
||||
}
|
||||
}
|
||||
}
|
313
GameContent/Achievements/AchievementsHelper.cs
Normal file
313
GameContent/Achievements/AchievementsHelper.cs
Normal file
|
@ -0,0 +1,313 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.AchievementsHelper
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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);
|
||||
|
||||
internal 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);
|
||||
for (int index = 0; index < player.bank4.item.Length; ++index)
|
||||
AchievementsHelper.OnItemPickup(player, (short) player.bank4.item[index].type, player.bank4.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 slot = 0; slot < 10; ++slot)
|
||||
{
|
||||
if (player.IsAValidEquipmentSlotForIteration(slot) && (player.dye[slot].type < 1 || player.dye[slot].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 slot = 0; slot < 10; ++slot)
|
||||
{
|
||||
if (player.IsAValidEquipmentSlotForIteration(slot) && (player.dye[slot].type < 1 || player.dye[slot].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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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);
|
||||
}
|
||||
}
|
68
GameContent/Achievements/CustomFloatCondition.cs
Normal file
68
GameContent/Achievements/CustomFloatCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomFloatCondition
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class CustomFloatCondition : AchievementCondition
|
||||
{
|
||||
[JsonProperty("Value")]
|
||||
private float _value;
|
||||
private float _maxValue;
|
||||
|
||||
public float Value
|
||||
{
|
||||
get => this._value;
|
||||
set
|
||||
{
|
||||
float newValue = Utils.Clamp<float>(value, 0.0f, this._maxValue);
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<float>) this._tracker).SetValue(newValue);
|
||||
this._value = newValue;
|
||||
if ((double) this._value != (double) this._maxValue)
|
||||
return;
|
||||
this.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private CustomFloatCondition(string name, float maxValue)
|
||||
: base(name)
|
||||
{
|
||||
this._maxValue = maxValue;
|
||||
this._value = 0.0f;
|
||||
}
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
this._value = 0.0f;
|
||||
base.Clear();
|
||||
}
|
||||
|
||||
public override void Load(JObject state)
|
||||
{
|
||||
base.Load(state);
|
||||
this._value = JToken.op_Explicit(state["Value"]);
|
||||
if (this._tracker == null)
|
||||
return;
|
||||
((AchievementTracker<float>) this._tracker).SetValue(this._value, false);
|
||||
}
|
||||
|
||||
protected override IAchievementTracker CreateAchievementTracker() => (IAchievementTracker) new ConditionFloatTracker(this._maxValue);
|
||||
|
||||
public static AchievementCondition Create(string name, float maxValue) => (AchievementCondition) new CustomFloatCondition(name, maxValue);
|
||||
|
||||
public override void Complete()
|
||||
{
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<float>) this._tracker).SetValue(this._maxValue);
|
||||
this._value = this._maxValue;
|
||||
base.Complete();
|
||||
}
|
||||
}
|
||||
}
|
68
GameContent/Achievements/CustomIntCondition.cs
Normal file
68
GameContent/Achievements/CustomIntCondition.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Achievements.CustomIntCondition
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Terraria.Achievements;
|
||||
|
||||
namespace Terraria.GameContent.Achievements
|
||||
{
|
||||
public class 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);
|
||||
|
||||
public override void Complete()
|
||||
{
|
||||
if (this._tracker != null)
|
||||
((AchievementTracker<int>) this._tracker).SetValue(this._maxValue);
|
||||
this._value = this._maxValue;
|
||||
base.Complete();
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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;
|
||||
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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;
|
||||
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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;
|
||||
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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;
|
||||
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using 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;
|
||||
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);
|
||||
}
|
||||
}
|
143
GameContent/Ambience/AmbienceServer.cs
Normal file
143
GameContent/Ambience/AmbienceServer.cs
Normal file
|
@ -0,0 +1,143 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Ambience.AmbienceServer
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.GameContent.NetModules;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.Ambience
|
||||
{
|
||||
public class AmbienceServer
|
||||
{
|
||||
private const int MINIMUM_SECONDS_BETWEEN_SPAWNS = 10;
|
||||
private const int MAXIMUM_SECONDS_BETWEEN_SPAWNS = 120;
|
||||
private readonly Dictionary<SkyEntityType, Func<bool>> _spawnConditions = new Dictionary<SkyEntityType, Func<bool>>();
|
||||
private readonly Dictionary<SkyEntityType, Func<Player, bool>> _secondarySpawnConditionsPerPlayer = new Dictionary<SkyEntityType, Func<Player, bool>>();
|
||||
private int _updatesUntilNextAttempt;
|
||||
private List<AmbienceServer.AmbienceSpawnInfo> _forcedSpawns = new List<AmbienceServer.AmbienceSpawnInfo>();
|
||||
|
||||
private static bool IsSunnyDay() => !Main.IsItRaining && Main.dayTime && !Main.eclipse;
|
||||
|
||||
private static bool IsSunset() => Main.dayTime && Main.time > 40500.0;
|
||||
|
||||
private static bool IsCalmNight() => !Main.IsItRaining && !Main.dayTime && !Main.bloodMoon && !Main.pumpkinMoon && !Main.snowMoon;
|
||||
|
||||
public AmbienceServer()
|
||||
{
|
||||
this.ResetSpawnTime();
|
||||
this._spawnConditions[SkyEntityType.BirdsV] = new Func<bool>(AmbienceServer.IsSunnyDay);
|
||||
this._spawnConditions[SkyEntityType.Wyvern] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() && Main.hardMode);
|
||||
this._spawnConditions[SkyEntityType.Airship] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() && Main.IsItAHappyWindyDay);
|
||||
this._spawnConditions[SkyEntityType.AirBalloon] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() && !Main.IsItAHappyWindyDay);
|
||||
this._spawnConditions[SkyEntityType.Eyeball] = (Func<bool>) (() => !Main.dayTime);
|
||||
this._spawnConditions[SkyEntityType.Butterflies] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() && !Main.IsItAHappyWindyDay && !NPC.TooWindyForButterflies && NPC.butterflyChance < 6);
|
||||
this._spawnConditions[SkyEntityType.LostKite] = (Func<bool>) (() => Main.dayTime && !Main.eclipse && Main.IsItAHappyWindyDay);
|
||||
this._spawnConditions[SkyEntityType.Vulture] = (Func<bool>) (() => AmbienceServer.IsSunnyDay());
|
||||
this._spawnConditions[SkyEntityType.Bats] = (Func<bool>) (() => AmbienceServer.IsSunset() && AmbienceServer.IsSunnyDay() || AmbienceServer.IsCalmNight());
|
||||
this._spawnConditions[SkyEntityType.PixiePosse] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() || AmbienceServer.IsCalmNight());
|
||||
this._spawnConditions[SkyEntityType.Seagulls] = (Func<bool>) (() => AmbienceServer.IsSunnyDay());
|
||||
this._spawnConditions[SkyEntityType.SlimeBalloons] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() && Main.IsItAHappyWindyDay);
|
||||
this._spawnConditions[SkyEntityType.Gastropods] = (Func<bool>) (() => AmbienceServer.IsCalmNight());
|
||||
this._spawnConditions[SkyEntityType.Pegasus] = (Func<bool>) (() => AmbienceServer.IsSunnyDay());
|
||||
this._spawnConditions[SkyEntityType.EaterOfSouls] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() || AmbienceServer.IsCalmNight());
|
||||
this._spawnConditions[SkyEntityType.Crimera] = (Func<bool>) (() => AmbienceServer.IsSunnyDay() || AmbienceServer.IsCalmNight());
|
||||
this._spawnConditions[SkyEntityType.Hellbats] = (Func<bool>) (() => true);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Vulture] = (Func<Player, bool>) (player => player.ZoneDesert);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.PixiePosse] = (Func<Player, bool>) (player => player.ZoneHallow);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Seagulls] = (Func<Player, bool>) (player => player.ZoneBeach);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Gastropods] = (Func<Player, bool>) (player => player.ZoneHallow);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Pegasus] = (Func<Player, bool>) (player => player.ZoneHallow);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.EaterOfSouls] = (Func<Player, bool>) (player => player.ZoneCorrupt);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Crimera] = (Func<Player, bool>) (player => player.ZoneCrimson);
|
||||
this._secondarySpawnConditionsPerPlayer[SkyEntityType.Bats] = (Func<Player, bool>) (player => player.ZoneJungle);
|
||||
}
|
||||
|
||||
private bool IsPlayerAtRightHeightForType(SkyEntityType type, Player plr) => type == SkyEntityType.Hellbats ? AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbienceHell(plr) : AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbienceSky(plr);
|
||||
|
||||
public void Update()
|
||||
{
|
||||
this.SpawnForcedEntities();
|
||||
if (this._updatesUntilNextAttempt > 0)
|
||||
{
|
||||
this._updatesUntilNextAttempt -= Main.dayRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ResetSpawnTime();
|
||||
IEnumerable<SkyEntityType> source1 = this._spawnConditions.Where<KeyValuePair<SkyEntityType, Func<bool>>>((Func<KeyValuePair<SkyEntityType, Func<bool>>, bool>) (pair => pair.Value())).Select<KeyValuePair<SkyEntityType, Func<bool>>, SkyEntityType>((Func<KeyValuePair<SkyEntityType, Func<bool>>, SkyEntityType>) (pair => pair.Key));
|
||||
if (source1.Count<SkyEntityType>((Func<SkyEntityType, bool>) (type => true)) == 0)
|
||||
return;
|
||||
Player player;
|
||||
AmbienceServer.FindPlayerThatCanSeeBackgroundAmbience(out player);
|
||||
if (player == null)
|
||||
return;
|
||||
IEnumerable<SkyEntityType> source2 = source1.Where<SkyEntityType>((Func<SkyEntityType, bool>) (type => this.IsPlayerAtRightHeightForType(type, player) && this._secondarySpawnConditionsPerPlayer.ContainsKey(type) && this._secondarySpawnConditionsPerPlayer[type](player)));
|
||||
int maxValue = source2.Count<SkyEntityType>((Func<SkyEntityType, bool>) (type => true));
|
||||
if (maxValue == 0 || Main.rand.Next(5) < 3)
|
||||
{
|
||||
source2 = source1.Where<SkyEntityType>((Func<SkyEntityType, bool>) (type =>
|
||||
{
|
||||
if (!this.IsPlayerAtRightHeightForType(type, player))
|
||||
return false;
|
||||
return !this._secondarySpawnConditionsPerPlayer.ContainsKey(type) || this._secondarySpawnConditionsPerPlayer[type](player);
|
||||
}));
|
||||
maxValue = source2.Count<SkyEntityType>((Func<SkyEntityType, bool>) (type => true));
|
||||
}
|
||||
if (maxValue == 0)
|
||||
return;
|
||||
SkyEntityType type1 = source2.ElementAt<SkyEntityType>(Main.rand.Next(maxValue));
|
||||
this.SpawnForPlayer(player, type1);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetSpawnTime() => this._updatesUntilNextAttempt = Main.rand.Next(600, 7200);
|
||||
|
||||
public void ForceEntitySpawn(AmbienceServer.AmbienceSpawnInfo info) => this._forcedSpawns.Add(info);
|
||||
|
||||
private void SpawnForcedEntities()
|
||||
{
|
||||
if (this._forcedSpawns.Count == 0)
|
||||
return;
|
||||
for (int index = this._forcedSpawns.Count - 1; index >= 0; --index)
|
||||
{
|
||||
AmbienceServer.AmbienceSpawnInfo forcedSpawn = this._forcedSpawns[index];
|
||||
Player player;
|
||||
if (forcedSpawn.targetPlayer == -1)
|
||||
AmbienceServer.FindPlayerThatCanSeeBackgroundAmbience(out player);
|
||||
else
|
||||
player = Main.player[forcedSpawn.targetPlayer];
|
||||
if (player != null && this.IsPlayerAtRightHeightForType(forcedSpawn.skyEntityType, player))
|
||||
this.SpawnForPlayer(player, forcedSpawn.skyEntityType);
|
||||
this._forcedSpawns.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
private static void FindPlayerThatCanSeeBackgroundAmbience(out Player player)
|
||||
{
|
||||
player = (Player) null;
|
||||
int maxValue = ((IEnumerable<Player>) Main.player).Count<Player>((Func<Player, bool>) (plr => plr.active && AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbience(plr)));
|
||||
if (maxValue == 0)
|
||||
return;
|
||||
player = ((IEnumerable<Player>) Main.player).Where<Player>((Func<Player, bool>) (plr => plr.active && AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbience(plr))).ElementAt<Player>(Main.rand.Next(maxValue));
|
||||
}
|
||||
|
||||
private static bool IsPlayerInAPlaceWhereTheyCanSeeAmbience(Player plr) => AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbienceSky(plr) || AmbienceServer.IsPlayerInAPlaceWhereTheyCanSeeAmbienceHell(plr);
|
||||
|
||||
private static bool IsPlayerInAPlaceWhereTheyCanSeeAmbienceSky(Player plr) => (double) plr.position.Y <= Main.worldSurface * 16.0 + 1600.0;
|
||||
|
||||
private static bool IsPlayerInAPlaceWhereTheyCanSeeAmbienceHell(Player plr) => (double) plr.position.Y >= (double) ((Main.UnderworldLayer - 100) * 16);
|
||||
|
||||
private void SpawnForPlayer(Player player, SkyEntityType type) => NetManager.Instance.BroadcastOrLoopback(NetAmbienceModule.SerializeSkyEntitySpawn(player, type));
|
||||
|
||||
public struct AmbienceSpawnInfo
|
||||
{
|
||||
public SkyEntityType skyEntityType;
|
||||
public int targetPlayer;
|
||||
}
|
||||
}
|
||||
}
|
37
GameContent/Ambience/AmbientSkyDrawCache.cs
Normal file
37
GameContent/Ambience/AmbientSkyDrawCache.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Ambience.AmbientSkyDrawCache
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Ambience
|
||||
{
|
||||
public class AmbientSkyDrawCache
|
||||
{
|
||||
public static AmbientSkyDrawCache Instance = new AmbientSkyDrawCache();
|
||||
public AmbientSkyDrawCache.UnderworldCache[] Underworld = new AmbientSkyDrawCache.UnderworldCache[5];
|
||||
public AmbientSkyDrawCache.OceanLineCache OceanLineInfo;
|
||||
|
||||
public void SetUnderworldInfo(int drawIndex, float scale) => this.Underworld[drawIndex] = new AmbientSkyDrawCache.UnderworldCache()
|
||||
{
|
||||
Scale = scale
|
||||
};
|
||||
|
||||
public void SetOceanLineInfo(float yScreenPosition, float oceanOpacity) => this.OceanLineInfo = new AmbientSkyDrawCache.OceanLineCache()
|
||||
{
|
||||
YScreenPosition = yScreenPosition,
|
||||
OceanOpacity = oceanOpacity
|
||||
};
|
||||
|
||||
public struct UnderworldCache
|
||||
{
|
||||
public float Scale;
|
||||
}
|
||||
|
||||
public struct OceanLineCache
|
||||
{
|
||||
public float YScreenPosition;
|
||||
public float OceanOpacity;
|
||||
}
|
||||
}
|
||||
}
|
31
GameContent/Ambience/SkyEntityType.cs
Normal file
31
GameContent/Ambience/SkyEntityType.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Ambience.SkyEntityType
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Ambience
|
||||
{
|
||||
public enum SkyEntityType : byte
|
||||
{
|
||||
BirdsV,
|
||||
Wyvern,
|
||||
Airship,
|
||||
AirBalloon,
|
||||
Eyeball,
|
||||
Meteor,
|
||||
BoneSerpent,
|
||||
Bats,
|
||||
Butterflies,
|
||||
LostKite,
|
||||
Vulture,
|
||||
PixiePosse,
|
||||
Seagulls,
|
||||
SlimeBalloons,
|
||||
Gastropods,
|
||||
Pegasus,
|
||||
EaterOfSouls,
|
||||
Crimera,
|
||||
Hellbats,
|
||||
}
|
||||
}
|
134
GameContent/AmbientWindSystem.cs
Normal file
134
GameContent/AmbientWindSystem.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.AmbientWindSystem
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class AmbientWindSystem
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private List<Point> _spotsForAirboneWind = new List<Point>();
|
||||
private int _updatesCounter;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (!Main.LocalPlayer.ZoneGraveyard)
|
||||
return;
|
||||
++this._updatesCounter;
|
||||
Rectangle tileWorkSpace = this.GetTileWorkSpace();
|
||||
int num1 = tileWorkSpace.X + tileWorkSpace.Width;
|
||||
int num2 = tileWorkSpace.Y + tileWorkSpace.Height;
|
||||
for (int x = tileWorkSpace.X; x < num1; ++x)
|
||||
{
|
||||
for (int y = tileWorkSpace.Y; y < num2; ++y)
|
||||
this.TrySpawningWind(x, y);
|
||||
}
|
||||
if (this._updatesCounter % 30 != 0)
|
||||
return;
|
||||
this.SpawnAirborneWind();
|
||||
}
|
||||
|
||||
private void SpawnAirborneWind()
|
||||
{
|
||||
foreach (Point point in this._spotsForAirboneWind)
|
||||
this.SpawnAirborneCloud(point.X, point.Y);
|
||||
this._spotsForAirboneWind.Clear();
|
||||
}
|
||||
|
||||
private Rectangle GetTileWorkSpace()
|
||||
{
|
||||
Point tileCoordinates = Main.LocalPlayer.Center.ToTileCoordinates();
|
||||
int width = 120;
|
||||
int height = 30;
|
||||
return new Rectangle(tileCoordinates.X - width / 2, tileCoordinates.Y - height / 2, width, height);
|
||||
}
|
||||
|
||||
private void TrySpawningWind(int x, int y)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y, 10) || Main.tile[x, y] == null)
|
||||
return;
|
||||
this.TestAirCloud(x, y);
|
||||
Tile tile = Main.tile[x, y];
|
||||
if (!tile.active() || tile.slope() > (byte) 0 || tile.halfBrick() || !Main.tileSolid[(int) tile.type] || WorldGen.SolidTile(Main.tile[x, y - 1]) || this._random.Next(120) != 0)
|
||||
return;
|
||||
this.SpawnFloorCloud(x, y);
|
||||
if (this._random.Next(3) != 0)
|
||||
return;
|
||||
this.SpawnFloorCloud(x, y - 1);
|
||||
}
|
||||
|
||||
private void SpawnAirborneCloud(int x, int y)
|
||||
{
|
||||
int num1 = this._random.Next(2, 6);
|
||||
float num2 = 1.1f;
|
||||
float num3 = 2.2f;
|
||||
float num4 = 3f * (float) Math.PI / 400f * this._random.NextFloatDirection();
|
||||
float num5 = 3f * (float) Math.PI / 400f * this._random.NextFloatDirection();
|
||||
while ((double) num5 > -3.0 * Math.PI / 800.0 && (double) num5 < 3.0 * Math.PI / 800.0)
|
||||
num5 = 3f * (float) Math.PI / 400f * this._random.NextFloatDirection();
|
||||
if (this._random.Next(4) == 0)
|
||||
{
|
||||
num1 = this._random.Next(9, 16);
|
||||
num2 = 1.1f;
|
||||
num3 = 1.2f;
|
||||
}
|
||||
else if (this._random.Next(4) == 0)
|
||||
{
|
||||
num1 = this._random.Next(9, 16);
|
||||
num2 = 1.1f;
|
||||
num3 = 0.2f;
|
||||
}
|
||||
Vector2 vector2_1 = new Vector2(-10f, 0.0f);
|
||||
Vector2 worldCoordinates = new Point(x, y).ToWorldCoordinates();
|
||||
float num6 = num4 - (float) ((double) num5 * (double) num1 * 0.5);
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
if (Main.rand.Next(10) == 0)
|
||||
num5 *= this._random.NextFloatDirection();
|
||||
Vector2 vector2_2 = this._random.NextVector2Circular(4f, 4f);
|
||||
int Type = 1091 + this._random.Next(2) * 2;
|
||||
float num7 = 1.4f;
|
||||
float Scale = num2 + this._random.NextFloat() * num3;
|
||||
float num8 = num6 + num5;
|
||||
Vector2 vector2_3 = Vector2.UnitX.RotatedBy((double) num8) * num7;
|
||||
Gore.NewGorePerfect(worldCoordinates + vector2_2 - vector2_1, vector2_3 * Main.WindForVisuals, Type, Scale);
|
||||
worldCoordinates += vector2_3 * 6.5f * Scale;
|
||||
num6 = num8;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnFloorCloud(int x, int y)
|
||||
{
|
||||
Vector2 worldCoordinates = new Point(x, y - 1).ToWorldCoordinates();
|
||||
int Type = this._random.Next(1087, 1090);
|
||||
float num1 = 16f * this._random.NextFloat();
|
||||
worldCoordinates.Y -= num1;
|
||||
if ((double) num1 < 4.0)
|
||||
Type = 1090;
|
||||
float num2 = 0.4f;
|
||||
float Scale = (float) (0.800000011920929 + (double) this._random.NextFloat() * 0.200000002980232);
|
||||
Gore.NewGorePerfect(worldCoordinates, Vector2.UnitX * num2 * Main.WindForVisuals, Type, Scale);
|
||||
}
|
||||
|
||||
private void TestAirCloud(int x, int y)
|
||||
{
|
||||
if (this._random.Next(120000) != 0)
|
||||
return;
|
||||
for (int index = -2; index <= 2; ++index)
|
||||
{
|
||||
if (index != 0 && (!this.DoesTileAllowWind(Main.tile[x + index, y]) || !this.DoesTileAllowWind(Main.tile[x, y + index])))
|
||||
return;
|
||||
}
|
||||
this._spotsForAirboneWind.Add(new Point(x, y));
|
||||
}
|
||||
|
||||
private bool DoesTileAllowWind(Tile t) => !t.active() || !Main.tileSolid[(int) t.type];
|
||||
}
|
||||
}
|
68
GameContent/AnOutlinedDrawRenderTargetContent.cs
Normal file
68
GameContent/AnOutlinedDrawRenderTargetContent.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.AnOutlinedDrawRenderTargetContent
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public abstract class AnOutlinedDrawRenderTargetContent : ARenderTargetContentByRequest
|
||||
{
|
||||
protected int width = 84;
|
||||
protected int height = 84;
|
||||
public Color _borderColor = Color.White;
|
||||
private EffectPass _coloringShader;
|
||||
private RenderTarget2D _helperTarget;
|
||||
|
||||
public void UseColor(Color color) => this._borderColor = color;
|
||||
|
||||
protected override void HandleUseReqest(GraphicsDevice device, SpriteBatch spriteBatch)
|
||||
{
|
||||
Effect pixelShader = Main.pixelShader;
|
||||
if (this._coloringShader == null)
|
||||
this._coloringShader = pixelShader.CurrentTechnique.Passes["ColorOnly"];
|
||||
Rectangle rectangle = new Rectangle(0, 0, this.width, this.height);
|
||||
this.PrepareARenderTarget_AndListenToEvents(ref this._target, device, this.width, this.height, RenderTargetUsage.PreserveContents);
|
||||
this.PrepareARenderTarget_WithoutListeningToEvents(ref this._helperTarget, device, this.width, this.height, RenderTargetUsage.DiscardContents);
|
||||
device.SetRenderTarget(this._helperTarget);
|
||||
device.Clear(Color.Transparent);
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, (Effect) null);
|
||||
this.DrawTheContent(spriteBatch);
|
||||
spriteBatch.End();
|
||||
device.SetRenderTarget(this._target);
|
||||
device.Clear(Color.Transparent);
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise, (Effect) null);
|
||||
this._coloringShader.Apply();
|
||||
int num1 = 2;
|
||||
int num2 = num1 * 2;
|
||||
for (int index1 = -num2; index1 <= num2; index1 += num1)
|
||||
{
|
||||
for (int index2 = -num2; index2 <= num2; index2 += num1)
|
||||
{
|
||||
if (Math.Abs(index1) + Math.Abs(index2) == num2)
|
||||
spriteBatch.Draw((Texture2D) this._helperTarget, new Vector2((float) index1, (float) index2), Color.Black);
|
||||
}
|
||||
}
|
||||
int num3 = num1;
|
||||
for (int index3 = -num3; index3 <= num3; index3 += num1)
|
||||
{
|
||||
for (int index4 = -num3; index4 <= num3; index4 += num1)
|
||||
{
|
||||
if (Math.Abs(index3) + Math.Abs(index4) == num3)
|
||||
spriteBatch.Draw((Texture2D) this._helperTarget, new Vector2((float) index3, (float) index4), this._borderColor);
|
||||
}
|
||||
}
|
||||
pixelShader.CurrentTechnique.Passes[0].Apply();
|
||||
spriteBatch.Draw((Texture2D) this._helperTarget, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
device.SetRenderTarget((RenderTarget2D) null);
|
||||
this._wasPrepared = true;
|
||||
}
|
||||
|
||||
internal abstract void DrawTheContent(SpriteBatch spriteBatch);
|
||||
}
|
||||
}
|
53
GameContent/AssetSourceController.cs
Normal file
53
GameContent/AssetSourceController.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.AssetSourceController
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using ReLogic.Content;
|
||||
using ReLogic.Content.Sources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.IO;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class AssetSourceController
|
||||
{
|
||||
private readonly List<IContentSource> _staticSources;
|
||||
private readonly IAssetRepository _assetRepository;
|
||||
|
||||
public event Action<ResourcePackList> OnResourcePackChange;
|
||||
|
||||
public ResourcePackList ActiveResourcePackList { get; private set; }
|
||||
|
||||
public AssetSourceController(
|
||||
IAssetRepository assetRepository,
|
||||
IEnumerable<IContentSource> staticSources)
|
||||
{
|
||||
this._assetRepository = assetRepository;
|
||||
this._staticSources = staticSources.ToList<IContentSource>();
|
||||
this.UseResourcePacks(new ResourcePackList());
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
foreach (ResourcePack allPack in this.ActiveResourcePackList.AllPacks)
|
||||
allPack.Refresh();
|
||||
this.UseResourcePacks(this.ActiveResourcePackList);
|
||||
}
|
||||
|
||||
public void UseResourcePacks(ResourcePackList resourcePacks)
|
||||
{
|
||||
if (this.OnResourcePackChange != null)
|
||||
this.OnResourcePackChange(resourcePacks);
|
||||
this.ActiveResourcePackList = resourcePacks;
|
||||
List<IContentSource> icontentSourceList = new List<IContentSource>(resourcePacks.EnabledPacks.OrderBy<ResourcePack, int>((Func<ResourcePack, int>) (pack => pack.SortingOrder)).Select<ResourcePack, IContentSource>((Func<ResourcePack, IContentSource>) (pack => pack.GetContentSource())));
|
||||
icontentSourceList.AddRange((IEnumerable<IContentSource>) this._staticSources);
|
||||
foreach (IContentSource icontentSource in icontentSourceList)
|
||||
icontentSource.ClearRejections();
|
||||
this._assetRepository.SetSources((IEnumerable<IContentSource>) icontentSourceList, (AssetRequestMode) 1);
|
||||
}
|
||||
}
|
||||
}
|
58
GameContent/BackgroundChangeFlashInfo.cs
Normal file
58
GameContent/BackgroundChangeFlashInfo.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.BackgroundChangeFlashInfo
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent
|
||||
{
|
||||
public class BackgroundChangeFlashInfo
|
||||
{
|
||||
private int[] _variations = new int[13];
|
||||
private float[] _flashPower = new float[13];
|
||||
|
||||
public void UpdateCache()
|
||||
{
|
||||
this.UpdateVariation(0, WorldGen.treeBG1);
|
||||
this.UpdateVariation(1, WorldGen.treeBG2);
|
||||
this.UpdateVariation(2, WorldGen.treeBG3);
|
||||
this.UpdateVariation(3, WorldGen.treeBG4);
|
||||
this.UpdateVariation(4, WorldGen.corruptBG);
|
||||
this.UpdateVariation(5, WorldGen.jungleBG);
|
||||
this.UpdateVariation(6, WorldGen.snowBG);
|
||||
this.UpdateVariation(7, WorldGen.hallowBG);
|
||||
this.UpdateVariation(8, WorldGen.crimsonBG);
|
||||
this.UpdateVariation(9, WorldGen.desertBG);
|
||||
this.UpdateVariation(10, WorldGen.oceanBG);
|
||||
this.UpdateVariation(11, WorldGen.mushroomBG);
|
||||
this.UpdateVariation(12, WorldGen.underworldBG);
|
||||
}
|
||||
|
||||
private void UpdateVariation(int areaId, int newVariationValue)
|
||||
{
|
||||
int variation = this._variations[areaId];
|
||||
this._variations[areaId] = newVariationValue;
|
||||
int num = newVariationValue;
|
||||
if (variation == num)
|
||||
return;
|
||||
this.ValueChanged(areaId);
|
||||
}
|
||||
|
||||
private void ValueChanged(int areaId)
|
||||
{
|
||||
if (Main.gameMenu)
|
||||
return;
|
||||
this._flashPower[areaId] = 1f;
|
||||
}
|
||||
|
||||
public void UpdateFlashValues()
|
||||
{
|
||||
for (int index = 0; index < this._flashPower.Length; ++index)
|
||||
this._flashPower[index] = MathHelper.Clamp(this._flashPower[index] - 0.05f, 0.0f, 1f);
|
||||
}
|
||||
|
||||
public float GetFlashPower(int areaId) => this._flashPower[areaId];
|
||||
}
|
||||
}
|
86
GameContent/Bestiary/BestiaryDatabase.cs
Normal file
86
GameContent/Bestiary/BestiaryDatabase.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryDatabase
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.ItemDropRules;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BestiaryDatabase
|
||||
{
|
||||
private List<BestiaryEntry> _entries = new List<BestiaryEntry>();
|
||||
private List<IBestiaryEntryFilter> _filters = new List<IBestiaryEntryFilter>();
|
||||
private List<IBestiarySortStep> _sortSteps = new List<IBestiarySortStep>();
|
||||
private Dictionary<int, BestiaryEntry> _byNpcId = new Dictionary<int, BestiaryEntry>();
|
||||
private BestiaryEntry _trashEntry = new BestiaryEntry();
|
||||
|
||||
public List<BestiaryEntry> Entries => this._entries;
|
||||
|
||||
public List<IBestiaryEntryFilter> Filters => this._filters;
|
||||
|
||||
public List<IBestiarySortStep> SortSteps => this._sortSteps;
|
||||
|
||||
public BestiaryEntry Register(BestiaryEntry entry)
|
||||
{
|
||||
this._entries.Add(entry);
|
||||
for (int index = 0; index < entry.Info.Count; ++index)
|
||||
{
|
||||
if (entry.Info[index] is NPCNetIdBestiaryInfoElement bestiaryInfoElement1)
|
||||
this._byNpcId[bestiaryInfoElement1.NetId] = entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
|
||||
public IBestiaryEntryFilter Register(IBestiaryEntryFilter filter)
|
||||
{
|
||||
this._filters.Add(filter);
|
||||
return filter;
|
||||
}
|
||||
|
||||
public IBestiarySortStep Register(IBestiarySortStep sortStep)
|
||||
{
|
||||
this._sortSteps.Add(sortStep);
|
||||
return sortStep;
|
||||
}
|
||||
|
||||
public BestiaryEntry FindEntryByNPCID(int npcNetId)
|
||||
{
|
||||
BestiaryEntry bestiaryEntry;
|
||||
if (this._byNpcId.TryGetValue(npcNetId, out bestiaryEntry))
|
||||
return bestiaryEntry;
|
||||
this._trashEntry.Info.Clear();
|
||||
return this._trashEntry;
|
||||
}
|
||||
|
||||
public void Merge(ItemDropDatabase dropsDatabase)
|
||||
{
|
||||
for (int npcId = -65; npcId < 663; ++npcId)
|
||||
this.ExtractDropsForNPC(dropsDatabase, npcId);
|
||||
}
|
||||
|
||||
private void ExtractDropsForNPC(ItemDropDatabase dropsDatabase, int npcId)
|
||||
{
|
||||
BestiaryEntry entryByNpcid = this.FindEntryByNPCID(npcId);
|
||||
if (entryByNpcid == null)
|
||||
return;
|
||||
List<IItemDropRule> rulesForNpcid = dropsDatabase.GetRulesForNPCID(npcId, false);
|
||||
List<DropRateInfo> drops = new List<DropRateInfo>();
|
||||
DropRateInfoChainFeed ratesInfo = new DropRateInfoChainFeed(1f);
|
||||
foreach (IItemDropRule itemDropRule in rulesForNpcid)
|
||||
itemDropRule.ReportDroprates(drops, ratesInfo);
|
||||
foreach (DropRateInfo info in drops)
|
||||
entryByNpcid.Info.Add((IBestiaryInfoElement) new ItemDropBestiaryInfoElement(info));
|
||||
}
|
||||
|
||||
public void ApplyPass(BestiaryDatabase.BestiaryEntriesPass pass)
|
||||
{
|
||||
for (int index = 0; index < this._entries.Count; ++index)
|
||||
pass(this._entries[index]);
|
||||
}
|
||||
|
||||
public delegate void BestiaryEntriesPass(BestiaryEntry entry);
|
||||
}
|
||||
}
|
3601
GameContent/Bestiary/BestiaryDatabaseNPCsPopulator.cs
Normal file
3601
GameContent/Bestiary/BestiaryDatabaseNPCsPopulator.cs
Normal file
File diff suppressed because it is too large
Load diff
109
GameContent/Bestiary/BestiaryEntry.cs
Normal file
109
GameContent/Bestiary/BestiaryEntry.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryEntry
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BestiaryEntry
|
||||
{
|
||||
public IEntryIcon Icon;
|
||||
public IBestiaryUICollectionInfoProvider UIInfoProvider;
|
||||
|
||||
public List<IBestiaryInfoElement> Info { get; private set; }
|
||||
|
||||
public BestiaryEntry() => this.Info = new List<IBestiaryInfoElement>();
|
||||
|
||||
public static BestiaryEntry Enemy(int npcNetId)
|
||||
{
|
||||
NPC npc = ContentSamples.NpcsByNetId[npcNetId];
|
||||
List<IBestiaryInfoElement> bestiaryInfoElementList = new List<IBestiaryInfoElement>()
|
||||
{
|
||||
(IBestiaryInfoElement) new NPCNetIdBestiaryInfoElement(npcNetId),
|
||||
(IBestiaryInfoElement) new NamePlateInfoElement(Lang.GetNPCName(npcNetId).Key, npcNetId),
|
||||
(IBestiaryInfoElement) new NPCPortraitInfoElement(new int?(ContentSamples.NpcBestiaryRarityStars[npcNetId]))
|
||||
};
|
||||
foreach (int key in Main.RegisterdGameModes.Keys)
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new NPCStatsReportInfoElement(npcNetId, key));
|
||||
if (npc.rarity != 0)
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new RareSpawnBestiaryInfoElement(npc.rarity));
|
||||
IBestiaryUICollectionInfoProvider collectionInfoProvider;
|
||||
if (npc.boss || NPCID.Sets.ShouldBeCountedAsBoss[npc.type])
|
||||
{
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new BossBestiaryInfoElement());
|
||||
collectionInfoProvider = (IBestiaryUICollectionInfoProvider) new CommonEnemyUICollectionInfoProvider(npc.GetBestiaryCreditId(), true);
|
||||
}
|
||||
else
|
||||
collectionInfoProvider = (IBestiaryUICollectionInfoProvider) new CommonEnemyUICollectionInfoProvider(npc.GetBestiaryCreditId(), false);
|
||||
string str = "Bestiary_FlavorText.npc_" + Lang.GetNPCName(npc.netID).Key.Replace("NPCName.", "");
|
||||
if (Language.Exists(str))
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new FlavorTextBestiaryInfoElement(str));
|
||||
return new BestiaryEntry()
|
||||
{
|
||||
Icon = (IEntryIcon) new UnlockableNPCEntryIcon(npcNetId),
|
||||
Info = bestiaryInfoElementList,
|
||||
UIInfoProvider = collectionInfoProvider
|
||||
};
|
||||
}
|
||||
|
||||
public static BestiaryEntry TownNPC(int npcNetId)
|
||||
{
|
||||
NPC npc = ContentSamples.NpcsByNetId[npcNetId];
|
||||
List<IBestiaryInfoElement> bestiaryInfoElementList = new List<IBestiaryInfoElement>()
|
||||
{
|
||||
(IBestiaryInfoElement) new NPCNetIdBestiaryInfoElement(npcNetId),
|
||||
(IBestiaryInfoElement) new NamePlateInfoElement(Lang.GetNPCName(npcNetId).Key, npcNetId),
|
||||
(IBestiaryInfoElement) new NPCPortraitInfoElement(new int?(ContentSamples.NpcBestiaryRarityStars[npcNetId]))
|
||||
};
|
||||
string str = "Bestiary_FlavorText.npc_" + Lang.GetNPCName(npc.netID).Key.Replace("NPCName.", "");
|
||||
if (Language.Exists(str))
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new FlavorTextBestiaryInfoElement(str));
|
||||
return new BestiaryEntry()
|
||||
{
|
||||
Icon = (IEntryIcon) new UnlockableNPCEntryIcon(npcNetId),
|
||||
Info = bestiaryInfoElementList,
|
||||
UIInfoProvider = (IBestiaryUICollectionInfoProvider) new TownNPCUICollectionInfoProvider(npc.GetBestiaryCreditId())
|
||||
};
|
||||
}
|
||||
|
||||
public static BestiaryEntry Critter(int npcNetId)
|
||||
{
|
||||
NPC npc = ContentSamples.NpcsByNetId[npcNetId];
|
||||
List<IBestiaryInfoElement> bestiaryInfoElementList = new List<IBestiaryInfoElement>()
|
||||
{
|
||||
(IBestiaryInfoElement) new NPCNetIdBestiaryInfoElement(npcNetId),
|
||||
(IBestiaryInfoElement) new NamePlateInfoElement(Lang.GetNPCName(npcNetId).Key, npcNetId),
|
||||
(IBestiaryInfoElement) new NPCPortraitInfoElement(new int?(ContentSamples.NpcBestiaryRarityStars[npcNetId]))
|
||||
};
|
||||
string str = "Bestiary_FlavorText.npc_" + Lang.GetNPCName(npc.netID).Key.Replace("NPCName.", "");
|
||||
if (Language.Exists(str))
|
||||
bestiaryInfoElementList.Add((IBestiaryInfoElement) new FlavorTextBestiaryInfoElement(str));
|
||||
return new BestiaryEntry()
|
||||
{
|
||||
Icon = (IEntryIcon) new UnlockableNPCEntryIcon(npcNetId),
|
||||
Info = bestiaryInfoElementList,
|
||||
UIInfoProvider = (IBestiaryUICollectionInfoProvider) new CritterUICollectionInfoProvider(npc.GetBestiaryCreditId())
|
||||
};
|
||||
}
|
||||
|
||||
public static BestiaryEntry Biome(
|
||||
string nameLanguageKey,
|
||||
string texturePath,
|
||||
Func<bool> unlockCondition)
|
||||
{
|
||||
return new BestiaryEntry()
|
||||
{
|
||||
Icon = (IEntryIcon) new CustomEntryIcon(nameLanguageKey, texturePath, unlockCondition),
|
||||
Info = new List<IBestiaryInfoElement>()
|
||||
};
|
||||
}
|
||||
|
||||
public void AddTags(params IBestiaryInfoElement[] elements) => this.Info.AddRange((IEnumerable<IBestiaryInfoElement>) elements);
|
||||
}
|
||||
}
|
17
GameContent/Bestiary/BestiaryEntryUnlockState.cs
Normal file
17
GameContent/Bestiary/BestiaryEntryUnlockState.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryEntryUnlockState
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public enum BestiaryEntryUnlockState
|
||||
{
|
||||
NotKnownAtAll_0,
|
||||
CanShowPortraitOnly_1,
|
||||
CanShowStats_2,
|
||||
CanShowDropsWithoutDropRates_3,
|
||||
CanShowDropsWithDropRates_4,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryPortraitBackgroundBasedOnWorldEvilProviderPreferenceInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BestiaryPortraitBackgroundBasedOnWorldEvilProviderPreferenceInfoElement :
|
||||
IPreferenceProviderElement,
|
||||
IBestiaryInfoElement
|
||||
{
|
||||
private IBestiaryBackgroundImagePathAndColorProvider _preferredProviderCorrupt;
|
||||
private IBestiaryBackgroundImagePathAndColorProvider _preferredProviderCrimson;
|
||||
|
||||
public BestiaryPortraitBackgroundBasedOnWorldEvilProviderPreferenceInfoElement(
|
||||
IBestiaryBackgroundImagePathAndColorProvider preferredProviderCorrupt,
|
||||
IBestiaryBackgroundImagePathAndColorProvider preferredProviderCrimson)
|
||||
{
|
||||
this._preferredProviderCorrupt = preferredProviderCorrupt;
|
||||
this._preferredProviderCrimson = preferredProviderCrimson;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
|
||||
public bool Matches(
|
||||
IBestiaryBackgroundImagePathAndColorProvider provider)
|
||||
{
|
||||
return Main.ActiveWorldFileData == null || !WorldGen.crimson ? provider == this._preferredProviderCorrupt : provider == this._preferredProviderCrimson;
|
||||
}
|
||||
|
||||
public IBestiaryBackgroundImagePathAndColorProvider GetPreferredProvider() => Main.ActiveWorldFileData == null || !WorldGen.crimson ? this._preferredProviderCorrupt : this._preferredProviderCrimson;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryPortraitBackgroundProviderPreferenceInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BestiaryPortraitBackgroundProviderPreferenceInfoElement :
|
||||
IPreferenceProviderElement,
|
||||
IBestiaryInfoElement
|
||||
{
|
||||
private IBestiaryBackgroundImagePathAndColorProvider _preferredProvider;
|
||||
|
||||
public BestiaryPortraitBackgroundProviderPreferenceInfoElement(
|
||||
IBestiaryBackgroundImagePathAndColorProvider preferredProvider)
|
||||
{
|
||||
this._preferredProvider = preferredProvider;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
|
||||
public bool Matches(
|
||||
IBestiaryBackgroundImagePathAndColorProvider provider)
|
||||
{
|
||||
return provider == this._preferredProvider;
|
||||
}
|
||||
|
||||
public IBestiaryBackgroundImagePathAndColorProvider GetPreferredProvider() => this._preferredProvider;
|
||||
}
|
||||
}
|
14
GameContent/Bestiary/BestiaryUICollectionInfo.cs
Normal file
14
GameContent/Bestiary/BestiaryUICollectionInfo.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryUICollectionInfo
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public struct BestiaryUICollectionInfo
|
||||
{
|
||||
public BestiaryEntry OwnerEntry;
|
||||
public BestiaryEntryUnlockState UnlockState;
|
||||
}
|
||||
}
|
16
GameContent/Bestiary/BestiaryUnlockProgressReport.cs
Normal file
16
GameContent/Bestiary/BestiaryUnlockProgressReport.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryUnlockProgressReport
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public struct BestiaryUnlockProgressReport
|
||||
{
|
||||
public int EntriesTotal;
|
||||
public float CompletionAmountTotal;
|
||||
|
||||
public float CompletionPercent => this.EntriesTotal == 0 ? 1f : this.CompletionAmountTotal / (float) this.EntriesTotal;
|
||||
}
|
||||
}
|
56
GameContent/Bestiary/BestiaryUnlocksTracker.cs
Normal file
56
GameContent/Bestiary/BestiaryUnlocksTracker.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BestiaryUnlocksTracker
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BestiaryUnlocksTracker : IPersistentPerWorldContent, IOnPlayerJoining
|
||||
{
|
||||
public NPCKillsTracker Kills = new NPCKillsTracker();
|
||||
public NPCWasNearPlayerTracker Sights = new NPCWasNearPlayerTracker();
|
||||
public NPCWasChatWithTracker Chats = new NPCWasChatWithTracker();
|
||||
|
||||
public void Save(BinaryWriter writer)
|
||||
{
|
||||
this.Kills.Save(writer);
|
||||
this.Sights.Save(writer);
|
||||
this.Chats.Save(writer);
|
||||
}
|
||||
|
||||
public void Load(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
this.Kills.Load(reader, gameVersionSaveWasMadeOn);
|
||||
this.Sights.Load(reader, gameVersionSaveWasMadeOn);
|
||||
this.Chats.Load(reader, gameVersionSaveWasMadeOn);
|
||||
}
|
||||
|
||||
public void ValidateWorld(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
this.Kills.ValidateWorld(reader, gameVersionSaveWasMadeOn);
|
||||
this.Sights.ValidateWorld(reader, gameVersionSaveWasMadeOn);
|
||||
this.Chats.ValidateWorld(reader, gameVersionSaveWasMadeOn);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.Kills.Reset();
|
||||
this.Sights.Reset();
|
||||
this.Chats.Reset();
|
||||
}
|
||||
|
||||
public void OnPlayerJoining(int playerIndex)
|
||||
{
|
||||
this.Kills.OnPlayerJoining(playerIndex);
|
||||
this.Sights.OnPlayerJoining(playerIndex);
|
||||
this.Chats.OnPlayerJoining(playerIndex);
|
||||
}
|
||||
|
||||
public void FillBasedOnVersionBefore210()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
18
GameContent/Bestiary/BossBestiaryInfoElement.cs
Normal file
18
GameContent/Bestiary/BossBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.BossBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class BossBestiaryInfoElement : IBestiaryInfoElement, IProvideSearchFilterString
|
||||
{
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState < BestiaryEntryUnlockState.CanShowPortraitOnly_1 ? (string) null : Language.GetText("BestiaryInfo.IsBoss").Value;
|
||||
}
|
||||
}
|
40
GameContent/Bestiary/CommonEnemyUICollectionInfoProvider.cs
Normal file
40
GameContent/Bestiary/CommonEnemyUICollectionInfoProvider.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.CommonEnemyUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class CommonEnemyUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private string _persistentIdentifierToCheck;
|
||||
private bool _quickUnlock;
|
||||
|
||||
public CommonEnemyUICollectionInfoProvider(string persistentId, bool quickUnlock)
|
||||
{
|
||||
this._persistentIdentifierToCheck = persistentId;
|
||||
this._quickUnlock = quickUnlock;
|
||||
}
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo()
|
||||
{
|
||||
BestiaryEntryUnlockState stateByKillCount = CommonEnemyUICollectionInfoProvider.GetUnlockStateByKillCount(Main.BestiaryTracker.Kills.GetKillCount(this._persistentIdentifierToCheck), this._quickUnlock);
|
||||
return new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = stateByKillCount
|
||||
};
|
||||
}
|
||||
|
||||
public static BestiaryEntryUnlockState GetUnlockStateByKillCount(
|
||||
int killCount,
|
||||
bool quickUnlock)
|
||||
{
|
||||
return !quickUnlock || killCount <= 0 ? (killCount < 50 ? (killCount < 25 ? (killCount < 10 ? (killCount < 1 ? BestiaryEntryUnlockState.NotKnownAtAll_0 : BestiaryEntryUnlockState.CanShowPortraitOnly_1) : BestiaryEntryUnlockState.CanShowStats_2) : BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3) : BestiaryEntryUnlockState.CanShowDropsWithDropRates_4) : BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
24
GameContent/Bestiary/CritterUICollectionInfoProvider.cs
Normal file
24
GameContent/Bestiary/CritterUICollectionInfoProvider.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.CritterUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class CritterUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private string _persistentIdentifierToCheck;
|
||||
|
||||
public CritterUICollectionInfoProvider(string persistentId) => this._persistentIdentifierToCheck = persistentId;
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo() => new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = Main.BestiaryTracker.Sights.GetWasNearbyBefore(this._persistentIdentifierToCheck) ? BestiaryEntryUnlockState.CanShowDropsWithDropRates_4 : BestiaryEntryUnlockState.NotKnownAtAll_0
|
||||
};
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
59
GameContent/Bestiary/CustomEntryIcon.cs
Normal file
59
GameContent/Bestiary/CustomEntryIcon.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.CustomEntryIcon
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class CustomEntryIcon : IEntryIcon
|
||||
{
|
||||
private LocalizedText _text;
|
||||
private Asset<Texture2D> _textureAsset;
|
||||
private Rectangle _sourceRectangle;
|
||||
private Func<bool> _unlockCondition;
|
||||
|
||||
public CustomEntryIcon(string nameLanguageKey, string texturePath, Func<bool> unlockCondition)
|
||||
{
|
||||
this._text = Language.GetText(nameLanguageKey);
|
||||
this._textureAsset = Main.Assets.Request<Texture2D>(texturePath, (AssetRequestMode) 1);
|
||||
this._unlockCondition = unlockCondition;
|
||||
this.UpdateUnlockState(false);
|
||||
}
|
||||
|
||||
public IEntryIcon CreateClone() => (IEntryIcon) new CustomEntryIcon(this._text.Key, this._textureAsset.Name, this._unlockCondition);
|
||||
|
||||
public void Update(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
Rectangle hitbox,
|
||||
EntryIconDrawSettings settings)
|
||||
{
|
||||
this.UpdateUnlockState(this.GetUnlockState(providedInfo));
|
||||
}
|
||||
|
||||
public void Draw(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
SpriteBatch spriteBatch,
|
||||
EntryIconDrawSettings settings)
|
||||
{
|
||||
Rectangle iconbox = settings.iconbox;
|
||||
spriteBatch.Draw(this._textureAsset.Value, iconbox.Center.ToVector2() + Vector2.One, new Rectangle?(this._sourceRectangle), Color.White, 0.0f, this._sourceRectangle.Size() / 2f, 1f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public string GetHoverText(BestiaryUICollectionInfo providedInfo) => this.GetUnlockState(providedInfo) ? this._text.Value : "???";
|
||||
|
||||
private void UpdateUnlockState(bool state)
|
||||
{
|
||||
this._sourceRectangle = this._textureAsset.Frame(2, frameX: state.ToInt());
|
||||
this._sourceRectangle.Inflate(-2, -2);
|
||||
}
|
||||
|
||||
public bool GetUnlockState(BestiaryUICollectionInfo providedInfo) => providedInfo.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;
|
||||
}
|
||||
}
|
17
GameContent/Bestiary/EntryIconDrawSettings.cs
Normal file
17
GameContent/Bestiary/EntryIconDrawSettings.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.EntryIconDrawSettings
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public struct EntryIconDrawSettings
|
||||
{
|
||||
public bool IsPortrait;
|
||||
public bool IsHovered;
|
||||
public Rectangle iconbox;
|
||||
}
|
||||
}
|
88
GameContent/Bestiary/FilterProviderInfoElement.cs
Normal file
88
GameContent/Bestiary/FilterProviderInfoElement.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.FilterProviderInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class FilterProviderInfoElement :
|
||||
IFilterInfoProvider,
|
||||
IProvideSearchFilterString,
|
||||
IBestiaryInfoElement
|
||||
{
|
||||
private const int framesPerRow = 16;
|
||||
private const int framesPerColumn = 5;
|
||||
private Point _filterIconFrame;
|
||||
private string _key;
|
||||
|
||||
public int DisplayTextPriority { get; set; }
|
||||
|
||||
public FilterProviderInfoElement(string nameLanguageKey, int filterIconFrame)
|
||||
{
|
||||
this._key = nameLanguageKey;
|
||||
this._filterIconFrame.X = filterIconFrame % 16;
|
||||
this._filterIconFrame.Y = filterIconFrame / 16;
|
||||
}
|
||||
|
||||
public UIElement GetFilterImage()
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(16, 5, this._filterIconFrame.X, this._filterIconFrame.Y));
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
return (UIElement) uiImageFramed;
|
||||
}
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0 ? (string) null : Language.GetText(this._key).Value;
|
||||
|
||||
public string GetDisplayNameKey() => this._key;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
|
||||
return (UIElement) null;
|
||||
UIPanel uiPanel = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode) 1), (Asset<Texture2D>) null, customBarSize: 7);
|
||||
uiPanel.Width = new StyleDimension(-14f, 1f);
|
||||
uiPanel.Height = new StyleDimension(34f, 0.0f);
|
||||
uiPanel.BackgroundColor = new Color(43, 56, 101);
|
||||
uiPanel.BorderColor = Color.Transparent;
|
||||
uiPanel.Left = new StyleDimension(5f, 0.0f);
|
||||
UIElement button = (UIElement) uiPanel;
|
||||
button.SetPadding(0.0f);
|
||||
button.PaddingRight = 5f;
|
||||
UIElement filterImage = this.GetFilterImage();
|
||||
filterImage.HAlign = 0.0f;
|
||||
filterImage.Left = new StyleDimension(5f, 0.0f);
|
||||
UIText uiText1 = new UIText(Language.GetText(this.GetDisplayNameKey()), 0.8f);
|
||||
uiText1.HAlign = 0.0f;
|
||||
uiText1.Left = new StyleDimension(38f, 0.0f);
|
||||
uiText1.TextOriginX = 0.0f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.DynamicallyScaleDownToWidth = true;
|
||||
UIText uiText2 = uiText1;
|
||||
if (filterImage != null)
|
||||
button.Append(filterImage);
|
||||
button.Append((UIElement) uiText2);
|
||||
this.AddOnHover(button);
|
||||
return button;
|
||||
}
|
||||
|
||||
private void AddOnHover(UIElement button) => button.OnUpdate += (UIElement.ElementEvent) (e => this.ShowButtonName(e));
|
||||
|
||||
private void ShowButtonName(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
string textValue = Language.GetTextValue(this.GetDisplayNameKey());
|
||||
Main.instance.MouseText(textValue);
|
||||
}
|
||||
}
|
||||
}
|
147
GameContent/Bestiary/Filters.cs
Normal file
147
GameContent/Bestiary/Filters.cs
Normal file
|
@ -0,0 +1,147 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.Filters
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public static class Filters
|
||||
{
|
||||
public class BySearch :
|
||||
IBestiaryEntryFilter,
|
||||
IEntryFilter<BestiaryEntry>,
|
||||
ISearchFilter<BestiaryEntry>
|
||||
{
|
||||
private string _search;
|
||||
|
||||
public bool? ForcedDisplay => new bool?(true);
|
||||
|
||||
public bool FitsFilter(BestiaryEntry entry)
|
||||
{
|
||||
if (this._search == null)
|
||||
return true;
|
||||
BestiaryUICollectionInfo uiCollectionInfo = entry.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
for (int index = 0; index < entry.Info.Count; ++index)
|
||||
{
|
||||
if (entry.Info[index] is IProvideSearchFilterString searchFilterString1)
|
||||
{
|
||||
string searchString = searchFilterString1.GetSearchString(ref uiCollectionInfo);
|
||||
if (searchString != null && searchString.ToLower().IndexOf(this._search, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.IfSearched";
|
||||
|
||||
public UIElement GetImage()
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Rank_Light", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame());
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
return (UIElement) uiImageFramed;
|
||||
}
|
||||
|
||||
public void SetSearch(string searchText) => this._search = searchText;
|
||||
}
|
||||
|
||||
public class ByUnlockState : IBestiaryEntryFilter, IEntryFilter<BestiaryEntry>
|
||||
{
|
||||
public bool? ForcedDisplay => new bool?(true);
|
||||
|
||||
public bool FitsFilter(BestiaryEntry entry)
|
||||
{
|
||||
BestiaryUICollectionInfo uiCollectionInfo = entry.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
return entry.Icon.GetUnlockState(uiCollectionInfo);
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.IfUnlocked";
|
||||
|
||||
public UIElement GetImage()
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(16, 5, 14, 3));
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
return (UIElement) uiImageFramed;
|
||||
}
|
||||
}
|
||||
|
||||
public class ByRareCreature : IBestiaryEntryFilter, IEntryFilter<BestiaryEntry>
|
||||
{
|
||||
public bool? ForcedDisplay => new bool?();
|
||||
|
||||
public bool FitsFilter(BestiaryEntry entry)
|
||||
{
|
||||
for (int index = 0; index < entry.Info.Count; ++index)
|
||||
{
|
||||
if (entry.Info[index] is RareSpawnBestiaryInfoElement)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.IsRare";
|
||||
|
||||
public UIElement GetImage()
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Rank_Light", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame());
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
return (UIElement) uiImageFramed;
|
||||
}
|
||||
}
|
||||
|
||||
public class ByBoss : IBestiaryEntryFilter, IEntryFilter<BestiaryEntry>
|
||||
{
|
||||
public bool? ForcedDisplay => new bool?();
|
||||
|
||||
public bool FitsFilter(BestiaryEntry entry)
|
||||
{
|
||||
for (int index = 0; index < entry.Info.Count; ++index)
|
||||
{
|
||||
if (entry.Info[index] is BossBestiaryInfoElement)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.IsBoss";
|
||||
|
||||
public UIElement GetImage()
|
||||
{
|
||||
Asset<Texture2D> asset = Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Icon_Tags_Shadow", (AssetRequestMode) 1);
|
||||
UIImageFramed uiImageFramed = new UIImageFramed(asset, asset.Frame(16, 5, 15, 3));
|
||||
uiImageFramed.HAlign = 0.5f;
|
||||
uiImageFramed.VAlign = 0.5f;
|
||||
return (UIElement) uiImageFramed;
|
||||
}
|
||||
}
|
||||
|
||||
public class ByInfoElement : IBestiaryEntryFilter, IEntryFilter<BestiaryEntry>
|
||||
{
|
||||
private IBestiaryInfoElement _element;
|
||||
|
||||
public bool? ForcedDisplay => new bool?();
|
||||
|
||||
public ByInfoElement(IBestiaryInfoElement element) => this._element = element;
|
||||
|
||||
public bool FitsFilter(BestiaryEntry entry) => entry.Info.Contains(this._element);
|
||||
|
||||
public string GetDisplayNameKey() => !(this._element is IFilterInfoProvider element) ? (string) null : element.GetDisplayNameKey();
|
||||
|
||||
public UIElement GetImage() => !(this._element is IFilterInfoProvider element) ? (UIElement) null : element.GetFilterImage();
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Bestiary/FlavorTextBestiaryInfoElement.cs
Normal file
49
GameContent/Bestiary/FlavorTextBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.FlavorTextBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class FlavorTextBestiaryInfoElement : IBestiaryInfoElement
|
||||
{
|
||||
private string _key;
|
||||
|
||||
public FlavorTextBestiaryInfoElement(string languageKey) => this._key = languageKey;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
|
||||
return (UIElement) null;
|
||||
UIPanel uiPanel = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode) 1), (Asset<Texture2D>) null, customBarSize: 7);
|
||||
uiPanel.Width = new StyleDimension(-11f, 1f);
|
||||
uiPanel.Height = new StyleDimension(109f, 0.0f);
|
||||
uiPanel.BackgroundColor = new Color(43, 56, 101);
|
||||
uiPanel.BorderColor = Color.Transparent;
|
||||
uiPanel.Left = new StyleDimension(3f, 0.0f);
|
||||
uiPanel.PaddingLeft = 4f;
|
||||
uiPanel.PaddingRight = 4f;
|
||||
UIText uiText = new UIText(Language.GetText(this._key), 0.8f);
|
||||
uiText.HAlign = 0.0f;
|
||||
uiText.VAlign = 0.0f;
|
||||
uiText.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText.IsWrapped = true;
|
||||
UIText text = uiText;
|
||||
FlavorTextBestiaryInfoElement.AddDynamicResize((UIElement) uiPanel, text);
|
||||
uiPanel.Append((UIElement) text);
|
||||
return (UIElement) uiPanel;
|
||||
}
|
||||
|
||||
private static void AddDynamicResize(UIElement container, UIText text) => text.OnInternalTextChange += (Action) (() => container.Height = new StyleDimension(text.MinHeight.Pixels, 0.0f));
|
||||
}
|
||||
}
|
67
GameContent/Bestiary/GoldCritterUICollectionInfoProvider.cs
Normal file
67
GameContent/Bestiary/GoldCritterUICollectionInfoProvider.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.GoldCritterUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.ID;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class GoldCritterUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private string[] _normalCritterPersistentId;
|
||||
private string _goldCritterPersistentId;
|
||||
|
||||
public GoldCritterUICollectionInfoProvider(
|
||||
int[] normalCritterPersistentId,
|
||||
string goldCritterPersistentId)
|
||||
{
|
||||
this._normalCritterPersistentId = new string[normalCritterPersistentId.Length];
|
||||
for (int index = 0; index < normalCritterPersistentId.Length; ++index)
|
||||
this._normalCritterPersistentId[index] = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[normalCritterPersistentId[index]];
|
||||
this._goldCritterPersistentId = goldCritterPersistentId;
|
||||
}
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo()
|
||||
{
|
||||
BestiaryEntryUnlockState unlockStateForCritter1 = this.GetUnlockStateForCritter(this._goldCritterPersistentId);
|
||||
BestiaryEntryUnlockState entryUnlockState = BestiaryEntryUnlockState.NotKnownAtAll_0;
|
||||
if (unlockStateForCritter1 > entryUnlockState)
|
||||
entryUnlockState = unlockStateForCritter1;
|
||||
foreach (string persistentId in this._normalCritterPersistentId)
|
||||
{
|
||||
BestiaryEntryUnlockState unlockStateForCritter2 = this.GetUnlockStateForCritter(persistentId);
|
||||
if (unlockStateForCritter2 > entryUnlockState)
|
||||
entryUnlockState = unlockStateForCritter2;
|
||||
}
|
||||
BestiaryUICollectionInfo uiCollectionInfo = new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = entryUnlockState
|
||||
};
|
||||
if (entryUnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0 || this.TryFindingOneGoldCritterThatIsAlreadyUnlocked())
|
||||
return uiCollectionInfo;
|
||||
return new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = BestiaryEntryUnlockState.NotKnownAtAll_0
|
||||
};
|
||||
}
|
||||
|
||||
private bool TryFindingOneGoldCritterThatIsAlreadyUnlocked()
|
||||
{
|
||||
for (int index = 0; index < NPCID.Sets.GoldCrittersCollection.Count; ++index)
|
||||
{
|
||||
int goldCritters = NPCID.Sets.GoldCrittersCollection[index];
|
||||
if (this.GetUnlockStateForCritter(ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[goldCritters]) > BestiaryEntryUnlockState.NotKnownAtAll_0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private BestiaryEntryUnlockState GetUnlockStateForCritter(
|
||||
string persistentId)
|
||||
{
|
||||
return !Main.BestiaryTracker.Sights.GetWasNearbyBefore(persistentId) ? BestiaryEntryUnlockState.NotKnownAtAll_0 : BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.HighestOfMultipleUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class HighestOfMultipleUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private IBestiaryUICollectionInfoProvider[] _providers;
|
||||
private int _mainProviderIndex;
|
||||
|
||||
public HighestOfMultipleUICollectionInfoProvider(
|
||||
params IBestiaryUICollectionInfoProvider[] providers)
|
||||
{
|
||||
this._providers = providers;
|
||||
this._mainProviderIndex = 0;
|
||||
}
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo()
|
||||
{
|
||||
BestiaryUICollectionInfo uiCollectionInfo1 = this._providers[this._mainProviderIndex].GetEntryUICollectionInfo();
|
||||
BestiaryEntryUnlockState unlockState = uiCollectionInfo1.UnlockState;
|
||||
for (int index = 0; index < this._providers.Length; ++index)
|
||||
{
|
||||
BestiaryUICollectionInfo uiCollectionInfo2 = this._providers[index].GetEntryUICollectionInfo();
|
||||
if (unlockState < uiCollectionInfo2.UnlockState)
|
||||
unlockState = uiCollectionInfo2.UnlockState;
|
||||
}
|
||||
uiCollectionInfo1.UnlockState = unlockState;
|
||||
return uiCollectionInfo1;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryBackgroundImagePathAndColorProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryBackgroundImagePathAndColorProvider
|
||||
{
|
||||
Asset<Texture2D> GetBackgroundImage();
|
||||
|
||||
Color? GetBackgroundColor();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryBackgroundOverlayAndColorProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryBackgroundOverlayAndColorProvider
|
||||
{
|
||||
Asset<Texture2D> GetBackgroundOverlayImage();
|
||||
|
||||
Color? GetBackgroundOverlayColor();
|
||||
|
||||
float DisplayPriority { get; }
|
||||
}
|
||||
}
|
13
GameContent/Bestiary/IBestiaryEntryDisplayIndex.cs
Normal file
13
GameContent/Bestiary/IBestiaryEntryDisplayIndex.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryEntryDisplayIndex
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryEntryDisplayIndex
|
||||
{
|
||||
int BestiaryDisplayIndex { get; }
|
||||
}
|
||||
}
|
15
GameContent/Bestiary/IBestiaryEntryFilter.cs
Normal file
15
GameContent/Bestiary/IBestiaryEntryFilter.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryEntryFilter
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryEntryFilter : IEntryFilter<BestiaryEntry>
|
||||
{
|
||||
bool? ForcedDisplay { get; }
|
||||
}
|
||||
}
|
15
GameContent/Bestiary/IBestiaryInfoElement.cs
Normal file
15
GameContent/Bestiary/IBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryInfoElement
|
||||
{
|
||||
UIElement ProvideUIElement(BestiaryUICollectionInfo info);
|
||||
}
|
||||
}
|
16
GameContent/Bestiary/IBestiarySortStep.cs
Normal file
16
GameContent/Bestiary/IBestiarySortStep.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiarySortStep
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiarySortStep : IEntrySortStep<BestiaryEntry>, IComparer<BestiaryEntry>
|
||||
{
|
||||
bool HiddenFromSortOptions { get; }
|
||||
}
|
||||
}
|
13
GameContent/Bestiary/IBestiaryUICollectionInfoProvider.cs
Normal file
13
GameContent/Bestiary/IBestiaryUICollectionInfoProvider.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IBestiaryUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
BestiaryUICollectionInfo GetEntryUICollectionInfo();
|
||||
}
|
||||
}
|
30
GameContent/Bestiary/IEntryIcon.cs
Normal file
30
GameContent/Bestiary/IEntryIcon.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IEntryIcon
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IEntryIcon
|
||||
{
|
||||
void Update(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
Rectangle hitbox,
|
||||
EntryIconDrawSettings settings);
|
||||
|
||||
void Draw(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
SpriteBatch spriteBatch,
|
||||
EntryIconDrawSettings settings);
|
||||
|
||||
bool GetUnlockState(BestiaryUICollectionInfo providedInfo);
|
||||
|
||||
string GetHoverText(BestiaryUICollectionInfo providedInfo);
|
||||
|
||||
IEntryIcon CreateClone();
|
||||
}
|
||||
}
|
17
GameContent/Bestiary/IFilterInfoProvider.cs
Normal file
17
GameContent/Bestiary/IFilterInfoProvider.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IFilterInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IFilterInfoProvider
|
||||
{
|
||||
UIElement GetFilterImage();
|
||||
|
||||
string GetDisplayNameKey();
|
||||
}
|
||||
}
|
12
GameContent/Bestiary/IItemBestiaryInfoElement.cs
Normal file
12
GameContent/Bestiary/IItemBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IItemBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IItemBestiaryInfoElement : IBestiaryInfoElement
|
||||
{
|
||||
}
|
||||
}
|
16
GameContent/Bestiary/IPreferenceProviderElement.cs
Normal file
16
GameContent/Bestiary/IPreferenceProviderElement.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IPreferenceProviderElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IPreferenceProviderElement : IBestiaryInfoElement
|
||||
{
|
||||
IBestiaryBackgroundImagePathAndColorProvider GetPreferredProvider();
|
||||
|
||||
bool Matches(
|
||||
IBestiaryBackgroundImagePathAndColorProvider provider);
|
||||
}
|
||||
}
|
13
GameContent/Bestiary/IProvideSearchFilterString.cs
Normal file
13
GameContent/Bestiary/IProvideSearchFilterString.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.IProvideSearchFilterString
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public interface IProvideSearchFilterString
|
||||
{
|
||||
string GetSearchString(ref BestiaryUICollectionInfo info);
|
||||
}
|
||||
}
|
56
GameContent/Bestiary/ItemDropBestiaryInfoElement.cs
Normal file
56
GameContent/Bestiary/ItemDropBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.ItemDropBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.GameContent.ItemDropRules;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class ItemDropBestiaryInfoElement :
|
||||
IItemBestiaryInfoElement,
|
||||
IBestiaryInfoElement,
|
||||
IProvideSearchFilterString
|
||||
{
|
||||
protected DropRateInfo _droprateInfo;
|
||||
|
||||
public ItemDropBestiaryInfoElement(DropRateInfo info) => this._droprateInfo = info;
|
||||
|
||||
public virtual UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
bool flag = ItemDropBestiaryInfoElement.ShouldShowItem(ref this._droprateInfo);
|
||||
if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
|
||||
flag = false;
|
||||
return !flag ? (UIElement) null : (UIElement) new UIBestiaryInfoItemLine(this._droprateInfo, info);
|
||||
}
|
||||
|
||||
private static bool ShouldShowItem(ref DropRateInfo dropRateInfo)
|
||||
{
|
||||
bool flag = true;
|
||||
if (dropRateInfo.conditions != null && dropRateInfo.conditions.Count > 0)
|
||||
{
|
||||
for (int index = 0; index < dropRateInfo.conditions.Count; ++index)
|
||||
{
|
||||
if (!dropRateInfo.conditions[index].CanShowItemDropInUI())
|
||||
{
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info)
|
||||
{
|
||||
bool flag = ItemDropBestiaryInfoElement.ShouldShowItem(ref this._droprateInfo);
|
||||
if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
|
||||
flag = false;
|
||||
return !flag ? (string) null : ContentSamples.ItemsByType[this._droprateInfo.itemId].Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.ItemFromCatchingNPCBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class ItemFromCatchingNPCBestiaryInfoElement :
|
||||
IItemBestiaryInfoElement,
|
||||
IBestiaryInfoElement,
|
||||
IProvideSearchFilterString
|
||||
{
|
||||
private int _itemType;
|
||||
|
||||
public ItemFromCatchingNPCBestiaryInfoElement(int itemId) => this._itemType = itemId;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => info.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3 ? (UIElement) null : (UIElement) new UIBestiaryInfoLine<string>("catch item #" + (object) this._itemType ?? "");
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState < BestiaryEntryUnlockState.CanShowDropsWithoutDropRates_3 ? (string) null : ContentSamples.ItemsByType[this._itemType].Name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.MoonLordPortraitBackgroundProviderBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class MoonLordPortraitBackgroundProviderBestiaryInfoElement :
|
||||
IBestiaryInfoElement,
|
||||
IBestiaryBackgroundImagePathAndColorProvider
|
||||
{
|
||||
public Asset<Texture2D> GetBackgroundImage() => Main.Assets.Request<Texture2D>("Images/MapBG1", (AssetRequestMode) 1);
|
||||
|
||||
public Color? GetBackgroundColor() => new Color?(Color.Black);
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
86
GameContent/Bestiary/NPCKillsTracker.cs
Normal file
86
GameContent/Bestiary/NPCKillsTracker.cs
Normal file
|
@ -0,0 +1,86 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCKillsTracker
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.GameContent.NetModules;
|
||||
using Terraria.ID;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCKillsTracker : IPersistentPerWorldContent, IOnPlayerJoining
|
||||
{
|
||||
public const int POSITIVE_KILL_COUNT_CAP = 9999;
|
||||
private Dictionary<string, int> _killCountsByNpcId;
|
||||
|
||||
public NPCKillsTracker() => this._killCountsByNpcId = new Dictionary<string, int>();
|
||||
|
||||
public void RegisterKill(NPC npc)
|
||||
{
|
||||
string bestiaryCreditId = npc.GetBestiaryCreditId();
|
||||
int num;
|
||||
this._killCountsByNpcId.TryGetValue(bestiaryCreditId, out num);
|
||||
int killcount = num + 1;
|
||||
this._killCountsByNpcId[bestiaryCreditId] = Utils.Clamp<int>(killcount, 0, 9999);
|
||||
if (Main.netMode != 2)
|
||||
return;
|
||||
NetManager.Instance.Broadcast(NetBestiaryModule.SerializeKillCount(npc.netID, killcount));
|
||||
}
|
||||
|
||||
public int GetKillCount(NPC npc) => this.GetKillCount(npc.GetBestiaryCreditId());
|
||||
|
||||
public void SetKillCountDirectly(string persistentId, int killCount) => this._killCountsByNpcId[persistentId] = Utils.Clamp<int>(killCount, 0, 9999);
|
||||
|
||||
public int GetKillCount(string persistentId)
|
||||
{
|
||||
int num;
|
||||
this._killCountsByNpcId.TryGetValue(persistentId, out num);
|
||||
return num;
|
||||
}
|
||||
|
||||
public void Save(BinaryWriter writer)
|
||||
{
|
||||
lock (this._killCountsByNpcId)
|
||||
{
|
||||
writer.Write(this._killCountsByNpcId.Count);
|
||||
foreach (KeyValuePair<string, int> keyValuePair in this._killCountsByNpcId)
|
||||
{
|
||||
writer.Write(keyValuePair.Key);
|
||||
writer.Write(keyValuePair.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
this._killCountsByNpcId[reader.ReadString()] = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public void ValidateWorld(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
reader.ReadString();
|
||||
reader.ReadInt32();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset() => this._killCountsByNpcId.Clear();
|
||||
|
||||
public void OnPlayerJoining(int playerIndex)
|
||||
{
|
||||
foreach (KeyValuePair<string, int> keyValuePair in this._killCountsByNpcId)
|
||||
{
|
||||
int idsByPersistentId = ContentSamples.NpcNetIdsByPersistentIds[keyValuePair.Key];
|
||||
NetManager.Instance.SendToClient(NetBestiaryModule.SerializeKillCount(idsByPersistentId, keyValuePair.Value), playerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
22
GameContent/Bestiary/NPCNetIdBestiaryInfoElement.cs
Normal file
22
GameContent/Bestiary/NPCNetIdBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCNetIdBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCNetIdBestiaryInfoElement : IBestiaryInfoElement, IBestiaryEntryDisplayIndex
|
||||
{
|
||||
public int NetId { get; private set; }
|
||||
|
||||
public NPCNetIdBestiaryInfoElement(int npcNetId) => this.NetId = npcNetId;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
|
||||
public int BestiaryDisplayIndex => ContentSamples.NpcBestiarySortingId[this.NetId];
|
||||
}
|
||||
}
|
137
GameContent/Bestiary/NPCPortraitInfoElement.cs
Normal file
137
GameContent/Bestiary/NPCPortraitInfoElement.cs
Normal file
|
@ -0,0 +1,137 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCPortraitInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCPortraitInfoElement : IBestiaryInfoElement
|
||||
{
|
||||
private int? _filledStarsCount;
|
||||
|
||||
public NPCPortraitInfoElement(int? rarityStars = null) => this._filledStarsCount = rarityStars;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
UIElement uiElement = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension(112f, 0.0f)
|
||||
};
|
||||
uiElement.SetPadding(0.0f);
|
||||
BestiaryEntry entry = new BestiaryEntry();
|
||||
Asset<Texture2D> portraitBackgroundAsset = (Asset<Texture2D>) null;
|
||||
Color white = Color.White;
|
||||
entry.Icon = info.OwnerEntry.Icon.CreateClone();
|
||||
entry.UIInfoProvider = info.OwnerEntry.UIInfoProvider;
|
||||
List<IBestiaryBackgroundOverlayAndColorProvider> overlays = new List<IBestiaryBackgroundOverlayAndColorProvider>();
|
||||
bool flag1 = info.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;
|
||||
if (flag1)
|
||||
{
|
||||
List<IBestiaryInfoElement> source1 = new List<IBestiaryInfoElement>();
|
||||
IEnumerable<IBestiaryBackgroundImagePathAndColorProvider> source2 = info.OwnerEntry.Info.OfType<IBestiaryBackgroundImagePathAndColorProvider>();
|
||||
IEnumerable<IPreferenceProviderElement> preferences = info.OwnerEntry.Info.OfType<IPreferenceProviderElement>();
|
||||
Func<IBestiaryBackgroundImagePathAndColorProvider, bool> predicate = (Func<IBestiaryBackgroundImagePathAndColorProvider, bool>) (provider => preferences.Any<IPreferenceProviderElement>((Func<IPreferenceProviderElement, bool>) (preference => preference.Matches(provider))));
|
||||
IEnumerable<IBestiaryBackgroundImagePathAndColorProvider> andColorProviders = source2.Where<IBestiaryBackgroundImagePathAndColorProvider>(predicate);
|
||||
bool flag2 = false;
|
||||
foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in andColorProviders)
|
||||
{
|
||||
Asset<Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
|
||||
if (backgroundImage != null)
|
||||
{
|
||||
portraitBackgroundAsset = backgroundImage;
|
||||
flag2 = true;
|
||||
Color? backgroundColor = andColorProvider.GetBackgroundColor();
|
||||
if (backgroundColor.HasValue)
|
||||
{
|
||||
white = backgroundColor.Value;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach (IBestiaryInfoElement bestiaryInfoElement in info.OwnerEntry.Info)
|
||||
{
|
||||
if (bestiaryInfoElement is IBestiaryBackgroundImagePathAndColorProvider andColorProvider9)
|
||||
{
|
||||
Asset<Texture2D> backgroundImage = andColorProvider9.GetBackgroundImage();
|
||||
if (backgroundImage != null)
|
||||
{
|
||||
if (!flag2)
|
||||
portraitBackgroundAsset = backgroundImage;
|
||||
Color? backgroundColor = andColorProvider9.GetBackgroundColor();
|
||||
if (backgroundColor.HasValue)
|
||||
white = backgroundColor.Value;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
if (!flag2 && bestiaryInfoElement is IBestiaryBackgroundOverlayAndColorProvider andColorProvider10 && andColorProvider10.GetBackgroundOverlayImage() != null)
|
||||
source1.Add(bestiaryInfoElement);
|
||||
}
|
||||
overlays.AddRange(source1.OrderBy<IBestiaryInfoElement, float>(new Func<IBestiaryInfoElement, float>(this.GetSortingValueForElement)).Select<IBestiaryInfoElement, IBestiaryBackgroundOverlayAndColorProvider>((Func<IBestiaryInfoElement, IBestiaryBackgroundOverlayAndColorProvider>) (x => x as IBestiaryBackgroundOverlayAndColorProvider)));
|
||||
}
|
||||
UIBestiaryNPCEntryPortrait npcEntryPortrait1 = new UIBestiaryNPCEntryPortrait(entry, portraitBackgroundAsset, white, overlays);
|
||||
npcEntryPortrait1.Left = new StyleDimension(4f, 0.0f);
|
||||
npcEntryPortrait1.HAlign = 0.0f;
|
||||
UIBestiaryNPCEntryPortrait npcEntryPortrait2 = npcEntryPortrait1;
|
||||
uiElement.Append((UIElement) npcEntryPortrait2);
|
||||
if (flag1 && this._filledStarsCount.HasValue)
|
||||
{
|
||||
UIElement starsContainer = this.CreateStarsContainer();
|
||||
uiElement.Append(starsContainer);
|
||||
}
|
||||
return uiElement;
|
||||
}
|
||||
|
||||
private float GetSortingValueForElement(IBestiaryInfoElement element) => element is IBestiaryBackgroundOverlayAndColorProvider andColorProvider ? andColorProvider.DisplayPriority : 0.0f;
|
||||
|
||||
private UIElement CreateStarsContainer()
|
||||
{
|
||||
int num1 = 14;
|
||||
int num2 = 14;
|
||||
int num3 = -4;
|
||||
int num4 = num1 + num3;
|
||||
int val2 = 5;
|
||||
int val1 = 5;
|
||||
int num5 = this._filledStarsCount.Value;
|
||||
float num6 = 1f;
|
||||
int num7 = num4 * Math.Min(val1, val2) - num3;
|
||||
double num8 = (double) num4 * Math.Ceiling((double) val2 / (double) val1) - (double) num3;
|
||||
UIPanel uiPanel = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode) 1), (Asset<Texture2D>) null, 5, 21);
|
||||
uiPanel.Width = new StyleDimension((float) num7 + num6 * 2f, 0.0f);
|
||||
uiPanel.Height = new StyleDimension((float) num8 + num6 * 2f, 0.0f);
|
||||
uiPanel.BackgroundColor = Color.Gray * 0.0f;
|
||||
uiPanel.BorderColor = Color.Transparent;
|
||||
uiPanel.Left = new StyleDimension(10f, 0.0f);
|
||||
uiPanel.Top = new StyleDimension(6f, 0.0f);
|
||||
uiPanel.VAlign = 0.0f;
|
||||
UIElement uiElement = (UIElement) uiPanel;
|
||||
uiElement.SetPadding(0.0f);
|
||||
for (int index = val2 - 1; index >= 0; --index)
|
||||
{
|
||||
string str = "Images/UI/Bestiary/Icon_Rank_Light";
|
||||
if (index >= num5)
|
||||
str = "Images/UI/Bestiary/Icon_Rank_Dim";
|
||||
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>(str, (AssetRequestMode) 1));
|
||||
uiImage1.Left = new StyleDimension((float) ((double) (num4 * (index % val1)) - (double) num7 * 0.5 + (double) num1 * 0.5), 0.0f);
|
||||
uiImage1.Top = new StyleDimension((float) ((double) (num4 * (index / val1)) - num8 * 0.5 + (double) num2 * 0.5), 0.0f);
|
||||
uiImage1.HAlign = 0.5f;
|
||||
uiImage1.VAlign = 0.5f;
|
||||
UIImage uiImage2 = uiImage1;
|
||||
uiElement.Append((UIElement) uiImage2);
|
||||
}
|
||||
return uiElement;
|
||||
}
|
||||
}
|
||||
}
|
245
GameContent/Bestiary/NPCStatsReportInfoElement.cs
Normal file
245
GameContent/Bestiary/NPCStatsReportInfoElement.cs
Normal file
|
@ -0,0 +1,245 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCStatsReportInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCStatsReportInfoElement : IBestiaryInfoElement
|
||||
{
|
||||
public int NpcId;
|
||||
public int GameMode;
|
||||
public int Damage;
|
||||
public int LifeMax;
|
||||
public float MonetaryValue;
|
||||
public int Defense;
|
||||
public float KnockbackResist;
|
||||
|
||||
public NPCStatsReportInfoElement(int npcNetId, int gameMode)
|
||||
{
|
||||
this.NpcId = npcNetId;
|
||||
this.GameMode = gameMode;
|
||||
if (!Main.RegisterdGameModes.TryGetValue(this.GameMode, out GameModeData _))
|
||||
return;
|
||||
NPC npc = new NPC();
|
||||
npc.SetDefaults(this.NpcId);
|
||||
this.Damage = npc.damage;
|
||||
this.LifeMax = npc.lifeMax;
|
||||
this.MonetaryValue = npc.value;
|
||||
this.Defense = npc.defense;
|
||||
this.KnockbackResist = npc.knockBackResist;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
if (info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0)
|
||||
return (UIElement) null;
|
||||
if (this.GameMode != Main.GameMode)
|
||||
return (UIElement) null;
|
||||
UIElement uiElement = new UIElement()
|
||||
{
|
||||
Width = new StyleDimension(0.0f, 1f),
|
||||
Height = new StyleDimension(109f, 0.0f)
|
||||
};
|
||||
int num1 = 99;
|
||||
int num2 = 35;
|
||||
int num3 = 3;
|
||||
int num4 = 0;
|
||||
UIImage uiImage1 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_HP", (AssetRequestMode) 1));
|
||||
uiImage1.Top = new StyleDimension((float) num4, 0.0f);
|
||||
uiImage1.Left = new StyleDimension((float) num3, 0.0f);
|
||||
UIImage uiImage2 = uiImage1;
|
||||
UIImage uiImage3 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Attack", (AssetRequestMode) 1));
|
||||
uiImage3.Top = new StyleDimension((float) (num4 + num2), 0.0f);
|
||||
uiImage3.Left = new StyleDimension((float) num3, 0.0f);
|
||||
UIImage uiImage4 = uiImage3;
|
||||
UIImage uiImage5 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Defense", (AssetRequestMode) 1));
|
||||
uiImage5.Top = new StyleDimension((float) (num4 + num2), 0.0f);
|
||||
uiImage5.Left = new StyleDimension((float) (num3 + num1), 0.0f);
|
||||
UIImage uiImage6 = uiImage5;
|
||||
UIImage uiImage7 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Knockback", (AssetRequestMode) 1));
|
||||
uiImage7.Top = new StyleDimension((float) num4, 0.0f);
|
||||
uiImage7.Left = new StyleDimension((float) (num3 + num1), 0.0f);
|
||||
UIImage uiImage8 = uiImage7;
|
||||
uiElement.Append((UIElement) uiImage2);
|
||||
uiElement.Append((UIElement) uiImage4);
|
||||
uiElement.Append((UIElement) uiImage6);
|
||||
uiElement.Append((UIElement) uiImage8);
|
||||
int num5 = -10;
|
||||
int num6 = 0;
|
||||
int monetaryValue = (int) this.MonetaryValue;
|
||||
string text1 = Utils.Clamp<int>(monetaryValue / 1000000, 0, 999).ToString();
|
||||
string text2 = Utils.Clamp<int>(monetaryValue % 1000000 / 10000, 0, 99).ToString();
|
||||
string text3 = Utils.Clamp<int>(monetaryValue % 10000 / 100, 0, 99).ToString();
|
||||
string text4 = Utils.Clamp<int>(monetaryValue % 100 / 1, 0, 99).ToString();
|
||||
if (monetaryValue / 1000000 < 1)
|
||||
text1 = "-";
|
||||
if (monetaryValue / 10000 < 1)
|
||||
text2 = "-";
|
||||
if (monetaryValue / 100 < 1)
|
||||
text3 = "-";
|
||||
if (monetaryValue < 1)
|
||||
text4 = "-";
|
||||
string text5 = this.LifeMax.ToString();
|
||||
string text6 = this.Damage.ToString();
|
||||
string text7 = this.Defense.ToString();
|
||||
string text8 = (double) this.KnockbackResist <= 0.800000011920929 ? ((double) this.KnockbackResist <= 0.400000005960464 ? ((double) this.KnockbackResist <= 0.0 ? Language.GetText("BestiaryInfo.KnockbackNone").Value : Language.GetText("BestiaryInfo.KnockbackLow").Value) : Language.GetText("BestiaryInfo.KnockbackMedium").Value) : Language.GetText("BestiaryInfo.KnockbackHigh").Value;
|
||||
if (info.UnlockState < BestiaryEntryUnlockState.CanShowStats_2)
|
||||
{
|
||||
string str1;
|
||||
text4 = str1 = "?";
|
||||
text3 = str1;
|
||||
text2 = str1;
|
||||
text1 = str1;
|
||||
string str2;
|
||||
text8 = str2 = "???";
|
||||
text7 = str2;
|
||||
text6 = str2;
|
||||
text5 = str2;
|
||||
}
|
||||
UIText uiText1 = new UIText(text5);
|
||||
uiText1.HAlign = 1f;
|
||||
uiText1.VAlign = 0.5f;
|
||||
uiText1.Left = new StyleDimension((float) num5, 0.0f);
|
||||
uiText1.Top = new StyleDimension((float) num6, 0.0f);
|
||||
uiText1.IgnoresMouseInteraction = true;
|
||||
UIText uiText2 = uiText1;
|
||||
UIText uiText3 = new UIText(text8);
|
||||
uiText3.HAlign = 1f;
|
||||
uiText3.VAlign = 0.5f;
|
||||
uiText3.Left = new StyleDimension((float) num5, 0.0f);
|
||||
uiText3.Top = new StyleDimension((float) num6, 0.0f);
|
||||
uiText3.IgnoresMouseInteraction = true;
|
||||
UIText uiText4 = uiText3;
|
||||
UIText uiText5 = new UIText(text6);
|
||||
uiText5.HAlign = 1f;
|
||||
uiText5.VAlign = 0.5f;
|
||||
uiText5.Left = new StyleDimension((float) num5, 0.0f);
|
||||
uiText5.Top = new StyleDimension((float) num6, 0.0f);
|
||||
uiText5.IgnoresMouseInteraction = true;
|
||||
UIText uiText6 = uiText5;
|
||||
UIText uiText7 = new UIText(text7);
|
||||
uiText7.HAlign = 1f;
|
||||
uiText7.VAlign = 0.5f;
|
||||
uiText7.Left = new StyleDimension((float) num5, 0.0f);
|
||||
uiText7.Top = new StyleDimension((float) num6, 0.0f);
|
||||
uiText7.IgnoresMouseInteraction = true;
|
||||
UIText uiText8 = uiText7;
|
||||
uiImage2.Append((UIElement) uiText2);
|
||||
uiImage4.Append((UIElement) uiText6);
|
||||
uiImage6.Append((UIElement) uiText8);
|
||||
uiImage8.Append((UIElement) uiText4);
|
||||
if (monetaryValue > 0)
|
||||
{
|
||||
UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator();
|
||||
horizontalSeparator1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
horizontalSeparator1.Color = new Color(89, 116, 213, (int) byte.MaxValue) * 0.9f;
|
||||
horizontalSeparator1.Left = new StyleDimension(0.0f, 0.0f);
|
||||
horizontalSeparator1.Top = new StyleDimension((float) (num6 + num2 * 2), 0.0f);
|
||||
UIHorizontalSeparator horizontalSeparator2 = horizontalSeparator1;
|
||||
uiElement.Append((UIElement) horizontalSeparator2);
|
||||
int num7 = num3;
|
||||
int num8 = num6 + num2 * 2 + 8;
|
||||
int num9 = 49;
|
||||
UIImage uiImage9 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Platinum", (AssetRequestMode) 1));
|
||||
uiImage9.Top = new StyleDimension((float) num8, 0.0f);
|
||||
uiImage9.Left = new StyleDimension((float) num7, 0.0f);
|
||||
UIImage uiImage10 = uiImage9;
|
||||
UIImage uiImage11 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Gold", (AssetRequestMode) 1));
|
||||
uiImage11.Top = new StyleDimension((float) num8, 0.0f);
|
||||
uiImage11.Left = new StyleDimension((float) (num7 + num9), 0.0f);
|
||||
UIImage uiImage12 = uiImage11;
|
||||
UIImage uiImage13 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Silver", (AssetRequestMode) 1));
|
||||
uiImage13.Top = new StyleDimension((float) num8, 0.0f);
|
||||
uiImage13.Left = new StyleDimension((float) (num7 + num9 * 2 + 1), 0.0f);
|
||||
UIImage uiImage14 = uiImage13;
|
||||
UIImage uiImage15 = new UIImage(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Copper", (AssetRequestMode) 1));
|
||||
uiImage15.Top = new StyleDimension((float) num8, 0.0f);
|
||||
uiImage15.Left = new StyleDimension((float) (num7 + num9 * 3 + 1), 0.0f);
|
||||
UIImage uiImage16 = uiImage15;
|
||||
if (text1 != "-")
|
||||
uiElement.Append((UIElement) uiImage10);
|
||||
if (text2 != "-")
|
||||
uiElement.Append((UIElement) uiImage12);
|
||||
if (text3 != "-")
|
||||
uiElement.Append((UIElement) uiImage14);
|
||||
if (text4 != "-")
|
||||
uiElement.Append((UIElement) uiImage16);
|
||||
int num10 = num5 + 3;
|
||||
float textScale = 0.85f;
|
||||
UIText uiText9 = new UIText(text1, textScale);
|
||||
uiText9.HAlign = 1f;
|
||||
uiText9.VAlign = 0.5f;
|
||||
uiText9.Left = new StyleDimension((float) num10, 0.0f);
|
||||
uiText9.Top = new StyleDimension((float) num6, 0.0f);
|
||||
UIText uiText10 = uiText9;
|
||||
UIText uiText11 = new UIText(text2, textScale);
|
||||
uiText11.HAlign = 1f;
|
||||
uiText11.VAlign = 0.5f;
|
||||
uiText11.Left = new StyleDimension((float) num10, 0.0f);
|
||||
uiText11.Top = new StyleDimension((float) num6, 0.0f);
|
||||
UIText uiText12 = uiText11;
|
||||
UIText uiText13 = new UIText(text3, textScale);
|
||||
uiText13.HAlign = 1f;
|
||||
uiText13.VAlign = 0.5f;
|
||||
uiText13.Left = new StyleDimension((float) num10, 0.0f);
|
||||
uiText13.Top = new StyleDimension((float) num6, 0.0f);
|
||||
UIText uiText14 = uiText13;
|
||||
UIText uiText15 = new UIText(text4, textScale);
|
||||
uiText15.HAlign = 1f;
|
||||
uiText15.VAlign = 0.5f;
|
||||
uiText15.Left = new StyleDimension((float) num10, 0.0f);
|
||||
uiText15.Top = new StyleDimension((float) num6, 0.0f);
|
||||
UIText uiText16 = uiText15;
|
||||
uiImage10.Append((UIElement) uiText10);
|
||||
uiImage12.Append((UIElement) uiText12);
|
||||
uiImage14.Append((UIElement) uiText14);
|
||||
uiImage16.Append((UIElement) uiText16);
|
||||
}
|
||||
else
|
||||
uiElement.Height.Pixels = (float) (num6 + num2 * 2 - 4);
|
||||
uiImage4.OnUpdate += new UIElement.ElementEvent(this.ShowStats_Attack);
|
||||
uiImage6.OnUpdate += new UIElement.ElementEvent(this.ShowStats_Defense);
|
||||
uiImage2.OnUpdate += new UIElement.ElementEvent(this.ShowStats_Life);
|
||||
uiImage8.OnUpdate += new UIElement.ElementEvent(this.ShowStats_Knockback);
|
||||
return uiElement;
|
||||
}
|
||||
|
||||
private void ShowStats_Attack(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(Language.GetTextValue("BestiaryInfo.Attack"));
|
||||
}
|
||||
|
||||
private void ShowStats_Defense(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(Language.GetTextValue("BestiaryInfo.Defense"));
|
||||
}
|
||||
|
||||
private void ShowStats_Knockback(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(Language.GetTextValue("BestiaryInfo.Knockback"));
|
||||
}
|
||||
|
||||
private void ShowStats_Life(UIElement element)
|
||||
{
|
||||
if (!element.IsMouseHovering)
|
||||
return;
|
||||
Main.instance.MouseText(Language.GetTextValue("BestiaryInfo.Life"));
|
||||
}
|
||||
}
|
||||
}
|
73
GameContent/Bestiary/NPCWasChatWithTracker.cs
Normal file
73
GameContent/Bestiary/NPCWasChatWithTracker.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCWasChatWithTracker
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.GameContent.NetModules;
|
||||
using Terraria.ID;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCWasChatWithTracker : IPersistentPerWorldContent, IOnPlayerJoining
|
||||
{
|
||||
private HashSet<string> _chattedWithPlayer;
|
||||
|
||||
public NPCWasChatWithTracker() => this._chattedWithPlayer = new HashSet<string>();
|
||||
|
||||
public void RegisterChatStartWith(NPC npc)
|
||||
{
|
||||
string bestiaryCreditId = npc.GetBestiaryCreditId();
|
||||
bool flag = !this._chattedWithPlayer.Contains(bestiaryCreditId);
|
||||
this._chattedWithPlayer.Add(bestiaryCreditId);
|
||||
if (!(Main.netMode == 2 & flag))
|
||||
return;
|
||||
NetManager.Instance.Broadcast(NetBestiaryModule.SerializeChat(npc.netID));
|
||||
}
|
||||
|
||||
public void SetWasChatWithDirectly(string persistentId) => this._chattedWithPlayer.Add(persistentId);
|
||||
|
||||
public bool GetWasChatWith(NPC npc) => this._chattedWithPlayer.Contains(npc.GetBestiaryCreditId());
|
||||
|
||||
public bool GetWasChatWith(string persistentId) => this._chattedWithPlayer.Contains(persistentId);
|
||||
|
||||
public void Save(BinaryWriter writer)
|
||||
{
|
||||
lock (this._chattedWithPlayer)
|
||||
{
|
||||
writer.Write(this._chattedWithPlayer.Count);
|
||||
foreach (string str in this._chattedWithPlayer)
|
||||
writer.Write(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
this._chattedWithPlayer.Add(reader.ReadString());
|
||||
}
|
||||
|
||||
public void ValidateWorld(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
reader.ReadString();
|
||||
}
|
||||
|
||||
public void Reset() => this._chattedWithPlayer.Clear();
|
||||
|
||||
public void OnPlayerJoining(int playerIndex)
|
||||
{
|
||||
foreach (string key in this._chattedWithPlayer)
|
||||
{
|
||||
int npcNetId;
|
||||
if (ContentSamples.NpcNetIdsByPersistentIds.TryGetValue(key, out npcNetId))
|
||||
NetManager.Instance.SendToClient(NetBestiaryModule.SerializeChat(npcNetId), playerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
121
GameContent/Bestiary/NPCWasNearPlayerTracker.cs
Normal file
121
GameContent/Bestiary/NPCWasNearPlayerTracker.cs
Normal file
|
@ -0,0 +1,121 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NPCWasNearPlayerTracker
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Terraria.GameContent.NetModules;
|
||||
using Terraria.ID;
|
||||
using Terraria.Net;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NPCWasNearPlayerTracker : IPersistentPerWorldContent, IOnPlayerJoining
|
||||
{
|
||||
private HashSet<string> _wasNearPlayer;
|
||||
private List<Rectangle> _playerHitboxesForBestiary;
|
||||
private List<int> _wasSeenNearPlayerByNetId;
|
||||
|
||||
public void PrepareSamplesBasedOptimizations()
|
||||
{
|
||||
}
|
||||
|
||||
public NPCWasNearPlayerTracker()
|
||||
{
|
||||
this._wasNearPlayer = new HashSet<string>();
|
||||
this._playerHitboxesForBestiary = new List<Rectangle>();
|
||||
this._wasSeenNearPlayerByNetId = new List<int>();
|
||||
}
|
||||
|
||||
public void RegisterWasNearby(NPC npc)
|
||||
{
|
||||
string bestiaryCreditId = npc.GetBestiaryCreditId();
|
||||
bool flag = !this._wasNearPlayer.Contains(bestiaryCreditId);
|
||||
this._wasNearPlayer.Add(bestiaryCreditId);
|
||||
if (!(Main.netMode == 2 & flag))
|
||||
return;
|
||||
NetManager.Instance.Broadcast(NetBestiaryModule.SerializeSight(npc.netID));
|
||||
}
|
||||
|
||||
public void SetWasSeenDirectly(string persistentId) => this._wasNearPlayer.Add(persistentId);
|
||||
|
||||
public bool GetWasNearbyBefore(NPC npc) => this.GetWasNearbyBefore(npc.GetBestiaryCreditId());
|
||||
|
||||
public bool GetWasNearbyBefore(string persistentIdentifier) => this._wasNearPlayer.Contains(persistentIdentifier);
|
||||
|
||||
public void Save(BinaryWriter writer)
|
||||
{
|
||||
lock (this._wasNearPlayer)
|
||||
{
|
||||
writer.Write(this._wasNearPlayer.Count);
|
||||
foreach (string str in this._wasNearPlayer)
|
||||
writer.Write(str);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
this._wasNearPlayer.Add(reader.ReadString());
|
||||
}
|
||||
|
||||
public void ValidateWorld(BinaryReader reader, int gameVersionSaveWasMadeOn)
|
||||
{
|
||||
int num = reader.ReadInt32();
|
||||
for (int index = 0; index < num; ++index)
|
||||
reader.ReadString();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this._wasNearPlayer.Clear();
|
||||
this._playerHitboxesForBestiary.Clear();
|
||||
this._wasSeenNearPlayerByNetId.Clear();
|
||||
}
|
||||
|
||||
public void ScanWorldForFinds()
|
||||
{
|
||||
this._playerHitboxesForBestiary.Clear();
|
||||
for (int index = 0; index < (int) byte.MaxValue; ++index)
|
||||
{
|
||||
Player player = Main.player[index];
|
||||
if (player.active)
|
||||
{
|
||||
Rectangle hitbox = player.Hitbox;
|
||||
hitbox.Inflate(300, 200);
|
||||
this._playerHitboxesForBestiary.Add(hitbox);
|
||||
}
|
||||
}
|
||||
for (int index1 = 0; index1 < 200; ++index1)
|
||||
{
|
||||
NPC npc = Main.npc[index1];
|
||||
if (npc.active && npc.CountsAsACritter && !this._wasSeenNearPlayerByNetId.Contains(npc.netID))
|
||||
{
|
||||
Rectangle hitbox = npc.Hitbox;
|
||||
for (int index2 = 0; index2 < this._playerHitboxesForBestiary.Count; ++index2)
|
||||
{
|
||||
Rectangle rectangle = this._playerHitboxesForBestiary[index2];
|
||||
if (hitbox.Intersects(rectangle))
|
||||
{
|
||||
this._wasSeenNearPlayerByNetId.Add(npc.netID);
|
||||
this.RegisterWasNearby(npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPlayerJoining(int playerIndex)
|
||||
{
|
||||
foreach (string key in this._wasNearPlayer)
|
||||
{
|
||||
int idsByPersistentId = ContentSamples.NpcNetIdsByPersistentIds[key];
|
||||
NetManager.Instance.SendToClient(NetBestiaryModule.SerializeSight(idsByPersistentId), playerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
40
GameContent/Bestiary/NamePlateInfoElement.cs
Normal file
40
GameContent/Bestiary/NamePlateInfoElement.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.NamePlateInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class NamePlateInfoElement : IBestiaryInfoElement, IProvideSearchFilterString
|
||||
{
|
||||
private string _key;
|
||||
private int _npcNetId;
|
||||
|
||||
public NamePlateInfoElement(string languageKey, int npcNetId)
|
||||
{
|
||||
this._key = languageKey;
|
||||
this._npcNetId = npcNetId;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
UIElement element = info.UnlockState != BestiaryEntryUnlockState.NotKnownAtAll_0 ? (UIElement) new UIText(Language.GetText(this._key)) : (UIElement) new UIText("???");
|
||||
element.HAlign = 0.5f;
|
||||
element.VAlign = 0.5f;
|
||||
element.Top = new StyleDimension(2f, 0.0f);
|
||||
element.IgnoresMouseInteraction = true;
|
||||
UIElement uiElement = new UIElement();
|
||||
uiElement.Width = new StyleDimension(0.0f, 1f);
|
||||
uiElement.Height = new StyleDimension(24f, 0.0f);
|
||||
uiElement.Append(element);
|
||||
return uiElement;
|
||||
}
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0 ? (string) null : Language.GetText(this._key).Value;
|
||||
}
|
||||
}
|
22
GameContent/Bestiary/RareSpawnBestiaryInfoElement.cs
Normal file
22
GameContent/Bestiary/RareSpawnBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.RareSpawnBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class RareSpawnBestiaryInfoElement : IBestiaryInfoElement, IProvideSearchFilterString
|
||||
{
|
||||
public int RarityLevel { get; private set; }
|
||||
|
||||
public RareSpawnBestiaryInfoElement(int rarityLevel) => this.RarityLevel = rarityLevel;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0 ? (string) null : Language.GetText("BestiaryInfo.IsRare").Value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SalamanderShellyDadUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.ID;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class SalamanderShellyDadUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private string _persistentIdentifierToCheck;
|
||||
|
||||
public SalamanderShellyDadUICollectionInfoProvider(string persistentId) => this._persistentIdentifierToCheck = persistentId;
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo()
|
||||
{
|
||||
BestiaryEntryUnlockState unlockstatus = CommonEnemyUICollectionInfoProvider.GetUnlockStateByKillCount(Main.BestiaryTracker.Kills.GetKillCount(this._persistentIdentifierToCheck), false);
|
||||
if (!this.IsIncludedInCurrentWorld())
|
||||
unlockstatus = this.GetLowestAvailableUnlockStateFromEntriesThatAreInWorld(unlockstatus);
|
||||
return new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = unlockstatus
|
||||
};
|
||||
}
|
||||
|
||||
private BestiaryEntryUnlockState GetLowestAvailableUnlockStateFromEntriesThatAreInWorld(
|
||||
BestiaryEntryUnlockState unlockstatus)
|
||||
{
|
||||
BestiaryEntryUnlockState entryUnlockState = BestiaryEntryUnlockState.CanShowDropsWithDropRates_4;
|
||||
int[,] cavernMonsterType = NPC.cavernMonsterType;
|
||||
for (int index1 = 0; index1 < cavernMonsterType.GetLength(0); ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < cavernMonsterType.GetLength(1); ++index2)
|
||||
{
|
||||
string creditIdsByNpcNetId = ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[cavernMonsterType[index1, index2]];
|
||||
BestiaryEntryUnlockState stateByKillCount = CommonEnemyUICollectionInfoProvider.GetUnlockStateByKillCount(Main.BestiaryTracker.Kills.GetKillCount(creditIdsByNpcNetId), false);
|
||||
if (entryUnlockState > stateByKillCount)
|
||||
entryUnlockState = stateByKillCount;
|
||||
}
|
||||
}
|
||||
unlockstatus = entryUnlockState;
|
||||
return unlockstatus;
|
||||
}
|
||||
|
||||
private bool IsIncludedInCurrentWorld()
|
||||
{
|
||||
int idsByPersistentId = ContentSamples.NpcNetIdsByPersistentIds[this._persistentIdentifierToCheck];
|
||||
int[,] cavernMonsterType = NPC.cavernMonsterType;
|
||||
for (int index1 = 0; index1 < cavernMonsterType.GetLength(0); ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < cavernMonsterType.GetLength(1); ++index2)
|
||||
{
|
||||
if (ContentSamples.NpcBestiaryCreditIdsByNpcNetIds[cavernMonsterType[index1, index2]] == this._persistentIdentifierToCheck)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
21
GameContent/Bestiary/SearchAliasInfoElement.cs
Normal file
21
GameContent/Bestiary/SearchAliasInfoElement.cs
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SearchAliasInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class SearchAliasInfoElement : IBestiaryInfoElement, IProvideSearchFilterString
|
||||
{
|
||||
private readonly string _alias;
|
||||
|
||||
public SearchAliasInfoElement(string alias) => this._alias = alias;
|
||||
|
||||
public string GetSearchString(ref BestiaryUICollectionInfo info) => info.UnlockState == BestiaryEntryUnlockState.NotKnownAtAll_0 ? (string) null : this._alias;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
172
GameContent/Bestiary/SortingSteps.cs
Normal file
172
GameContent/Bestiary/SortingSteps.cs
Normal file
|
@ -0,0 +1,172 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SortingSteps
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public static class SortingSteps
|
||||
{
|
||||
public class ByNetId : IBestiarySortStep, IEntrySortStep<BestiaryEntry>, IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => true;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement1 = x.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement2 = y.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
if (bestiaryInfoElement1 == null && bestiaryInfoElement2 != null)
|
||||
return 1;
|
||||
if (bestiaryInfoElement2 == null && bestiaryInfoElement1 != null)
|
||||
return -1;
|
||||
return bestiaryInfoElement1 == null || bestiaryInfoElement2 == null ? 0 : bestiaryInfoElement1.NetId.CompareTo(bestiaryInfoElement2.NetId);
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.Sort_ID";
|
||||
}
|
||||
|
||||
public class ByUnlockState :
|
||||
IBestiarySortStep,
|
||||
IEntrySortStep<BestiaryEntry>,
|
||||
IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => true;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
BestiaryUICollectionInfo uiCollectionInfo1 = x.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
BestiaryUICollectionInfo uiCollectionInfo2 = y.UIInfoProvider.GetEntryUICollectionInfo();
|
||||
return y.Icon.GetUnlockState(uiCollectionInfo2).CompareTo(x.Icon.GetUnlockState(uiCollectionInfo1));
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.Sort_Unlocks";
|
||||
}
|
||||
|
||||
public class ByBestiarySortingId :
|
||||
IBestiarySortStep,
|
||||
IEntrySortStep<BestiaryEntry>,
|
||||
IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => false;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement1 = x.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement2 = y.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
if (bestiaryInfoElement1 == null && bestiaryInfoElement2 != null)
|
||||
return 1;
|
||||
if (bestiaryInfoElement2 == null && bestiaryInfoElement1 != null)
|
||||
return -1;
|
||||
return bestiaryInfoElement1 == null || bestiaryInfoElement2 == null ? 0 : ContentSamples.NpcBestiarySortingId[bestiaryInfoElement1.NetId].CompareTo(ContentSamples.NpcBestiarySortingId[bestiaryInfoElement2.NetId]);
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.Sort_BestiaryID";
|
||||
}
|
||||
|
||||
public class ByBestiaryRarity :
|
||||
IBestiarySortStep,
|
||||
IEntrySortStep<BestiaryEntry>,
|
||||
IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => false;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement1 = x.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement2 = y.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
if (bestiaryInfoElement1 == null && bestiaryInfoElement2 != null)
|
||||
return 1;
|
||||
if (bestiaryInfoElement2 == null && bestiaryInfoElement1 != null)
|
||||
return -1;
|
||||
if (bestiaryInfoElement1 == null || bestiaryInfoElement2 == null)
|
||||
return 0;
|
||||
int bestiaryRarityStar = ContentSamples.NpcBestiaryRarityStars[bestiaryInfoElement1.NetId];
|
||||
return ContentSamples.NpcBestiaryRarityStars[bestiaryInfoElement2.NetId].CompareTo(bestiaryRarityStar);
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.Sort_Rarity";
|
||||
}
|
||||
|
||||
public class Alphabetical :
|
||||
IBestiarySortStep,
|
||||
IEntrySortStep<BestiaryEntry>,
|
||||
IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => false;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement1 = x.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
NPCNetIdBestiaryInfoElement bestiaryInfoElement2 = y.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => element is NPCNetIdBestiaryInfoElement)) as NPCNetIdBestiaryInfoElement;
|
||||
if (bestiaryInfoElement1 == null && bestiaryInfoElement2 != null)
|
||||
return 1;
|
||||
if (bestiaryInfoElement2 == null && bestiaryInfoElement1 != null)
|
||||
return -1;
|
||||
return bestiaryInfoElement1 == null || bestiaryInfoElement2 == null ? 0 : Language.GetTextValue(ContentSamples.NpcsByNetId[bestiaryInfoElement1.NetId].TypeName).CompareTo(Language.GetTextValue(ContentSamples.NpcsByNetId[bestiaryInfoElement2.NetId].TypeName));
|
||||
}
|
||||
|
||||
public string GetDisplayNameKey() => "BestiaryInfo.Sort_Alphabetical";
|
||||
}
|
||||
|
||||
public abstract class ByStat :
|
||||
IBestiarySortStep,
|
||||
IEntrySortStep<BestiaryEntry>,
|
||||
IComparer<BestiaryEntry>
|
||||
{
|
||||
public bool HiddenFromSortOptions => false;
|
||||
|
||||
public int Compare(BestiaryEntry x, BestiaryEntry y)
|
||||
{
|
||||
NPCStatsReportInfoElement cardX = x.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => this.IsAStatsCardINeed(element, Main.GameMode))) as NPCStatsReportInfoElement;
|
||||
NPCStatsReportInfoElement cardY = y.Info.FirstOrDefault<IBestiaryInfoElement>((Func<IBestiaryInfoElement, bool>) (element => this.IsAStatsCardINeed(element, Main.GameMode))) as NPCStatsReportInfoElement;
|
||||
if (cardX == null && cardY != null)
|
||||
return 1;
|
||||
if (cardY == null && cardX != null)
|
||||
return -1;
|
||||
return cardX == null || cardY == null ? 0 : this.Compare(cardX, cardY);
|
||||
}
|
||||
|
||||
public abstract int Compare(NPCStatsReportInfoElement cardX, NPCStatsReportInfoElement cardY);
|
||||
|
||||
public abstract string GetDisplayNameKey();
|
||||
|
||||
private bool IsAStatsCardINeed(IBestiaryInfoElement element, int gameMode) => element is NPCStatsReportInfoElement reportInfoElement && reportInfoElement.GameMode == gameMode;
|
||||
}
|
||||
|
||||
public class ByAttack : SortingSteps.ByStat
|
||||
{
|
||||
public override int Compare(NPCStatsReportInfoElement cardX, NPCStatsReportInfoElement cardY) => cardY.Damage.CompareTo(cardX.Damage);
|
||||
|
||||
public override string GetDisplayNameKey() => "BestiaryInfo.Sort_Attack";
|
||||
}
|
||||
|
||||
public class ByDefense : SortingSteps.ByStat
|
||||
{
|
||||
public override int Compare(NPCStatsReportInfoElement cardX, NPCStatsReportInfoElement cardY) => cardY.Defense.CompareTo(cardX.Defense);
|
||||
|
||||
public override string GetDisplayNameKey() => "BestiaryInfo.Sort_Defense";
|
||||
}
|
||||
|
||||
public class ByCoins : SortingSteps.ByStat
|
||||
{
|
||||
public override int Compare(NPCStatsReportInfoElement cardX, NPCStatsReportInfoElement cardY) => cardY.MonetaryValue.CompareTo(cardX.MonetaryValue);
|
||||
|
||||
public override string GetDisplayNameKey() => "BestiaryInfo.Sort_Coins";
|
||||
}
|
||||
|
||||
public class ByHP : SortingSteps.ByStat
|
||||
{
|
||||
public override int Compare(NPCStatsReportInfoElement cardX, NPCStatsReportInfoElement cardY) => cardY.LifeMax.CompareTo(cardX.LifeMax);
|
||||
|
||||
public override string GetDisplayNameKey() => "BestiaryInfo.Sort_HitPoints";
|
||||
}
|
||||
}
|
||||
}
|
35
GameContent/Bestiary/SpawnConditionBestiaryInfoElement.cs
Normal file
35
GameContent/Bestiary/SpawnConditionBestiaryInfoElement.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SpawnConditionBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class SpawnConditionBestiaryInfoElement :
|
||||
FilterProviderInfoElement,
|
||||
IBestiaryBackgroundImagePathAndColorProvider
|
||||
{
|
||||
private string _backgroundImagePath;
|
||||
private Color? _backgroundColor;
|
||||
|
||||
public SpawnConditionBestiaryInfoElement(
|
||||
string nameLanguageKey,
|
||||
int filterIconFrame,
|
||||
string backgroundImagePath = null,
|
||||
Color? backgroundColor = null)
|
||||
: base(nameLanguageKey, filterIconFrame)
|
||||
{
|
||||
this._backgroundImagePath = backgroundImagePath;
|
||||
this._backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
public Asset<Texture2D> GetBackgroundImage() => this._backgroundImagePath == null ? (Asset<Texture2D>) null : Main.Assets.Request<Texture2D>(this._backgroundImagePath, (AssetRequestMode) 1);
|
||||
|
||||
public Color? GetBackgroundColor() => this._backgroundColor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SpawnConditionBestiaryOverlayInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class SpawnConditionBestiaryOverlayInfoElement :
|
||||
FilterProviderInfoElement,
|
||||
IBestiaryBackgroundOverlayAndColorProvider
|
||||
{
|
||||
private string _overlayImagePath;
|
||||
private Color? _overlayColor;
|
||||
|
||||
public float DisplayPriority { get; set; }
|
||||
|
||||
public SpawnConditionBestiaryOverlayInfoElement(
|
||||
string nameLanguageKey,
|
||||
int filterIconFrame,
|
||||
string overlayImagePath = null,
|
||||
Color? overlayColor = null)
|
||||
: base(nameLanguageKey, filterIconFrame)
|
||||
{
|
||||
this._overlayImagePath = overlayImagePath;
|
||||
this._overlayColor = overlayColor;
|
||||
}
|
||||
|
||||
public Asset<Texture2D> GetBackgroundOverlayImage() => this._overlayImagePath == null ? (Asset<Texture2D>) null : Main.Assets.Request<Texture2D>(this._overlayImagePath, (AssetRequestMode) 1);
|
||||
|
||||
public Color? GetBackgroundOverlayColor() => this._overlayColor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.SpawnConditionDecorativeOverlayInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class SpawnConditionDecorativeOverlayInfoElement :
|
||||
IBestiaryInfoElement,
|
||||
IBestiaryBackgroundOverlayAndColorProvider
|
||||
{
|
||||
private string _overlayImagePath;
|
||||
private Color? _overlayColor;
|
||||
|
||||
public float DisplayPriority { get; set; }
|
||||
|
||||
public SpawnConditionDecorativeOverlayInfoElement(string overlayImagePath = null, Color? overlayColor = null)
|
||||
{
|
||||
this._overlayImagePath = overlayImagePath;
|
||||
this._overlayColor = overlayColor;
|
||||
}
|
||||
|
||||
public Asset<Texture2D> GetBackgroundOverlayImage() => this._overlayImagePath == null ? (Asset<Texture2D>) null : Main.Assets.Request<Texture2D>(this._overlayImagePath, (AssetRequestMode) 1);
|
||||
|
||||
public Color? GetBackgroundOverlayColor() => this._overlayColor;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
24
GameContent/Bestiary/TownNPCUICollectionInfoProvider.cs
Normal file
24
GameContent/Bestiary/TownNPCUICollectionInfoProvider.cs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.TownNPCUICollectionInfoProvider
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class TownNPCUICollectionInfoProvider : IBestiaryUICollectionInfoProvider
|
||||
{
|
||||
private string _persistentIdentifierToCheck;
|
||||
|
||||
public TownNPCUICollectionInfoProvider(string persistentId) => this._persistentIdentifierToCheck = persistentId;
|
||||
|
||||
public BestiaryUICollectionInfo GetEntryUICollectionInfo() => new BestiaryUICollectionInfo()
|
||||
{
|
||||
UnlockState = Main.BestiaryTracker.Chats.GetWasChatWith(this._persistentIdentifierToCheck) ? BestiaryEntryUnlockState.CanShowDropsWithDropRates_4 : BestiaryEntryUnlockState.NotKnownAtAll_0
|
||||
};
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info) => (UIElement) null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.UnlockProgressDisplayBestiaryInfoElement
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using System;
|
||||
using Terraria.GameContent.UI.Elements;
|
||||
using Terraria.UI;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class UnlockProgressDisplayBestiaryInfoElement : IBestiaryInfoElement
|
||||
{
|
||||
private BestiaryUnlockProgressReport _progressReport;
|
||||
private UIElement _text1;
|
||||
private UIElement _text2;
|
||||
|
||||
public UnlockProgressDisplayBestiaryInfoElement(BestiaryUnlockProgressReport progressReport) => this._progressReport = progressReport;
|
||||
|
||||
public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
|
||||
{
|
||||
UIPanel uiPanel = new UIPanel(Main.Assets.Request<Texture2D>("Images/UI/Bestiary/Stat_Panel", (AssetRequestMode) 1), (Asset<Texture2D>) null, customBarSize: 7);
|
||||
uiPanel.Width = new StyleDimension(-11f, 1f);
|
||||
uiPanel.Height = new StyleDimension(109f, 0.0f);
|
||||
uiPanel.BackgroundColor = new Color(43, 56, 101);
|
||||
uiPanel.BorderColor = Color.Transparent;
|
||||
uiPanel.Left = new StyleDimension(3f, 0.0f);
|
||||
UIElement container = (UIElement) uiPanel;
|
||||
container.PaddingLeft = 4f;
|
||||
container.PaddingRight = 4f;
|
||||
string text1 = string.Format("{0} Entry Collected", (object) Utils.PrettifyPercentDisplay((float) info.UnlockState / 4f, "P2"));
|
||||
string text2 = string.Format("{0} Bestiary Collected", (object) Utils.PrettifyPercentDisplay(this._progressReport.CompletionPercent, "P2"));
|
||||
int num = 8;
|
||||
UIText uiText1 = new UIText(text1, 0.8f);
|
||||
uiText1.HAlign = 0.0f;
|
||||
uiText1.VAlign = 0.0f;
|
||||
uiText1.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText1.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText1.IsWrapped = true;
|
||||
uiText1.PaddingTop = (float) -num;
|
||||
uiText1.PaddingBottom = (float) -num;
|
||||
UIText text3 = uiText1;
|
||||
UIText uiText2 = new UIText(text2, 0.8f);
|
||||
uiText2.HAlign = 0.0f;
|
||||
uiText2.VAlign = 0.0f;
|
||||
uiText2.Width = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText2.Height = StyleDimension.FromPixelsAndPercent(0.0f, 1f);
|
||||
uiText2.IsWrapped = true;
|
||||
uiText2.PaddingTop = (float) -num;
|
||||
uiText2.PaddingBottom = (float) -num;
|
||||
UIText uiText3 = uiText2;
|
||||
this._text1 = (UIElement) text3;
|
||||
this._text2 = (UIElement) uiText3;
|
||||
this.AddDynamicResize(container, text3);
|
||||
container.Append((UIElement) text3);
|
||||
container.Append((UIElement) uiText3);
|
||||
return container;
|
||||
}
|
||||
|
||||
private void AddDynamicResize(UIElement container, UIText text) => text.OnInternalTextChange += (Action) (() =>
|
||||
{
|
||||
container.Height = new StyleDimension(this._text1.MinHeight.Pixels + 4f + this._text2.MinHeight.Pixels, 0.0f);
|
||||
this._text2.Top = new StyleDimension(this._text1.MinHeight.Pixels + 4f, 0.0f);
|
||||
});
|
||||
}
|
||||
}
|
208
GameContent/Bestiary/UnlockableNPCEntryIcon.cs
Normal file
208
GameContent/Bestiary/UnlockableNPCEntryIcon.cs
Normal file
|
@ -0,0 +1,208 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Bestiary.UnlockableNPCEntryIcon
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using ReLogic.Content;
|
||||
using Terraria.ID;
|
||||
using Terraria.Localization;
|
||||
|
||||
namespace Terraria.GameContent.Bestiary
|
||||
{
|
||||
public class UnlockableNPCEntryIcon : IEntryIcon
|
||||
{
|
||||
private int _npcNetId;
|
||||
private NPC _npcCache;
|
||||
private bool _firstUpdateDone;
|
||||
private Asset<Texture2D> _customTexture;
|
||||
private Vector2 _positionOffsetCache;
|
||||
private string _overrideNameKey;
|
||||
|
||||
public UnlockableNPCEntryIcon(
|
||||
int npcNetId,
|
||||
float ai0 = 0.0f,
|
||||
float ai1 = 0.0f,
|
||||
float ai2 = 0.0f,
|
||||
float ai3 = 0.0f,
|
||||
string overrideNameKey = null)
|
||||
{
|
||||
this._npcNetId = npcNetId;
|
||||
this._npcCache = new NPC();
|
||||
this._npcCache.SetDefaults(this._npcNetId);
|
||||
this._npcCache.IsABestiaryIconDummy = true;
|
||||
this._firstUpdateDone = false;
|
||||
this._npcCache.ai[0] = ai0;
|
||||
this._npcCache.ai[1] = ai1;
|
||||
this._npcCache.ai[2] = ai2;
|
||||
this._npcCache.ai[3] = ai3;
|
||||
this._customTexture = (Asset<Texture2D>) null;
|
||||
this._overrideNameKey = overrideNameKey;
|
||||
}
|
||||
|
||||
public IEntryIcon CreateClone() => (IEntryIcon) new UnlockableNPCEntryIcon(this._npcNetId, overrideNameKey: this._overrideNameKey);
|
||||
|
||||
public void Update(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
Rectangle hitbox,
|
||||
EntryIconDrawSettings settings)
|
||||
{
|
||||
Vector2 vector2 = new Vector2();
|
||||
int? nullable1 = new int?();
|
||||
int? nullable2 = new int?();
|
||||
int? nullable3 = new int?();
|
||||
bool flag = false;
|
||||
float velocity = 0.0f;
|
||||
Asset<Texture2D> asset = (Asset<Texture2D>) null;
|
||||
NPCID.Sets.NPCBestiaryDrawModifiers bestiaryDrawModifiers;
|
||||
if (NPCID.Sets.NPCBestiaryDrawOffset.TryGetValue(this._npcNetId, out bestiaryDrawModifiers))
|
||||
{
|
||||
this._npcCache.rotation = bestiaryDrawModifiers.Rotation;
|
||||
this._npcCache.scale = bestiaryDrawModifiers.Scale;
|
||||
if (bestiaryDrawModifiers.PortraitScale.HasValue && settings.IsPortrait)
|
||||
this._npcCache.scale = bestiaryDrawModifiers.PortraitScale.Value;
|
||||
vector2 = bestiaryDrawModifiers.Position;
|
||||
nullable1 = bestiaryDrawModifiers.Frame;
|
||||
nullable2 = bestiaryDrawModifiers.Direction;
|
||||
nullable3 = bestiaryDrawModifiers.SpriteDirection;
|
||||
velocity = bestiaryDrawModifiers.Velocity;
|
||||
flag = bestiaryDrawModifiers.IsWet;
|
||||
if (bestiaryDrawModifiers.PortraitPositionXOverride.HasValue && settings.IsPortrait)
|
||||
vector2.X = bestiaryDrawModifiers.PortraitPositionXOverride.Value;
|
||||
if (bestiaryDrawModifiers.PortraitPositionYOverride.HasValue && settings.IsPortrait)
|
||||
vector2.Y = bestiaryDrawModifiers.PortraitPositionYOverride.Value;
|
||||
if (bestiaryDrawModifiers.CustomTexturePath != null)
|
||||
asset = Main.Assets.Request<Texture2D>(bestiaryDrawModifiers.CustomTexturePath, (AssetRequestMode) 1);
|
||||
if (asset != null && asset.IsLoaded)
|
||||
this._customTexture = asset;
|
||||
}
|
||||
this._positionOffsetCache = vector2;
|
||||
this.UpdatePosition(settings);
|
||||
if (NPCID.Sets.TrailingMode[this._npcCache.type] != -1)
|
||||
{
|
||||
for (int index = 0; index < this._npcCache.oldPos.Length; ++index)
|
||||
this._npcCache.oldPos[index] = this._npcCache.position;
|
||||
}
|
||||
this._npcCache.direction = this._npcCache.spriteDirection = nullable2.HasValue ? nullable2.Value : -1;
|
||||
if (nullable3.HasValue)
|
||||
this._npcCache.spriteDirection = nullable3.Value;
|
||||
this._npcCache.wet = flag;
|
||||
this.AdjustSpecialSpawnRulesForVisuals(settings);
|
||||
this.SimulateFirstHover(velocity);
|
||||
if (!nullable1.HasValue && (settings.IsPortrait || settings.IsHovered))
|
||||
{
|
||||
this._npcCache.velocity.X = (float) this._npcCache.direction * velocity;
|
||||
this._npcCache.FindFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!nullable1.HasValue)
|
||||
return;
|
||||
this._npcCache.FindFrame();
|
||||
this._npcCache.frame.Y = this._npcCache.frame.Height * nullable1.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePosition(EntryIconDrawSettings settings)
|
||||
{
|
||||
if (this._npcCache.noGravity)
|
||||
this._npcCache.Center = settings.iconbox.Center.ToVector2() + this._positionOffsetCache;
|
||||
else
|
||||
this._npcCache.Bottom = settings.iconbox.TopLeft() + settings.iconbox.Size() * new Vector2(0.5f, 1f) + new Vector2(0.0f, -8f) + this._positionOffsetCache;
|
||||
this._npcCache.position = this._npcCache.position.Floor();
|
||||
}
|
||||
|
||||
private void AdjustSpecialSpawnRulesForVisuals(EntryIconDrawSettings settings)
|
||||
{
|
||||
int num;
|
||||
if (NPCID.Sets.SpecialSpawningRules.TryGetValue(this._npcNetId, out num) && num == 0)
|
||||
{
|
||||
Point tileCoordinates = (this._npcCache.position - this._npcCache.rotation.ToRotationVector2() * -1600f).ToTileCoordinates();
|
||||
this._npcCache.ai[0] = (float) tileCoordinates.X;
|
||||
this._npcCache.ai[1] = (float) tileCoordinates.Y;
|
||||
}
|
||||
switch (this._npcNetId)
|
||||
{
|
||||
case 244:
|
||||
this._npcCache.AI_001_SetRainbowSlimeColor();
|
||||
break;
|
||||
case 299:
|
||||
case 538:
|
||||
case 539:
|
||||
case 639:
|
||||
case 640:
|
||||
case 641:
|
||||
case 642:
|
||||
case 643:
|
||||
case 644:
|
||||
case 645:
|
||||
if (!settings.IsPortrait || this._npcCache.frame.Y != 0)
|
||||
break;
|
||||
this._npcCache.frame.Y = this._npcCache.frame.Height;
|
||||
break;
|
||||
case 330:
|
||||
case 372:
|
||||
case 586:
|
||||
case 587:
|
||||
case 619:
|
||||
case 620:
|
||||
this._npcCache.alpha = 0;
|
||||
break;
|
||||
case 356:
|
||||
this._npcCache.ai[2] = 1f;
|
||||
break;
|
||||
case 636:
|
||||
this._npcCache.Opacity = 1f;
|
||||
if ((double) ++this._npcCache.localAI[0] < 44.0)
|
||||
break;
|
||||
this._npcCache.localAI[0] = 0.0f;
|
||||
break;
|
||||
case 656:
|
||||
this._npcCache.townNpcVariationIndex = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SimulateFirstHover(float velocity)
|
||||
{
|
||||
if (this._firstUpdateDone)
|
||||
return;
|
||||
this._firstUpdateDone = true;
|
||||
this._npcCache.SetFrameSize();
|
||||
this._npcCache.velocity.X = (float) this._npcCache.direction * velocity;
|
||||
for (int index = 0; index < 1; ++index)
|
||||
this._npcCache.FindFrame();
|
||||
}
|
||||
|
||||
public void Draw(
|
||||
BestiaryUICollectionInfo providedInfo,
|
||||
SpriteBatch spriteBatch,
|
||||
EntryIconDrawSettings settings)
|
||||
{
|
||||
this.UpdatePosition(settings);
|
||||
if (this._customTexture != null)
|
||||
{
|
||||
spriteBatch.Draw(this._customTexture.Value, this._npcCache.Center, new Rectangle?(), Color.White, 0.0f, this._customTexture.Size() / 2f, this._npcCache.scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ITownNPCProfile profile;
|
||||
if (this._npcCache.townNPC && TownNPCProfiles.Instance.GetProfile(this._npcCache.type, out profile))
|
||||
TextureAssets.Npc[this._npcCache.type] = profile.GetTextureNPCShouldUse(this._npcCache);
|
||||
Main.instance.DrawNPCDirect(spriteBatch, this._npcCache, this._npcCache.behindTiles, Vector2.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHoverText(BestiaryUICollectionInfo providedInfo)
|
||||
{
|
||||
string str = Lang.GetNPCNameValue(this._npcCache.netID);
|
||||
if (!string.IsNullOrWhiteSpace(this._overrideNameKey))
|
||||
str = Language.GetTextValue(this._overrideNameKey);
|
||||
return this.GetUnlockState(providedInfo) ? str : "???";
|
||||
}
|
||||
|
||||
public bool GetUnlockState(BestiaryUICollectionInfo providedInfo) => providedInfo.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;
|
||||
}
|
||||
}
|
88
GameContent/Biomes/CampsiteBiome.cs
Normal file
88
GameContent/Biomes/CampsiteBiome.cs
Normal file
|
@ -0,0 +1,88 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CampsiteBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
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;
|
||||
ushort type1 = (ushort) (byte) (196 + WorldGen.genRand.Next(4));
|
||||
for (int index1 = origin.X - radius; index1 <= origin.X + radius; ++index1)
|
||||
{
|
||||
for (int index2 = origin.Y - radius; index2 <= origin.Y + radius; ++index2)
|
||||
{
|
||||
if (Main.tile[index1, index2].active())
|
||||
{
|
||||
int type2 = (int) Main.tile[index1, index2].type;
|
||||
if (type2 == 53 || type2 == 396 || type2 == 397 || type2 == 404)
|
||||
type1 = (ushort) 187;
|
||||
if (type2 == 161 || type2 == 147)
|
||||
type1 = (ushort) 40;
|
||||
if (type2 == 60)
|
||||
type1 = (ushort) (byte) (204 + WorldGen.genRand.Next(4));
|
||||
if (type2 == 367)
|
||||
type1 = (ushort) 178;
|
||||
if (type2 == 368)
|
||||
type1 = (ushort) 180;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 ushort[1]), (GenAction) new Actions.PlaceWall(type1)));
|
||||
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 ushort[1]), (GenAction) new Actions.PlaceWall(type1)));
|
||||
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 index3 = 0; index3 < num2; ++index3)
|
||||
{
|
||||
int num4 = GenBase._random.Next(1, 3);
|
||||
for (int index4 = 0; index4 < num4; ++index4)
|
||||
WorldGen.PlaceTile(origin.X + num3 - index3, j - index4, 332, true);
|
||||
}
|
||||
}
|
||||
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.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
55
GameContent/Biomes/CaveHouse/DesertHouseBuilder.cs
Normal file
55
GameContent/Biomes/CaveHouse/DesertHouseBuilder.cs
Normal file
|
@ -0,0 +1,55 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.DesertHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class DesertHouseBuilder : HouseBuilder
|
||||
{
|
||||
public DesertHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Desert, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 396;
|
||||
this.WallType = (ushort) 187;
|
||||
this.BeamType = (ushort) 577;
|
||||
this.PlatformStyle = 42;
|
||||
this.DoorStyle = 43;
|
||||
this.TableStyle = 7;
|
||||
this.UsesTables2 = true;
|
||||
this.WorkbenchStyle = 39;
|
||||
this.PianoStyle = 38;
|
||||
this.BookcaseStyle = 39;
|
||||
this.ChairStyle = 43;
|
||||
this.ChestStyle = 1;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((ushort) 396, true), (GenAction) new Modifiers.Dither(), (GenAction) new Actions.SetTileKeepWall((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 ushort[1]
|
||||
{
|
||||
this.WallType
|
||||
}), (GenAction) new Actions.PlaceWall((ushort) 216)));
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Biomes/CaveHouse/GraniteHouseBuilder.cs
Normal file
49
GameContent/Biomes/CaveHouse/GraniteHouseBuilder.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.GraniteHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class GraniteHouseBuilder : HouseBuilder
|
||||
{
|
||||
public GraniteHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Granite, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 369;
|
||||
this.WallType = (ushort) 181;
|
||||
this.BeamType = (ushort) 576;
|
||||
this.PlatformStyle = 28;
|
||||
this.DoorStyle = 34;
|
||||
this.TableStyle = 33;
|
||||
this.WorkbenchStyle = 29;
|
||||
this.PianoStyle = 28;
|
||||
this.BookcaseStyle = 30;
|
||||
this.ChairStyle = 34;
|
||||
this.ChestStyle = 50;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((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((ushort) 180)));
|
||||
}
|
||||
}
|
||||
}
|
441
GameContent/Biomes/CaveHouse/HouseBuilder.cs
Normal file
441
GameContent/Biomes/CaveHouse/HouseBuilder.cs
Normal file
|
@ -0,0 +1,441 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.HouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Terraria.Utilities;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class HouseBuilder
|
||||
{
|
||||
private const int VERTICAL_EXIT_WIDTH = 3;
|
||||
public static readonly HouseBuilder Invalid = new HouseBuilder();
|
||||
public readonly HouseType Type;
|
||||
public readonly bool IsValid;
|
||||
protected ushort[] SkipTilesDuringWallAging = new ushort[5]
|
||||
{
|
||||
(ushort) 245,
|
||||
(ushort) 246,
|
||||
(ushort) 240,
|
||||
(ushort) 241,
|
||||
(ushort) 242
|
||||
};
|
||||
|
||||
public float ChestChance { get; set; }
|
||||
|
||||
public ushort TileType { get; protected set; }
|
||||
|
||||
public ushort WallType { get; protected set; }
|
||||
|
||||
public ushort BeamType { get; protected set; }
|
||||
|
||||
public int PlatformStyle { get; protected set; }
|
||||
|
||||
public int DoorStyle { get; protected set; }
|
||||
|
||||
public int TableStyle { get; protected set; }
|
||||
|
||||
public bool UsesTables2 { get; protected set; }
|
||||
|
||||
public int WorkbenchStyle { get; protected set; }
|
||||
|
||||
public int PianoStyle { get; protected set; }
|
||||
|
||||
public int BookcaseStyle { get; protected set; }
|
||||
|
||||
public int ChairStyle { get; protected set; }
|
||||
|
||||
public int ChestStyle { get; protected set; }
|
||||
|
||||
public ReadOnlyCollection<Microsoft.Xna.Framework.Rectangle> Rooms { get; private set; }
|
||||
|
||||
public Microsoft.Xna.Framework.Rectangle TopRoom => this.Rooms.First<Microsoft.Xna.Framework.Rectangle>();
|
||||
|
||||
public Microsoft.Xna.Framework.Rectangle BottomRoom => this.Rooms.Last<Microsoft.Xna.Framework.Rectangle>();
|
||||
|
||||
private UnifiedRandom _random => WorldGen.genRand;
|
||||
|
||||
private Tile[,] _tiles => Main.tile;
|
||||
|
||||
private HouseBuilder() => this.IsValid = false;
|
||||
|
||||
protected HouseBuilder(HouseType type, IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
{
|
||||
this.Type = type;
|
||||
this.IsValid = true;
|
||||
List<Microsoft.Xna.Framework.Rectangle> list = rooms.ToList<Microsoft.Xna.Framework.Rectangle>();
|
||||
list.Sort((Comparison<Microsoft.Xna.Framework.Rectangle>) ((lhs, rhs) => lhs.Top.CompareTo(rhs.Top)));
|
||||
this.Rooms = list.AsReadOnly();
|
||||
}
|
||||
|
||||
protected virtual void AgeRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
}
|
||||
|
||||
public void Place(HouseBuilderContext context, StructureMap structures)
|
||||
{
|
||||
this.PlaceEmptyRooms();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
structures.AddProtectedStructure(room, 8);
|
||||
this.PlaceStairs();
|
||||
this.PlaceDoors();
|
||||
this.PlacePlatforms();
|
||||
this.PlaceSupportBeams();
|
||||
this.FillRooms();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
this.AgeRoom(room);
|
||||
this.PlaceChests();
|
||||
this.PlaceBiomeSpecificTool(context);
|
||||
}
|
||||
|
||||
private void PlaceEmptyRooms()
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
WorldUtils.Gen(new Point(room.X, room.Y), (GenShape) new Shapes.Rectangle(room.Width, room.Height), Actions.Chain((GenAction) new Actions.SetTileKeepWall(this.TileType), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(new Point(room.X + 1, room.Y + 1), (GenShape) new Shapes.Rectangle(room.Width - 2, room.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(this.WallType)));
|
||||
}
|
||||
}
|
||||
|
||||
private void FillRooms()
|
||||
{
|
||||
int x1 = 14;
|
||||
if (this.UsesTables2)
|
||||
x1 = 469;
|
||||
Point[] pointArray = new Point[7]
|
||||
{
|
||||
new Point(x1, this.TableStyle),
|
||||
new Point(16, 0),
|
||||
new Point(18, this.WorkbenchStyle),
|
||||
new Point(86, 0),
|
||||
new Point(87, this.PianoStyle),
|
||||
new Point(94, 0),
|
||||
new Point(101, this.BookcaseStyle)
|
||||
};
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int num1 = room.Width / 8;
|
||||
int num2 = room.Width / (num1 + 1);
|
||||
int num3 = this._random.Next(2);
|
||||
for (int index1 = 0; index1 < num1; ++index1)
|
||||
{
|
||||
int i = (index1 + 1) * num2 + room.X;
|
||||
switch (index1 + num3 % 2)
|
||||
{
|
||||
case 0:
|
||||
int j1 = room.Y + Math.Min(room.Height / 2, room.Height - 5);
|
||||
Vector2 vector2 = this.Type != HouseType.Desert ? WorldGen.randHousePicture() : WorldGen.RandHousePictureDesert();
|
||||
int x2 = (int) vector2.X;
|
||||
int y = (int) vector2.Y;
|
||||
WorldGen.PlaceTile(i, j1, x2, true, style: y);
|
||||
break;
|
||||
case 1:
|
||||
int j2 = room.Y + 1;
|
||||
WorldGen.PlaceTile(i, j2, 34, true, style: this._random.Next(6));
|
||||
for (int index2 = -1; index2 < 2; ++index2)
|
||||
{
|
||||
for (int index3 = 0; index3 < 3; ++index3)
|
||||
this._tiles[index2 + i, index3 + j2].frameX += (short) 54;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
int num4 = room.Width / 8 + 3;
|
||||
WorldGen.SetupStatueList();
|
||||
for (; num4 > 0; --num4)
|
||||
{
|
||||
int num5 = this._random.Next(room.Width - 3) + 1 + room.X;
|
||||
int num6 = room.Y + room.Height - 2;
|
||||
switch (this._random.Next(4))
|
||||
{
|
||||
case 0:
|
||||
WorldGen.PlaceSmallPile(num5, num6, this._random.Next(31, 34), 1);
|
||||
break;
|
||||
case 1:
|
||||
WorldGen.PlaceTile(num5, num6, 186, true, style: this._random.Next(22, 26));
|
||||
break;
|
||||
case 2:
|
||||
int index = this._random.Next(2, WorldGen.statueList.Length);
|
||||
WorldGen.PlaceTile(num5, num6, (int) WorldGen.statueList[index].X, true, style: ((int) WorldGen.statueList[index].Y));
|
||||
if (WorldGen.StatuesWithTraps.Contains(index))
|
||||
{
|
||||
WorldGen.PlaceStatueTrap(num5, num6);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Point point = Utils.SelectRandom<Point>(this._random, pointArray);
|
||||
WorldGen.PlaceTile(num5, num6, point.X, true, style: point.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceStairs()
|
||||
{
|
||||
foreach (Tuple<Point, Point> stairs in this.CreateStairsList())
|
||||
{
|
||||
Point origin = stairs.Item1;
|
||||
Point point = stairs.Item2;
|
||||
int num = point.X > origin.X ? 1 : -1;
|
||||
ShapeData data = new ShapeData();
|
||||
for (int y = 0; y < point.Y - origin.Y; ++y)
|
||||
data.Add(num * (y + 1), y);
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort) 19, this.PlatformStyle), (GenAction) new Actions.SetSlope(num == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
|
||||
WorldUtils.Gen(new Point(origin.X + (num == 1 ? 1 : -4), origin.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(this.WallType), (GenAction) new Actions.PlaceTile((ushort) 19, this.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Tuple<Point, Point>> CreateStairsList()
|
||||
{
|
||||
List<Tuple<Point, Point>> tupleList = new List<Tuple<Point, Point>>();
|
||||
for (int index = 1; index < this.Rooms.Count; ++index)
|
||||
{
|
||||
Microsoft.Xna.Framework.Rectangle room1 = this.Rooms[index];
|
||||
Microsoft.Xna.Framework.Rectangle room2 = this.Rooms[index - 1];
|
||||
if (room2.X - room1.X > room1.X + room1.Width - (room2.X + room2.Width))
|
||||
tupleList.Add(new Tuple<Point, Point>(new Point(room1.X + room1.Width - 1, room1.Y + 1), new Point(room1.X + room1.Width - room1.Height + 1, room1.Y + room1.Height - 1)));
|
||||
else
|
||||
tupleList.Add(new Tuple<Point, Point>(new Point(room1.X, room1.Y + 1), new Point(room1.X + room1.Height - 1, room1.Y + room1.Height - 1)));
|
||||
}
|
||||
return tupleList;
|
||||
}
|
||||
|
||||
private void PlaceDoors()
|
||||
{
|
||||
foreach (Point door in this.CreateDoorList())
|
||||
{
|
||||
WorldUtils.Gen(door, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
|
||||
WorldGen.PlaceTile(door.X, door.Y, 10, true, true, style: this.DoorStyle);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Point> CreateDoorList()
|
||||
{
|
||||
List<Point> pointList = new List<Point>();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int exitY;
|
||||
if (HouseBuilder.FindSideExit(new Microsoft.Xna.Framework.Rectangle(room.X + room.Width, room.Y + 1, 1, room.Height - 2), false, out exitY))
|
||||
pointList.Add(new Point(room.X + room.Width - 1, exitY));
|
||||
if (HouseBuilder.FindSideExit(new Microsoft.Xna.Framework.Rectangle(room.X, room.Y + 1, 1, room.Height - 2), true, out exitY))
|
||||
pointList.Add(new Point(room.X, exitY));
|
||||
}
|
||||
return pointList;
|
||||
}
|
||||
|
||||
private void PlacePlatforms()
|
||||
{
|
||||
foreach (Point platforms in this.CreatePlatformsList())
|
||||
WorldUtils.Gen(platforms, (GenShape) new Shapes.Rectangle(3, 1), Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort) 19, this.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
|
||||
}
|
||||
|
||||
private List<Point> CreatePlatformsList()
|
||||
{
|
||||
List<Point> pointList = new List<Point>();
|
||||
Microsoft.Xna.Framework.Rectangle topRoom = this.TopRoom;
|
||||
Microsoft.Xna.Framework.Rectangle bottomRoom = this.BottomRoom;
|
||||
int exitX;
|
||||
if (HouseBuilder.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(topRoom.X + 2, topRoom.Y, topRoom.Width - 4, 1), true, out exitX))
|
||||
pointList.Add(new Point(exitX, topRoom.Y));
|
||||
if (HouseBuilder.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(bottomRoom.X + 2, bottomRoom.Y + bottomRoom.Height - 1, bottomRoom.Width - 4, 1), false, out exitX))
|
||||
pointList.Add(new Point(exitX, bottomRoom.Y + bottomRoom.Height - 1));
|
||||
return pointList;
|
||||
}
|
||||
|
||||
private void PlaceSupportBeams()
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle supportBeam in this.CreateSupportBeamList())
|
||||
{
|
||||
if (supportBeam.Height > 1 && this._tiles[supportBeam.X, supportBeam.Y - 1].type != (ushort) 19)
|
||||
{
|
||||
WorldUtils.Gen(new Point(supportBeam.X, supportBeam.Y), (GenShape) new Shapes.Rectangle(supportBeam.Width, supportBeam.Height), Actions.Chain((GenAction) new Actions.SetTileKeepWall(this.BeamType), (GenAction) new Actions.SetFrames(true)));
|
||||
Tile tile = this._tiles[supportBeam.X, supportBeam.Y + supportBeam.Height];
|
||||
tile.slope((byte) 0);
|
||||
tile.halfBrick(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<Microsoft.Xna.Framework.Rectangle> CreateSupportBeamList()
|
||||
{
|
||||
List<Microsoft.Xna.Framework.Rectangle> rectangleList = new List<Microsoft.Xna.Framework.Rectangle>();
|
||||
int num1 = this.Rooms.Min<Microsoft.Xna.Framework.Rectangle>((Func<Microsoft.Xna.Framework.Rectangle, int>) (room => room.Left));
|
||||
int num2 = this.Rooms.Max<Microsoft.Xna.Framework.Rectangle>((Func<Microsoft.Xna.Framework.Rectangle, int>) (room => room.Right)) - 1;
|
||||
int num3 = 6;
|
||||
while (num3 > 4 && (num2 - num1) % num3 != 0)
|
||||
--num3;
|
||||
for (int x = num1; x <= num2; x += num3)
|
||||
{
|
||||
for (int index1 = 0; index1 < this.Rooms.Count; ++index1)
|
||||
{
|
||||
Microsoft.Xna.Framework.Rectangle room = this.Rooms[index1];
|
||||
if (x >= room.X && x < room.X + room.Width)
|
||||
{
|
||||
int y = room.Y + room.Height;
|
||||
int num4 = 50;
|
||||
for (int index2 = index1 + 1; index2 < this.Rooms.Count; ++index2)
|
||||
{
|
||||
if (x >= this.Rooms[index2].X && x < this.Rooms[index2].X + this.Rooms[index2].Width)
|
||||
num4 = Math.Min(num4, this.Rooms[index2].Y - y);
|
||||
}
|
||||
if (num4 > 0)
|
||||
{
|
||||
Point result;
|
||||
bool flag = WorldUtils.Find(new Point(x, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result);
|
||||
if (num4 < 50)
|
||||
{
|
||||
flag = true;
|
||||
result = new Point(x, y + num4);
|
||||
}
|
||||
if (flag)
|
||||
rectangleList.Add(new Microsoft.Xna.Framework.Rectangle(x, y, 1, result.Y - y));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rectangleList;
|
||||
}
|
||||
|
||||
private static 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 static 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 void PlaceChests()
|
||||
{
|
||||
if ((double) this._random.NextFloat() > (double) this.ChestChance)
|
||||
return;
|
||||
bool flag = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int j = room.Height - 1 + room.Y;
|
||||
int Style = j > (int) Main.worldSurface ? this.ChestStyle : 0;
|
||||
int num = 0;
|
||||
while (num < 10 && !(flag = WorldGen.AddBuriedChest(this._random.Next(2, room.Width - 2) + room.X, j, Style: Style)))
|
||||
++num;
|
||||
if (!flag)
|
||||
{
|
||||
int i = room.X + 2;
|
||||
while (i <= room.X + room.Width - 2 && !(flag = WorldGen.AddBuriedChest(i, j, Style: Style)))
|
||||
++i;
|
||||
if (flag)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int j = room.Y - 1;
|
||||
int Style = j > (int) Main.worldSurface ? this.ChestStyle : 0;
|
||||
int num = 0;
|
||||
while (num < 10 && !(flag = WorldGen.AddBuriedChest(this._random.Next(2, room.Width - 2) + room.X, j, Style: Style)))
|
||||
++num;
|
||||
if (!flag)
|
||||
{
|
||||
int i = room.X + 2;
|
||||
while (i <= room.X + room.Width - 2 && !(flag = WorldGen.AddBuriedChest(i, j, Style: Style)))
|
||||
++i;
|
||||
if (flag)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
return;
|
||||
for (int index = 0; index < 1000; ++index)
|
||||
{
|
||||
int i = this._random.Next(this.Rooms[0].X - 30, this.Rooms[0].X + 30);
|
||||
int num1 = this._random.Next(this.Rooms[0].Y - 30, this.Rooms[0].Y + 30);
|
||||
int num2 = num1 > (int) Main.worldSurface ? this.ChestStyle : 0;
|
||||
int j = num1;
|
||||
int Style = num2;
|
||||
if (WorldGen.AddBuriedChest(i, j, Style: Style))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceBiomeSpecificTool(HouseBuilderContext context)
|
||||
{
|
||||
if (this.Type == HouseType.Jungle && context.SharpenerCount < this._random.Next(2, 5))
|
||||
{
|
||||
bool flag = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int j = room.Height - 2 + room.Y;
|
||||
for (int index = 0; index < 10; ++index)
|
||||
{
|
||||
int i = this._random.Next(2, room.Width - 2) + room.X;
|
||||
WorldGen.PlaceTile(i, j, 377, true, true);
|
||||
if (flag = this._tiles[i, j].active() && this._tiles[i, j].type == (ushort) 377)
|
||||
break;
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
int i = room.X + 2;
|
||||
while (i <= room.X + room.Width - 2 && !(flag = WorldGen.PlaceTile(i, j, 377, true, true)))
|
||||
++i;
|
||||
if (flag)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (flag)
|
||||
++context.SharpenerCount;
|
||||
}
|
||||
if (this.Type != HouseType.Desert || context.ExtractinatorCount >= this._random.Next(2, 5))
|
||||
return;
|
||||
bool flag1 = false;
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
|
||||
{
|
||||
int j = room.Height - 2 + room.Y;
|
||||
for (int index = 0; index < 10; ++index)
|
||||
{
|
||||
int i = this._random.Next(2, room.Width - 2) + room.X;
|
||||
WorldGen.PlaceTile(i, j, 219, true, true);
|
||||
if (flag1 = this._tiles[i, j].active() && this._tiles[i, j].type == (ushort) 219)
|
||||
break;
|
||||
}
|
||||
if (!flag1)
|
||||
{
|
||||
int i = room.X + 2;
|
||||
while (i <= room.X + room.Width - 2 && !(flag1 = WorldGen.PlaceTile(i, j, 219, true, true)))
|
||||
++i;
|
||||
if (flag1)
|
||||
break;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (!flag1)
|
||||
return;
|
||||
++context.ExtractinatorCount;
|
||||
}
|
||||
}
|
||||
}
|
14
GameContent/Biomes/CaveHouse/HouseBuilderContext.cs
Normal file
14
GameContent/Biomes/CaveHouse/HouseBuilderContext.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.HouseBuilderContext
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class HouseBuilderContext
|
||||
{
|
||||
public int SharpenerCount;
|
||||
public int ExtractinatorCount;
|
||||
}
|
||||
}
|
19
GameContent/Biomes/CaveHouse/HouseType.cs
Normal file
19
GameContent/Biomes/CaveHouse/HouseType.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.HouseType
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public enum HouseType
|
||||
{
|
||||
Wood,
|
||||
Ice,
|
||||
Desert,
|
||||
Jungle,
|
||||
Mushroom,
|
||||
Granite,
|
||||
Marble,
|
||||
}
|
||||
}
|
180
GameContent/Biomes/CaveHouse/HouseUtils.cs
Normal file
180
GameContent/Biomes/CaveHouse/HouseUtils.cs
Normal file
|
@ -0,0 +1,180 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.HouseUtils
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public static class HouseUtils
|
||||
{
|
||||
private static readonly bool[] BlacklistedTiles = TileID.Sets.Factory.CreateBoolSet(true, 225, 41, 43, 44, 226, 203, 112, 25, 151);
|
||||
private static readonly bool[] BeelistedTiles = TileID.Sets.Factory.CreateBoolSet(true, 41, 43, 44, 226, 203, 112, 25, 151);
|
||||
|
||||
public static HouseBuilder CreateBuilder(Point origin, StructureMap structures)
|
||||
{
|
||||
List<Microsoft.Xna.Framework.Rectangle> rooms = HouseUtils.CreateRooms(origin);
|
||||
if (rooms.Count == 0 || !HouseUtils.AreRoomLocationsValid((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms))
|
||||
return HouseBuilder.Invalid;
|
||||
HouseType houseType = HouseUtils.GetHouseType((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
if (!HouseUtils.AreRoomsValid((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms, structures, houseType))
|
||||
return HouseBuilder.Invalid;
|
||||
switch (houseType)
|
||||
{
|
||||
case HouseType.Wood:
|
||||
return (HouseBuilder) new WoodHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Ice:
|
||||
return (HouseBuilder) new IceHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Desert:
|
||||
return (HouseBuilder) new DesertHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Jungle:
|
||||
return (HouseBuilder) new JungleHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Mushroom:
|
||||
return (HouseBuilder) new MushroomHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Granite:
|
||||
return (HouseBuilder) new GraniteHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
case HouseType.Marble:
|
||||
return (HouseBuilder) new MarbleHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
default:
|
||||
return (HouseBuilder) new WoodHouseBuilder((IEnumerable<Microsoft.Xna.Framework.Rectangle>) rooms);
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Microsoft.Xna.Framework.Rectangle> CreateRooms(Point origin)
|
||||
{
|
||||
Point result;
|
||||
if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result) || result == origin)
|
||||
return new List<Microsoft.Xna.Framework.Rectangle>();
|
||||
Microsoft.Xna.Framework.Rectangle room1 = HouseUtils.FindRoom(result);
|
||||
Microsoft.Xna.Framework.Rectangle room2 = HouseUtils.FindRoom(new Point(room1.Center.X, room1.Y + 1));
|
||||
Microsoft.Xna.Framework.Rectangle room3 = HouseUtils.FindRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
|
||||
room3.Y = room1.Y + room1.Height - 1;
|
||||
float roomSolidPrecentage1 = HouseUtils.GetRoomSolidPrecentage(room2);
|
||||
float roomSolidPrecentage2 = HouseUtils.GetRoomSolidPrecentage(room3);
|
||||
room1.Y += 3;
|
||||
room2.Y += 3;
|
||||
room3.Y += 3;
|
||||
List<Microsoft.Xna.Framework.Rectangle> rectangleList = new List<Microsoft.Xna.Framework.Rectangle>();
|
||||
if ((double) WorldGen.genRand.NextFloat() > (double) roomSolidPrecentage1 + 0.200000002980232)
|
||||
rectangleList.Add(room2);
|
||||
rectangleList.Add(room1);
|
||||
if ((double) WorldGen.genRand.NextFloat() > (double) roomSolidPrecentage2 + 0.200000002980232)
|
||||
rectangleList.Add(room3);
|
||||
return rectangleList;
|
||||
}
|
||||
|
||||
private static Microsoft.Xna.Framework.Rectangle FindRoom(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 static float GetRoomSolidPrecentage(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 static int SortBiomeResults(Tuple<HouseType, int> item1, Tuple<HouseType, int> item2) => item2.Item2.CompareTo(item1.Item2);
|
||||
|
||||
private static bool AreRoomLocationsValid(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in rooms)
|
||||
{
|
||||
if (room.Y + room.Height > Main.maxTilesY - 220)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static HouseType GetHouseType(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
{
|
||||
Dictionary<ushort, int> resultsOutput = new Dictionary<ushort, int>();
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in rooms)
|
||||
WorldUtils.Gen(new Point(room.X - 10, room.Y - 10), (GenShape) new Shapes.Rectangle(room.Width + 20, room.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<HouseType, int>> tupleList = new List<Tuple<HouseType, int>>();
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Wood, resultsOutput[(ushort) 0] + resultsOutput[(ushort) 1]));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Jungle, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 60] * 10));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Mushroom, resultsOutput[(ushort) 59] + resultsOutput[(ushort) 70] * 10));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Ice, resultsOutput[(ushort) 147] + resultsOutput[(ushort) 161]));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Desert, resultsOutput[(ushort) 397] + resultsOutput[(ushort) 396] + resultsOutput[(ushort) 53]));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Granite, resultsOutput[(ushort) 368]));
|
||||
tupleList.Add(Tuple.Create<HouseType, int>(HouseType.Marble, resultsOutput[(ushort) 367]));
|
||||
tupleList.Sort(new Comparison<Tuple<HouseType, int>>(HouseUtils.SortBiomeResults));
|
||||
return tupleList[0].Item1;
|
||||
}
|
||||
|
||||
private static bool AreRoomsValid(
|
||||
IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms,
|
||||
StructureMap structures,
|
||||
HouseType style)
|
||||
{
|
||||
foreach (Microsoft.Xna.Framework.Rectangle room in rooms)
|
||||
{
|
||||
if (style != HouseType.Granite)
|
||||
{
|
||||
if (WorldUtils.Find(new Point(room.X - 2, room.Y - 2), Searches.Chain(new Searches.Rectangle(room.Width + 4, room.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out Point _))
|
||||
return false;
|
||||
}
|
||||
if (WorldGen.notTheBees)
|
||||
{
|
||||
if (!structures.CanPlace(room, HouseUtils.BeelistedTiles, 5))
|
||||
return false;
|
||||
}
|
||||
else if (!structures.CanPlace(room, HouseUtils.BlacklistedTiles, 5))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Biomes/CaveHouse/IceHouseBuilder.cs
Normal file
49
GameContent/Biomes/CaveHouse/IceHouseBuilder.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.IceHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class IceHouseBuilder : HouseBuilder
|
||||
{
|
||||
public IceHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Ice, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 321;
|
||||
this.WallType = (ushort) 149;
|
||||
this.BeamType = (ushort) 574;
|
||||
this.DoorStyle = 30;
|
||||
this.PlatformStyle = 19;
|
||||
this.TableStyle = 28;
|
||||
this.WorkbenchStyle = 23;
|
||||
this.PianoStyle = 23;
|
||||
this.BookcaseStyle = 25;
|
||||
this.ChairStyle = 30;
|
||||
this.ChestStyle = 11;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((ushort) 161, true), (GenAction) new Modifiers.Dither(0.8), (GenAction) new Actions.SetTileKeepWall((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), (GenAction) new Modifiers.SkipTiles(this.SkipTilesDuringWallAging), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((ushort) 40)));
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Biomes/CaveHouse/JungleHouseBuilder.cs
Normal file
49
GameContent/Biomes/CaveHouse/JungleHouseBuilder.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.JungleHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class JungleHouseBuilder : HouseBuilder
|
||||
{
|
||||
public JungleHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Jungle, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 158;
|
||||
this.WallType = (ushort) 42;
|
||||
this.BeamType = (ushort) 575;
|
||||
this.PlatformStyle = 2;
|
||||
this.DoorStyle = 2;
|
||||
this.TableStyle = 2;
|
||||
this.WorkbenchStyle = 2;
|
||||
this.PianoStyle = 2;
|
||||
this.BookcaseStyle = 12;
|
||||
this.ChairStyle = 3;
|
||||
this.ChestStyle = 8;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((ushort) 60, true), (GenAction) new Modifiers.Dither(0.800000011920929), (GenAction) new Actions.SetTileKeepWall((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 Modifiers.IsEmpty(), (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 Modifiers.IsEmpty(), (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((ushort) 64)));
|
||||
}
|
||||
}
|
||||
}
|
49
GameContent/Biomes/CaveHouse/MarbleHouseBuilder.cs
Normal file
49
GameContent/Biomes/CaveHouse/MarbleHouseBuilder.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.MarbleHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class MarbleHouseBuilder : HouseBuilder
|
||||
{
|
||||
public MarbleHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Marble, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 357;
|
||||
this.WallType = (ushort) 179;
|
||||
this.BeamType = (ushort) 561;
|
||||
this.PlatformStyle = 29;
|
||||
this.DoorStyle = 35;
|
||||
this.TableStyle = 34;
|
||||
this.WorkbenchStyle = 30;
|
||||
this.PianoStyle = 29;
|
||||
this.BookcaseStyle = 31;
|
||||
this.ChairStyle = 35;
|
||||
this.ChestStyle = 51;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((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((ushort) 178)));
|
||||
}
|
||||
}
|
||||
}
|
48
GameContent/Biomes/CaveHouse/MushroomHouseBuilder.cs
Normal file
48
GameContent/Biomes/CaveHouse/MushroomHouseBuilder.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.MushroomHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class MushroomHouseBuilder : HouseBuilder
|
||||
{
|
||||
public MushroomHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Mushroom, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 190;
|
||||
this.WallType = (ushort) 74;
|
||||
this.BeamType = (ushort) 578;
|
||||
this.PlatformStyle = 18;
|
||||
this.DoorStyle = 6;
|
||||
this.TableStyle = 27;
|
||||
this.WorkbenchStyle = 7;
|
||||
this.PianoStyle = 22;
|
||||
this.BookcaseStyle = 24;
|
||||
this.ChairStyle = 9;
|
||||
this.ChestStyle = 32;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(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]
|
||||
{
|
||||
this.TileType
|
||||
}), (GenAction) new Actions.SetTileKeepWall((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 Modifiers.IsEmpty(), (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 Modifiers.IsEmpty(), (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()));
|
||||
}
|
||||
}
|
||||
}
|
47
GameContent/Biomes/CaveHouse/WoodHouseBuilder.cs
Normal file
47
GameContent/Biomes/CaveHouse/WoodHouseBuilder.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouse.WoodHouseBuilder
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.CaveHouse
|
||||
{
|
||||
public class WoodHouseBuilder : HouseBuilder
|
||||
{
|
||||
public WoodHouseBuilder(IEnumerable<Microsoft.Xna.Framework.Rectangle> rooms)
|
||||
: base(HouseType.Wood, rooms)
|
||||
{
|
||||
this.TileType = (ushort) 30;
|
||||
this.WallType = (ushort) 27;
|
||||
this.BeamType = (ushort) 124;
|
||||
this.PlatformStyle = 0;
|
||||
this.DoorStyle = 0;
|
||||
this.TableStyle = 0;
|
||||
this.WorkbenchStyle = 0;
|
||||
this.PianoStyle = 0;
|
||||
this.BookcaseStyle = 0;
|
||||
this.ChairStyle = 0;
|
||||
this.ChestStyle = 1;
|
||||
}
|
||||
|
||||
protected override void AgeRoom(Microsoft.Xna.Framework.Rectangle room)
|
||||
{
|
||||
for (int index = 0; index < room.Width * room.Height / 16; ++index)
|
||||
WorldUtils.Gen(new Point(WorldGen.genRand.Next(1, room.Width - 1) + room.X, WorldGen.genRand.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 ushort[1]
|
||||
{
|
||||
this.WallType
|
||||
}), (GenAction) new Modifiers.SkipTiles(this.SkipTilesDuringWallAging), (double) room.Y > Main.worldSurface ? (GenAction) new Actions.ClearWall(true) : (GenAction) new Actions.PlaceWall((ushort) 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)));
|
||||
}
|
||||
}
|
||||
}
|
89
GameContent/Biomes/CaveHouseBiome.cs
Normal file
89
GameContent/Biomes/CaveHouseBiome.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.CaveHouseBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using Terraria.GameContent.Biomes.CaveHouse;
|
||||
using Terraria.ID;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class CaveHouseBiome : MicroBiome
|
||||
{
|
||||
private readonly HouseBuilderContext _builderContext = new HouseBuilderContext();
|
||||
|
||||
[JsonProperty]
|
||||
public float IceChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float JungleChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float GoldChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float GraniteChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float MarbleChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float MushroomChestChance { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public float DesertChestChance { get; set; }
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (!WorldGen.InWorld(origin.X, origin.Y, 10))
|
||||
return false;
|
||||
int num = 25;
|
||||
for (int index1 = origin.X - num; index1 <= origin.X + num; ++index1)
|
||||
{
|
||||
for (int index2 = origin.Y - num; index2 <= origin.Y + num; ++index2)
|
||||
{
|
||||
if (Main.tile[index1, index2].wire() || TileID.Sets.BasicChest[(int) Main.tile[index1, index2].type])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
HouseBuilder builder = HouseUtils.CreateBuilder(origin, structures);
|
||||
if (!builder.IsValid)
|
||||
return false;
|
||||
this.ApplyConfigurationToBuilder(builder);
|
||||
builder.Place(this._builderContext, structures);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ApplyConfigurationToBuilder(HouseBuilder builder)
|
||||
{
|
||||
switch (builder.Type)
|
||||
{
|
||||
case HouseType.Wood:
|
||||
builder.ChestChance = this.GoldChestChance;
|
||||
break;
|
||||
case HouseType.Ice:
|
||||
builder.ChestChance = this.IceChestChance;
|
||||
break;
|
||||
case HouseType.Desert:
|
||||
builder.ChestChance = this.DesertChestChance;
|
||||
break;
|
||||
case HouseType.Jungle:
|
||||
builder.ChestChance = this.JungleChestChance;
|
||||
break;
|
||||
case HouseType.Mushroom:
|
||||
builder.ChestChance = this.MushroomChestChance;
|
||||
break;
|
||||
case HouseType.Granite:
|
||||
builder.ChestChance = this.GraniteChestChance;
|
||||
break;
|
||||
case HouseType.Marble:
|
||||
builder.ChestChance = this.MarbleChestChance;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.ID;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
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 == (ushort) 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((ushort) 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((ushort) 69));
|
||||
structures.AddProtectedStructure(bounds, 2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
461
GameContent/Biomes/DeadMansChestBiome.cs
Normal file
461
GameContent/Biomes/DeadMansChestBiome.cs
Normal file
|
@ -0,0 +1,461 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.DeadMansChestBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ID;
|
||||
using Terraria.Utilities;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class DeadMansChestBiome : MicroBiome
|
||||
{
|
||||
private List<DeadMansChestBiome.DartTrapPlacementAttempt> _dartTrapPlacementSpots = new List<DeadMansChestBiome.DartTrapPlacementAttempt>();
|
||||
private List<DeadMansChestBiome.WirePlacementAttempt> _wirePlacementSpots = new List<DeadMansChestBiome.WirePlacementAttempt>();
|
||||
private List<DeadMansChestBiome.BoulderPlacementAttempt> _boulderPlacementSpots = new List<DeadMansChestBiome.BoulderPlacementAttempt>();
|
||||
private List<DeadMansChestBiome.ExplosivePlacementAttempt> _explosivePlacementAttempt = new List<DeadMansChestBiome.ExplosivePlacementAttempt>();
|
||||
[JsonProperty("NumberOfDartTraps")]
|
||||
private IntRange _numberOfDartTraps = new IntRange(3, 6);
|
||||
[JsonProperty("NumberOfBoulderTraps")]
|
||||
private IntRange _numberOfBoulderTraps = new IntRange(2, 4);
|
||||
[JsonProperty("NumberOfStepsBetweenBoulderTraps")]
|
||||
private IntRange _numberOfStepsBetweenBoulderTraps = new IntRange(2, 4);
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (!DeadMansChestBiome.IsAGoodSpot(origin))
|
||||
return false;
|
||||
this.ClearCaches();
|
||||
Point position = new Point(origin.X, origin.Y + 1);
|
||||
this.FindBoulderTrapSpots(position);
|
||||
this.FindDartTrapSpots(position);
|
||||
this.FindExplosiveTrapSpots(position);
|
||||
if (!this.AreThereEnoughTraps())
|
||||
return false;
|
||||
this.TurnGoldChestIntoDeadMansChest(origin);
|
||||
foreach (DeadMansChestBiome.DartTrapPlacementAttempt trapPlacementSpot in this._dartTrapPlacementSpots)
|
||||
this.ActuallyPlaceDartTrap(trapPlacementSpot.position, trapPlacementSpot.directionX, trapPlacementSpot.x, trapPlacementSpot.y, trapPlacementSpot.xPush, trapPlacementSpot.t);
|
||||
foreach (DeadMansChestBiome.WirePlacementAttempt wirePlacementSpot in this._wirePlacementSpots)
|
||||
this.PlaceWireLine(wirePlacementSpot.position, wirePlacementSpot.dirX, wirePlacementSpot.dirY, wirePlacementSpot.steps);
|
||||
foreach (DeadMansChestBiome.BoulderPlacementAttempt boulderPlacementSpot in this._boulderPlacementSpots)
|
||||
this.ActuallyPlaceBoulderTrap(boulderPlacementSpot.position, boulderPlacementSpot.yPush, boulderPlacementSpot.requiredHeight, boulderPlacementSpot.bestType);
|
||||
foreach (DeadMansChestBiome.ExplosivePlacementAttempt placementAttempt in this._explosivePlacementAttempt)
|
||||
this.ActuallyPlaceExplosive(placementAttempt.position);
|
||||
this.PlaceWiresForExplosives(origin);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PlaceWiresForExplosives(Point origin)
|
||||
{
|
||||
if (this._explosivePlacementAttempt.Count <= 0)
|
||||
return;
|
||||
this.PlaceWireLine(origin, 0, 1, this._explosivePlacementAttempt[0].position.Y - origin.Y);
|
||||
int x1 = this._explosivePlacementAttempt[0].position.X;
|
||||
int num = this._explosivePlacementAttempt[0].position.X;
|
||||
int y = this._explosivePlacementAttempt[0].position.Y;
|
||||
for (int index = 1; index < this._explosivePlacementAttempt.Count; ++index)
|
||||
{
|
||||
int x2 = this._explosivePlacementAttempt[index].position.X;
|
||||
if (x1 > x2)
|
||||
x1 = x2;
|
||||
if (num < x2)
|
||||
num = x2;
|
||||
}
|
||||
this.PlaceWireLine(new Point(x1, y), 1, 0, num - x1);
|
||||
}
|
||||
|
||||
private bool AreThereEnoughTraps() => (this._boulderPlacementSpots.Count >= 1 || this._explosivePlacementAttempt.Count >= 1) && this._dartTrapPlacementSpots.Count >= 1;
|
||||
|
||||
private void ClearCaches()
|
||||
{
|
||||
this._dartTrapPlacementSpots.Clear();
|
||||
this._wirePlacementSpots.Clear();
|
||||
this._boulderPlacementSpots.Clear();
|
||||
this._explosivePlacementAttempt.Clear();
|
||||
}
|
||||
|
||||
private void FindBoulderTrapSpots(Point position)
|
||||
{
|
||||
int x1 = position.X;
|
||||
int num1 = GenBase._random.Next(this._numberOfBoulderTraps);
|
||||
int num2 = GenBase._random.Next(this._numberOfStepsBetweenBoulderTraps);
|
||||
int x2 = x1 - num1 / 2 * num2;
|
||||
int y = position.Y - 6;
|
||||
for (int index = 0; index <= num1; ++index)
|
||||
{
|
||||
this.FindBoulderTrapSpot(new Point(x2, y));
|
||||
x2 += num2;
|
||||
}
|
||||
if (this._boulderPlacementSpots.Count <= 0)
|
||||
return;
|
||||
int x3 = this._boulderPlacementSpots[0].position.X;
|
||||
int num3 = this._boulderPlacementSpots[0].position.X;
|
||||
for (int index = 1; index < this._boulderPlacementSpots.Count; ++index)
|
||||
{
|
||||
int x4 = this._boulderPlacementSpots[index].position.X;
|
||||
if (x3 > x4)
|
||||
x3 = x4;
|
||||
if (num3 < x4)
|
||||
num3 = x4;
|
||||
}
|
||||
if (x3 > position.X)
|
||||
x3 = position.X;
|
||||
if (num3 < position.X)
|
||||
num3 = position.X;
|
||||
this._wirePlacementSpots.Add(new DeadMansChestBiome.WirePlacementAttempt(new Point(x3, y - 1), 1, 0, num3 - x3));
|
||||
this._wirePlacementSpots.Add(new DeadMansChestBiome.WirePlacementAttempt(position, 0, -1, 7));
|
||||
}
|
||||
|
||||
private void FindBoulderTrapSpot(Point position)
|
||||
{
|
||||
int x = position.X;
|
||||
int y = position.Y;
|
||||
for (int yPush = 0; yPush < 50; ++yPush)
|
||||
{
|
||||
if (Main.tile[x, y - yPush].active())
|
||||
{
|
||||
this.PlaceBoulderTrapSpot(new Point(x, y - yPush), yPush);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PlaceBoulderTrapSpot(Point position, int yPush)
|
||||
{
|
||||
int[] numArray = new int[623];
|
||||
for (int x = position.X; x < position.X + 2; ++x)
|
||||
{
|
||||
for (int index = position.Y - 4; index <= position.Y; ++index)
|
||||
{
|
||||
Tile tile = Main.tile[x, index];
|
||||
if (tile.active() && !Main.tileFrameImportant[(int) tile.type] && Main.tileSolid[(int) tile.type])
|
||||
++numArray[(int) tile.type];
|
||||
if (tile.active() && !TileID.Sets.CanBeClearedDuringGeneration[(int) tile.type])
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int index1 = position.X - 1; index1 < position.X + 2 + 1; ++index1)
|
||||
{
|
||||
for (int index2 = position.Y - 4 - 1; index2 <= position.Y - 4 + 2; ++index2)
|
||||
{
|
||||
if (!Main.tile[index1, index2].active())
|
||||
return;
|
||||
}
|
||||
}
|
||||
int bestType = -1;
|
||||
for (int index = 0; index < numArray.Length; ++index)
|
||||
{
|
||||
if (bestType == -1 || numArray[bestType] < numArray[index])
|
||||
bestType = index;
|
||||
}
|
||||
this._boulderPlacementSpots.Add(new DeadMansChestBiome.BoulderPlacementAttempt(position, yPush - 1, 4, bestType));
|
||||
}
|
||||
|
||||
private void FindDartTrapSpots(Point position)
|
||||
{
|
||||
int num1 = GenBase._random.Next(this._numberOfDartTraps);
|
||||
int directionX = GenBase._random.Next(2) == 0 ? -1 : 1;
|
||||
int steps = -1;
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
int num2 = this.FindDartTrapSpotSingle(position, directionX) ? 1 : 0;
|
||||
directionX *= -1;
|
||||
--position.Y;
|
||||
if (num2 != 0)
|
||||
steps = index;
|
||||
}
|
||||
this._wirePlacementSpots.Add(new DeadMansChestBiome.WirePlacementAttempt(new Point(position.X, position.Y + num1), 0, -1, steps));
|
||||
}
|
||||
|
||||
private bool FindDartTrapSpotSingle(Point position, int directionX)
|
||||
{
|
||||
int x = position.X;
|
||||
int y = position.Y;
|
||||
for (int xPush = 0; xPush < 20; ++xPush)
|
||||
{
|
||||
Tile t = Main.tile[x + xPush * directionX, y];
|
||||
if (t.type != (ushort) 467 && t.active() && Main.tileSolid[(int) t.type])
|
||||
{
|
||||
if (xPush < 5 || t.actuator() || Main.tileFrameImportant[(int) t.type] || !TileID.Sets.CanBeClearedDuringGeneration[(int) t.type])
|
||||
return false;
|
||||
this._dartTrapPlacementSpots.Add(new DeadMansChestBiome.DartTrapPlacementAttempt(position, directionX, x, y, xPush, t));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void FindExplosiveTrapSpots(Point position)
|
||||
{
|
||||
int x1 = position.X;
|
||||
int y = position.Y + 3;
|
||||
List<int> intList = new List<int>();
|
||||
if (this.IsGoodSpotsForExplosive(x1, y))
|
||||
intList.Add(x1);
|
||||
int x2 = x1 + 1;
|
||||
if (this.IsGoodSpotsForExplosive(x2, y))
|
||||
intList.Add(x2);
|
||||
int x3 = -1;
|
||||
if (intList.Count > 0)
|
||||
x3 = intList[GenBase._random.Next(intList.Count)];
|
||||
intList.Clear();
|
||||
int num1 = x2 + GenBase._random.Next(2, 6);
|
||||
int num2 = 4;
|
||||
for (int x4 = num1; x4 < num1 + num2; ++x4)
|
||||
{
|
||||
if (this.IsGoodSpotsForExplosive(x4, y))
|
||||
intList.Add(x4);
|
||||
}
|
||||
int x5 = -1;
|
||||
if (intList.Count > 0)
|
||||
x5 = intList[GenBase._random.Next(intList.Count)];
|
||||
int num3 = position.X - num2 - GenBase._random.Next(2, 6);
|
||||
for (int x6 = num3; x6 < num3 + num2; ++x6)
|
||||
{
|
||||
if (this.IsGoodSpotsForExplosive(x6, y))
|
||||
intList.Add(x6);
|
||||
}
|
||||
int x7 = -1;
|
||||
if (intList.Count > 0)
|
||||
x7 = intList[GenBase._random.Next(intList.Count)];
|
||||
if (x7 != -1)
|
||||
this._explosivePlacementAttempt.Add(new DeadMansChestBiome.ExplosivePlacementAttempt(new Point(x7, y)));
|
||||
if (x3 != -1)
|
||||
this._explosivePlacementAttempt.Add(new DeadMansChestBiome.ExplosivePlacementAttempt(new Point(x3, y)));
|
||||
if (x5 == -1)
|
||||
return;
|
||||
this._explosivePlacementAttempt.Add(new DeadMansChestBiome.ExplosivePlacementAttempt(new Point(x5, y)));
|
||||
}
|
||||
|
||||
private bool IsGoodSpotsForExplosive(int x, int y)
|
||||
{
|
||||
Tile tile = Main.tile[x, y];
|
||||
return tile.active() && Main.tileSolid[(int) tile.type] && !Main.tileFrameImportant[(int) tile.type] && !Main.tileSolidTop[(int) tile.type];
|
||||
}
|
||||
|
||||
public List<int> GetPossibleChestsToTrapify(StructureMap structures)
|
||||
{
|
||||
List<int> intList = new List<int>();
|
||||
bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
|
||||
for (int index = 0; index < validTiles.Length; ++index)
|
||||
validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
|
||||
validTiles[21] = true;
|
||||
validTiles[467] = true;
|
||||
for (int index = 0; index < 8000; ++index)
|
||||
{
|
||||
Chest chest = Main.chest[index];
|
||||
if (chest != null)
|
||||
{
|
||||
Point position1 = new Point(chest.x, chest.y);
|
||||
if (DeadMansChestBiome.IsAGoodSpot(position1))
|
||||
{
|
||||
this.ClearCaches();
|
||||
Point position2 = new Point(position1.X, position1.Y + 1);
|
||||
this.FindBoulderTrapSpots(position2);
|
||||
this.FindDartTrapSpots(position2);
|
||||
if (this.AreThereEnoughTraps() && (structures == null || structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(position1.X, position1.Y, 1, 1), validTiles, 10)))
|
||||
intList.Add(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
return intList;
|
||||
}
|
||||
|
||||
private static bool IsAGoodSpot(Point position)
|
||||
{
|
||||
if (!WorldGen.InWorld(position.X, position.Y, 50) || WorldGen.oceanDepths(position.X, position.Y))
|
||||
return false;
|
||||
Tile tile1 = Main.tile[position.X, position.Y];
|
||||
if (tile1.type != (ushort) 21 || (int) tile1.frameX / 36 != 1)
|
||||
return false;
|
||||
Tile tile2 = Main.tile[position.X, position.Y + 2];
|
||||
return TileID.Sets.CanBeClearedDuringGeneration[(int) tile2.type] && WorldGen.countWires(position.X, position.Y, 20) <= 0 && WorldGen.countTiles(position.X, position.Y, lavaOk: true) >= 40;
|
||||
}
|
||||
|
||||
private void TurnGoldChestIntoDeadMansChest(Point position)
|
||||
{
|
||||
for (int index1 = 0; index1 < 2; ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < 2; ++index2)
|
||||
{
|
||||
int index3 = position.X + index1;
|
||||
int index4 = position.Y + index2;
|
||||
Tile tile = Main.tile[index3, index4];
|
||||
tile.type = (ushort) 467;
|
||||
tile.frameX = (short) (144 + index1 * 18);
|
||||
tile.frameY = (short) (index2 * 18);
|
||||
}
|
||||
}
|
||||
if (GenBase._random.Next(3) != 0)
|
||||
return;
|
||||
int chest = Chest.FindChest(position.X, position.Y);
|
||||
if (chest <= -1)
|
||||
return;
|
||||
Item[] objArray = Main.chest[chest].item;
|
||||
for (int index = objArray.Length - 2; index > 0; --index)
|
||||
{
|
||||
Item obj = objArray[index];
|
||||
if (obj.stack != 0)
|
||||
objArray[index + 1] = obj.DeepClone();
|
||||
}
|
||||
objArray[1] = new Item();
|
||||
objArray[1].SetDefaults(5007);
|
||||
Main.chest[chest].item = objArray;
|
||||
}
|
||||
|
||||
private void ActuallyPlaceDartTrap(
|
||||
Point position,
|
||||
int directionX,
|
||||
int x,
|
||||
int y,
|
||||
int xPush,
|
||||
Tile t)
|
||||
{
|
||||
t.type = (ushort) 137;
|
||||
t.frameY = (short) 0;
|
||||
t.frameX = directionX != -1 ? (short) 0 : (short) 18;
|
||||
t.slope((byte) 0);
|
||||
t.halfBrick(false);
|
||||
WorldGen.TileFrame(x, y, true);
|
||||
this.PlaceWireLine(position, directionX, 0, xPush);
|
||||
}
|
||||
|
||||
private void PlaceWireLine(Point start, int offsetX, int offsetY, int steps)
|
||||
{
|
||||
for (int index = 0; index <= steps; ++index)
|
||||
Main.tile[start.X + offsetX * index, start.Y + offsetY * index].wire(true);
|
||||
}
|
||||
|
||||
private void ActuallyPlaceBoulderTrap(
|
||||
Point position,
|
||||
int yPush,
|
||||
int requiredHeight,
|
||||
int bestType)
|
||||
{
|
||||
for (int x = position.X; x < position.X + 2; ++x)
|
||||
{
|
||||
for (int j = position.Y - requiredHeight; j <= position.Y + 2; ++j)
|
||||
{
|
||||
Tile tile = Main.tile[x, j];
|
||||
if (j < position.Y - requiredHeight + 2)
|
||||
tile.ClearTile();
|
||||
else if (j <= position.Y)
|
||||
{
|
||||
if (!tile.active())
|
||||
{
|
||||
tile.active(true);
|
||||
tile.type = (ushort) bestType;
|
||||
}
|
||||
tile.slope((byte) 0);
|
||||
tile.halfBrick(false);
|
||||
tile.actuator(true);
|
||||
tile.wire(true);
|
||||
WorldGen.TileFrame(x, j, true);
|
||||
}
|
||||
else
|
||||
tile.ClearTile();
|
||||
}
|
||||
}
|
||||
int i = position.X + 1;
|
||||
int j1 = position.Y - requiredHeight + 1;
|
||||
int num1 = 3;
|
||||
int num2 = i - num1;
|
||||
int num3 = j1 - num1;
|
||||
int num4 = i + num1 - 1;
|
||||
int num5 = j1 + num1 - 1;
|
||||
for (int index1 = num2; index1 <= num4; ++index1)
|
||||
{
|
||||
for (int index2 = num3; index2 <= num5; ++index2)
|
||||
{
|
||||
if (Main.tile[index1, index2].type != (ushort) 138)
|
||||
Main.tile[index1, index2].type = (ushort) 1;
|
||||
}
|
||||
}
|
||||
WorldGen.PlaceTile(i, j1, 138);
|
||||
this.PlaceWireLine(position, 0, 1, yPush);
|
||||
}
|
||||
|
||||
private void ActuallyPlaceExplosive(Point position)
|
||||
{
|
||||
Tile tile = Main.tile[position.X, position.Y];
|
||||
tile.type = (ushort) 141;
|
||||
int num1;
|
||||
short num2 = (short) (num1 = 0);
|
||||
tile.frameY = (short) num1;
|
||||
tile.frameX = num2;
|
||||
tile.slope((byte) 0);
|
||||
tile.halfBrick(false);
|
||||
WorldGen.TileFrame(position.X, position.Y, true);
|
||||
}
|
||||
|
||||
private class DartTrapPlacementAttempt
|
||||
{
|
||||
public int directionX;
|
||||
public int xPush;
|
||||
public int x;
|
||||
public int y;
|
||||
public Point position;
|
||||
public Tile t;
|
||||
|
||||
public DartTrapPlacementAttempt(
|
||||
Point position,
|
||||
int directionX,
|
||||
int x,
|
||||
int y,
|
||||
int xPush,
|
||||
Tile t)
|
||||
{
|
||||
this.position = position;
|
||||
this.directionX = directionX;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.xPush = xPush;
|
||||
this.t = t;
|
||||
}
|
||||
}
|
||||
|
||||
private class BoulderPlacementAttempt
|
||||
{
|
||||
public Point position;
|
||||
public int yPush;
|
||||
public int requiredHeight;
|
||||
public int bestType;
|
||||
|
||||
public BoulderPlacementAttempt(Point position, int yPush, int requiredHeight, int bestType)
|
||||
{
|
||||
this.position = position;
|
||||
this.yPush = yPush;
|
||||
this.requiredHeight = requiredHeight;
|
||||
this.bestType = bestType;
|
||||
}
|
||||
}
|
||||
|
||||
private class WirePlacementAttempt
|
||||
{
|
||||
public Point position;
|
||||
public int dirX;
|
||||
public int dirY;
|
||||
public int steps;
|
||||
|
||||
public WirePlacementAttempt(Point position, int dirX, int dirY, int steps)
|
||||
{
|
||||
this.position = position;
|
||||
this.dirX = dirX;
|
||||
this.dirY = dirY;
|
||||
this.steps = steps;
|
||||
}
|
||||
}
|
||||
|
||||
private class ExplosivePlacementAttempt
|
||||
{
|
||||
public Point position;
|
||||
|
||||
public ExplosivePlacementAttempt(Point position) => this.position = position;
|
||||
}
|
||||
}
|
||||
}
|
75
GameContent/Biomes/Desert/AnthillEntrance.cs
Normal file
75
GameContent/Biomes/Desert/AnthillEntrance.cs
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.AnthillEntrance
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class AnthillEntrance
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
int num1 = WorldGen.genRand.Next(2, 4);
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
int holeRadius = WorldGen.genRand.Next(15, 18);
|
||||
int num2 = (int) ((double) (index + 1) / (double) (num1 + 1) * (double) description.Surface.Width) + description.Desert.Left;
|
||||
int y = (int) description.Surface[num2];
|
||||
AnthillEntrance.PlaceAt(description, new Point(num2, y), holeRadius);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
|
||||
{
|
||||
ShapeData data = new ShapeData();
|
||||
Point origin = new Point(position.X, position.Y + 6);
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Tail((float) (holeRadius * 2), new Vector2(0.0f, (float) -holeRadius * 1.5f)), Actions.Chain(new Actions.SetTile((ushort) 53).Output(data)));
|
||||
GenShapeActionPair pair1 = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
GenShapeActionPair genShapeActionPair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
GenShapeActionPair pair2 = new GenShapeActionPair((GenShape) new Shapes.Circle(2, 3), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort) 397), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
GenShapeActionPair pair3 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius, 3), Actions.Chain((GenAction) new Modifiers.SkipWalls(new ushort[1]
|
||||
{
|
||||
(ushort) 187
|
||||
}), (GenAction) new Actions.SetTile((ushort) 53)));
|
||||
GenShapeActionPair pair4 = new GenShapeActionPair((GenShape) new Shapes.Circle(holeRadius - 2, 3), Actions.Chain((GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
int x = position.X;
|
||||
int y1 = position.Y - holeRadius - 3;
|
||||
while (true)
|
||||
{
|
||||
int num1 = y1;
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = description.Hive;
|
||||
int top1 = rectangle.Top;
|
||||
int y2 = position.Y;
|
||||
rectangle = description.Desert;
|
||||
int top2 = rectangle.Top;
|
||||
int num2 = (y2 - top2) * 2;
|
||||
int num3 = top1 + num2 + 12;
|
||||
if (num1 < num3)
|
||||
{
|
||||
WorldUtils.Gen(new Point(x, y1), y1 < position.Y ? genShapeActionPair : pair1);
|
||||
WorldUtils.Gen(new Point(x, y1), pair2);
|
||||
if (y1 % 3 == 0 && y1 >= position.Y)
|
||||
{
|
||||
x += WorldGen.genRand.Next(-1, 2);
|
||||
WorldUtils.Gen(new Point(x, y1), pair1);
|
||||
if (y1 >= position.Y + 5)
|
||||
{
|
||||
WorldUtils.Gen(new Point(x, y1), pair3);
|
||||
WorldUtils.Gen(new Point(x, y1), pair4);
|
||||
}
|
||||
WorldUtils.Gen(new Point(x, y1), pair2);
|
||||
}
|
||||
++y1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
WorldUtils.Gen(new Point(origin.X, origin.Y - (int) ((double) holeRadius * 1.5) + 3), (GenShape) new Shapes.Circle(holeRadius / 2, holeRadius / 3), Actions.Chain(Actions.Chain((GenAction) new Actions.ClearTile(), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort) 0))));
|
||||
WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), (GenAction) new Actions.Smooth());
|
||||
}
|
||||
}
|
||||
}
|
85
GameContent/Biomes/Desert/ChambersEntrance.cs
Normal file
85
GameContent/Biomes/Desert/ChambersEntrance.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.ChambersEntrance
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Utilities;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class ChambersEntrance
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
int num = description.Desert.Center.X + WorldGen.genRand.Next(-40, 41);
|
||||
Point position = new Point(num, (int) description.Surface[num]);
|
||||
ChambersEntrance.PlaceAt(description, position);
|
||||
}
|
||||
|
||||
private static void PlaceAt(DesertDescription description, Point position)
|
||||
{
|
||||
ShapeData shapeData = new ShapeData();
|
||||
Point origin = new Point(position.X, position.Y + 2);
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(24, 12), Actions.Chain((GenAction) new Modifiers.Blotches(), new Actions.SetTile((ushort) 53).Output(shapeData)));
|
||||
UnifiedRandom genRand = WorldGen.genRand;
|
||||
ShapeData data = new ShapeData();
|
||||
int num1 = description.Hive.Top - position.Y;
|
||||
int direction = genRand.Next(2) == 0 ? -1 : 1;
|
||||
List<ChambersEntrance.PathConnection> pathConnectionList = new List<ChambersEntrance.PathConnection>()
|
||||
{
|
||||
new ChambersEntrance.PathConnection(new Point(position.X + -direction * 26, position.Y - 8), direction)
|
||||
};
|
||||
int num2 = genRand.Next(2, 4);
|
||||
for (int index = 0; index < num2; ++index)
|
||||
{
|
||||
int y = (int) ((double) (index + 1) / (double) num2 * (double) num1) + genRand.Next(-8, 9);
|
||||
int x = direction * genRand.Next(20, 41);
|
||||
int num3 = genRand.Next(18, 29);
|
||||
WorldUtils.Gen(position, (GenShape) new Shapes.Circle(num3 / 2, 3), Actions.Chain((GenAction) new Modifiers.Offset(x, y), (GenAction) new Modifiers.Blotches(), new Actions.Clear().Output(data), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
pathConnectionList.Add(new ChambersEntrance.PathConnection(new Point(x + num3 / 2 * -direction + position.X, y + position.Y), -direction));
|
||||
direction *= -1;
|
||||
}
|
||||
WorldUtils.Gen(position, (GenShape) new ModShapes.OuterOutline(data), Actions.Chain((GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 53
|
||||
}), (GenAction) new Actions.SetTile((ushort) 397), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
GenShapeActionPair pair = new GenShapeActionPair((GenShape) new Shapes.Rectangle(2, 4), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Modifiers.Blotches(), (GenAction) new Actions.Clear(), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort) 187), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 53
|
||||
}), (GenAction) new Actions.SetTile((ushort) 397)));
|
||||
for (int index = 1; index < pathConnectionList.Count; ++index)
|
||||
{
|
||||
ChambersEntrance.PathConnection pathConnection1 = pathConnectionList[index - 1];
|
||||
ChambersEntrance.PathConnection pathConnection2 = pathConnectionList[index];
|
||||
float num4 = Math.Abs(pathConnection2.Position.X - pathConnection1.Position.X) * 1.5f;
|
||||
for (float amount = 0.0f; (double) amount <= 1.0; amount += 0.02f)
|
||||
{
|
||||
Vector2 vector2_1 = new Vector2(pathConnection1.Position.X + pathConnection1.Direction * num4 * amount, pathConnection1.Position.Y);
|
||||
Vector2 vector2_2 = new Vector2(pathConnection2.Position.X + (float) ((double) pathConnection2.Direction * (double) num4 * (1.0 - (double) amount)), pathConnection2.Position.Y);
|
||||
Vector2 vector2_3 = Vector2.Lerp(pathConnection1.Position, pathConnection2.Position, amount);
|
||||
Vector2 vector2_4 = vector2_3;
|
||||
double num5 = (double) amount;
|
||||
WorldUtils.Gen(Vector2.Lerp(Vector2.Lerp(vector2_1, vector2_4, (float) num5), Vector2.Lerp(vector2_3, vector2_2, amount), amount).ToPoint(), pair);
|
||||
}
|
||||
}
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Rectangle(new Microsoft.Xna.Framework.Rectangle(-29, -12, 58, 12)), Actions.Chain((GenAction) new Modifiers.NotInShape(shapeData), (GenAction) new Modifiers.Expand(1), (GenAction) new Actions.PlaceWall((ushort) 0)));
|
||||
}
|
||||
|
||||
private struct PathConnection
|
||||
{
|
||||
public readonly Vector2 Position;
|
||||
public readonly float Direction;
|
||||
|
||||
public PathConnection(Point position, int direction)
|
||||
{
|
||||
this.Position = new Vector2((float) position.X, (float) position.Y);
|
||||
this.Direction = (float) direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
90
GameContent/Biomes/Desert/DesertDescription.cs
Normal file
90
GameContent/Biomes/Desert/DesertDescription.cs
Normal file
|
@ -0,0 +1,90 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.DesertDescription
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public class DesertDescription
|
||||
{
|
||||
public static readonly DesertDescription Invalid = new DesertDescription()
|
||||
{
|
||||
IsValid = false
|
||||
};
|
||||
private static readonly Vector2 DefaultBlockScale = new Vector2(4f, 2f);
|
||||
private const int SCAN_PADDING = 5;
|
||||
|
||||
public Rectangle CombinedArea { get; private set; }
|
||||
|
||||
public Rectangle Desert { get; private set; }
|
||||
|
||||
public Rectangle Hive { get; private set; }
|
||||
|
||||
public Vector2 BlockScale { get; private set; }
|
||||
|
||||
public int BlockColumnCount { get; private set; }
|
||||
|
||||
public int BlockRowCount { get; private set; }
|
||||
|
||||
public bool IsValid { get; private set; }
|
||||
|
||||
public SurfaceMap Surface { get; private set; }
|
||||
|
||||
private DesertDescription()
|
||||
{
|
||||
}
|
||||
|
||||
public void UpdateSurfaceMap() => this.Surface = SurfaceMap.FromArea(this.CombinedArea.Left - 5, this.CombinedArea.Width + 10);
|
||||
|
||||
public static DesertDescription CreateFromPlacement(Point origin)
|
||||
{
|
||||
Vector2 defaultBlockScale = DesertDescription.DefaultBlockScale;
|
||||
float num1 = (float) Main.maxTilesX / 4200f;
|
||||
int num2 = (int) (80.0 * (double) num1);
|
||||
int num3 = (int) (((double) WorldGen.genRand.NextFloat() + 1.0) * 170.0 * (double) num1);
|
||||
int width = (int) ((double) defaultBlockScale.X * (double) num2);
|
||||
int height = (int) ((double) defaultBlockScale.Y * (double) num3);
|
||||
origin.X -= width / 2;
|
||||
SurfaceMap surfaceMap = SurfaceMap.FromArea(origin.X - 5, width + 10);
|
||||
if (DesertDescription.RowHasInvalidTiles(origin.X, surfaceMap.Bottom, width))
|
||||
return DesertDescription.Invalid;
|
||||
int y = (int) ((double) surfaceMap.Average + (double) surfaceMap.Bottom) / 2;
|
||||
origin.Y = y + WorldGen.genRand.Next(40, 60);
|
||||
return new DesertDescription()
|
||||
{
|
||||
CombinedArea = new Rectangle(origin.X, y, width, origin.Y + height - y),
|
||||
Hive = new Rectangle(origin.X, origin.Y, width, height),
|
||||
Desert = new Rectangle(origin.X, y, width, origin.Y + height / 2 - y),
|
||||
BlockScale = defaultBlockScale,
|
||||
BlockColumnCount = num2,
|
||||
BlockRowCount = num3,
|
||||
Surface = surfaceMap,
|
||||
IsValid = true
|
||||
};
|
||||
}
|
||||
|
||||
private static bool RowHasInvalidTiles(int startX, int startY, int width)
|
||||
{
|
||||
if (WorldGen.skipDesertTileCheck)
|
||||
return false;
|
||||
for (int index = startX; index < startX + width; ++index)
|
||||
{
|
||||
switch (Main.tile[index, startY].type)
|
||||
{
|
||||
case 59:
|
||||
case 60:
|
||||
return true;
|
||||
case 147:
|
||||
case 161:
|
||||
return true;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
366
GameContent/Biomes/Desert/DesertHive.cs
Normal file
366
GameContent/Biomes/Desert/DesertHive.cs
Normal file
|
@ -0,0 +1,366 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.DesertHive
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class DesertHive
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
DesertHive.ClusterGroup clusters = DesertHive.ClusterGroup.FromDescription(description);
|
||||
DesertHive.PlaceClusters(description, clusters);
|
||||
DesertHive.AddTileVariance(description);
|
||||
}
|
||||
|
||||
private static void PlaceClusters(
|
||||
DesertDescription description,
|
||||
DesertHive.ClusterGroup clusters)
|
||||
{
|
||||
Rectangle hive = description.Hive;
|
||||
hive.Inflate(20, 20);
|
||||
DesertHive.PostPlacementEffect[,] postEffectMap = new DesertHive.PostPlacementEffect[hive.Width, hive.Height];
|
||||
DesertHive.PlaceClustersArea(description, clusters, hive, postEffectMap, Point.Zero);
|
||||
for (int left = hive.Left; left < hive.Right; ++left)
|
||||
{
|
||||
for (int top = hive.Top; top < hive.Bottom; ++top)
|
||||
{
|
||||
if (postEffectMap[left - hive.Left, top - hive.Top].HasFlag((Enum) DesertHive.PostPlacementEffect.Smooth))
|
||||
Tile.SmoothSlope(left, top, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PlaceClustersArea(
|
||||
DesertDescription description,
|
||||
DesertHive.ClusterGroup clusters,
|
||||
Rectangle area,
|
||||
DesertHive.PostPlacementEffect[,] postEffectMap,
|
||||
Point postEffectMapOffset)
|
||||
{
|
||||
FastRandom fastRandom1 = new FastRandom(Main.ActiveWorldFileData.Seed).WithModifier(57005UL);
|
||||
Vector2 vector2_1 = new Vector2((float) description.Hive.Width, (float) description.Hive.Height);
|
||||
Vector2 vector2_2 = new Vector2((float) clusters.Width, (float) clusters.Height);
|
||||
Vector2 vector2_3 = description.BlockScale / 2f;
|
||||
for (int left = area.Left; left < area.Right; ++left)
|
||||
{
|
||||
for (int top = area.Top; top < area.Bottom; ++top)
|
||||
{
|
||||
if (WorldGen.InWorld(left, top, 1))
|
||||
{
|
||||
float num1 = 0.0f;
|
||||
int num2 = -1;
|
||||
float num3 = 0.0f;
|
||||
ushort type = 53;
|
||||
if (fastRandom1.Next(3) == 0)
|
||||
type = (ushort) 397;
|
||||
int x = left - description.Hive.X;
|
||||
int y = top - description.Hive.Y;
|
||||
Vector2 vector2_4 = (new Vector2((float) x, (float) y) - vector2_3) / vector2_1 * vector2_2;
|
||||
for (int index = 0; index < clusters.Count; ++index)
|
||||
{
|
||||
DesertHive.Cluster cluster = clusters[index];
|
||||
if ((double) Math.Abs(cluster[0].Position.X - vector2_4.X) <= 10.0 && (double) Math.Abs(cluster[0].Position.Y - vector2_4.Y) <= 10.0)
|
||||
{
|
||||
float num4 = 0.0f;
|
||||
foreach (DesertHive.Block block in (List<DesertHive.Block>) cluster)
|
||||
num4 += 1f / Vector2.DistanceSquared(block.Position, vector2_4);
|
||||
if ((double) num4 > (double) num1)
|
||||
{
|
||||
if ((double) num1 > (double) num3)
|
||||
num3 = num1;
|
||||
num1 = num4;
|
||||
num2 = index;
|
||||
}
|
||||
else if ((double) num4 > (double) num3)
|
||||
num3 = num4;
|
||||
}
|
||||
}
|
||||
float num5 = num1 + num3;
|
||||
Tile tile = Main.tile[left, top];
|
||||
bool flag = (double) ((new Vector2((float) x, (float) y) - vector2_3) / vector2_1 * 2f - Vector2.One).Length() >= 0.800000011920929;
|
||||
DesertHive.PostPlacementEffect postPlacementEffect = DesertHive.PostPlacementEffect.None;
|
||||
if ((double) num5 > 3.5)
|
||||
{
|
||||
postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
|
||||
tile.ClearEverything();
|
||||
tile.wall = (ushort) 187;
|
||||
if (num2 % 15 == 2)
|
||||
tile.ResetToType((ushort) 404);
|
||||
}
|
||||
else if ((double) num5 > 1.79999995231628)
|
||||
{
|
||||
tile.wall = (ushort) 187;
|
||||
if ((double) top < Main.worldSurface)
|
||||
tile.liquid = (byte) 0;
|
||||
else
|
||||
tile.lava(true);
|
||||
if (!flag || tile.active())
|
||||
{
|
||||
tile.ResetToType((ushort) 396);
|
||||
postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
|
||||
}
|
||||
}
|
||||
else if ((double) num5 > 0.699999988079071 || !flag)
|
||||
{
|
||||
tile.wall = (ushort) 216;
|
||||
tile.liquid = (byte) 0;
|
||||
if (!flag || tile.active())
|
||||
{
|
||||
tile.ResetToType(type);
|
||||
postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
|
||||
}
|
||||
}
|
||||
else if ((double) num5 > 0.25)
|
||||
{
|
||||
FastRandom fastRandom2 = fastRandom1.WithModifier(x, y);
|
||||
float num6 = (float) (((double) num5 - 0.25) / 0.449999988079071);
|
||||
if ((double) fastRandom2.NextFloat() < (double) num6)
|
||||
{
|
||||
tile.wall = (ushort) 187;
|
||||
if ((double) top < Main.worldSurface)
|
||||
tile.liquid = (byte) 0;
|
||||
else
|
||||
tile.lava(true);
|
||||
if (tile.active())
|
||||
{
|
||||
tile.ResetToType(type);
|
||||
postPlacementEffect = DesertHive.PostPlacementEffect.Smooth;
|
||||
}
|
||||
}
|
||||
}
|
||||
postEffectMap[left - area.X + postEffectMapOffset.X, top - area.Y + postEffectMapOffset.Y] = postPlacementEffect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddTileVariance(DesertDescription description)
|
||||
{
|
||||
for (int index1 = -20; index1 < description.Hive.Width + 20; ++index1)
|
||||
{
|
||||
for (int index2 = -20; index2 < description.Hive.Height + 20; ++index2)
|
||||
{
|
||||
int x = index1 + description.Hive.X;
|
||||
int y = index2 + description.Hive.Y;
|
||||
if (WorldGen.InWorld(x, y, 1))
|
||||
{
|
||||
Tile tile = Main.tile[x, y];
|
||||
Tile testTile1 = Main.tile[x, y + 1];
|
||||
Tile testTile2 = Main.tile[x, y + 2];
|
||||
if (tile.type == (ushort) 53 && (!WorldGen.SolidTile(testTile1) || !WorldGen.SolidTile(testTile2)))
|
||||
tile.type = (ushort) 397;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index3 = -20; index3 < description.Hive.Width + 20; ++index3)
|
||||
{
|
||||
for (int index4 = -20; index4 < description.Hive.Height + 20; ++index4)
|
||||
{
|
||||
int index5 = index3 + description.Hive.X;
|
||||
int y = index4 + description.Hive.Y;
|
||||
if (WorldGen.InWorld(index5, y, 1))
|
||||
{
|
||||
Tile tile = Main.tile[index5, y];
|
||||
if (tile.active() && tile.type == (ushort) 396)
|
||||
{
|
||||
bool flag1 = true;
|
||||
for (int index6 = -1; index6 >= -3; --index6)
|
||||
{
|
||||
if (Main.tile[index5, y + index6].active())
|
||||
{
|
||||
flag1 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool flag2 = true;
|
||||
for (int index7 = 1; index7 <= 3; ++index7)
|
||||
{
|
||||
if (Main.tile[index5, y + index7].active())
|
||||
{
|
||||
flag2 = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag1 && WorldGen.genRand.Next(5) == 0)
|
||||
WorldGen.PlaceTile(index5, y - 1, 485, true, true, style: WorldGen.genRand.Next(4));
|
||||
else if (flag1 && WorldGen.genRand.Next(5) == 0)
|
||||
WorldGen.PlaceTile(index5, y - 1, 484, true, true);
|
||||
else if (flag1 ^ flag2 && WorldGen.genRand.Next(5) == 0)
|
||||
WorldGen.PlaceTile(index5, y + (flag1 ? -1 : 1), 165, true, true);
|
||||
else if (flag1 && WorldGen.genRand.Next(5) == 0)
|
||||
WorldGen.PlaceTile(index5, y - 1, 187, true, true, style: (29 + WorldGen.genRand.Next(6)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct Block
|
||||
{
|
||||
public Vector2 Position;
|
||||
|
||||
public Block(float x, float y) => this.Position = new Vector2(x, y);
|
||||
}
|
||||
|
||||
private class Cluster : List<DesertHive.Block>
|
||||
{
|
||||
}
|
||||
|
||||
private class ClusterGroup : List<DesertHive.Cluster>
|
||||
{
|
||||
public readonly int Width;
|
||||
public readonly int Height;
|
||||
|
||||
private ClusterGroup(int width, int height)
|
||||
{
|
||||
this.Width = width;
|
||||
this.Height = height;
|
||||
this.Generate();
|
||||
}
|
||||
|
||||
public static DesertHive.ClusterGroup FromDescription(DesertDescription description) => new DesertHive.ClusterGroup(description.BlockColumnCount, description.BlockRowCount);
|
||||
|
||||
private static void SearchForCluster(
|
||||
bool[,] blockMap,
|
||||
List<Point> pointCluster,
|
||||
int x,
|
||||
int y,
|
||||
int level = 2)
|
||||
{
|
||||
pointCluster.Add(new Point(x, y));
|
||||
blockMap[x, y] = false;
|
||||
--level;
|
||||
if (level == -1)
|
||||
return;
|
||||
if (x > 0 && blockMap[x - 1, y])
|
||||
DesertHive.ClusterGroup.SearchForCluster(blockMap, pointCluster, x - 1, y, level);
|
||||
if (x < blockMap.GetLength(0) - 1 && blockMap[x + 1, y])
|
||||
DesertHive.ClusterGroup.SearchForCluster(blockMap, pointCluster, x + 1, y, level);
|
||||
if (y > 0 && blockMap[x, y - 1])
|
||||
DesertHive.ClusterGroup.SearchForCluster(blockMap, pointCluster, x, y - 1, level);
|
||||
if (y >= blockMap.GetLength(1) - 1 || !blockMap[x, y + 1])
|
||||
return;
|
||||
DesertHive.ClusterGroup.SearchForCluster(blockMap, pointCluster, x, y + 1, level);
|
||||
}
|
||||
|
||||
private static 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;
|
||||
}
|
||||
|
||||
private void Generate()
|
||||
{
|
||||
this.Clear();
|
||||
bool[,] blockMap = new bool[this.Width, this.Height];
|
||||
int num1 = this.Width / 2 - 1;
|
||||
int y1 = this.Height / 2 - 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)
|
||||
blockMap[index2, index1] = WorldGen.genRand.Next(2) == 0;
|
||||
}
|
||||
List<List<Point>> pointClusters = new List<List<Point>>();
|
||||
for (int x = 0; x < blockMap.GetLength(0); ++x)
|
||||
{
|
||||
for (int y2 = 0; y2 < blockMap.GetLength(1); ++y2)
|
||||
{
|
||||
if (blockMap[x, y2] && WorldGen.genRand.Next(2) == 0)
|
||||
{
|
||||
List<Point> pointCluster = new List<Point>();
|
||||
DesertHive.ClusterGroup.SearchForCluster(blockMap, pointCluster, x, y2);
|
||||
if (pointCluster.Count > 2)
|
||||
pointClusters.Add(pointCluster);
|
||||
}
|
||||
}
|
||||
}
|
||||
int[,] clusterIndexMap = new int[blockMap.GetLength(0), blockMap.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)
|
||||
DesertHive.ClusterGroup.AttemptClaim(x - 1, y3, clusterIndexMap, pointClusters, index6);
|
||||
if (x < clusterIndexMap.GetLength(0) - 1)
|
||||
DesertHive.ClusterGroup.AttemptClaim(x + 1, y3, clusterIndexMap, pointClusters, index6);
|
||||
if (y3 > 0)
|
||||
DesertHive.ClusterGroup.AttemptClaim(x, y3 - 1, clusterIndexMap, pointClusters, index6);
|
||||
if (y3 < clusterIndexMap.GetLength(1) - 1)
|
||||
DesertHive.ClusterGroup.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)
|
||||
{
|
||||
DesertHive.Cluster cluster = new DesertHive.Cluster();
|
||||
if (pointList.Count > 0)
|
||||
{
|
||||
foreach (Point point4 in pointList)
|
||||
cluster.Add(new DesertHive.Block((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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum PostPlacementEffect : byte
|
||||
{
|
||||
None = 0,
|
||||
Smooth = 1,
|
||||
}
|
||||
}
|
||||
}
|
64
GameContent/Biomes/Desert/LarvaHoleEntrance.cs
Normal file
64
GameContent/Biomes/Desert/LarvaHoleEntrance.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.LarvaHoleEntrance
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class LarvaHoleEntrance
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
int num1 = WorldGen.genRand.Next(2, 4);
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
int holeRadius = WorldGen.genRand.Next(13, 16);
|
||||
int num2 = (int) ((double) (index + 1) / (double) (num1 + 1) * (double) description.Surface.Width) + description.Desert.Left;
|
||||
int y = (int) description.Surface[num2];
|
||||
LarvaHoleEntrance.PlaceAt(description, new Point(num2, y), holeRadius);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
|
||||
{
|
||||
ShapeData data = new ShapeData();
|
||||
WorldUtils.Gen(position, (GenShape) new Shapes.Rectangle(new Microsoft.Xna.Framework.Rectangle(-holeRadius, -holeRadius * 2, holeRadius * 2, holeRadius * 2)), new Actions.Clear().Output(data));
|
||||
WorldUtils.Gen(position, (GenShape) new Shapes.Tail((float) (holeRadius * 2), new Vector2(0.0f, (float) holeRadius * 1.5f)), Actions.Chain(new Actions.Clear().Output(data)));
|
||||
WorldUtils.Gen(position, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Modifiers.Offset(0, 1), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Smooth(true)));
|
||||
GenShapeActionPair pair1 = new GenShapeActionPair((GenShape) new Shapes.Rectangle(1, 1), Actions.Chain((GenAction) new Modifiers.Blotches(), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
GenShapeActionPair pair2 = new GenShapeActionPair((GenShape) new Shapes.Circle(2, 3), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort) 397), (GenAction) new Actions.PlaceWall((ushort) 187)));
|
||||
int x = position.X;
|
||||
int y1 = position.Y + (int) ((double) holeRadius * 1.5);
|
||||
while (true)
|
||||
{
|
||||
int num1 = y1;
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = description.Hive;
|
||||
int top1 = rectangle.Top;
|
||||
int y2 = position.Y;
|
||||
rectangle = description.Desert;
|
||||
int top2 = rectangle.Top;
|
||||
int num2 = (y2 - top2) * 2;
|
||||
int num3 = top1 + num2 + 12;
|
||||
if (num1 < num3)
|
||||
{
|
||||
WorldUtils.Gen(new Point(x, y1), pair1);
|
||||
WorldUtils.Gen(new Point(x, y1), pair2);
|
||||
if (y1 % 3 == 0)
|
||||
{
|
||||
x += WorldGen.genRand.Next(-1, 2);
|
||||
WorldUtils.Gen(new Point(x, y1), pair1);
|
||||
WorldUtils.Gen(new Point(x, y1), pair2);
|
||||
}
|
||||
++y1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
WorldUtils.Gen(new Point(position.X, position.Y + 2), (GenShape) new ModShapes.All(data), (GenAction) new Actions.PlaceWall((ushort) 0));
|
||||
}
|
||||
}
|
||||
}
|
78
GameContent/Biomes/Desert/PitEntrance.cs
Normal file
78
GameContent/Biomes/Desert/PitEntrance.cs
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.PitEntrance
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class PitEntrance
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
int holeRadius = WorldGen.genRand.Next(6, 9);
|
||||
Point center = description.CombinedArea.Center;
|
||||
center.Y = (int) description.Surface[center.X];
|
||||
PitEntrance.PlaceAt(description, center, holeRadius);
|
||||
}
|
||||
|
||||
private static void PlaceAt(DesertDescription description, Point position, int holeRadius)
|
||||
{
|
||||
for (int index = -holeRadius - 3; index < holeRadius + 3; ++index)
|
||||
{
|
||||
int j = (int) description.Surface[index + position.X];
|
||||
while (true)
|
||||
{
|
||||
int num1 = j;
|
||||
Rectangle rectangle = description.Hive;
|
||||
int num2 = rectangle.Top + 10;
|
||||
if (num1 <= num2)
|
||||
{
|
||||
double num3 = (double) (j - (int) description.Surface[index + position.X]);
|
||||
rectangle = description.Hive;
|
||||
int top1 = rectangle.Top;
|
||||
rectangle = description.Desert;
|
||||
int top2 = rectangle.Top;
|
||||
double num4 = (double) (top1 - top2);
|
||||
float yProgress = MathHelper.Clamp((float) (num3 / num4), 0.0f, 1f);
|
||||
int num5 = (int) ((double) PitEntrance.GetHoleRadiusScaleAt(yProgress) * (double) holeRadius);
|
||||
if (Math.Abs(index) < num5)
|
||||
Main.tile[index + position.X, j].ClearEverything();
|
||||
else if (Math.Abs(index) < num5 + 3 && (double) yProgress > 0.349999994039536)
|
||||
Main.tile[index + position.X, j].ResetToType((ushort) 397);
|
||||
float num6 = Math.Abs((float) index / (float) holeRadius);
|
||||
float num7 = num6 * num6;
|
||||
if (Math.Abs(index) < num5 + 3 && (double) (j - position.Y) > 15.0 - 3.0 * (double) num7)
|
||||
{
|
||||
Main.tile[index + position.X, j].wall = (ushort) 187;
|
||||
WorldGen.SquareWallFrame(index + position.X, j - 1);
|
||||
WorldGen.SquareWallFrame(index + position.X, j);
|
||||
}
|
||||
++j;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
holeRadius += 4;
|
||||
for (int index1 = -holeRadius; index1 < holeRadius; ++index1)
|
||||
{
|
||||
int num8 = holeRadius - Math.Abs(index1);
|
||||
int num9 = Math.Min(10, num8 * num8);
|
||||
for (int index2 = 0; index2 < num9; ++index2)
|
||||
Main.tile[index1 + position.X, index2 + (int) description.Surface[index1 + position.X]].ClearEverything();
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetHoleRadiusScaleAt(float yProgress) => (double) yProgress < 0.600000023841858 ? 1f : (float) ((1.0 - (double) PitEntrance.SmootherStep((float) (((double) yProgress - 0.600000023841858) / 0.400000005960464))) * 0.5 + 0.5);
|
||||
|
||||
private static float SmootherStep(float delta)
|
||||
{
|
||||
delta = MathHelper.Clamp(delta, 0.0f, 1f);
|
||||
return (float) (1.0 - Math.Cos((double) delta * 3.14159274101257) * 0.5 - 0.5);
|
||||
}
|
||||
}
|
||||
}
|
69
GameContent/Biomes/Desert/SandMound.cs
Normal file
69
GameContent/Biomes/Desert/SandMound.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.SandMound
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public static class SandMound
|
||||
{
|
||||
public static void Place(DesertDescription description)
|
||||
{
|
||||
Rectangle desert1 = description.Desert;
|
||||
desert1.Height = Math.Min(description.Desert.Height, description.Hive.Height / 2);
|
||||
Rectangle desert2 = description.Desert;
|
||||
desert2.Y = desert1.Bottom;
|
||||
desert2.Height = Math.Max(0, description.Desert.Bottom - desert1.Bottom);
|
||||
SurfaceMap surface = description.Surface;
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
for (int index1 = -5; index1 < desert1.Width + 5; ++index1)
|
||||
{
|
||||
float num3 = MathHelper.Clamp((float) ((double) Math.Abs((float) (index1 + 5) / (float) (desert1.Width + 10)) * 2.0 - 1.0), -1f, 1f);
|
||||
if (index1 % 3 == 0)
|
||||
num1 = Utils.Clamp<int>(num1 + WorldGen.genRand.Next(-1, 2), -10, 10);
|
||||
num2 = Utils.Clamp<int>(num2 + WorldGen.genRand.Next(-1, 2), -10, 10);
|
||||
float num4 = (float) Math.Sqrt(1.0 - (double) num3 * (double) num3 * (double) num3 * (double) num3);
|
||||
int num5 = desert1.Bottom - (int) ((double) num4 * (double) desert1.Height) + num1;
|
||||
if ((double) Math.Abs(num3) < 1.0)
|
||||
{
|
||||
float num6 = Utils.UnclampedSmoothStep(0.5f, 0.8f, Math.Abs(num3));
|
||||
float num7 = num6 * num6 * num6;
|
||||
int num8 = Math.Min(10 + (int) ((double) desert1.Top - (double) num7 * 20.0) + num2, num5);
|
||||
for (int index2 = (int) surface[index1 + desert1.X] - 1; index2 < num8; ++index2)
|
||||
{
|
||||
int index3 = index1 + desert1.X;
|
||||
int index4 = index2;
|
||||
Main.tile[index3, index4].active(false);
|
||||
Main.tile[index3, index4].wall = (ushort) 0;
|
||||
}
|
||||
}
|
||||
SandMound.PlaceSandColumn(index1 + desert1.X, num5, desert2.Bottom - num5);
|
||||
}
|
||||
}
|
||||
|
||||
private static void PlaceSandColumn(int startX, int startY, int height)
|
||||
{
|
||||
for (int index = startY + height - 1; index >= startY; --index)
|
||||
{
|
||||
int i = startX;
|
||||
int j = index;
|
||||
Tile tile1 = Main.tile[i, j];
|
||||
tile1.liquid = (byte) 0;
|
||||
Tile tile2 = Main.tile[i, j + 1];
|
||||
Tile tile3 = Main.tile[i, j + 2];
|
||||
tile1.type = (ushort) 53;
|
||||
tile1.slope((byte) 0);
|
||||
tile1.halfBrick(false);
|
||||
tile1.active(true);
|
||||
if (index < startY)
|
||||
tile1.active(false);
|
||||
WorldGen.SquareWallFrame(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
71
GameContent/Biomes/Desert/SurfaceMap.cs
Normal file
71
GameContent/Biomes/Desert/SurfaceMap.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.Desert.SurfaceMap
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using System;
|
||||
|
||||
namespace Terraria.GameContent.Biomes.Desert
|
||||
{
|
||||
public class SurfaceMap
|
||||
{
|
||||
public readonly float Average;
|
||||
public readonly int Bottom;
|
||||
public readonly int Top;
|
||||
public readonly int X;
|
||||
private readonly short[] _heights;
|
||||
|
||||
public int Width => this._heights.Length;
|
||||
|
||||
private SurfaceMap(short[] heights, int x)
|
||||
{
|
||||
this._heights = heights;
|
||||
this.X = x;
|
||||
int val1_1 = 0;
|
||||
int val1_2 = int.MaxValue;
|
||||
int num = 0;
|
||||
for (int index = 0; index < heights.Length; ++index)
|
||||
{
|
||||
num += (int) heights[index];
|
||||
val1_1 = Math.Max(val1_1, (int) heights[index]);
|
||||
val1_2 = Math.Min(val1_2, (int) heights[index]);
|
||||
}
|
||||
if ((double) val1_1 > Main.worldSurface - 10.0)
|
||||
val1_1 = (int) Main.worldSurface - 10;
|
||||
this.Bottom = val1_1;
|
||||
this.Top = val1_2;
|
||||
this.Average = (float) num / (float) this._heights.Length;
|
||||
}
|
||||
|
||||
public short this[int absoluteX] => this._heights[absoluteX - this.X];
|
||||
|
||||
public static SurfaceMap FromArea(int startX, int width)
|
||||
{
|
||||
int num1 = Main.maxTilesY / 2;
|
||||
short[] heights = new short[width];
|
||||
for (int index1 = startX; index1 < startX + width; ++index1)
|
||||
{
|
||||
bool flag = false;
|
||||
int num2 = 0;
|
||||
for (int index2 = 50; index2 < 50 + num1; ++index2)
|
||||
{
|
||||
if (Main.tile[index1, index2].active())
|
||||
{
|
||||
if (Main.tile[index1, index2].type == (ushort) 189 || Main.tile[index1, index2].type == (ushort) 196 || Main.tile[index1, index2].type == (ushort) 460)
|
||||
flag = false;
|
||||
else if (!flag)
|
||||
{
|
||||
num2 = index2;
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
num2 = num1 + 50;
|
||||
}
|
||||
heights[index1 - startX] = (short) num2;
|
||||
}
|
||||
return new SurfaceMap(heights, startX);
|
||||
}
|
||||
}
|
||||
}
|
74
GameContent/Biomes/DesertBiome.cs
Normal file
74
GameContent/Biomes/DesertBiome.cs
Normal file
|
@ -0,0 +1,74 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.DesertBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using Terraria.GameContent.Biomes.Desert;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class DesertBiome : MicroBiome
|
||||
{
|
||||
[JsonProperty("ChanceOfEntrance")]
|
||||
public float ChanceOfEntrance = 0.3333f;
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
DesertDescription fromPlacement = DesertDescription.CreateFromPlacement(origin);
|
||||
if (!fromPlacement.IsValid)
|
||||
return false;
|
||||
DesertBiome.ExportDescriptionToEngine(fromPlacement);
|
||||
SandMound.Place(fromPlacement);
|
||||
fromPlacement.UpdateSurfaceMap();
|
||||
if ((double) GenBase._random.NextFloat() <= (double) this.ChanceOfEntrance)
|
||||
{
|
||||
switch (GenBase._random.Next(4))
|
||||
{
|
||||
case 0:
|
||||
ChambersEntrance.Place(fromPlacement);
|
||||
break;
|
||||
case 1:
|
||||
AnthillEntrance.Place(fromPlacement);
|
||||
break;
|
||||
case 2:
|
||||
LarvaHoleEntrance.Place(fromPlacement);
|
||||
break;
|
||||
case 3:
|
||||
PitEntrance.Place(fromPlacement);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DesertHive.Place(fromPlacement);
|
||||
DesertBiome.CleanupArea(fromPlacement.Hive);
|
||||
Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(fromPlacement.CombinedArea.X, 50, fromPlacement.CombinedArea.Width, fromPlacement.CombinedArea.Bottom - 20);
|
||||
structures.AddStructure(area, 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void ExportDescriptionToEngine(DesertDescription description)
|
||||
{
|
||||
WorldGen.UndergroundDesertLocation = description.CombinedArea;
|
||||
WorldGen.UndergroundDesertLocation.Inflate(10, 10);
|
||||
WorldGen.UndergroundDesertHiveLocation = description.Hive;
|
||||
}
|
||||
|
||||
private static void CleanupArea(Microsoft.Xna.Framework.Rectangle area)
|
||||
{
|
||||
for (int index1 = area.Left - 20; index1 < area.Right + 20; ++index1)
|
||||
{
|
||||
for (int index2 = area.Top - 20; index2 < area.Bottom + 20; ++index2)
|
||||
{
|
||||
if (index1 > 0 && index1 < Main.maxTilesX - 1 && index2 > 0 && index2 < Main.maxTilesY - 1)
|
||||
{
|
||||
WorldGen.SquareWallFrame(index1, index2);
|
||||
WorldUtils.TileFrame(index1, index2, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
150
GameContent/Biomes/DunesBiome.cs
Normal file
150
GameContent/Biomes/DunesBiome.cs
Normal file
|
@ -0,0 +1,150 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.DunesBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using Terraria.GameContent.Biomes.Desert;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class DunesBiome : MicroBiome
|
||||
{
|
||||
[JsonProperty("SingleDunesWidth")]
|
||||
private WorldGenRange _singleDunesWidth = WorldGenRange.Empty;
|
||||
[JsonProperty("HeightScale")]
|
||||
private float _heightScale = 1f;
|
||||
|
||||
public int MaximumWidth => this._singleDunesWidth.ScaledMaximum * 2;
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
int height1 = (int) ((double) GenBase._random.Next(60, 100) * (double) this._heightScale);
|
||||
int height2 = (int) ((double) GenBase._random.Next(60, 100) * (double) this._heightScale);
|
||||
int random1 = this._singleDunesWidth.GetRandom(GenBase._random);
|
||||
int random2 = this._singleDunesWidth.GetRandom(GenBase._random);
|
||||
DunesBiome.DunesDescription fromPlacement1 = DunesBiome.DunesDescription.CreateFromPlacement(new Point(origin.X - random1 / 2 + 30, origin.Y), random1, height1);
|
||||
DunesBiome.DunesDescription fromPlacement2 = DunesBiome.DunesDescription.CreateFromPlacement(new Point(origin.X + random2 / 2 - 30, origin.Y), random2, height2);
|
||||
this.PlaceSingle(fromPlacement1, structures);
|
||||
this.PlaceSingle(fromPlacement2, structures);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PlaceSingle(DunesBiome.DunesDescription description, StructureMap structures)
|
||||
{
|
||||
int num1 = GenBase._random.Next(3) + 8;
|
||||
for (int index = 0; index < num1 - 1; ++index)
|
||||
{
|
||||
int num2 = (int) (2.0 / (double) num1 * (double) description.Area.Width);
|
||||
int num3 = (int) ((double) index / (double) num1 * (double) description.Area.Width + (double) description.Area.Left) + num2 * 2 / 5 + GenBase._random.Next(-5, 6);
|
||||
float num4 = (float) (1.0 - (double) Math.Abs((float) index / (float) (num1 - 2) - 0.5f) * 2.0);
|
||||
DunesBiome.PlaceHill(num3 - num2 / 2, num3 + num2 / 2, (float) ((double) num4 * 0.300000011920929 + 0.200000002980232) * this._heightScale, description);
|
||||
}
|
||||
int num5 = GenBase._random.Next(2) + 1;
|
||||
for (int index = 0; index < num5; ++index)
|
||||
{
|
||||
int num6 = description.Area.Width / 2;
|
||||
int num7 = description.Area.Center.X + GenBase._random.Next(-10, 11);
|
||||
DunesBiome.PlaceHill(num7 - num6 / 2, num7 + num6 / 2, 0.8f * this._heightScale, description);
|
||||
}
|
||||
structures.AddStructure(description.Area, 20);
|
||||
}
|
||||
|
||||
private static void PlaceHill(
|
||||
int startX,
|
||||
int endX,
|
||||
float scale,
|
||||
DunesBiome.DunesDescription description)
|
||||
{
|
||||
Point startPoint = new Point(startX, (int) description.Surface[startX]);
|
||||
Point endPoint = new Point(endX, (int) description.Surface[endX]);
|
||||
Point point1 = new Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2 - (int) (35.0 * (double) scale));
|
||||
int num = (endPoint.X - point1.X) / 4;
|
||||
int minValue = (endPoint.X - point1.X) / 16;
|
||||
if (description.WindDirection == DunesBiome.WindDirection.Left)
|
||||
point1.X -= WorldGen.genRand.Next(minValue, num + 1);
|
||||
else
|
||||
point1.X += WorldGen.genRand.Next(minValue, num + 1);
|
||||
Point point2 = new Point(0, (int) ((double) scale * 12.0));
|
||||
Point point3 = new Point(point2.X / -2, point2.Y / -2);
|
||||
DunesBiome.PlaceCurvedLine(startPoint, point1, description.WindDirection != DunesBiome.WindDirection.Left ? point3 : point2, description);
|
||||
DunesBiome.PlaceCurvedLine(point1, endPoint, description.WindDirection == DunesBiome.WindDirection.Left ? point3 : point2, description);
|
||||
}
|
||||
|
||||
private static void PlaceCurvedLine(
|
||||
Point startPoint,
|
||||
Point endPoint,
|
||||
Point anchorOffset,
|
||||
DunesBiome.DunesDescription description)
|
||||
{
|
||||
Point p = new Point((startPoint.X + endPoint.X) / 2, (startPoint.Y + endPoint.Y) / 2);
|
||||
p.X += anchorOffset.X;
|
||||
p.Y += anchorOffset.Y;
|
||||
Vector2 vector2_1 = startPoint.ToVector2();
|
||||
Vector2 vector2_2 = endPoint.ToVector2();
|
||||
Vector2 vector2_3 = p.ToVector2();
|
||||
float num1 = (float) (0.5 / ((double) vector2_2.X - (double) vector2_1.X));
|
||||
Point point1 = new Point(-1, -1);
|
||||
for (float amount = 0.0f; (double) amount <= 1.0; amount += num1)
|
||||
{
|
||||
Point point2 = Vector2.Lerp(Vector2.Lerp(vector2_1, vector2_3, amount), Vector2.Lerp(vector2_3, vector2_2, amount), amount).ToPoint();
|
||||
if (!(point2 == point1))
|
||||
{
|
||||
point1 = point2;
|
||||
int num2 = description.Area.Width / 2 - Math.Abs(point2.X - description.Area.Center.X);
|
||||
int num3 = (int) description.Surface[point2.X] + (int) (Math.Sqrt((double) num2) * 3.0);
|
||||
for (int index = point2.Y - 10; index < point2.Y; ++index)
|
||||
{
|
||||
if (GenBase._tiles[point2.X, index].active() && GenBase._tiles[point2.X, index].type != (ushort) 53)
|
||||
GenBase._tiles[point2.X, index].ClearEverything();
|
||||
}
|
||||
for (int y = point2.Y; y < num3; ++y)
|
||||
{
|
||||
GenBase._tiles[point2.X, y].ResetToType((ushort) 53);
|
||||
Tile.SmoothSlope(point2.X, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DunesDescription
|
||||
{
|
||||
public bool IsValid { get; private set; }
|
||||
|
||||
public SurfaceMap Surface { get; private set; }
|
||||
|
||||
public Microsoft.Xna.Framework.Rectangle Area { get; private set; }
|
||||
|
||||
public DunesBiome.WindDirection WindDirection { get; private set; }
|
||||
|
||||
private DunesDescription()
|
||||
{
|
||||
}
|
||||
|
||||
public static DunesBiome.DunesDescription CreateFromPlacement(
|
||||
Point origin,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle(origin.X - width / 2, origin.Y - height / 2, width, height);
|
||||
return new DunesBiome.DunesDescription()
|
||||
{
|
||||
Area = rectangle,
|
||||
IsValid = true,
|
||||
Surface = SurfaceMap.FromArea(rectangle.Left - 20, rectangle.Width + 40),
|
||||
WindDirection = WorldGen.genRand.Next(2) == 0 ? DunesBiome.WindDirection.Left : DunesBiome.WindDirection.Right
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private enum WindDirection
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
}
|
||||
}
|
87
GameContent/Biomes/EnchantedSwordBiome.cs
Normal file
87
GameContent/Biomes/EnchantedSwordBiome.cs
Normal file
|
@ -0,0 +1,87 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.EnchantedSwordBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.ID;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class EnchantedSwordBiome : MicroBiome
|
||||
{
|
||||
[JsonProperty("ChanceOfEntrance")]
|
||||
private float _chanceOfEntrance;
|
||||
[JsonProperty("ChanceOfRealSword")]
|
||||
private float _chanceOfRealSword;
|
||||
|
||||
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);
|
||||
bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
|
||||
for (int index = 0; index < validTiles.Length; ++index)
|
||||
validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
|
||||
validTiles[21] = false;
|
||||
validTiles[467] = false;
|
||||
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), validTiles) || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), validTiles, 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((ushort) 68), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
|
||||
{
|
||||
(ushort) 2
|
||||
}), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 382)));
|
||||
if ((double) GenBase._random.NextFloat() <= (double) this._chanceOfEntrance)
|
||||
{
|
||||
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), (GenAction) new Modifiers.SkipTiles(new ushort[2]
|
||||
{
|
||||
(ushort) 191,
|
||||
(ushort) 192
|
||||
}), 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 ((double) GenBase._random.NextFloat() <= (double) this._chanceOfRealSword)
|
||||
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.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int) (20.0 * (double) xScale), point1.Y - 20, (int) (40.0 * (double) xScale), 40), 10);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
292
GameContent/Biomes/GraniteBiome.cs
Normal file
292
GameContent/Biomes/GraniteBiome.cs
Normal file
|
@ -0,0 +1,292 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.GraniteBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.ID;
|
||||
using Terraria.Utilities;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class GraniteBiome : MicroBiome
|
||||
{
|
||||
private const int MAX_MAGMA_ITERATIONS = 300;
|
||||
private GraniteBiome.Magma[,] _sourceMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
private GraniteBiome.Magma[,] _targetMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
private static Vector2[] _normalisedVectors = new Vector2[9]
|
||||
{
|
||||
Vector2.Normalize(new Vector2(-1f, -1f)),
|
||||
Vector2.Normalize(new Vector2(-1f, 0.0f)),
|
||||
Vector2.Normalize(new Vector2(-1f, 1f)),
|
||||
Vector2.Normalize(new Vector2(0.0f, -1f)),
|
||||
new Vector2(0.0f, 0.0f),
|
||||
Vector2.Normalize(new Vector2(0.0f, 1f)),
|
||||
Vector2.Normalize(new Vector2(1f, -1f)),
|
||||
Vector2.Normalize(new Vector2(1f, 0.0f)),
|
||||
Vector2.Normalize(new Vector2(1f, 1f))
|
||||
};
|
||||
|
||||
public static bool CanPlace(Point origin, StructureMap structures) => !WorldGen.BiomeTileCheck(origin.X, origin.Y) && !GenBase._tiles[origin.X, origin.Y].active();
|
||||
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (GenBase._tiles[origin.X, origin.Y].active())
|
||||
return false;
|
||||
origin.X -= this._sourceMagmaMap.GetLength(0) / 2;
|
||||
origin.Y -= this._sourceMagmaMap.GetLength(1) / 2;
|
||||
this.BuildMagmaMap(origin);
|
||||
Microsoft.Xna.Framework.Rectangle effectedMapArea;
|
||||
this.SimulatePressure(out effectedMapArea);
|
||||
this.PlaceGranite(origin, effectedMapArea);
|
||||
this.CleanupTiles(origin, effectedMapArea);
|
||||
this.PlaceDecorations(origin, effectedMapArea);
|
||||
structures.AddStructure(effectedMapArea, 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void BuildMagmaMap(Point tileOrigin)
|
||||
{
|
||||
this._sourceMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
this._targetMagmaMap = new GraniteBiome.Magma[200, 200];
|
||||
for (int index1 = 0; index1 < this._sourceMagmaMap.GetLength(0); ++index1)
|
||||
{
|
||||
for (int index2 = 0; index2 < this._sourceMagmaMap.GetLength(1); ++index2)
|
||||
{
|
||||
int i = index1 + tileOrigin.X;
|
||||
int j = index2 + tileOrigin.Y;
|
||||
this._sourceMagmaMap[index1, index2] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
|
||||
this._targetMagmaMap[index1, index2] = this._sourceMagmaMap[index1, index2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SimulatePressure(out Microsoft.Xna.Framework.Rectangle effectedMapArea)
|
||||
{
|
||||
int length1 = this._sourceMagmaMap.GetLength(0);
|
||||
int length2 = this._sourceMagmaMap.GetLength(1);
|
||||
int index1 = length1 / 2;
|
||||
int index2 = length2 / 2;
|
||||
int num1 = index1;
|
||||
int min1 = num1;
|
||||
int num2 = index2;
|
||||
int min2 = num2;
|
||||
for (int index3 = 0; index3 < 300; ++index3)
|
||||
{
|
||||
for (int index4 = num1; index4 <= min1; ++index4)
|
||||
{
|
||||
for (int index5 = num2; index5 <= min2; ++index5)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma1 = this._sourceMagmaMap[index4, index5];
|
||||
if (sourceMagma1.IsActive)
|
||||
{
|
||||
float num3 = 0.0f;
|
||||
Vector2 zero = Vector2.Zero;
|
||||
for (int index6 = -1; index6 <= 1; ++index6)
|
||||
{
|
||||
for (int index7 = -1; index7 <= 1; ++index7)
|
||||
{
|
||||
if (index6 != 0 || index7 != 0)
|
||||
{
|
||||
Vector2 normalisedVector = GraniteBiome._normalisedVectors[(index6 + 1) * 3 + (index7 + 1)];
|
||||
GraniteBiome.Magma sourceMagma2 = this._sourceMagmaMap[index4 + index6, index5 + index7];
|
||||
if ((double) sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive)
|
||||
{
|
||||
if (index6 == -1)
|
||||
num1 = Utils.Clamp<int>(index4 + index6, 1, num1);
|
||||
else
|
||||
min1 = Utils.Clamp<int>(index4 + index6, min1, length1 - 2);
|
||||
if (index7 == -1)
|
||||
num2 = Utils.Clamp<int>(index5 + index7, 1, num2);
|
||||
else
|
||||
min2 = Utils.Clamp<int>(index5 + index7, min2, length2 - 2);
|
||||
this._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow();
|
||||
}
|
||||
float pressure = sourceMagma2.Pressure;
|
||||
num3 += pressure;
|
||||
zero += pressure * normalisedVector;
|
||||
}
|
||||
}
|
||||
}
|
||||
float num4 = num3 / 8f;
|
||||
if ((double) num4 > (double) sourceMagma1.Resistance)
|
||||
{
|
||||
float num5 = zero.Length() / 8f;
|
||||
float pressure = Math.Max(0.0f, (float) ((double) Math.Max(num4 - num5 - sourceMagma1.Pressure, 0.0f) + (double) num5 + (double) sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance);
|
||||
this._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (index3 < 2)
|
||||
this._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f);
|
||||
Utils.Swap<GraniteBiome.Magma[,]>(ref this._sourceMagmaMap, ref this._targetMagmaMap);
|
||||
}
|
||||
effectedMapArea = new Microsoft.Xna.Framework.Rectangle(num1, num2, min1 - num1 + 1, min2 - num2 + 1);
|
||||
}
|
||||
|
||||
private bool ShouldUseLava(Point tileOrigin)
|
||||
{
|
||||
int length1 = this._sourceMagmaMap.GetLength(0);
|
||||
int length2 = this._sourceMagmaMap.GetLength(1);
|
||||
int num1 = length1 / 2;
|
||||
int num2 = length2 / 2;
|
||||
if (tileOrigin.Y + num2 <= WorldGen.lavaLine - 30)
|
||||
return false;
|
||||
for (int index1 = -50; index1 < 50; ++index1)
|
||||
{
|
||||
for (int index2 = -50; index2 < 50; ++index2)
|
||||
{
|
||||
if (GenBase._tiles[tileOrigin.X + num1 + index1, tileOrigin.Y + num2 + index2].active())
|
||||
{
|
||||
switch (GenBase._tiles[tileOrigin.X + num1 + index1, tileOrigin.Y + num2 + index2].type)
|
||||
{
|
||||
case 147:
|
||||
case 161:
|
||||
case 162:
|
||||
case 163:
|
||||
case 200:
|
||||
return false;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void PlaceGranite(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea)
|
||||
{
|
||||
bool flag = this.ShouldUseLava(tileOrigin);
|
||||
ushort type = 368;
|
||||
ushort num = 180;
|
||||
if (WorldGen.drunkWorldGen)
|
||||
{
|
||||
type = (ushort) 367;
|
||||
num = (ushort) 178;
|
||||
}
|
||||
for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left)
|
||||
{
|
||||
for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma = this._sourceMagmaMap[left, top];
|
||||
if (sourceMagma.IsActive)
|
||||
{
|
||||
Tile tile = GenBase._tiles[tileOrigin.X + left, tileOrigin.Y + top];
|
||||
if ((double) Math.Max(1f - Math.Max(0.0f, (float) (Math.Sin((double) (tileOrigin.Y + top) * 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(tileOrigin.X + left, tileOrigin.Y + top) ? 0.0 : 0.5))
|
||||
{
|
||||
if (TileID.Sets.Ore[(int) tile.type])
|
||||
tile.ResetToType(tile.type);
|
||||
else
|
||||
tile.ResetToType(type);
|
||||
tile.wall = num;
|
||||
}
|
||||
else if ((double) sourceMagma.Resistance < 0.00999999977648258)
|
||||
{
|
||||
WorldUtils.ClearTile(tileOrigin.X + left, tileOrigin.Y + top);
|
||||
tile.wall = num;
|
||||
}
|
||||
if (tile.liquid > (byte) 0 & flag)
|
||||
tile.liquidType(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CleanupTiles(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea)
|
||||
{
|
||||
ushort num1 = 180;
|
||||
if (WorldGen.drunkWorldGen)
|
||||
num1 = (ushort) 178;
|
||||
List<Point16> point16List = new List<Point16>();
|
||||
for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left)
|
||||
{
|
||||
for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top)
|
||||
{
|
||||
if (this._sourceMagmaMap[left, top].IsActive)
|
||||
{
|
||||
int num2 = 0;
|
||||
int num3 = left + tileOrigin.X;
|
||||
int num4 = top + tileOrigin.Y;
|
||||
if (WorldGen.SolidTile(num3, num4))
|
||||
{
|
||||
for (int index1 = -1; index1 <= 1; ++index1)
|
||||
{
|
||||
for (int index2 = -1; index2 <= 1; ++index2)
|
||||
{
|
||||
if (WorldGen.SolidTile(num3 + index1, num4 + index2))
|
||||
++num2;
|
||||
}
|
||||
}
|
||||
if (num2 < 3)
|
||||
point16List.Add(new Point16(num3, num4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 = num1;
|
||||
}
|
||||
point16List.Clear();
|
||||
}
|
||||
|
||||
private void PlaceDecorations(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea)
|
||||
{
|
||||
FastRandom fastRandom1 = new FastRandom(Main.ActiveWorldFileData.Seed).WithModifier(65440UL);
|
||||
for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left)
|
||||
{
|
||||
for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top)
|
||||
{
|
||||
GraniteBiome.Magma sourceMagma = this._sourceMagmaMap[left, top];
|
||||
int index1 = left + tileOrigin.X;
|
||||
int index2 = top + tileOrigin.Y;
|
||||
if (sourceMagma.IsActive)
|
||||
{
|
||||
WorldUtils.TileFrame(index1, index2);
|
||||
WorldGen.SquareWallFrame(index1, index2);
|
||||
FastRandom fastRandom2 = fastRandom1.WithModifier(index1, index2);
|
||||
if (fastRandom2.Next(8) == 0 && GenBase._tiles[index1, index2].active())
|
||||
{
|
||||
if (!GenBase._tiles[index1, index2 + 1].active())
|
||||
WorldGen.PlaceUncheckedStalactite(index1, index2 + 1, fastRandom2.Next(2) == 0, fastRandom2.Next(3), false);
|
||||
if (!GenBase._tiles[index1, index2 - 1].active())
|
||||
WorldGen.PlaceUncheckedStalactite(index1, index2 - 1, fastRandom2.Next(2) == 0, fastRandom2.Next(3), false);
|
||||
}
|
||||
if (fastRandom2.Next(2) == 0)
|
||||
Tile.SmoothSlope(index1, index2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
324
GameContent/Biomes/HiveBiome.cs
Normal file
324
GameContent/Biomes/HiveBiome.cs
Normal file
|
@ -0,0 +1,324 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.HiveBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.Utilities;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class HiveBiome : MicroBiome
|
||||
{
|
||||
public override bool Place(Point origin, StructureMap structures)
|
||||
{
|
||||
if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100)) || HiveBiome.TooCloseToImportantLocations(origin))
|
||||
return false;
|
||||
Ref<int> count1 = new Ref<int>(0);
|
||||
Ref<int> count2 = new Ref<int>(0);
|
||||
Ref<int> count3 = new Ref<int>(0);
|
||||
WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(15), Actions.Chain((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(count3)));
|
||||
if ((double) count2.Value / (double) count1.Value < 0.75 || count3.Value < 2)
|
||||
return false;
|
||||
int index1 = 0;
|
||||
int[] numArray1 = new int[1000];
|
||||
int[] numArray2 = new int[1000];
|
||||
Vector2 position1 = origin.ToVector2();
|
||||
int num1 = WorldGen.genRand.Next(2, 5);
|
||||
if (WorldGen.drunkWorldGen)
|
||||
num1 += WorldGen.genRand.Next(7, 10);
|
||||
for (int index2 = 0; index2 < num1; ++index2)
|
||||
{
|
||||
Vector2 vector2 = position1;
|
||||
int num2 = WorldGen.genRand.Next(2, 5);
|
||||
for (int index3 = 0; index3 < num2; ++index3)
|
||||
vector2 = HiveBiome.CreateHiveTunnel((int) position1.X, (int) position1.Y, WorldGen.genRand);
|
||||
position1 = vector2;
|
||||
numArray1[index1] = (int) position1.X;
|
||||
numArray2[index1] = (int) position1.Y;
|
||||
++index1;
|
||||
}
|
||||
HiveBiome.FrameOutAllHiveContents(origin, 50);
|
||||
for (int index4 = 0; index4 < index1; ++index4)
|
||||
{
|
||||
int x1 = numArray1[index4];
|
||||
int y = numArray2[index4];
|
||||
int dir = 1;
|
||||
if (WorldGen.genRand.Next(2) == 0)
|
||||
dir = -1;
|
||||
bool flag = false;
|
||||
while (WorldGen.InWorld(x1, y, 10) && HiveBiome.BadSpotForHoneyFall(x1, y))
|
||||
{
|
||||
x1 += dir;
|
||||
if (Math.Abs(x1 - numArray1[index4]) > 50)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
int x2 = x1 + dir;
|
||||
if (!HiveBiome.SpotActuallyNotInHive(x2, y))
|
||||
{
|
||||
HiveBiome.CreateBlockedHoneyCube(x2, y);
|
||||
HiveBiome.CreateDentForHoneyFall(x2, y, dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
HiveBiome.CreateStandForLarva(position1);
|
||||
if (WorldGen.drunkWorldGen)
|
||||
{
|
||||
for (int index5 = 0; index5 < 1000; ++index5)
|
||||
{
|
||||
Vector2 position2 = position1;
|
||||
position2.X += (float) WorldGen.genRand.Next(-50, 51);
|
||||
position2.Y += (float) WorldGen.genRand.Next(-50, 51);
|
||||
if (WorldGen.InWorld((int) position2.X, (int) position2.Y) && (double) Vector2.Distance(position1, position2) > 10.0 && !Main.tile[(int) position2.X, (int) position2.Y].active() && Main.tile[(int) position2.X, (int) position2.Y].wall == (ushort) 86)
|
||||
{
|
||||
HiveBiome.CreateStandForLarva(position2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void FrameOutAllHiveContents(Point origin, int squareHalfWidth)
|
||||
{
|
||||
int num1 = Math.Max(10, origin.X - squareHalfWidth);
|
||||
int num2 = Math.Min(Main.maxTilesX - 10, origin.X + squareHalfWidth);
|
||||
int num3 = Math.Max(10, origin.Y - squareHalfWidth);
|
||||
int num4 = Math.Min(Main.maxTilesY - 10, origin.Y + squareHalfWidth);
|
||||
for (int i = num1; i < num2; ++i)
|
||||
{
|
||||
for (int j = num3; j < num4; ++j)
|
||||
{
|
||||
Tile tile = Main.tile[i, j];
|
||||
if (tile.active() && tile.type == (ushort) 225)
|
||||
WorldGen.SquareTileFrame(i, j);
|
||||
if (tile.wall == (ushort) 86)
|
||||
WorldGen.SquareWallFrame(i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector2 CreateHiveTunnel(int i, int j, UnifiedRandom random)
|
||||
{
|
||||
double num1 = (double) random.Next(12, 21);
|
||||
float num2 = (float) random.Next(10, 21);
|
||||
if (WorldGen.drunkWorldGen)
|
||||
{
|
||||
double num3 = (double) random.Next(8, 26);
|
||||
float num4 = (float) random.Next(10, 41);
|
||||
float num5 = (float) (((double) (Main.maxTilesX / 4200) + 1.0) / 2.0);
|
||||
num1 = num3 * (double) num5;
|
||||
num2 = num4 * num5;
|
||||
}
|
||||
double num6 = num1;
|
||||
Vector2 vector2_1;
|
||||
vector2_1.X = (float) i;
|
||||
vector2_1.Y = (float) j;
|
||||
Vector2 vector2_2;
|
||||
vector2_2.X = (float) random.Next(-10, 11) * 0.2f;
|
||||
vector2_2.Y = (float) random.Next(-10, 11) * 0.2f;
|
||||
while (num1 > 0.0 && (double) num2 > 0.0)
|
||||
{
|
||||
if ((double) vector2_1.Y > (double) (Main.maxTilesY - 250))
|
||||
num2 = 0.0f;
|
||||
num1 = num6 * (1.0 + (double) random.Next(-20, 20) * 0.00999999977648258);
|
||||
float num7 = num2 - 1f;
|
||||
int num8 = (int) ((double) vector2_1.X - num1);
|
||||
int num9 = (int) ((double) vector2_1.X + num1);
|
||||
int num10 = (int) ((double) vector2_1.Y - num1);
|
||||
int num11 = (int) ((double) vector2_1.Y + num1);
|
||||
if (num8 < 1)
|
||||
num8 = 1;
|
||||
if (num9 > Main.maxTilesX - 1)
|
||||
num9 = Main.maxTilesX - 1;
|
||||
if (num10 < 1)
|
||||
num10 = 1;
|
||||
if (num11 > Main.maxTilesY - 1)
|
||||
num11 = Main.maxTilesY - 1;
|
||||
for (int x = num8; x < num9; ++x)
|
||||
{
|
||||
for (int y = num10; y < num11; ++y)
|
||||
{
|
||||
if (!WorldGen.InWorld(x, y, 50))
|
||||
{
|
||||
num7 = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Main.tile[x - 10, y].wall == (ushort) 87)
|
||||
num7 = 0.0f;
|
||||
if (Main.tile[x + 10, y].wall == (ushort) 87)
|
||||
num7 = 0.0f;
|
||||
if (Main.tile[x, y - 10].wall == (ushort) 87)
|
||||
num7 = 0.0f;
|
||||
if (Main.tile[x, y + 10].wall == (ushort) 87)
|
||||
num7 = 0.0f;
|
||||
}
|
||||
if ((double) y < Main.worldSurface && Main.tile[x, y - 5].wall == (ushort) 0)
|
||||
num7 = 0.0f;
|
||||
double num12 = (double) Math.Abs((float) x - vector2_1.X);
|
||||
float num13 = Math.Abs((float) y - vector2_1.Y);
|
||||
double num14 = Math.Sqrt(num12 * num12 + (double) num13 * (double) num13);
|
||||
if (num14 < num6 * 0.4 * (1.0 + (double) random.Next(-10, 11) * 0.005))
|
||||
{
|
||||
if (random.Next(3) == 0)
|
||||
Main.tile[x, y].liquid = byte.MaxValue;
|
||||
if (WorldGen.drunkWorldGen)
|
||||
Main.tile[x, y].liquid = byte.MaxValue;
|
||||
Main.tile[x, y].honey(true);
|
||||
Main.tile[x, y].wall = (ushort) 86;
|
||||
Main.tile[x, y].active(false);
|
||||
Main.tile[x, y].halfBrick(false);
|
||||
Main.tile[x, y].slope((byte) 0);
|
||||
}
|
||||
else if (num14 < num6 * 0.75 * (1.0 + (double) random.Next(-10, 11) * 0.005))
|
||||
{
|
||||
Main.tile[x, y].liquid = (byte) 0;
|
||||
if (Main.tile[x, y].wall != (ushort) 86)
|
||||
{
|
||||
Main.tile[x, y].active(true);
|
||||
Main.tile[x, y].halfBrick(false);
|
||||
Main.tile[x, y].slope((byte) 0);
|
||||
Main.tile[x, y].type = (ushort) 225;
|
||||
}
|
||||
}
|
||||
if (num14 < num6 * 0.6 * (1.0 + (double) random.Next(-10, 11) * 0.005))
|
||||
{
|
||||
Main.tile[x, y].wall = (ushort) 86;
|
||||
if (WorldGen.drunkWorldGen && random.Next(2) == 0)
|
||||
{
|
||||
Main.tile[x, y].liquid = byte.MaxValue;
|
||||
Main.tile[x, y].honey(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
vector2_1 += vector2_2;
|
||||
num2 = num7 - 1f;
|
||||
vector2_2.Y += (float) random.Next(-10, 11) * 0.05f;
|
||||
vector2_2.X += (float) random.Next(-10, 11) * 0.05f;
|
||||
}
|
||||
return vector2_1;
|
||||
}
|
||||
|
||||
private static bool TooCloseToImportantLocations(Point origin)
|
||||
{
|
||||
int x = origin.X;
|
||||
int y = origin.Y;
|
||||
int num = 150;
|
||||
for (int index1 = x - num; index1 < x + num; index1 += 10)
|
||||
{
|
||||
if (index1 > 0 && index1 <= Main.maxTilesX - 1)
|
||||
{
|
||||
for (int index2 = y - num; index2 < y + num; 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 == (ushort) 83 || Main.tile[index1, index2].wall == (ushort) 3 || Main.tile[index1, index2].wall == (ushort) 87))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void CreateDentForHoneyFall(int x, int y, int dir)
|
||||
{
|
||||
dir *= -1;
|
||||
++y;
|
||||
int num = 0;
|
||||
while ((num < 4 || WorldGen.SolidTile(x, y)) && x > 10 && x < Main.maxTilesX - 10)
|
||||
{
|
||||
++num;
|
||||
x += dir;
|
||||
if (WorldGen.SolidTile(x, y))
|
||||
{
|
||||
WorldGen.PoundTile(x, y);
|
||||
if (!Main.tile[x, y + 1].active())
|
||||
{
|
||||
Main.tile[x, y + 1].active(true);
|
||||
Main.tile[x, y + 1].type = (ushort) 225;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateBlockedHoneyCube(int x, int y)
|
||||
{
|
||||
for (int index1 = x - 1; index1 <= x + 2; ++index1)
|
||||
{
|
||||
for (int index2 = y - 1; index2 <= y + 2; ++index2)
|
||||
{
|
||||
if (index1 >= x && index1 <= x + 1 && index2 >= y && index2 <= y + 1)
|
||||
{
|
||||
Main.tile[index1, index2].active(false);
|
||||
Main.tile[index1, index2].liquid = byte.MaxValue;
|
||||
Main.tile[index1, index2].honey(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[index1, index2].active(true);
|
||||
Main.tile[index1, index2].type = (ushort) 225;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool SpotActuallyNotInHive(int x, int y)
|
||||
{
|
||||
for (int index1 = x - 1; index1 <= x + 2; ++index1)
|
||||
{
|
||||
for (int index2 = y - 1; index2 <= y + 2; ++index2)
|
||||
{
|
||||
if (index1 < 10 || index1 > Main.maxTilesX - 10 || Main.tile[index1, index2].active() && Main.tile[index1, index2].type != (ushort) 225)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool BadSpotForHoneyFall(int x, int y) => !Main.tile[x, y].active() || !Main.tile[x, y + 1].active() || !Main.tile[x + 1, y].active() || !Main.tile[x + 1, y + 1].active();
|
||||
|
||||
public static void CreateStandForLarva(Vector2 position)
|
||||
{
|
||||
WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp<int>((int) position.X, 5, Main.maxTilesX - 5);
|
||||
WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp<int>((int) position.Y, 5, Main.maxTilesY - 5);
|
||||
++WorldGen.numLarva;
|
||||
if (WorldGen.numLarva >= WorldGen.larvaX.Length)
|
||||
WorldGen.numLarva = WorldGen.larvaX.Length - 1;
|
||||
int x = (int) position.X;
|
||||
int y = (int) position.Y;
|
||||
for (int index1 = x - 1; index1 <= x + 1 && index1 > 0 && index1 < Main.maxTilesX; ++index1)
|
||||
{
|
||||
for (int index2 = y - 2; index2 <= y + 1 && index2 > 0 && index2 < Main.maxTilesY; ++index2)
|
||||
{
|
||||
if (index2 != y + 1)
|
||||
{
|
||||
Main.tile[index1, index2].active(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Main.tile[index1, index2].active(true);
|
||||
Main.tile[index1, index2].type = (ushort) 225;
|
||||
Main.tile[index1, index2].slope((byte) 0);
|
||||
Main.tile[index1, index2].halfBrick(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
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.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
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.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
232
GameContent/Biomes/JunglePass.cs
Normal file
232
GameContent/Biomes/JunglePass.cs
Normal file
|
@ -0,0 +1,232 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.JunglePass
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.IO;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
namespace Terraria.GameContent.Biomes
|
||||
{
|
||||
public class JunglePass : GenPass
|
||||
{
|
||||
private float _worldScale;
|
||||
|
||||
public int JungleOriginX { get; set; }
|
||||
|
||||
public int DungeonSide { get; set; }
|
||||
|
||||
public double WorldSurface { get; set; }
|
||||
|
||||
public int LeftBeachEnd { get; set; }
|
||||
|
||||
public int RightBeachStart { get; set; }
|
||||
|
||||
public int JungleX { get; private set; }
|
||||
|
||||
public JunglePass()
|
||||
: base("Jungle", 10154.65f)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
|
||||
{
|
||||
progress.Message = Lang.gen[11].Value;
|
||||
this._worldScale = (float) (Main.maxTilesX / 4200) * 1.5f;
|
||||
float worldScale = this._worldScale;
|
||||
Point startPoint = this.CreateStartPoint();
|
||||
int x = startPoint.X;
|
||||
int y = startPoint.Y;
|
||||
Point zero = Point.Zero;
|
||||
this.ApplyRandomMovement(ref x, ref y, 100, 100);
|
||||
zero.X += x;
|
||||
zero.Y += y;
|
||||
this.PlaceFirstPassMud(x, y, 3);
|
||||
this.PlaceGemsAt(x, y, (ushort) 63, 2);
|
||||
progress.Set(0.15f);
|
||||
this.ApplyRandomMovement(ref x, ref y, 250, 150);
|
||||
zero.X += x;
|
||||
zero.Y += y;
|
||||
this.PlaceFirstPassMud(x, y, 0);
|
||||
this.PlaceGemsAt(x, y, (ushort) 65, 2);
|
||||
progress.Set(0.3f);
|
||||
int oldX = x;
|
||||
int oldY = y;
|
||||
this.ApplyRandomMovement(ref x, ref y, 400, 150);
|
||||
zero.X += x;
|
||||
zero.Y += y;
|
||||
this.PlaceFirstPassMud(x, y, -3);
|
||||
this.PlaceGemsAt(x, y, (ushort) 67, 2);
|
||||
progress.Set(0.45f);
|
||||
int num1 = zero.X / 3;
|
||||
int j = zero.Y / 3;
|
||||
int num2 = GenBase._random.Next((int) (400.0 * (double) worldScale), (int) (600.0 * (double) worldScale));
|
||||
int num3 = (int) (25.0 * (double) worldScale);
|
||||
int i = Utils.Clamp<int>(num1, this.LeftBeachEnd + num2 / 2 + num3, this.RightBeachStart - num2 / 2 - num3);
|
||||
WorldGen.mudWall = true;
|
||||
WorldGen.TileRunner(i, j, (double) num2, 10000, 59, speedY: -20f, noYChange: true);
|
||||
this.GenerateTunnelToSurface(i, j);
|
||||
WorldGen.mudWall = false;
|
||||
progress.Set(0.6f);
|
||||
this.GenerateHolesInMudWalls();
|
||||
this.GenerateFinishingTouches(progress, oldX, oldY);
|
||||
}
|
||||
|
||||
private void PlaceGemsAt(int x, int y, ushort baseGem, int gemVariants)
|
||||
{
|
||||
for (int index = 0; (double) index < 6.0 * (double) this._worldScale; ++index)
|
||||
WorldGen.TileRunner(x + GenBase._random.Next(-(int) (125.0 * (double) this._worldScale), (int) (125.0 * (double) this._worldScale)), y + GenBase._random.Next(-(int) (125.0 * (double) this._worldScale), (int) (125.0 * (double) this._worldScale)), (double) GenBase._random.Next(3, 7), GenBase._random.Next(3, 8), GenBase._random.Next((int) baseGem, (int) baseGem + gemVariants));
|
||||
}
|
||||
|
||||
private void PlaceFirstPassMud(int x, int y, int xSpeedScale)
|
||||
{
|
||||
WorldGen.mudWall = true;
|
||||
WorldGen.TileRunner(x, y, (double) GenBase._random.Next((int) (250.0 * (double) this._worldScale), (int) (500.0 * (double) this._worldScale)), GenBase._random.Next(50, 150), 59, speedX: ((float) (this.DungeonSide * xSpeedScale)));
|
||||
WorldGen.mudWall = false;
|
||||
}
|
||||
|
||||
private Point CreateStartPoint() => new Point(this.JungleOriginX, (int) ((double) Main.maxTilesY + Main.rockLayer) / 2);
|
||||
|
||||
private void ApplyRandomMovement(ref int x, ref int y, int xRange, int yRange)
|
||||
{
|
||||
x += GenBase._random.Next((int) ((double) -xRange * (double) this._worldScale), 1 + (int) ((double) xRange * (double) this._worldScale));
|
||||
y += GenBase._random.Next((int) ((double) -yRange * (double) this._worldScale), 1 + (int) ((double) yRange * (double) this._worldScale));
|
||||
y = Utils.Clamp<int>(y, (int) Main.rockLayer, Main.maxTilesY);
|
||||
}
|
||||
|
||||
private void GenerateTunnelToSurface(int i, int j)
|
||||
{
|
||||
double num1 = (double) GenBase._random.Next(5, 11);
|
||||
Vector2 vector2_1;
|
||||
vector2_1.X = (float) i;
|
||||
vector2_1.Y = (float) j;
|
||||
Vector2 vector2_2;
|
||||
vector2_2.X = (float) GenBase._random.Next(-10, 11) * 0.1f;
|
||||
vector2_2.Y = (float) GenBase._random.Next(10, 20) * 0.1f;
|
||||
int num2 = 0;
|
||||
bool flag = true;
|
||||
while (flag)
|
||||
{
|
||||
if ((double) vector2_1.Y < Main.worldSurface)
|
||||
{
|
||||
if (WorldGen.drunkWorldGen)
|
||||
flag = false;
|
||||
int x = (int) vector2_1.X;
|
||||
int y = (int) vector2_1.Y;
|
||||
int index1 = Utils.Clamp<int>(x, 10, Main.maxTilesX - 10);
|
||||
int index2 = Utils.Clamp<int>(y, 10, Main.maxTilesY - 10);
|
||||
if (index2 < 5)
|
||||
index2 = 5;
|
||||
if (Main.tile[index1, index2].wall == (ushort) 0 && !Main.tile[index1, index2].active() && Main.tile[index1, index2 - 3].wall == (ushort) 0 && !Main.tile[index1, index2 - 3].active() && Main.tile[index1, index2 - 1].wall == (ushort) 0 && !Main.tile[index1, index2 - 1].active() && Main.tile[index1, index2 - 4].wall == (ushort) 0 && !Main.tile[index1, index2 - 4].active() && Main.tile[index1, index2 - 2].wall == (ushort) 0 && !Main.tile[index1, index2 - 2].active() && Main.tile[index1, index2 - 5].wall == (ushort) 0 && !Main.tile[index1, index2 - 5].active())
|
||||
flag = false;
|
||||
}
|
||||
this.JungleX = (int) vector2_1.X;
|
||||
num1 += (double) GenBase._random.Next(-20, 21) * 0.100000001490116;
|
||||
if (num1 < 5.0)
|
||||
num1 = 5.0;
|
||||
if (num1 > 10.0)
|
||||
num1 = 10.0;
|
||||
int num3 = (int) ((double) vector2_1.X - num1 * 0.5);
|
||||
int num4 = (int) ((double) vector2_1.X + num1 * 0.5);
|
||||
int num5 = (int) ((double) vector2_1.Y - num1 * 0.5);
|
||||
int num6 = (int) ((double) vector2_1.Y + num1 * 0.5);
|
||||
int max = Main.maxTilesX - 10;
|
||||
int num7 = Utils.Clamp<int>(num3, 10, max);
|
||||
int num8 = Utils.Clamp<int>(num4, 10, Main.maxTilesX - 10);
|
||||
int num9 = Utils.Clamp<int>(num5, 10, Main.maxTilesY - 10);
|
||||
int num10 = Utils.Clamp<int>(num6, 10, Main.maxTilesY - 10);
|
||||
for (int i1 = num7; i1 < num8; ++i1)
|
||||
{
|
||||
for (int j1 = num9; j1 < num10; ++j1)
|
||||
{
|
||||
if ((double) Math.Abs((float) i1 - vector2_1.X) + (double) Math.Abs((float) j1 - vector2_1.Y) < num1 * 0.5 * (1.0 + (double) GenBase._random.Next(-10, 11) * 0.015))
|
||||
WorldGen.KillTile(i1, j1);
|
||||
}
|
||||
}
|
||||
++num2;
|
||||
if (num2 > 10 && GenBase._random.Next(50) < num2)
|
||||
{
|
||||
num2 = 0;
|
||||
int num11 = -2;
|
||||
if (GenBase._random.Next(2) == 0)
|
||||
num11 = 2;
|
||||
WorldGen.TileRunner((int) vector2_1.X, (int) vector2_1.Y, (double) GenBase._random.Next(3, 20), GenBase._random.Next(10, 100), -1, speedX: ((float) num11));
|
||||
}
|
||||
vector2_1 += vector2_2;
|
||||
vector2_2.Y += (float) GenBase._random.Next(-10, 11) * 0.01f;
|
||||
if ((double) vector2_2.Y > 0.0)
|
||||
vector2_2.Y = 0.0f;
|
||||
if ((double) vector2_2.Y < -2.0)
|
||||
vector2_2.Y = -2f;
|
||||
vector2_2.X += (float) GenBase._random.Next(-10, 11) * 0.1f;
|
||||
if ((double) vector2_1.X < (double) (i - 200))
|
||||
vector2_2.X += (float) GenBase._random.Next(5, 21) * 0.1f;
|
||||
if ((double) vector2_1.X > (double) (i + 200))
|
||||
vector2_2.X -= (float) GenBase._random.Next(5, 21) * 0.1f;
|
||||
if ((double) vector2_2.X > 1.5)
|
||||
vector2_2.X = 1.5f;
|
||||
if ((double) vector2_2.X < -1.5)
|
||||
vector2_2.X = -1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateHolesInMudWalls()
|
||||
{
|
||||
for (int index = 0; index < Main.maxTilesX / 4; ++index)
|
||||
{
|
||||
int i = GenBase._random.Next(20, Main.maxTilesX - 20);
|
||||
int j;
|
||||
for (j = GenBase._random.Next((int) this.WorldSurface + 10, Main.UnderworldLayer); Main.tile[i, j].wall != (ushort) 64 && Main.tile[i, j].wall != (ushort) 15; j = GenBase._random.Next((int) this.WorldSurface + 10, Main.UnderworldLayer))
|
||||
i = GenBase._random.Next(20, Main.maxTilesX - 20);
|
||||
WorldGen.MudWallRunner(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateFinishingTouches(GenerationProgress progress, int oldX, int oldY)
|
||||
{
|
||||
int i1 = oldX;
|
||||
int j1 = oldY;
|
||||
float worldScale = this._worldScale;
|
||||
for (int index = 0; (double) index <= 20.0 * (double) worldScale; ++index)
|
||||
{
|
||||
progress.Set((float) ((60.0 + (double) index / (double) worldScale) * 0.00999999977648258));
|
||||
i1 += GenBase._random.Next((int) (-5.0 * (double) worldScale), (int) (6.0 * (double) worldScale));
|
||||
j1 += GenBase._random.Next((int) (-5.0 * (double) worldScale), (int) (6.0 * (double) worldScale));
|
||||
WorldGen.TileRunner(i1, j1, (double) GenBase._random.Next(40, 100), GenBase._random.Next(300, 500), 59);
|
||||
}
|
||||
for (int index1 = 0; (double) index1 <= 10.0 * (double) worldScale; ++index1)
|
||||
{
|
||||
progress.Set((float) ((80.0 + (double) index1 / (double) worldScale * 2.0) * 0.00999999977648258));
|
||||
int i2 = oldX + GenBase._random.Next((int) (-600.0 * (double) worldScale), (int) (600.0 * (double) worldScale));
|
||||
int j2;
|
||||
for (j2 = oldY + GenBase._random.Next((int) (-200.0 * (double) worldScale), (int) (200.0 * (double) worldScale)); i2 < 1 || i2 >= Main.maxTilesX - 1 || j2 < 1 || j2 >= Main.maxTilesY - 1 || Main.tile[i2, j2].type != (ushort) 59; j2 = oldY + GenBase._random.Next((int) (-200.0 * (double) worldScale), (int) (200.0 * (double) worldScale)))
|
||||
i2 = oldX + GenBase._random.Next((int) (-600.0 * (double) worldScale), (int) (600.0 * (double) worldScale));
|
||||
for (int index2 = 0; (double) index2 < 8.0 * (double) worldScale; ++index2)
|
||||
{
|
||||
i2 += GenBase._random.Next(-30, 31);
|
||||
j2 += GenBase._random.Next(-30, 31);
|
||||
int type = -1;
|
||||
if (GenBase._random.Next(7) == 0)
|
||||
type = -2;
|
||||
WorldGen.TileRunner(i2, j2, (double) GenBase._random.Next(10, 20), GenBase._random.Next(30, 70), type);
|
||||
}
|
||||
}
|
||||
for (int index = 0; (double) index <= 300.0 * (double) worldScale; ++index)
|
||||
{
|
||||
int i3 = oldX + GenBase._random.Next((int) (-600.0 * (double) worldScale), (int) (600.0 * (double) worldScale));
|
||||
int j3;
|
||||
for (j3 = oldY + GenBase._random.Next((int) (-200.0 * (double) worldScale), (int) (200.0 * (double) worldScale)); i3 < 1 || i3 >= Main.maxTilesX - 1 || j3 < 1 || j3 >= Main.maxTilesY - 1 || Main.tile[i3, j3].type != (ushort) 59; j3 = oldY + GenBase._random.Next((int) (-200.0 * (double) worldScale), (int) (200.0 * (double) worldScale)))
|
||||
i3 = oldX + GenBase._random.Next((int) (-600.0 * (double) worldScale), (int) (600.0 * (double) worldScale));
|
||||
WorldGen.TileRunner(i3, j3, (double) GenBase._random.Next(4, 10), GenBase._random.Next(5, 30), 1);
|
||||
if (GenBase._random.Next(4) == 0)
|
||||
{
|
||||
int type = GenBase._random.Next(63, 69);
|
||||
WorldGen.TileRunner(i3 + GenBase._random.Next(-1, 2), j3 + GenBase._random.Next(-1, 2), (double) GenBase._random.Next(3, 7), GenBase._random.Next(4, 8), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
95
GameContent/Biomes/MahoganyTreeBiome.cs
Normal file
95
GameContent/Biomes/MahoganyTreeBiome.cs
Normal file
|
@ -0,0 +1,95 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.MahoganyTreeBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.GameContent.Generation;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
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;
|
||||
if (!WorldGen.drunkWorldGen || WorldGen.genRand.Next(50) > 0)
|
||||
{
|
||||
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((ushort) 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((ushort) 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 ushort[1]
|
||||
{
|
||||
(ushort) 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.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 30, 60, 60));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
211
GameContent/Biomes/MarbleBiome.cs
Normal file
211
GameContent/Biomes/MarbleBiome.cs
Normal file
|
@ -0,0 +1,211 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Biomes.MarbleBiome
|
||||
// Assembly: Terraria, Version=1.4.0.5, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: 67F9E73E-0A81-4937-A22C-5515CD405A83
|
||||
// Assembly location: C:\Users\mikeyisbaeyt\Downloads\depotdownloader-2.4.5\depots\105601\6707058\Terraria.exe
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria.ID;
|
||||
using Terraria.WorldBuilding;
|
||||
|
||||
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)
|
||||
{
|
||||
ushort num1 = 367;
|
||||
ushort num2 = 178;
|
||||
if (WorldGen.drunkWorldGen)
|
||||
{
|
||||
num1 = (ushort) 368;
|
||||
num2 = (ushort) 180;
|
||||
}
|
||||
int num3 = -1;
|
||||
int num4 = scale + 1;
|
||||
int num5 = 0;
|
||||
int num6 = scale;
|
||||
for (int x = num3; x < num4; ++x)
|
||||
{
|
||||
if (x != num3 && x != num4 - 1 || WorldGen.genRand.Next(2) != 0)
|
||||
{
|
||||
if (WorldGen.genRand.Next(2) == 0)
|
||||
--num5;
|
||||
if (WorldGen.genRand.Next(2) == 0)
|
||||
++num6;
|
||||
for (int y = num5; y < num6; ++y)
|
||||
{
|
||||
Tile tile = GenBase._tiles[originX + x, originY + y];
|
||||
tile.ResetToType(TileID.Sets.Ore[(int) tile.type] ? tile.type : num1);
|
||||
bool active = slab.State(x, y, scale);
|
||||
tile.active(active);
|
||||
if (slab.HasWall)
|
||||
tile.wall = num2;
|
||||
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 static 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 (WorldGen.BiomeTileCheck(origin.X, origin.Y))
|
||||
return false;
|
||||
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)
|
||||
{
|
||||
double num4 = (double) (index1 - num1 / 2) / (double) num1 + 0.5;
|
||||
int num5 = (int) ((0.5 - Math.Abs(num4 - 0.5)) * 5.0) - 2;
|
||||
for (int index2 = -1; index2 < num2 + 1; ++index2)
|
||||
{
|
||||
bool hasWall = true;
|
||||
bool flag1 = false;
|
||||
bool flag2 = MarbleBiome.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 (Math.Abs(num4 - 0.5) > 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);
|
||||
}
|
||||
structures.AddStructure(new Microsoft.Xna.Framework.Rectangle(origin.X, origin.Y, num1 * 3, num2 * 3), 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
private delegate bool SlabState(int x, int y, int scale);
|
||||
|
||||
private static 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);
|
||||
}
|
||||
}
|
||||
}
|
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