Rewrote Power Cell Factories + Fixed universal netcode bug + Added Auralis

Reviewed by Dom
This commit is contained in:
Cameron Ewell authored and GitHub committed 2020-09-04 01:36:44 -04:00
commit 22ee4dad9b
27 files changed
+3829 -3410

No files matched your search

+18 -1
View File
@@ -130,7 +130,7 @@ namespace CalamityMod.CalPlayer
public int CurrentlyViewedFactoryX = -1;
public int CurrentlyViewedFactoryY = -1;
public TEDraedonFuelFactory CurrentlyViewedFactory;
public TEPowerCellFactory CurrentlyViewedFactory;
public int CurrentlyViewedChargerX = -1;
public int CurrentlyViewedChargerY = -1;
@@ -235,6 +235,10 @@ namespace CalamityMod.CalPlayer
public int danceOfLightCharge = 0;
public int shadowPotCooldown = 0;
public int dogTextCooldown = 0;
public float auralisStealthCounter = 0f;
public int auralisAuroraCounter = 0;
public int auralisAuroraCooldown = 0;
public int auralisAurora = 0;
public int fungalSymbioteTimer = 0;
public bool canFireReaverRangedProjectile = false;
public bool canFireAtaxiaRangedProjectile = false;
@@ -2044,6 +2048,10 @@ namespace CalamityMod.CalPlayer
soundCooldown = 0;
shadowPotCooldown = 0;
dogTextCooldown = 0;
auralisStealthCounter = 0f;
auralisAuroraCounter = 0;
auralisAuroraCooldown = 0;
auralisAurora = 0;
fungalSymbioteTimer = 0;
rage = 0;
adrenaline = 0;
@@ -6308,6 +6316,15 @@ namespace CalamityMod.CalPlayer
}
}
if (auralisAuroraCounter >= 300)
{
damage -= 100;
if (damage < 1)
damage = 1;
auralisAuroraCounter = 0;
auralisAuroraCooldown = CalamityUtils.SecondsToFrames(30f);
}
if (proj.type == ModContent.ProjectileType<BirbAura>())
{
damage = 0;
+40 -1
View File
@@ -215,7 +215,8 @@ namespace CalamityMod.CalPlayer
currentlyHeldItem.type == ModContent.ItemType<Apotheosis>() ||
currentlyHeldItem.type == ModContent.ItemType<CleansingBlaze>() ||
currentlyHeldItem.type == ModContent.ItemType<SubsumingVortex>() ||
currentlyHeldItem.type == ModContent.ItemType<AuroraBlazer>())
currentlyHeldItem.type == ModContent.ItemType<AuroraBlazer>() ||
currentlyHeldItem.type == ModContent.ItemType<Auralis>())
{
Texture2D texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/DeathwindGlow");
int offsetX = 10;
@@ -239,6 +240,11 @@ namespace CalamityMod.CalPlayer
texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/AuroraBlazerGlow");
offsetX = 44;
}
else if (currentlyHeldItem.type == ModContent.ItemType<Auralis>())
{
texture = ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/AuralisGlow");
offsetX = 62;
}
Vector2 center = Main.itemTexture[currentlyHeldItem.type].Size() * 0.5f;
int originOffsetX = (int)center.X - offsetX;
@@ -494,6 +500,38 @@ namespace CalamityMod.CalPlayer
}
});
public static readonly PlayerLayer AuralisAuroraEffects = new PlayerLayer("CalamityMod", "AuralisAurora", PlayerLayer.Body, drawInfo =>
{
Player drawPlayer = drawInfo.drawPlayer;
CalamityPlayer modPlayer = drawPlayer.Calamity();
if (modPlayer.auralisAuroraCounter < 300 || modPlayer.auralisAuroraCooldown > 0)
return;
float auroraCount = 7;
float opacity = 0.4f;
float time = Main.GlobalTime % 3f / 3f;
Texture2D auroraTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/AuroraTexture");
for (int i = 0; i < auroraCount; i++)
{
float incrementOffsetAngle = MathHelper.TwoPi * i / auroraCount;
float xOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f) * 20f;
float yOffset = (float)Math.Sin(time * MathHelper.TwoPi + incrementOffsetAngle * 2f + MathHelper.ToRadians(60f)) * 6f;
float rotation = (float)Math.Sin(incrementOffsetAngle) * MathHelper.Pi / 12f;
Color color = CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 3f);
Vector2 offset = new Vector2(xOffset, yOffset - 14f);
DrawData drawData = new DrawData(auroraTexture,
drawPlayer.Top + offset - Main.screenPosition,
null,
color * opacity,
rotation + MathHelper.PiOver2,
auroraTexture.Size() * 0.5f,
0.135f,
SpriteEffects.None,
1);
Main.playerDrawData.Add(drawData);
}
});
public static readonly PlayerLayer IbanDevRobot = new PlayerLayer("CalamityMod", "IbanDevRobot", PlayerLayer.Body, drawInfo =>
{
Player drawPlayer = drawInfo.drawPlayer;
@@ -647,6 +685,7 @@ namespace CalamityMod.CalPlayer
list.Add(RoverDriveShield);
list.Add(StratusSphereDrawing);
list.Add(ProfanedMoonlightDyeEffects);
list.Add(AuralisAuroraEffects);
list.Add(IbanDevRobot);
list.Add(DyeInvisibilityFix);
}
+78
View File
@@ -1032,6 +1032,10 @@ namespace CalamityMod.CalPlayer
}
else
modPlayer.roverDriveTimer = 616; //Doesn't reset to zero to prevent exploits
if (modPlayer.auralisAurora > 0)
modPlayer.auralisAurora--;
if (modPlayer.auralisAuroraCooldown > 0)
modPlayer.auralisAuroraCooldown--;
// Silva invincibility effects
if (modPlayer.silvaCountdown > 0 && modPlayer.hasSilvaEffect && modPlayer.silvaSet)
@@ -2345,6 +2349,80 @@ namespace CalamityMod.CalPlayer
}
else
modPlayer.modStealth = 1f;
if (player.ActiveItem().type == ModContent.ItemType<Auralis>() && player.StandingStill(0.1f))
{
if (modPlayer.auralisStealthCounter < 300f)
modPlayer.auralisStealthCounter++;
bool usingScope = false;
if (!Main.gameMenu && Main.netMode != NetmodeID.Server)
{
if (player.noThrow <= 0 && !player.lastMouseInterface || (Main.zoomX != 0f || Main.zoomY != 0f))
{
if (PlayerInput.UsingGamepad)
{
if (PlayerInput.GamepadThumbstickRight.Length() != 0f || !Main.SmartCursorEnabled)
{
usingScope = true;
}
}
else if (Main.mouseRight)
usingScope = true;
}
}
int chargeDuration = CalamityUtils.SecondsToFrames(5f);
int auroraDuration = CalamityUtils.SecondsToFrames(20f);
if (usingScope && modPlayer.auralisAuroraCounter < chargeDuration + auroraDuration)
modPlayer.auralisAuroraCounter++;
if (modPlayer.auralisAuroraCounter > chargeDuration + auroraDuration)
{
modPlayer.auralisAuroraCounter = 0;
modPlayer.auralisAuroraCooldown = CalamityUtils.SecondsToFrames(30f);
}
if (modPlayer.auralisAuroraCounter > 0 && modPlayer.auralisAuroraCounter < chargeDuration && !usingScope)
modPlayer.auralisAuroraCounter--;
if (modPlayer.auralisAuroraCounter > chargeDuration && modPlayer.auralisAuroraCounter < chargeDuration + auroraDuration && !usingScope)
modPlayer.auralisAuroraCounter = 0;
}
else
{
modPlayer.auralisStealthCounter = 0f;
modPlayer.auralisAuroraCounter = 0;
}
if (modPlayer.auralisAuroraCooldown > 0)
{
if (modPlayer.auralisAuroraCooldown == 1)
{
int dustAmt = 36;
for (int d = 0; d < dustAmt; d++)
{
Vector2 source = Vector2.Normalize(player.velocity) * new Vector2((float)player.width / 2f, (float)player.height) * 1f; //0.75
source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + player.Center;
Vector2 dustVel = source - player.Center;
int blue = Dust.NewDust(source + dustVel, 0, 0, 229, dustVel.X, dustVel.Y, 100, default, 1.2f);
Main.dust[blue].noGravity = true;
Main.dust[blue].noLight = false;
Main.dust[blue].velocity = dustVel;
}
for (int d = 0; d < dustAmt; d++)
{
Vector2 source = Vector2.Normalize(player.velocity) * new Vector2((float)player.width / 2f, (float)player.height) * 0.75f;
source = source.RotatedBy((double)((float)(d - (dustAmt / 2 - 1)) * MathHelper.TwoPi / (float)dustAmt), default) + player.Center;
Vector2 dustVel = source - player.Center;
int green = Dust.NewDust(source + dustVel, 0, 0, 107, dustVel.X, dustVel.Y, 100, default, 1.2f);
Main.dust[green].noGravity = true;
Main.dust[green].noLight = false;
Main.dust[green].velocity = dustVel;
}
}
modPlayer.auralisAuroraCounter = 0;
}
}
#endregion
+1
View File
@@ -1525,6 +1525,7 @@ namespace CalamityMod
scopedWeaponList = new List<int>()
{
ModContent.ItemType<AMR>(),
ModContent.ItemType<Auralis>(),
ModContent.ItemType<HalleysInferno>(),
ModContent.ItemType<Shroomer>(),
ModContent.ItemType<SpectreRifle>(),
+411 -403
View File
@@ -119,44 +119,44 @@ namespace CalamityMod
public static int ghostKillCount = 0;
public static int sharkKillCount = 0;
// Textures
// Textures
public static Texture2D heartOriginal2;
public static Texture2D heartOriginal;
public static Texture2D rainOriginal;
public static Texture2D manaOriginal;
public static Texture2D carpetOriginal;
public static Texture2D AstralCactusTexture;
public static Texture2D heartOriginal;
public static Texture2D rainOriginal;
public static Texture2D manaOriginal;
public static Texture2D carpetOriginal;
public static Texture2D AstralCactusTexture;
public static Texture2D AstralCactusGlowTexture;
public static Texture2D AstralSky;
// DR data structure
public static SortedDictionary<int, float> DRValues;
// Boss Kill Time data structure
public static SortedDictionary<int, int> bossKillTimes;
// Boss Kill Time data structure
public static SortedDictionary<int, int> bossKillTimes;
// Boss velocity scaling data structure
public static SortedDictionary<int, float> bossVelocityDamageScaleValues;
public const float velocityScaleMin = 0.5f;
public const float bitingEnemeyVelocityScale = 0.8f;
// Boss velocity scaling data structure
public static SortedDictionary<int, float> bossVelocityDamageScaleValues;
public const float velocityScaleMin = 0.5f;
public const float bitingEnemeyVelocityScale = 0.8f;
// TODO -- Calamity should check for other mods existing in exactly one place
internal Mod thorium = null;
public bool fargosMutant = false;
internal static CalamityMod Instance;
internal static CalamityMod Instance;
#region Load
public override void Load()
{
Instance = this;
heartOriginal2 = Main.heartTexture;
heartOriginal = Main.heart2Texture;
rainOriginal = Main.rainTexture;
manaOriginal = Main.manaTexture;
carpetOriginal = Main.flyingCarpetTexture;
Instance = this;
heartOriginal2 = Main.heartTexture;
heartOriginal = Main.heart2Texture;
rainOriginal = Main.rainTexture;
manaOriginal = Main.manaTexture;
carpetOriginal = Main.flyingCarpetTexture;
NormalityRelocatorHotKey = RegisterHotKey("Normality Relocator", "Z");
NormalityRelocatorHotKey = RegisterHotKey("Normality Relocator", "Z");
RageHotKey = RegisterHotKey("Rage Mode", "V");
AdrenalineHotKey = RegisterHotKey("Adrenaline Mode", "B");
AegisHotKey = RegisterHotKey("Elysian Guard", "N");
@@ -181,97 +181,97 @@ namespace CalamityMod
CalamityLists.LoadLists();
SetupVanillaDR();
SetupBossKillTimes();
SetupBossVelocityScalingValues();
SetupBossKillTimes();
SetupBossVelocityScalingValues();
SetupThoriumBossDR(thorium);
CalamityLocalization.AddLocalizations();
On.Terraria.Player.TileInteractionsUse += Player_TileInteractionsUse;
On.Terraria.WorldGen.OpenDoor += LabDoorsOpen;
On.Terraria.WorldGen.CloseDoor += LabDoorsClose;
On.Terraria.Player.TileInteractionsUse += Player_TileInteractionsUse;
On.Terraria.WorldGen.OpenDoor += LabDoorsOpen;
On.Terraria.WorldGen.CloseDoor += LabDoorsClose;
}
private static bool LabDoorsOpen(On.Terraria.WorldGen.orig_OpenDoor orig, int i, int j, int direction)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>() || tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>() ||
tile.type == ModContent.TileType<LaboratoryDoorOpen>() || tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
return false;
}
else
{
return orig(i, j, direction);
}
}
private static bool LabDoorsOpen(On.Terraria.WorldGen.orig_OpenDoor orig, int i, int j, int direction)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>() || tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>() ||
tile.type == ModContent.TileType<LaboratoryDoorOpen>() || tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
return false;
}
else
{
return orig(i, j, direction);
}
}
private static bool LabDoorsClose(On.Terraria.WorldGen.orig_CloseDoor orig, int i, int j, bool forced)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>() || tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>() ||
tile.type == ModContent.TileType<LaboratoryDoorOpen>() || tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
return false;
}
else
{
return orig(i, j, forced);
}
}
private static bool LabDoorsClose(On.Terraria.WorldGen.orig_CloseDoor orig, int i, int j, bool forced)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>() || tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>() ||
tile.type == ModContent.TileType<LaboratoryDoorOpen>() || tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
return false;
}
else
{
return orig(i, j, forced);
}
}
private static void Player_TileInteractionsUse(On.Terraria.Player.orig_TileInteractionsUse orig, Player player, int i, int j)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>())
{
DoorSwap(ModContent.TileType<AgedLaboratoryDoorClosed>(), ModContent.TileType<AgedLaboratoryDoorOpen>(), i, j);
}
else if (tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>())
{
DoorSwap(ModContent.TileType<AgedLaboratoryDoorOpen>(), ModContent.TileType<AgedLaboratoryDoorClosed>(), i, j);
}
else if (tile.type == ModContent.TileType<LaboratoryDoorOpen>())
{
DoorSwap(ModContent.TileType<LaboratoryDoorClosed>(), ModContent.TileType<LaboratoryDoorOpen>(), i, j);
}
else if (tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
DoorSwap(ModContent.TileType<LaboratoryDoorOpen>(), ModContent.TileType<LaboratoryDoorClosed>(), i, j);
}
else
{
orig(player, i, j);
}
}
private static void Player_TileInteractionsUse(On.Terraria.Player.orig_TileInteractionsUse orig, Player player, int i, int j)
{
Tile tile = Main.tile[i, j];
if (tile.type == ModContent.TileType<AgedLaboratoryDoorOpen>())
{
DoorSwap(ModContent.TileType<AgedLaboratoryDoorClosed>(), ModContent.TileType<AgedLaboratoryDoorOpen>(), i, j);
}
else if (tile.type == ModContent.TileType<AgedLaboratoryDoorClosed>())
{
DoorSwap(ModContent.TileType<AgedLaboratoryDoorOpen>(), ModContent.TileType<AgedLaboratoryDoorClosed>(), i, j);
}
else if (tile.type == ModContent.TileType<LaboratoryDoorOpen>())
{
DoorSwap(ModContent.TileType<LaboratoryDoorClosed>(), ModContent.TileType<LaboratoryDoorOpen>(), i, j);
}
else if (tile.type == ModContent.TileType<LaboratoryDoorClosed>())
{
DoorSwap(ModContent.TileType<LaboratoryDoorOpen>(), ModContent.TileType<LaboratoryDoorClosed>(), i, j);
}
else
{
orig(player, i, j);
}
}
public static void DoorSwap(int type1, int type2, int i, int j, bool forced = false)
{
if (PlayerInput.Triggers.JustPressed.MouseRight || forced)
{
ushort type = (ushort)type1;
short frameY = 0;
for (int dy = -4; dy < 4; dy++)
{
if (Main.tile[i, j + dy].frameY > 0 && frameY == 0)
continue;
if (Main.tile[i, j + dy].type == type2)
{
if (Main.tile[i, j + dy] is null)
{
Main.tile[i, j + dy] = new Tile();
}
Main.tile[i, j + dy].type = type;
Main.tile[i, j + dy].frameY = frameY;
frameY += 16;
if ((int)frameY / 16 >= 4)
break;
}
}
public static void DoorSwap(int type1, int type2, int i, int j, bool forced = false)
{
if (PlayerInput.Triggers.JustPressed.MouseRight || forced)
{
ushort type = (ushort)type1;
short frameY = 0;
for (int dy = -4; dy < 4; dy++)
{
if (Main.tile[i, j + dy].frameY > 0 && frameY == 0)
continue;
if (Main.tile[i, j + dy].type == type2)
{
if (Main.tile[i, j + dy] is null)
{
Main.tile[i, j + dy] = new Tile();
}
Main.tile[i, j + dy].type = type;
Main.tile[i, j + dy].frameY = frameY;
frameY += 16;
if ((int)frameY / 16 >= 4)
break;
}
}
Main.PlaySound(SoundID.DoorClosed, i * 16, j * 16, 1, 1f, 0f);
}
}
Main.PlaySound(SoundID.DoorClosed, i * 16, j * 16, 1, 1f, 0f);
}
}
private void LoadClient()
{
@@ -333,8 +333,8 @@ namespace CalamityMod
Filters.Scene["CalamityMod:SupremeCalamitas"] = new Filter(new SCalScreenShaderData("FilterMiniTower").UseColor(1.1f, 0.3f, 0.3f).UseOpacity(0.65f), EffectPriority.VeryHigh);
SkyManager.Instance["CalamityMod:SupremeCalamitas"] = new SCalSky();
Filters.Scene["CalamityMod:Signus"] = new Filter(new SignusScreenShaderData("FilterMiniTower").UseColor(0.35f, 0.1f, 0.55f).UseOpacity(0.35f), EffectPriority.VeryHigh);
SkyManager.Instance["CalamityMod:Signus"] = new SignusSky();
Filters.Scene["CalamityMod:Signus"] = new Filter(new SignusScreenShaderData("FilterMiniTower").UseColor(0.35f, 0.1f, 0.55f).UseOpacity(0.35f), EffectPriority.VeryHigh);
SkyManager.Instance["CalamityMod:Signus"] = new SignusSky();
SkyManager.Instance["CalamityMod:Astral"] = new AstralSky();
SkyManager.Instance["CalamityMod:Cryogen"] = new CryogenSky();
@@ -344,10 +344,10 @@ namespace CalamityMod
RipperUI.Reset();
AstralArcanumUI.Load(this);
GameShaders.Hair.BindShader(ModContent.ItemType<AdrenalineHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<RageHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<WingTimeHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(139, 205, 255), ((float)player.wingTime / (float)player.wingTimeMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<StealthHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(186, 85, 211), (player.Calamity().rogueStealth / player.Calamity().rogueStealthMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<AdrenalineHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(0, 255, 171), ((float)player.Calamity().adrenaline / (float)player.Calamity().adrenalineMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<RageHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(255, 83, 48), ((float)player.Calamity().rage / (float)player.Calamity().rageMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<WingTimeHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(139, 205, 255), ((float)player.wingTime / (float)player.wingTimeMax))));
GameShaders.Hair.BindShader(ModContent.ItemType<StealthHairDye>(), new LegacyHairShaderData().UseLegacyMethod((Player player, Color newColor, ref bool lighting) => Color.Lerp(player.hairColor, new Color(186, 85, 211), (player.Calamity().rogueStealth / player.Calamity().rogueStealthMax))));
SchematicLoader.LoadEverything();
@@ -377,17 +377,17 @@ namespace CalamityMod
DRValues?.Clear();
DRValues = null;
bossKillTimes?.Clear();
bossKillTimes = null;
bossVelocityDamageScaleValues?.Clear();
bossVelocityDamageScaleValues = null;
bossKillTimes?.Clear();
bossKillTimes = null;
bossVelocityDamageScaleValues?.Clear();
bossVelocityDamageScaleValues = null;
CalamityLists.UnloadLists();
thorium = null;
fargosMutant = false;
Instance = null;
Instance = null;
PopupGUIManager.UnloadGUIs();
InvasionProgressUIManager.UnloadGUIs();
@@ -402,20 +402,20 @@ namespace CalamityMod
AstralArcanumUI.Unload();
base.Unload();
if (!Main.dedServ)
{
Main.heartTexture = heartOriginal2;
Main.heart2Texture = heartOriginal;
Main.rainTexture = rainOriginal;
Main.manaTexture = manaOriginal;
Main.flyingCarpetTexture = carpetOriginal;
}
if (!Main.dedServ)
{
Main.heartTexture = heartOriginal2;
Main.heart2Texture = heartOriginal;
Main.rainTexture = rainOriginal;
Main.manaTexture = manaOriginal;
Main.flyingCarpetTexture = carpetOriginal;
}
heartOriginal2 = null;
heartOriginal = null;
rainOriginal = null;
manaOriginal = null;
carpetOriginal = null;
heartOriginal2 = null;
heartOriginal = null;
rainOriginal = null;
manaOriginal = null;
carpetOriginal = null;
}
#endregion
@@ -429,16 +429,16 @@ namespace CalamityMod
#region ConfigCrap
internal static void SaveConfig(CalamityConfig cfg)
{
// in-game ModConfig saving from mod code is not supported yet in tmodloader, and subject to change, so we need to be extra careful.
// This code only supports client configs, and doesn't call onchanged. It also doesn't support ReloadRequired or anything else.
MethodInfo saveMethodInfo = typeof(ConfigManager).GetMethod("Save", BindingFlags.Static | BindingFlags.NonPublic);
if (saveMethodInfo != null)
saveMethodInfo.Invoke(null, new object[] { cfg });
else
Instance.Logger.Warn("In-game SaveConfig failed, code update required");
}
#endregion
{
// in-game ModConfig saving from mod code is not supported yet in tmodloader, and subject to change, so we need to be extra careful.
// This code only supports client configs, and doesn't call onchanged. It also doesn't support ReloadRequired or anything else.
MethodInfo saveMethodInfo = typeof(ConfigManager).GetMethod("Save", BindingFlags.Static | BindingFlags.NonPublic);
if (saveMethodInfo != null)
saveMethodInfo.Invoke(null, new object[] { cfg });
else
Instance.Logger.Warn("In-game SaveConfig failed, code update required");
}
#endregion
#region Vanilla Enemy DR
private void SetupVanillaDR()
@@ -471,7 +471,7 @@ namespace CalamityMod
{ NPCID.DeadlySphere, 0.4f },
{ NPCID.DiabolistRed, 0.2f },
{ NPCID.DiabolistWhite, 0.2f },
{ NPCID.DukeFishron, 0.1f },
{ NPCID.DukeFishron, 0.1f },
{ NPCID.DungeonGuardian, 0.999999f },
{ NPCID.DungeonSpirit, 0.2f },
{ NPCID.ElfCopter, 0.15f },
@@ -516,9 +516,9 @@ namespace CalamityMod
{ NPCID.Paladin, 0.45f },
{ NPCID.PirateCaptain, 0.05f },
{ NPCID.PirateShipCannon, 0.15f },
{ NPCID.Plantera, 0.15f },
{ NPCID.PlanterasTentacle, 0.1f },
{ NPCID.PossessedArmor, 0.25f },
{ NPCID.Plantera, 0.15f },
{ NPCID.PlanterasTentacle, 0.1f },
{ NPCID.PossessedArmor, 0.25f },
{ NPCID.PresentMimic, 0.3f },
{ NPCID.PrimeCannon, 0.2f },
{ NPCID.PrimeLaser, 0.2f },
@@ -592,220 +592,220 @@ namespace CalamityMod
ThoriumDR("Omnicide", 0.3f);
ThoriumDR("Abyssion", 0.35f);
}
#endregion
#endregion
#region Boss Kill Times
private void SetupBossKillTimes()
{
// 3600 = 1 minute
#region Boss Kill Times
private void SetupBossKillTimes()
{
// 3600 = 1 minute
bossKillTimes = new SortedDictionary<int, int> {
{ NPCID.KingSlime, 3600 },
{ NPCID.EyeofCthulhu, 5400 },
{ NPCID.EaterofWorldsHead, 7200 },
{ NPCID.EaterofWorldsBody, 7200 },
{ NPCID.EaterofWorldsTail, 7200 },
{ NPCID.BrainofCthulhu, 5400 },
{ NPCID.Creeper, 1800 },
{ NPCID.QueenBee, 7200 },
{ NPCID.SkeletronHead, 9000 },
{ NPCID.WallofFlesh, 7200 },
{ NPCID.WallofFleshEye, 7200 },
{ NPCID.Spazmatism, 10800 },
{ NPCID.Retinazer, 10800 },
{ NPCID.TheDestroyer, 10800 },
bossKillTimes = new SortedDictionary<int, int> {
{ NPCID.KingSlime, 3600 },
{ NPCID.EyeofCthulhu, 5400 },
{ NPCID.EaterofWorldsHead, 7200 },
{ NPCID.EaterofWorldsBody, 7200 },
{ NPCID.EaterofWorldsTail, 7200 },
{ NPCID.BrainofCthulhu, 5400 },
{ NPCID.Creeper, 1800 },
{ NPCID.QueenBee, 7200 },
{ NPCID.SkeletronHead, 9000 },
{ NPCID.WallofFlesh, 7200 },
{ NPCID.WallofFleshEye, 7200 },
{ NPCID.Spazmatism, 10800 },
{ NPCID.Retinazer, 10800 },
{ NPCID.TheDestroyer, 10800 },
{ NPCID.TheDestroyerBody, 10800 },
{ NPCID.TheDestroyerTail, 10800 },
{ NPCID.SkeletronPrime, 10800 },
{ NPCID.Plantera, 10800 },
{ NPCID.Golem, 9000 },
{ NPCID.GolemHead, 3600 },
{ NPCID.DukeFishron, 9000 },
{ NPCID.CultistBoss, 9000 },
{ NPCID.MoonLordCore, 14400 },
{ NPCID.MoonLordHand, 7200 },
{ NPCID.MoonLordHead, 7200 },
{ ModContent.NPCType<DesertScourgeHead>(), 3600 },
{ ModContent.NPCType<DesertScourgeBody>(), 3600 },
{ ModContent.NPCType<DesertScourgeTail>(), 3600 },
{ ModContent.NPCType<CrabulonIdle>(), 5400 },
{ ModContent.NPCType<HiveMind>(), 1800 },
{ ModContent.NPCType<HiveMindP2>(), 5400 },
{ ModContent.NPCType<PerforatorHive>(), 7200 },
{ ModContent.NPCType<SlimeGodCore>(), 10800 },
{ ModContent.NPCType<SlimeGod>(), 3600 },
{ ModContent.NPCType<SlimeGodRun>(), 3600 },
{ ModContent.NPCType<SlimeGodSplit>(), 3600 },
{ ModContent.NPCType<SlimeGodRunSplit>(), 3600 },
{ ModContent.NPCType<Cryogen>(), 10800 },
{ ModContent.NPCType<AquaticScourgeHead>(), 7200 },
{ ModContent.NPCType<AquaticScourgeBody>(), 7200 },
{ ModContent.NPCType<AquaticScourgeBodyAlt>(), 7200 },
{ ModContent.NPCType<AquaticScourgeTail>(), 7200 },
{ ModContent.NPCType<BrimstoneElemental>(), 10800 },
{ ModContent.NPCType<Calamitas>(), 1200 },
{ ModContent.NPCType<CalamitasRun3>(), 11400 },
{ ModContent.NPCType<Leviathan>(), 10800 },
{ ModContent.NPCType<Siren>(), 10800 },
{ ModContent.NPCType<AstrumAureus>(), 10800 },
{ ModContent.NPCType<AstrumDeusHeadSpectral>(), 7200 },
{ ModContent.NPCType<AstrumDeusBodySpectral>(), 7200 },
{ ModContent.NPCType<AstrumDeusTailSpectral>(), 7200 },
{ ModContent.NPCType<PlaguebringerGoliath>(), 10800 },
{ ModContent.NPCType<RavagerBody>(), 10800 },
{ ModContent.NPCType<ProfanedGuardianBoss>(), 5400 },
{ ModContent.NPCType<Bumblefuck>(), 7200 },
{ ModContent.NPCType<Providence>(), 14400 },
{ ModContent.NPCType<DarkEnergy>(), 1200 },
{ ModContent.NPCType<DarkEnergy2>(), 1200 },
{ ModContent.NPCType<DarkEnergy3>(), 1200 },
{ ModContent.NPCType<StormWeaverHeadNaked>(), 5400 },
{ ModContent.NPCType<StormWeaverBodyNaked>(), 5400 },
{ ModContent.NPCType<StormWeaverTailNaked>(), 5400 },
{ ModContent.NPCType<Signus>(), 7200 },
{ ModContent.NPCType<Polterghast>(), 10800 },
{ ModContent.NPCType<OldDuke>(), 10800 },
{ ModContent.NPCType<DevourerofGodsHead>(), 5400 },
{ ModContent.NPCType<DevourerofGodsBody>(), 5400 },
{ ModContent.NPCType<DevourerofGodsTail>(), 5400 },
{ ModContent.NPCType<DevourerofGodsHeadS>(), 9000 },
{ ModContent.NPCType<DevourerofGodsBodyS>(), 9000 },
{ ModContent.NPCType<DevourerofGodsTailS>(), 9000 },
{ ModContent.NPCType<Yharon>(), 10800 },
{ ModContent.NPCType<SupremeCalamitas>(), 18000 }
};
}
#endregion
{ NPCID.TheDestroyerTail, 10800 },
{ NPCID.SkeletronPrime, 10800 },
{ NPCID.Plantera, 10800 },
{ NPCID.Golem, 9000 },
{ NPCID.GolemHead, 3600 },
{ NPCID.DukeFishron, 9000 },
{ NPCID.CultistBoss, 9000 },
{ NPCID.MoonLordCore, 14400 },
{ NPCID.MoonLordHand, 7200 },
{ NPCID.MoonLordHead, 7200 },
{ ModContent.NPCType<DesertScourgeHead>(), 3600 },
{ ModContent.NPCType<DesertScourgeBody>(), 3600 },
{ ModContent.NPCType<DesertScourgeTail>(), 3600 },
{ ModContent.NPCType<CrabulonIdle>(), 5400 },
{ ModContent.NPCType<HiveMind>(), 1800 },
{ ModContent.NPCType<HiveMindP2>(), 5400 },
{ ModContent.NPCType<PerforatorHive>(), 7200 },
{ ModContent.NPCType<SlimeGodCore>(), 10800 },
{ ModContent.NPCType<SlimeGod>(), 3600 },
{ ModContent.NPCType<SlimeGodRun>(), 3600 },
{ ModContent.NPCType<SlimeGodSplit>(), 3600 },
{ ModContent.NPCType<SlimeGodRunSplit>(), 3600 },
{ ModContent.NPCType<Cryogen>(), 10800 },
{ ModContent.NPCType<AquaticScourgeHead>(), 7200 },
{ ModContent.NPCType<AquaticScourgeBody>(), 7200 },
{ ModContent.NPCType<AquaticScourgeBodyAlt>(), 7200 },
{ ModContent.NPCType<AquaticScourgeTail>(), 7200 },
{ ModContent.NPCType<BrimstoneElemental>(), 10800 },
{ ModContent.NPCType<Calamitas>(), 1200 },
{ ModContent.NPCType<CalamitasRun3>(), 11400 },
{ ModContent.NPCType<Leviathan>(), 10800 },
{ ModContent.NPCType<Siren>(), 10800 },
{ ModContent.NPCType<AstrumAureus>(), 10800 },
{ ModContent.NPCType<AstrumDeusHeadSpectral>(), 7200 },
{ ModContent.NPCType<AstrumDeusBodySpectral>(), 7200 },
{ ModContent.NPCType<AstrumDeusTailSpectral>(), 7200 },
{ ModContent.NPCType<PlaguebringerGoliath>(), 10800 },
{ ModContent.NPCType<RavagerBody>(), 10800 },
{ ModContent.NPCType<ProfanedGuardianBoss>(), 5400 },
{ ModContent.NPCType<Bumblefuck>(), 7200 },
{ ModContent.NPCType<Providence>(), 14400 },
{ ModContent.NPCType<DarkEnergy>(), 1200 },
{ ModContent.NPCType<DarkEnergy2>(), 1200 },
{ ModContent.NPCType<DarkEnergy3>(), 1200 },
{ ModContent.NPCType<StormWeaverHeadNaked>(), 5400 },
{ ModContent.NPCType<StormWeaverBodyNaked>(), 5400 },
{ ModContent.NPCType<StormWeaverTailNaked>(), 5400 },
{ ModContent.NPCType<Signus>(), 7200 },
{ ModContent.NPCType<Polterghast>(), 10800 },
{ ModContent.NPCType<OldDuke>(), 10800 },
{ ModContent.NPCType<DevourerofGodsHead>(), 5400 },
{ ModContent.NPCType<DevourerofGodsBody>(), 5400 },
{ ModContent.NPCType<DevourerofGodsTail>(), 5400 },
{ ModContent.NPCType<DevourerofGodsHeadS>(), 9000 },
{ ModContent.NPCType<DevourerofGodsBodyS>(), 9000 },
{ ModContent.NPCType<DevourerofGodsTailS>(), 9000 },
{ ModContent.NPCType<Yharon>(), 10800 },
{ ModContent.NPCType<SupremeCalamitas>(), 18000 }
};
}
#endregion
#region Boss Velocity Contact Damage Scale Values
private void SetupBossVelocityScalingValues()
{
bossVelocityDamageScaleValues = new SortedDictionary<int, float> {
{ NPCID.KingSlime, velocityScaleMin },
{ NPCID.EyeofCthulhu, velocityScaleMin }, // Increases in phase 2
{ NPCID.EaterofWorldsHead, bitingEnemeyVelocityScale },
{ NPCID.EaterofWorldsBody, velocityScaleMin },
{ NPCID.EaterofWorldsTail, velocityScaleMin },
{ NPCID.Creeper, velocityScaleMin },
{ NPCID.BrainofCthulhu, velocityScaleMin },
{ NPCID.QueenBee, velocityScaleMin },
{ NPCID.SkeletronHead, velocityScaleMin },
{ NPCID.SkeletronHand, velocityScaleMin },
{ NPCID.TheHungry, bitingEnemeyVelocityScale },
{ NPCID.TheHungryII, bitingEnemeyVelocityScale },
{ NPCID.LeechHead, bitingEnemeyVelocityScale },
{ NPCID.LeechBody, velocityScaleMin },
{ NPCID.LeechTail, velocityScaleMin },
{ NPCID.Spazmatism, velocityScaleMin }, // Increases in phase 2
{ NPCID.Retinazer, velocityScaleMin },
{ NPCID.TheDestroyer, bitingEnemeyVelocityScale },
{ NPCID.TheDestroyerBody, velocityScaleMin },
{ NPCID.TheDestroyerTail, velocityScaleMin },
{ NPCID.Probe, velocityScaleMin },
{ NPCID.SkeletronPrime, velocityScaleMin },
{ NPCID.PrimeCannon, velocityScaleMin },
{ NPCID.PrimeLaser, velocityScaleMin },
{ NPCID.PrimeSaw, velocityScaleMin },
{ NPCID.PrimeVice, velocityScaleMin },
{ NPCID.Plantera, velocityScaleMin }, // Increases in phase 2
{ NPCID.PlanterasTentacle, bitingEnemeyVelocityScale },
{ NPCID.Golem, velocityScaleMin },
{ NPCID.GolemFistLeft, velocityScaleMin },
{ NPCID.GolemFistRight, velocityScaleMin },
{ NPCID.GolemHead, velocityScaleMin },
{ NPCID.DukeFishron, velocityScaleMin },
{ ModContent.NPCType<DesertScourgeHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DesertScourgeBody>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeTail>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeHeadSmall>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DesertScourgeBodySmall>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeTailSmall>(), velocityScaleMin },
{ ModContent.NPCType<CrabulonIdle>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<HiveMindP2>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHive>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadLarge>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodyLarge>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailLarge>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadMedium>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodyMedium>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailMedium>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadSmall>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodySmall>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailSmall>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodCore>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGod>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodRun>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodSplit>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodRunSplit>(), velocityScaleMin },
{ ModContent.NPCType<SlimeSpawnCorrupt>(), velocityScaleMin },
{ ModContent.NPCType<Cryogen>(), velocityScaleMin },
{ ModContent.NPCType<Cryocore>(), velocityScaleMin },
{ ModContent.NPCType<Cryocore2>(), velocityScaleMin },
{ ModContent.NPCType<IceMass>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<AquaticScourgeBody>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeBodyAlt>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeTail>(), velocityScaleMin },
{ ModContent.NPCType<BrimstoneElemental>(), velocityScaleMin },
{ ModContent.NPCType<Calamitas>(), velocityScaleMin },
{ ModContent.NPCType<CalamitasRun3>(), velocityScaleMin },
{ ModContent.NPCType<Leviathan>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<Siren>(), velocityScaleMin },
{ ModContent.NPCType<AstrumAureus>(), velocityScaleMin },
{ ModContent.NPCType<AstrumDeusHeadSpectral>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<AstrumDeusBodySpectral>(), velocityScaleMin },
{ ModContent.NPCType<AstrumDeusTailSpectral>(), velocityScaleMin },
{ ModContent.NPCType<PlaguebringerGoliath>(), velocityScaleMin },
{ ModContent.NPCType<PlaguebringerShade>(), velocityScaleMin },
{ ModContent.NPCType<PlagueBeeG>(), velocityScaleMin },
{ ModContent.NPCType<PlagueBeeLargeG>(), velocityScaleMin },
{ ModContent.NPCType<RavagerBody>(), velocityScaleMin },
{ ModContent.NPCType<RavagerClawLeft>(), velocityScaleMin },
{ ModContent.NPCType<RavagerClawRight>(), velocityScaleMin },
{ ModContent.NPCType<RavagerLegLeft>(), velocityScaleMin },
{ ModContent.NPCType<RavagerLegRight>(), velocityScaleMin },
{ ModContent.NPCType<RockPillar>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss2>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss3>(), velocityScaleMin },
{ ModContent.NPCType<Bumblefuck>(), velocityScaleMin },
{ ModContent.NPCType<Bumblefuck2>(), velocityScaleMin },
{ ModContent.NPCType<CeaselessVoid>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy2>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy3>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<StormWeaverBody>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverTail>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverHeadNaked>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<StormWeaverBodyNaked>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverTailNaked>(), velocityScaleMin },
{ ModContent.NPCType<StasisProbe>(), velocityScaleMin },
{ ModContent.NPCType<StasisProbeNaked>(), velocityScaleMin },
{ ModContent.NPCType<Signus>(), velocityScaleMin },
{ ModContent.NPCType<CosmicLantern>(), velocityScaleMin },
{ ModContent.NPCType<Polterghast>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PolterPhantom>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<OldDuke>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBody>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTail>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHead2>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBody2>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTail2>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHeadS>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBodyS>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTailS>(), velocityScaleMin },
{ ModContent.NPCType<Yharon>(), velocityScaleMin },
{ ModContent.NPCType<DetonatingFlare>(), velocityScaleMin },
{ ModContent.NPCType<DetonatingFlare2>(), velocityScaleMin },
{ ModContent.NPCType<SupremeCalamitas>(), velocityScaleMin }
};
}
#endregion
#region Boss Velocity Contact Damage Scale Values
private void SetupBossVelocityScalingValues()
{
bossVelocityDamageScaleValues = new SortedDictionary<int, float> {
{ NPCID.KingSlime, velocityScaleMin },
{ NPCID.EyeofCthulhu, velocityScaleMin }, // Increases in phase 2
{ NPCID.EaterofWorldsHead, bitingEnemeyVelocityScale },
{ NPCID.EaterofWorldsBody, velocityScaleMin },
{ NPCID.EaterofWorldsTail, velocityScaleMin },
{ NPCID.Creeper, velocityScaleMin },
{ NPCID.BrainofCthulhu, velocityScaleMin },
{ NPCID.QueenBee, velocityScaleMin },
{ NPCID.SkeletronHead, velocityScaleMin },
{ NPCID.SkeletronHand, velocityScaleMin },
{ NPCID.TheHungry, bitingEnemeyVelocityScale },
{ NPCID.TheHungryII, bitingEnemeyVelocityScale },
{ NPCID.LeechHead, bitingEnemeyVelocityScale },
{ NPCID.LeechBody, velocityScaleMin },
{ NPCID.LeechTail, velocityScaleMin },
{ NPCID.Spazmatism, velocityScaleMin }, // Increases in phase 2
{ NPCID.Retinazer, velocityScaleMin },
{ NPCID.TheDestroyer, bitingEnemeyVelocityScale },
{ NPCID.TheDestroyerBody, velocityScaleMin },
{ NPCID.TheDestroyerTail, velocityScaleMin },
{ NPCID.Probe, velocityScaleMin },
{ NPCID.SkeletronPrime, velocityScaleMin },
{ NPCID.PrimeCannon, velocityScaleMin },
{ NPCID.PrimeLaser, velocityScaleMin },
{ NPCID.PrimeSaw, velocityScaleMin },
{ NPCID.PrimeVice, velocityScaleMin },
{ NPCID.Plantera, velocityScaleMin }, // Increases in phase 2
{ NPCID.PlanterasTentacle, bitingEnemeyVelocityScale },
{ NPCID.Golem, velocityScaleMin },
{ NPCID.GolemFistLeft, velocityScaleMin },
{ NPCID.GolemFistRight, velocityScaleMin },
{ NPCID.GolemHead, velocityScaleMin },
{ NPCID.DukeFishron, velocityScaleMin },
{ ModContent.NPCType<DesertScourgeHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DesertScourgeBody>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeTail>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeHeadSmall>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DesertScourgeBodySmall>(), velocityScaleMin },
{ ModContent.NPCType<DesertScourgeTailSmall>(), velocityScaleMin },
{ ModContent.NPCType<CrabulonIdle>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<HiveMindP2>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHive>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadLarge>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodyLarge>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailLarge>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadMedium>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodyMedium>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailMedium>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorHeadSmall>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PerforatorBodySmall>(), velocityScaleMin },
{ ModContent.NPCType<PerforatorTailSmall>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodCore>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGod>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodRun>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodSplit>(), velocityScaleMin },
{ ModContent.NPCType<SlimeGodRunSplit>(), velocityScaleMin },
{ ModContent.NPCType<SlimeSpawnCorrupt>(), velocityScaleMin },
{ ModContent.NPCType<Cryogen>(), velocityScaleMin },
{ ModContent.NPCType<Cryocore>(), velocityScaleMin },
{ ModContent.NPCType<Cryocore2>(), velocityScaleMin },
{ ModContent.NPCType<IceMass>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<AquaticScourgeBody>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeBodyAlt>(), velocityScaleMin },
{ ModContent.NPCType<AquaticScourgeTail>(), velocityScaleMin },
{ ModContent.NPCType<BrimstoneElemental>(), velocityScaleMin },
{ ModContent.NPCType<Calamitas>(), velocityScaleMin },
{ ModContent.NPCType<CalamitasRun3>(), velocityScaleMin },
{ ModContent.NPCType<Leviathan>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<Siren>(), velocityScaleMin },
{ ModContent.NPCType<AstrumAureus>(), velocityScaleMin },
{ ModContent.NPCType<AstrumDeusHeadSpectral>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<AstrumDeusBodySpectral>(), velocityScaleMin },
{ ModContent.NPCType<AstrumDeusTailSpectral>(), velocityScaleMin },
{ ModContent.NPCType<PlaguebringerGoliath>(), velocityScaleMin },
{ ModContent.NPCType<PlaguebringerShade>(), velocityScaleMin },
{ ModContent.NPCType<PlagueBeeG>(), velocityScaleMin },
{ ModContent.NPCType<PlagueBeeLargeG>(), velocityScaleMin },
{ ModContent.NPCType<RavagerBody>(), velocityScaleMin },
{ ModContent.NPCType<RavagerClawLeft>(), velocityScaleMin },
{ ModContent.NPCType<RavagerClawRight>(), velocityScaleMin },
{ ModContent.NPCType<RavagerLegLeft>(), velocityScaleMin },
{ ModContent.NPCType<RavagerLegRight>(), velocityScaleMin },
{ ModContent.NPCType<RockPillar>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss2>(), velocityScaleMin },
{ ModContent.NPCType<ProfanedGuardianBoss3>(), velocityScaleMin },
{ ModContent.NPCType<Bumblefuck>(), velocityScaleMin },
{ ModContent.NPCType<Bumblefuck2>(), velocityScaleMin },
{ ModContent.NPCType<CeaselessVoid>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy2>(), velocityScaleMin },
{ ModContent.NPCType<DarkEnergy3>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<StormWeaverBody>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverTail>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverHeadNaked>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<StormWeaverBodyNaked>(), velocityScaleMin },
{ ModContent.NPCType<StormWeaverTailNaked>(), velocityScaleMin },
{ ModContent.NPCType<StasisProbe>(), velocityScaleMin },
{ ModContent.NPCType<StasisProbeNaked>(), velocityScaleMin },
{ ModContent.NPCType<Signus>(), velocityScaleMin },
{ ModContent.NPCType<CosmicLantern>(), velocityScaleMin },
{ ModContent.NPCType<Polterghast>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<PolterPhantom>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<OldDuke>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHead>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBody>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTail>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHead2>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBody2>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTail2>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsHeadS>(), bitingEnemeyVelocityScale },
{ ModContent.NPCType<DevourerofGodsBodyS>(), velocityScaleMin },
{ ModContent.NPCType<DevourerofGodsTailS>(), velocityScaleMin },
{ ModContent.NPCType<Yharon>(), velocityScaleMin },
{ ModContent.NPCType<DetonatingFlare>(), velocityScaleMin },
{ ModContent.NPCType<DetonatingFlare2>(), velocityScaleMin },
{ ModContent.NPCType<SupremeCalamitas>(), velocityScaleMin }
};
}
#endregion
#region Music
public override void UpdateMusic(ref int music, ref MusicPriority priority)
#region Music
public override void UpdateMusic(ref int music, ref MusicPriority priority)
{
Mod calamityModMusic = ModLoader.GetMod("CalamityModMusic");
if (Main.musicVolume != 0)
@@ -901,8 +901,8 @@ namespace CalamityMod
bool acidRain = CalamityWorld.rainingAcid;
if (calamityModMusic != null)
{
string rainMusic = "Sounds/Music/AcidRain";
string musicChoice = acidRain ? rainMusic + (CalamityWorld.downedPolterghast ? "2" : "1") : "Sounds/Music/Sulphur"; //replace first acidrain1 once second theme is added.
string rainMusic = "Sounds/Music/AcidRain";
string musicChoice = acidRain ? rainMusic + (CalamityWorld.downedPolterghast ? "2" : "1") : "Sounds/Music/Sulphur"; //replace first acidrain1 once second theme is added.
music = calamityModMusic.GetSoundSlot(SoundType.Music, musicChoice);
}
@@ -957,7 +957,7 @@ namespace CalamityMod
layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Draedon Factory Tiles", () =>
{
DraedonsFactoryUI.Draw(Main.spriteBatch);
CellFactoryUI.Draw(Main.spriteBatch);
DraedonsItemChargerUI.Draw(Main.spriteBatch);
return true;
}, InterfaceScaleType.Game)); // InterfaceScaleType.Game tells the game that this UI should take zoom into account.
@@ -1478,64 +1478,64 @@ namespace CalamityMod
#region Lighting
const float MaxCaveDarkness = -0.3f;
const float MaxSignusDarkness = -0.4f;
const float MaxAbyssDarkness = -0.7f;
const float MaxSignusDarkness = -0.4f;
const float MaxAbyssDarkness = -0.7f;
public override void ModifyLightingBrightness(ref float scale)
{
// Apply the calculated darkness value for the local player.
CalamityPlayer modPlayer = Main.LocalPlayer.Calamity();
float darkRatio = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 1f);
// Apply the calculated darkness value for the local player.
CalamityPlayer modPlayer = Main.LocalPlayer.Calamity();
float darkRatio = MathHelper.Clamp(modPlayer.caveDarkness, 0f, 1f);
if (modPlayer.ZoneAbyss)
scale += MaxAbyssDarkness * darkRatio;
else if (CalamityWorld.death)
scale += MaxCaveDarkness * darkRatio;
if (modPlayer.ZoneAbyss)
scale += MaxAbyssDarkness * darkRatio;
else if (CalamityWorld.death)
scale += MaxCaveDarkness * darkRatio;
if (CalamityWorld.revenge)
{
if (CalamityGlobalNPC.signus != -1)
{
if (Main.npc[CalamityGlobalNPC.signus].active)
{
if (Vector2.Distance(Main.LocalPlayer.Center, Main.npc[CalamityGlobalNPC.signus].Center) <= 5200f)
{
float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax);
if (CalamityWorld.revenge)
{
if (CalamityGlobalNPC.signus != -1)
{
if (Main.npc[CalamityGlobalNPC.signus].active)
{
if (Vector2.Distance(Main.LocalPlayer.Center, Main.npc[CalamityGlobalNPC.signus].Center) <= 5200f)
{
float signusLifeRatio = 1f - (Main.npc[CalamityGlobalNPC.signus].life / Main.npc[CalamityGlobalNPC.signus].lifeMax);
// Reduce the power of Signus darkness based on your light level.
float multiplier = 1f;
switch (modPlayer.GetTotalLightStrength())
{
case 0:
break;
case 1:
case 2:
multiplier = 0.75f;
break;
case 3:
case 4:
multiplier = 0.5f;
break;
case 5:
case 6:
multiplier = 0.25f;
break;
default:
multiplier = 0f;
break;
}
// Reduce the power of Signus darkness based on your light level.
float multiplier = 1f;
switch (modPlayer.GetTotalLightStrength())
{
case 0:
break;
case 1:
case 2:
multiplier = 0.75f;
break;
case 3:
case 4:
multiplier = 0.5f;
break;
case 5:
case 6:
multiplier = 0.25f;
break;
default:
multiplier = 0f;
break;
}
// Increased darkness in Death Mode
if (CalamityWorld.death)
multiplier += (1f - multiplier) * 0.1f;
// Increased darkness in Death Mode
if (CalamityWorld.death)
multiplier += (1f - multiplier) * 0.1f;
// Total darkness
float signusDarkness = signusLifeRatio * multiplier;
darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f);
scale += MaxSignusDarkness * darkRatio;
}
}
}
}
// Total darkness
float signusDarkness = signusLifeRatio * multiplier;
darkRatio = MathHelper.Clamp(signusDarkness, 0f, 1f);
scale += MaxSignusDarkness * darkRatio;
}
}
}
}
}
#endregion
@@ -1548,7 +1548,15 @@ namespace CalamityMod
CalamityNetcode.SyncWorld();
}
#endregion
}
#region Netcode
public override void HandlePacket(BinaryReader reader, int whoAmI) => CalamityNetcode.HandlePacket(reader, whoAmI);
#endregion
#region Tile Entity Time Handler
public override void MidUpdateTimeWorld() => TileEntityTimeHandler.Update();
#endregion
}
public enum Season : byte
{
+9 -9
View File
@@ -147,8 +147,8 @@ namespace CalamityMod
if (Main.netMode != NetmodeID.MultiplayerClient)
NPC.NewNPC(x, y, ModContent.NPCType<SuperDummyNPC>());
break;
case CalamityModMessageType.DraedonGeneratorStackSync:
(TileEntity.ByID[reader.ReadInt32()] as TEDraedonFuelFactory).HeldItem.stack = reader.ReadInt32();
case CalamityModMessageType.PowerCellFactory:
TEPowerCellFactory.ReadSyncPacket(reader);
break;
case CalamityModMessageType.DraedonChargerSync:
int entityID = reader.ReadInt32();
@@ -230,8 +230,8 @@ namespace CalamityMod
BossRushStage,
DoGCountdownSync,
BossSpawnCountdownSync,
BRHostileProjKillSync,
ArmoredDiggerCountdownSync,
BRHostileProjKillSync,
ArmoredDiggerCountdownSync,
BossTypeSync,
DeathCountSync,
RevengeanceBoolSync,
@@ -241,18 +241,18 @@ namespace CalamityMod
ArmageddonBoolSync,
DemonTrophyBoolSync,
NPCRegenerationSync,
DeathModeUnderworldTimeSync,
DeathModeBlizzardTimeSync,
DeathBossSpawnCountdownSync,
DeathModeUnderworldTimeSync,
DeathModeBlizzardTimeSync,
DeathBossSpawnCountdownSync,
AcidRainSync,
AcidRainUIDrawFadeSync,
AcidRainOldDukeSummonSync,
GaelsGreatswordSwingSync,
SpawnSuperDummy,
SyncCalamityNPCAIArray,
SyncCalamityNPCAIArray,
ProvidenceDyeConditionSync, // We shouldn't fucking need this. Die in a hole, Multiplayer.
PSCChallengeSync, // See above
DraedonGeneratorStackSync,
PowerCellFactory,
DraedonChargerSync,
DraedonFieldGeneratorSync
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 693 B

After

Width:  |  Height:  |  Size: 693 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 874 B

After

Width:  |  Height:  |  Size: 874 B

@@ -5,12 +5,12 @@ using Terraria.ModLoader;
namespace CalamityMod.Items.Placeables
{
public class DraedonsFuelFactoryItem : ModItem
public class PowerCellFactoryItem : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Draedon's Fuel Factory");
Tooltip.SetDefault("Produces Draedon Power Cells over time");
DisplayName.SetDefault("Power Cell Factory");
Tooltip.SetDefault("Produces Draedon Power Cells over time\n" + "One cell is produced every 15 seconds");
}
public override void SetDefaults()
@@ -23,11 +23,11 @@ namespace CalamityMod.Items.Placeables
item.useAnimation = item.useTime = 15;
item.useStyle = ItemUseStyleID.SwingThrow;
item.consumable = true;
item.createTile = ModContent.TileType<DraedonFuelFactory>();
item.createTile = ModContent.TileType<PowerCellFactory>();
item.rare = ItemRarityID.Red;
item.Calamity().customRarity = CalamityRarity.DraedonRust;
//item.value = Item.buyPrice(gold: 5);
item.value = Item.buyPrice(gold: 50);
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 451 B

+85
View File
@@ -0,0 +1,85 @@
using CalamityMod.Items.Materials;
using CalamityMod.Items.Potions;
using CalamityMod.Projectiles.Ranged;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class Auralis : ModItem
{
public static readonly Color blueColor = new Color(0, 77, 255);
public static readonly Color greenColor = new Color(0, 255, 77);
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Auralis");
Tooltip.SetDefault("Fires a high speed glowing bullet that inflicts debilitating debuffs\n" +
"Right click to zoom out\n" +
"Standing still provides increasing damage bonuses up to 25%\n" +
"Standing still for 5 or more seconds while using the scope ability will summon an aurora\n" +
"The aurora reduces the damage of the next projectile hit by a flat 100\n" +
"This effect lasts up to 20 seconds and has a 30 second cooldown\n" +
"50% chance to not consume bullets");
}
public override void SetDefaults()
{
item.damage = 650;
item.ranged = true;
item.useTime = item.useAnimation = 30;
item.knockBack = 10f;
item.autoReuse = true;
item.shoot = ModContent.ProjectileType<AuralisBullet>();
item.shootSpeed = 7.5f;
item.useAmmo = AmmoID.Bullet;
item.width = 96;
item.height = 34;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.UseSound = mod.GetLegacySoundSlot(SoundType.Item, "Sounds/Item/PlasmaBlast");
item.value = CalamityGlobalItem.Rarity13BuyPrice;
item.rare = 10;
item.Calamity().customRarity = CalamityRarity.Dedicated;
}
public override void ModifyWeaponDamage(Player player, ref float add, ref float mult, ref float flat)
{
float damageMult = MathHelper.Lerp(0f, 0.25f, player.Calamity().auralisStealthCounter / 300f);
add += damageMult;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Projectile.NewProjectile(position, new Vector2(speedX, speedY), item.shoot, damage, knockBack, player.whoAmI);
return false;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
Texture2D glowmask = ModContent.GetTexture("CalamityMod/Items/Weapons/Ranged/AuralisGlow");
Vector2 origin = new Vector2(glowmask.Width / 2f, glowmask.Height / 2f - 2f);
spriteBatch.Draw(glowmask, item.Center - Main.screenPosition, null, Color.White, rotation, origin, 1f, SpriteEffects.None, 0f);
}
public override Vector2? HoldoutOffset() => new Vector2(-10, 0);
public override bool ConsumeAmmo(Player player) => Main.rand.Next(100) >= 50;
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ModContent.ItemType<UeliaceBar>(), 5);
recipe.AddIngredient(ModContent.ItemType<AstralJelly>(), 5);
recipe.AddIngredient(ModContent.ItemType<Stardust>(), 50);
recipe.AddIngredient(ItemID.SniperRifle);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

+1 -1
View File
@@ -30,7 +30,7 @@ namespace CalamityMod.Items.Weapons.Ranged
item.width = 68;
item.height = 36;
item.useStyle = 5;
item.useStyle = ItemUseStyleID.HoldingOut;
item.noMelee = true;
item.UseSound = SoundID.Item34;
item.value = CalamityGlobalItem.Rarity7BuyPrice;
+5 -17
View File
@@ -47,26 +47,12 @@ namespace CalamityMod.Projectiles.Magic
public override void Kill(int timeLeft)
{
Main.PlaySound(SoundID.Item125, projectile.position);
Main.PlaySound(SoundID.Item125, projectile.Center);
for (int n = 0; n < 5; n++)
{
float x = projectile.position.X + (float)Main.rand.Next(-200, 200);
float y = projectile.position.Y - 1500f;
Vector2 vector = new Vector2(x, y);
float num13 = projectile.position.X + (float)(projectile.width / 2) - vector.X;
float num14 = projectile.position.Y + (float)(projectile.height / 2) - vector.Y;
num13 += (float)Main.rand.Next(-100, 101);
int num15 = 29;
float num16 = (float)Math.Sqrt((double)(num13 * num13 + num14 * num14));
num16 = (float)num15 / num16;
num13 *= num16;
num14 *= num16;
Projectile.NewProjectile(x, y, num13, num14, ModContent.ProjectileType<ThunderstormShotSplit>(), projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
CalamityUtils.ProjectileRain(projectile.Center, 200f, 100f, 1500f, 1500f, 29f, ModContent.ProjectileType<ThunderstormShotSplit>(), projectile.damage, projectile.knockBack, projectile.owner, projectile.owner);
}
projectile.position = projectile.Center;
projectile.width = projectile.height = 36;
projectile.position.X = projectile.position.X - (float)(projectile.width / 2);
projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2);
CalamityGlobalProjectile.ExpandHitboxBy(projectile, 36);
int num226 = 36;
for (int num227 = 0; num227 < num226; num227++)
{
@@ -88,6 +74,8 @@ namespace CalamityMod.Projectiles.Magic
Main.dust[num228].noLight = true;
Main.dust[num228].velocity = vector7;
}
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
projectile.Damage();
}
}
+64
View File
@@ -0,0 +1,64 @@
using CalamityMod.Buffs.StatDebuffs;
using CalamityMod.Items.Weapons.Ranged;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class AuralisBullet : ModProjectile
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Bullet");
}
public override void SetDefaults()
{
projectile.width = 4;
projectile.height = 4;
projectile.friendly = true;
projectile.ranged = true;
projectile.penetrate = 5;
projectile.alpha = 255;
projectile.timeLeft = 200;
projectile.extraUpdates = 10;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 10;
}
public override void AI()
{
projectile.ai[0] += 1f;
if (projectile.ai[0] > 6f)
{
for (int d = 0; d < 5; d++)
{
Dust dust = Main.dust[Dust.NewDust(projectile.position, projectile.width, projectile.height, 229, projectile.velocity.X, projectile.velocity.Y, 100, CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 1f), 1f)];
dust.velocity = Vector2.Zero;
dust.position -= projectile.velocity / 5f * d;
dust.noGravity = true;
dust.scale = 0.65f;
dust.noLight = true;
dust.color = CalamityUtils.ColorSwap(Auralis.blueColor, Auralis.greenColor, 1f);
}
}
}
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
{
int duration = 600;
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), duration);
target.AddBuff(BuffID.Ichor, duration);
target.AddBuff(BuffID.CursedInferno, duration);
}
public override void OnHitPvp(Player target, int damage, bool crit)
{
int duration = 600;
target.AddBuff(ModContent.BuffType<MarkedforDeath>(), duration);
target.AddBuff(BuffID.Ichor, duration);
target.AddBuff(BuffID.CursedInferno, duration);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

-118
View File
@@ -1,118 +0,0 @@
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Tiles;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace CalamityMod.TileEntities
{
public class TEDraedonFuelFactory : ModTileEntity
{
public int Time = 0;
public Item HeldItem = new Item();
public void ClientToServerSync()
{
if (Main.netMode != NetmodeID.SinglePlayer)
{
var netMessage = CalamityMod.Instance.GetPacket();
netMessage.Write((byte)CalamityModMessageType.DraedonGeneratorStackSync);
netMessage.Write(ID);
netMessage.Write(HeldItem.type);
netMessage.Write(HeldItem.stack);
netMessage.Send();
}
}
public override bool ValidTile(int i, int j)
{
Tile tile = Main.tile[i, j];
return tile.active() && tile.type == ModContent.TileType<DraedonFuelFactory>() && tile.frameX == 0 && tile.frameY == 0;
}
public override void Update()
{
if (HeldItem is null || HeldItem.type != ModContent.ItemType<PowerCell>())
{
HeldItem = new Item();
HeldItem.SetDefaults(ModContent.ItemType<PowerCell>());
HeldItem.stack = 0;
}
HeldItem.favorited = false;
Time++;
// Sometimes the item gets fucked up and it gets a maxStack of 0. Using it as a max can be unreliable as a result.
bool rightTimeToMakeCell = Time % 5 == 4 && Main.tileFrame[Main.tile[Position.X, Position.Y].type] == 43;
if (Main.netMode == NetmodeID.Server)
rightTimeToMakeCell = Time % (DraedonFuelFactory.CellCreationDelay + DraedonFuelFactory.TotalFrames * 5 + 5) == (DraedonFuelFactory.CellCreationDelay + DraedonFuelFactory.TotalFrames * 5 + 4);
if (HeldItem.stack < 999 && rightTimeToMakeCell)
{
HeldItem.stack++;
// Forcibly sync the tile entity whenever a cell is made.
ClientToServerSync();
}
}
// If this factory breaks, anyone who's viewing it is no longer viewing it.
public override void OnKill()
{
for (int i = 0; i < Main.player.Length; i++)
{
if (Main.player[i].Calamity().CurrentlyViewedFactory == this)
Main.player[i].Calamity().CurrentlyViewedFactory = null;
}
base.OnKill();
}
public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction)
{
if (Main.netMode == NetmodeID.MultiplayerClient)
{
NetMessage.SendTileSquare(Main.myPlayer, i, j, 5);
NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type, 0f, 0, 0, 0);
return -1;
}
return Place(i, j);
}
public override TagCompound Save()
{
TagCompound tag = new TagCompound
{
["Stack"] = HeldItem.stack,
["Prefix"] = HeldItem.prefix,
};
CalamityUtils.SaveModItem(tag, HeldItem);
return tag;
}
public override void Load(TagCompound tag)
{
HeldItem = CalamityUtils.LoadModItem(tag);
HeldItem.stack = tag.GetInt("Stack");
HeldItem.prefix = tag.GetByte("Prefix");
}
public override void NetSend(BinaryWriter writer, bool lightSend)
{
writer.Write(Time);
writer.Write(HeldItem.type);
writer.Write(HeldItem.stack);
writer.Write(HeldItem.prefix);
}
public override void NetReceive(BinaryReader reader, bool lightReceive)
{
Time = reader.ReadInt32();
HeldItem = new Item
{
type = reader.ReadInt32()
};
HeldItem.SetDefaults(HeldItem.type);
HeldItem.stack = reader.ReadInt32();
HeldItem.prefix = reader.ReadByte();
}
}
}
+182
View File
@@ -0,0 +1,182 @@
using CalamityMod.CalPlayer;
using CalamityMod.Tiles;
using System.IO;
using System.Reflection;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;
namespace CalamityMod.TileEntities
{
public class TEPowerCellFactory : ModTileEntity
{
public long Time = 0;
private short _stack = 0;
public short CellStack
{
get => _stack;
set
{
_stack = value;
SendSyncPacket();
}
}
private long CycleFrameCounter
{
get
{
long totalCycleTime = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.TotalFrames * PowerCellFactory.AnimationFramerate;
return Time % totalCycleTime;
}
}
private bool IsCellFrame
{
get
{
long magicFrame = PowerCellFactory.BetweenCellDowntime + PowerCellFactory.CellCreateFrame * PowerCellFactory.AnimationFramerate + PowerCellFactory.MagicFrameDelay;
return CycleFrameCounter == magicFrame;
}
}
// Property which allows anyone to get the current animation frame of this specific factory.
public int AnimationFrame
{
get
{
int f = (int)CycleFrameCounter;
// The animation sticks on the last frame throughout the entire downtime period.
if (f < PowerCellFactory.BetweenCellDowntime)
return PowerCellFactory.TotalFrames - 1;
// Remove the starting downtime period for the framerate divisor calculation.
return (f - PowerCellFactory.BetweenCellDowntime) / PowerCellFactory.AnimationFramerate;
}
}
// This guarantees that this tile entity will not persist if not placed directly on the top left corner of a Power Cell Factory tile.
public override bool ValidTile(int i, int j)
{
Tile tile = Main.tile[i, j];
return tile.active() && tile.type == ModContent.TileType<PowerCellFactory>() && tile.frameX == 0 && tile.frameY == 0;
}
public override void Update()
{
++Time;
if (IsCellFrame && CellStack < 999)
// The property setter will automatically send the necessary packet.
CellStack++;
}
// This code is called as a hook when the player places the Power Cell Factory tile so that the tile entity may be placed.
public override int Hook_AfterPlacement(int i, int j, int type, int style, int direction)
{
// If in multiplayer, tell the server to place the tile entity and DO NOT place it yourself. That will mismatch IDs.
// Also tell the server that you placed the 4x4 tiles that make up the Power Cell Factory.
if (Main.netMode == NetmodeID.MultiplayerClient)
{
NetMessage.SendTileRange(Main.myPlayer, i, j, PowerCellFactory.Width, PowerCellFactory.Height);
NetMessage.SendData(MessageID.TileEntityPlacement, -1, -1, null, i, j, Type);
return -1;
}
// If in single player, just place the tile entity, no problems.
int id = Place(i, j);
return id;
}
// This code is called on dedicated servers only. It is the server-side response to MessageID.TileEntityPlacement.
// When the server receives such a message from a client, it sends a MessageID.TileEntitySharing to all clients.
// This will cause them to Place the tile entity locally at that position, all with exactly the same ID.
public override void OnNetPlace() => NetMessage.SendData(MessageID.TileEntitySharing, -1, -1, null, ID, Position.X, Position.Y);
// If this factory breaks, anyone who's viewing it is no longer viewing it.
public override void OnKill()
{
for (int i = 0; i < Main.maxPlayers; i++)
{
Player p = Main.player[i];
if (!p.active)
continue;
// Use reflection to stop TML from spitting an error here.
// Try-catching will not stop this error, TML will print it to console anyway. The error is harmless.
ModPlayer[] mpStorageArray = (ModPlayer[])typeof(Player).GetField("modPlayers", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(p);
if (mpStorageArray.Length == 0)
continue;
CalamityPlayer mp = p.Calamity();
TEPowerCellFactory factory = mp.CurrentlyViewedFactory;
if (factory is null)
continue;
if (factory.ID == ID)
{
mp.CurrentlyViewedFactory = null;
mp.CurrentlyViewedFactoryX = -1;
mp.CurrentlyViewedFactoryY = -1;
}
}
}
public override TagCompound Save() => new TagCompound
{
{ "time", Time },
{ "cells", _stack }
};
public override void Load(TagCompound tag)
{
Time = tag.GetLong("time");
_stack = tag.GetShort("cells");
}
public override void NetSend(BinaryWriter writer, bool lightSend)
{
writer.Write(Time);
writer.Write(_stack);
}
public override void NetReceive(BinaryReader reader, bool lightReceive)
{
Time = reader.ReadInt64();
_stack = reader.ReadInt16();
}
private void SendSyncPacket()
{
if (Main.netMode == NetmodeID.SinglePlayer)
return;
var netMessage = mod.GetPacket();
netMessage.Write((byte)CalamityModMessageType.PowerCellFactory);
netMessage.Write(ID);
netMessage.Write(Time);
netMessage.Write(_stack);
netMessage.Send();
}
internal static bool ReadSyncPacket(BinaryReader reader)
{
int teID = reader.ReadInt32();
bool exists = ByID.TryGetValue(teID, out TileEntity te);
// The rest of the packet must be read even if it turns out the factory doesn't exist for whatever reason.
long time = reader.ReadInt64();
short cellStack = reader.ReadInt16();
if (exists && te is TEPowerCellFactory factory)
{
// Only clients update their timer from this packet. When a server receives this packet it ignores the time variable.
if (Main.netMode == NetmodeID.MultiplayerClient)
factory.Time = time;
factory._stack = cellStack;
return true;
}
return false;
}
}
}
+31
View File
@@ -0,0 +1,31 @@
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.TileEntities
{
public static class TileEntityTimeHandler
{
public static void Update()
{
// Specifically on multiplayer clients, manually update the time variables of Power Cell Factories every frame.
// This makes sure they animate. It will NOT produce cells; that code can only run server side.
// Time is manually synced from the server every time a cell is created, so even under heavy lag they cannot stay desynced indefinitely.
if (Main.netMode == NetmodeID.MultiplayerClient)
{
byte factoryType = ModContent.GetInstance<TEPowerCellFactory>().type;
var enumerator = TileEntity.ByID.Values.GetEnumerator();
do
{
TileEntity te = enumerator.Current;
if (te != null && te.type == factoryType)
{
TEPowerCellFactory factory = (TEPowerCellFactory)te;
++factory.Time;
}
} while (enumerator.MoveNext());
}
}
}
}
-172
View File
@@ -1,172 +0,0 @@
using CalamityMod.Items.Placeables;
using CalamityMod.TileEntities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Linq;
using Terraria;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles
{
public class DraedonFuelFactory : ModTile
{
public const int Width = 4;
public const int Height = 4;
public const int CellCreationDelay = 600;
public const int TotalFrames = 45;
public override void SetDefaults()
{
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = false;
Main.tileWaterDeath[Type] = false;
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2);
TileObjectData.newTile.Width = 4;
TileObjectData.newTile.Height = 4;
TileObjectData.newTile.Origin = new Point16(0, 3);
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 };
TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(ModContent.GetInstance<TEDraedonFuelFactory>().Hook_AfterPlacement, -1, 0, true);
TileObjectData.newTile.LavaDeath = false;
TileObjectData.addTile(Type);
ModTranslation name = CreateMapEntryName();
name.SetDefault("Fuel Factory");
AddMapEntry(new Color(67, 72, 81), name);
animationFrameHeight = 68;
}
public override bool CanExplode(int i, int j) => false;
public TEDraedonFuelFactory RetrieveTileEntity(int i, int j)
{
// This is very fucking important. ByID and ByPostion can apparently be different and as a result using both together is fucking unreliable.
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
if (!TileEntity.ByID.Any(tileEntity => tileEntity.Value.Position == new Point16(left, top)))
{
var factory = ModTileEntity.ConstructFromType(ModContent.TileEntityType<TEDraedonFuelFactory>());
factory.Position = new Point16(left, top);
TileEntity.ByID[TileEntity.ByID.Count] = factory;
}
return (TEDraedonFuelFactory)TileEntity.ByID.Where(tileEntity => tileEntity.Value.Position == new Point16(left, top)).First().Value;
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 226);
return false;
}
public override bool HasSmartInteract() => true;
public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType<DraedonsFuelFactoryItem>());
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
TEDraedonFuelFactory factory = RetrieveTileEntity(i, j);
if (factory.HeldItem.stack > 0)
{
Item.NewItem(new Vector2(i, j) * 16f, factory.HeldItem.type, factory.HeldItem.stack);
}
factory.Kill(left, top);
}
public override void AnimateTile(ref int frame, ref int frameCounter)
{
frameCounter++;
// After CellCreationDelay frames, start the fuel cell generation animation, and make one at the end.
// Otherwise, just continue waiting.
if (frameCounter % (CellCreationDelay + TotalFrames * 5 + 5) >= CellCreationDelay)
{
if (frameCounter % 5 == 4)
{
frame++;
if (frame >= TotalFrames)
{
frame = 0;
}
}
}
else
{
frame = TotalFrames - 1;
}
}
public override bool NewRightClick(int i, int j)
{
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
Player player = Main.LocalPlayer;
TEDraedonFuelFactory factory = RetrieveTileEntity(i, j);
Main.mouseRightRelease = false;
if (player.sign >= 0)
{
Main.PlaySound(SoundID.MenuClose);
player.sign = -1;
Main.editSign = false;
Main.npcChatText = "";
}
if (Main.editChest)
{
Main.PlaySound(SoundID.MenuTick);
Main.editChest = false;
Main.npcChatText = "";
}
if (player.Calamity().CurrentlyViewedFactory == factory)
{
player.Calamity().CurrentlyViewedFactory = null;
player.Calamity().CurrentlyViewedFactoryX = player.Calamity().CurrentlyViewedFactoryY = -1;
Main.PlaySound(SoundID.MenuClose);
}
else
{
// Ensure that the UI position is always centered and above the tile.
player.Calamity().CurrentlyViewedFactoryX = left * 16 + 16;
player.Calamity().CurrentlyViewedFactoryY = top * 16;
player.Calamity().CurrentlyViewedFactory = factory;
Main.playerInventory = true;
Main.recBigList = false;
Main.PlaySound(player.Calamity().CurrentlyViewedFactory == null ? SoundID.MenuOpen : SoundID.MenuTick);
}
Recipe.FindRecipes();
return true;
}
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Tile trackTile = Main.tile[i, j];
int xPos = Main.tile[i, j].frameX;
int yPos = Main.tile[i, j].frameY;
xPos += Main.tileFrame[trackTile.type] / 15 * 72;
yPos += Main.tileFrame[trackTile.type] % 15 * 72;
Texture2D glowmask = ModContent.GetTexture("CalamityMod/Tiles/DraedonFuelFactory");
Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset;
Color drawColor = Lighting.GetColor(i, j);
if (!trackTile.halfBrick() && trackTile.slope() == 0)
spriteBatch.Draw(glowmask, drawOffset, new Rectangle(xPos, yPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
else if (trackTile.halfBrick())
spriteBatch.Draw(glowmask, drawOffset + Vector2.UnitY * 8f, new Rectangle(xPos, yPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
return false;
}
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ namespace CalamityMod.Tiles
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType<DraedonsFuelFactoryItem>());
Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType<PowerCellFactoryItem>());
}
}
}
+190
View File
@@ -0,0 +1,190 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.Items.Placeables;
using CalamityMod.TileEntities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.Enums;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles
{
public class PowerCellFactory : ModTile
{
public const int Width = 4;
public const int Height = 4;
public const int OriginOffsetX = 1;
public const int OriginOffsetY = 3;
// The number of animation frames is 45. Cells are created on animation frame 42.
public const int TotalFrames = 45;
private const int FramesPerColumn = 15;
public const int AnimationFramerate = 5;
// 45 * 5 + 675 = 900 = 15 seconds per complete cell cycle.
// There are this many frames of downtime between cell creations.
public const int BetweenCellDowntime = 675;
// The cell is created on this animation frame.
public const int CellCreateFrame = 42;
// With a delay of this many extra frames after that animation frame starts.
public const int MagicFrameDelay = AnimationFramerate - 1;
public override void SetDefaults()
{
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
Main.tileNoAttach[Type] = true;
Main.tileLavaDeath[Type] = false;
Main.tileWaterDeath[Type] = false;
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2);
TileObjectData.newTile.Width = 4;
TileObjectData.newTile.Height = 4;
TileObjectData.newTile.Origin = new Point16(OriginOffsetX, OriginOffsetY);
TileObjectData.newTile.AnchorBottom = new AnchorData(AnchorType.SolidTile | AnchorType.SolidWithTop | AnchorType.SolidSide, TileObjectData.newTile.Width, 0);
TileObjectData.newTile.CoordinateHeights = new int[] { 16, 16, 16, 16 };
TileObjectData.newTile.LavaDeath = false;
// When this tile is placed, it places the power cell factory tile entity.
ModTileEntity te = ModContent.GetInstance<TEPowerCellFactory>();
TileObjectData.newTile.HookPostPlaceMyPlayer = new PlacementHook(te.Hook_AfterPlacement, -1, 0, true);
TileObjectData.addTile(Type);
ModTranslation name = CreateMapEntryName();
name.SetDefault("Power Cell Factory");
AddMapEntry(new Color(67, 72, 81), name);
animationFrameHeight = 68;
}
public override bool CanExplode(int i, int j) => false;
// Finds the Tile Entity associated with the Power Cell Factory tile that the player clicked on.
// This can return null, so code using this function needs to be prepared for that.
public TEPowerCellFactory FindTileEntity(int i, int j)
{
// Find the top left corner of the FrameImportant tile that the player clicked on in the world.
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
byte factoryType = ModContent.GetInstance<TEPowerCellFactory>().type;
bool exists = TileEntity.ByPosition.TryGetValue(new Point16(left, top), out TileEntity te);
return exists && te.type == factoryType ? (TEPowerCellFactory)te : null;
}
public override bool CreateDust(int i, int j, ref int type)
{
Dust.NewDust(new Vector2(i, j) * 16f, 16, 16, 226);
return false;
}
public override bool HasSmartInteract() => true;
public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
// Drop the factory itself.
Item.NewItem(i * 16, j * 16, 32, 32, ModContent.ItemType<PowerCellFactoryItem>());
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
// Drop any cells contained in the factory.
TEPowerCellFactory factory = FindTileEntity(i, j);
int numCells = factory?.CellStack ?? 0;
if (numCells > 0)
Item.NewItem(new Vector2(i, j) * 16f, ModContent.ItemType<PowerCell>(), numCells);
factory?.Kill(left, top);
}
public override bool NewRightClick(int i, int j)
{
int left = i - Main.tile[i, j].frameX % (Width * 18) / 18;
int top = j - Main.tile[i, j].frameY % (Height * 18) / 18;
TEPowerCellFactory thisFactory = FindTileEntity(i, j);
Player player = Main.LocalPlayer;
Main.mouseRightRelease = false;
// If a sign or chest was in use previously, close those GUIs.
if (player.sign >= 0)
{
Main.PlaySound(SoundID.MenuClose);
player.sign = -1;
Main.editSign = false;
Main.npcChatText = "";
}
if (Main.editChest)
{
Main.PlaySound(SoundID.MenuTick);
Main.editChest = false;
Main.npcChatText = "";
}
if (player.chest >= 0)
player.chest = -1;
CalamityPlayer mp = player.Calamity();
TEPowerCellFactory viewedFactory = mp.CurrentlyViewedFactory;
// If this is the factory the player is currently looking at OR this factory is doesn't really exist, close the GUI.
if (viewedFactory != null && (thisFactory is null || thisFactory.ID == viewedFactory.ID))
{
mp.CurrentlyViewedFactory = null;
mp.CurrentlyViewedFactoryX = mp.CurrentlyViewedFactoryY = -1;
Main.PlaySound(SoundID.MenuClose);
}
// Otherwise, "switch to" this factory when it exists. This can be either opening the GUI from nothing, or just opening a different factory.
else if(thisFactory != null)
{
// Play a sound depending on whether the player had another factory open previously.
Main.PlaySound(mp.CurrentlyViewedFactory is null ? SoundID.MenuOpen : SoundID.MenuTick);
// Ensure that the UI position is always centered and above the tile.
mp.CurrentlyViewedFactoryX = left * 16 + 16;
mp.CurrentlyViewedFactoryY = top * 16;
mp.CurrentlyViewedFactory = thisFactory;
Main.playerInventory = true;
Main.recBigList = false;
}
Recipe.FindRecipes();
return true;
}
// All tile drawcode is done manually because the tile's animation is controlled by a tile entity.
public override bool PreDraw(int i, int j, SpriteBatch spriteBatch)
{
Tile theTile = Main.tile[i, j];
// These offsets start as the tile offsets, i.e. which sub-tile of the FrameImportant structure this specific location is.
int frameXPos = Main.tile[i, j].frameX;
int frameYPos = Main.tile[i, j].frameY;
// Grab the tile entity because its internal timer controls the animation.
TEPowerCellFactory factory = FindTileEntity(i, j);
int frameIndex = factory?.AnimationFrame ?? TotalFrames - 1;
frameXPos += frameIndex / FramesPerColumn * 72;
frameYPos += frameIndex % FramesPerColumn * 72;
Texture2D tex = ModContent.GetTexture("CalamityMod/Tiles/PowerCellFactory");
Vector2 offset = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange);
Vector2 drawOffset = new Vector2(i * 16 - Main.screenPosition.X, j * 16 - Main.screenPosition.Y) + offset;
Color drawColor = Lighting.GetColor(i, j);
if (!theTile.halfBrick() && theTile.slope() == 0)
spriteBatch.Draw(tex, drawOffset, new Rectangle(frameXPos, frameYPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
else if (theTile.halfBrick())
spriteBatch.Draw(tex, drawOffset + Vector2.UnitY * 8f, new Rectangle(frameXPos, frameYPos, 16, 16), drawColor, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, 0.0f);
return false;
}
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

+174
View File
@@ -0,0 +1,174 @@
using CalamityMod.CalPlayer;
using CalamityMod.Items.DraedonMisc;
using CalamityMod.TileEntities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI.Chat;
namespace CalamityMod.UI
{
public class CellFactoryUI
{
public const float MaxPlayerDistance = 160f;
public const float IconScale = 0.7f;
private const int GuiWidth = 39;
private const int GuiHeight = 39;
public static void Draw(SpriteBatch spriteBatch)
{
Player p = Main.LocalPlayer;
CalamityPlayer mp = Main.LocalPlayer.Calamity();
TEPowerCellFactory factory = mp.CurrentlyViewedFactory;
// The UI only draws if the player is viewing a factory.
if (factory is null)
return;
// If the player's inventory isn't open, or they have a chest open, immediately destroy this UI.
if (!Main.playerInventory || p.chest != -1)
{
mp.CurrentlyViewedFactory = null;
return;
}
// If the player is too far away from their viewed factory, immediately destroy this UI and play the menu close sound.
Vector2 factoryWorldCenter = factory.Position.ToWorldCoordinates(32f, 32f);
if (Vector2.DistanceSquared(p.Center, factoryWorldCenter) > MaxPlayerDistance * MaxPlayerDistance)
{
Main.PlaySound(SoundID.MenuClose);
mp.CurrentlyViewedFactory = null;
return;
}
// What item is currently in the UI item slot? It's normally nothing, but it could be power cells.
int powercellID = ModContent.ItemType<PowerCell>();
Item powercell = new Item();
powercell.TurnToAir();
if (factory.CellStack > 0)
{
powercell.SetDefaults(powercellID);
powercell.stack = factory.CellStack;
}
Vector2 position = new Vector2(mp.CurrentlyViewedFactoryX, mp.CurrentlyViewedFactoryY);
// Draw the factory's stored item as an inventory slot.
DrawItemSlot(spriteBatch, ref powercell, position + new Vector2(16f, -34f) - Main.screenPosition);
int width = GuiWidth, height = GuiHeight;
Rectangle mouseRectangle = new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 2, 2);
Rectangle drawnItemRectangle = new Rectangle((int)position.X, (int)position.Y - 60, width, height);
// If the player's cursor is over the slot and there are power cells, then interaction with the UI is possible.
if (mouseRectangle.Intersects(drawnItemRectangle) && powercell.stack > 0)
{
Main.HoverItem.SetDefaults(powercell.type);
// If the slot is clicked, try to grab cells from the factory using both "current items" that a player can have.
int cellsGrabbed = 0;
bool shiftClicked = false;
if (Main.mouseLeft)
{
// If the player is holding shift and has space for the power cells, just spawn all of them on his or her face.
if (Main.keyState.PressingShift() && p.ItemSpace(powercell))
{
cellsGrabbed = powercell.stack;
shiftClicked = true;
DropHelper.DropItem(p, powercellID, cellsGrabbed);
}
else
{
cellsGrabbed = TryGrabCell(ref Main.mouseItem, ref powercell);
if (cellsGrabbed == 0)
cellsGrabbed = TryGrabCell(ref p.inventory[Main.LocalPlayer.selectedItem], ref powercell);
}
}
// If any cells were actually grabbed, take them from the factory's stockpile.
// Using the CellStack property setter automatically sends the correct packet to update the entity server side.
if (cellsGrabbed > 0)
{
factory.CellStack -= (short)cellsGrabbed;
// Play a sound, but ONLY if the player didn't shift click.
// If they did, they're going to hear the item be picked up in a few frames anyway because it spawned on their face.
if (!shiftClicked)
Main.PlaySound(SoundID.Grab);
}
// Since HoverItem is active, we don't need to input anything into this method.
Main.instance.MouseTextHackZoom("");
// Specifically do not block mouse input if holding a pickaxe, so that you can mine blocks behind the UI.
Main.blockMouse = Main.LocalPlayer.ActiveItem().pick <= 0;
}
}
public static void DrawItemSlot(SpriteBatch spriteBatch, ref Item item, Vector2 drawPosition)
{
Texture2D slotBackgroundTex = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CellFactoryItemSlot_Empty");
// This check is done twice because the draw order matters. We want to draw the background icon before any text.
if (item.stack > 0)
slotBackgroundTex = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/CellFactoryItemSlot_Filled");
spriteBatch.Draw(slotBackgroundTex, drawPosition, null, Color.White, 0f, slotBackgroundTex.Size() * 0.5f, IconScale, SpriteEffects.None, 0f);
if (item.stack > 0)
{
float inventoryScale = Main.inventoryScale;
Vector2 numberOffset = slotBackgroundTex.Size() * 0.2f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch,
Main.fontItemStack,
item.stack.ToString(),
drawPosition + numberOffset * inventoryScale,
Color.White,
0f,
Vector2.Zero,
new Vector2(inventoryScale),
-1f,
inventoryScale);
}
}
// Returns the number of cells grabbed.
public static int TryGrabCell(ref Item playerHandItem, ref Item cell)
{
Main.playerInventory = true;
Main.recBigList = false;
// You can only grab cells if you're stacking them with other cells or holding nothing.
if (playerHandItem.IsAir)
{
playerHandItem.SetDefaults(cell.type);
playerHandItem.stack = cell.stack;
cell.TurnToAir();
return playerHandItem.stack;
}
// You can grab cells while holding cells, but your held stack can't go over 999.
if (playerHandItem.type == cell.type)
{
int spaceLeft = 999 - playerHandItem.stack;
// If there's more cells than space left, take as many as possible. Otherwise take all the cells.
int cellsToTake = Math.Min(cell.stack, spaceLeft);
if (cellsToTake <= 0)
return 0;
playerHandItem.stack += cellsToTake;
cell.stack -= cellsToTake;
if (cell.stack == 0)
cell.TurnToAir();
return cellsToTake;
}
return 0;
}
}
}
-90
View File
@@ -1,90 +0,0 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.UI.Chat;
namespace CalamityMod.UI
{
public class DraedonsFactoryUI
{
public const float IconScale = 0.7f;
public static void Draw(SpriteBatch spriteBatch)
{
if (Main.LocalPlayer.Calamity().CurrentlyViewedFactory != null)
{
var time = Terraria.DataStructures.TileEntity.ByID;
var stack = Main.LocalPlayer.Calamity().CurrentlyViewedFactory;
if (Main.LocalPlayer.chest != -1)
{
Main.LocalPlayer.Calamity().CurrentlyViewedFactory = null;
return;
}
Item fuel = Main.LocalPlayer.Calamity().CurrentlyViewedFactory.HeldItem;
Vector2 position = new Vector2(Main.LocalPlayer.Calamity().CurrentlyViewedFactoryX, Main.LocalPlayer.Calamity().CurrentlyViewedFactoryY);
// Draw the fuel as an inventory slot.
DrawItemSlot(spriteBatch, ref fuel, position + new Vector2(16f, -34f) - Main.screenPosition);
int width = 39, height = 39;
Rectangle mouseRectangle = new Rectangle((int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, 2, 2);
Rectangle drawnItemRectangle = new Rectangle((int)position.X, (int)position.Y - 60, width, height);
if (mouseRectangle.Intersects(drawnItemRectangle) && fuel.stack > 0)
{
Main.HoverItem.SetDefaults(fuel.type);
// Take items from the chest if the item is clicked.
bool alreadyUsedItem = UseFuel(ref Main.mouseItem, ref fuel);
if (!alreadyUsedItem)
UseFuel(ref Main.LocalPlayer.inventory[Main.LocalPlayer.selectedItem], ref fuel);
Main.instance.MouseTextHackZoom(""); // Since HoverItem is active, we don't need to input anything into this method.
Main.blockMouse = Main.LocalPlayer.ActiveItem().pick <= 0; // Block mouse input if hovering over the item UI and not holding a pickaxe.
}
}
}
public static void DrawItemSlot(SpriteBatch spriteBatch, ref Item item, Vector2 drawPosition)
{
Texture2D iconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonFuelCellUISlot");
// This check is done twice because the draw order matters. We want to draw the background icon before any text.
if (item.stack > 0)
iconTexture = ModContent.GetTexture("CalamityMod/ExtraTextures/UI/DraedonFuelCellUISlotFilled");
spriteBatch.Draw(iconTexture, drawPosition, null, Color.White, 0f, iconTexture.Size() * 0.5f, IconScale, SpriteEffects.None, 0f);
if (item.stack > 0)
{
float inventoryScale = Main.inventoryScale;
Vector2 numberOffset = iconTexture.Size() * 0.2f;
ChatManager.DrawColorCodedStringWithShadow(spriteBatch,
Main.fontItemStack,
item.stack.ToString(),
drawPosition + numberOffset * inventoryScale,
Color.White,
0f,
Vector2.Zero,
new Vector2(inventoryScale),
-1f,
inventoryScale);
}
}
public static bool UseFuel(ref Item itemToUse, ref Item fuel)
{
if (Main.mouseLeft)
{
Main.playerInventory = true;
Main.recBigList = false;
if (itemToUse.type == fuel.type || itemToUse.type == ItemID.None)
{
itemToUse = fuel.Clone();
int stack = itemToUse.stack;
itemToUse.SetDefaults(itemToUse.type);
itemToUse.stack = stack;
fuel.stack = 0;
return true;
}
}
return false;
}
}
}
+2534 -2592
View File
File diff suppressed because it is too large. Load diff