2026-04-12 20:39:16 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using Terraria;
|
|
|
|
|
using Terraria.DataStructures;
|
|
|
|
|
using Terraria.Graphics.Effects;
|
|
|
|
|
using Terraria.ID;
|
|
|
|
|
using Terraria.ModLoader;
|
|
|
|
|
|
|
|
|
|
namespace smoothDeathTransitions {
|
|
|
|
|
public class TransitionPlayer : ModPlayer {
|
|
|
|
|
|
|
|
|
|
/*public override void Kill(double damage, int hitDirection, bool pvp, PlayerDeathReason damageSource)
|
|
|
|
|
{
|
|
|
|
|
Player.respawnTimer=150; // For testing
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
public string GetBiomeSpecificTransitions(){
|
|
|
|
|
// This code is going to suck.
|
|
|
|
|
if (ModLoader.TryGetMod("CalamityMod", out Mod CalamityMod)){
|
|
|
|
|
if((bool)CalamityMod.Call("GetInZone", Player, "SunkenSea")
|
|
|
|
|
|| (bool)CalamityMod.Call("GetInZone", Player, "Abyss")
|
|
|
|
|
|| (bool)CalamityMod.Call("GetInZone", Player, "SulphurousSea")) return "Flooding";
|
|
|
|
|
if((bool)CalamityMod.Call("GetInZone", Player, "AstralInfection"))return "Winding";
|
|
|
|
|
}
|
|
|
|
|
if(ModLoader.TryGetMod("TheConfectionRebirth", out Mod ConfectionMod) && ConfectionMod.TryFind("ConfectionBiome",out ModBiome ConfectionBiome)){
|
|
|
|
|
if(Player.InModBiome(ConfectionBiome)){
|
|
|
|
|
if(ModContent.GetInstance<TransitionsConfig>().PridefulHallow)return "Prideful";
|
|
|
|
|
return "Wonder";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(Player.ZoneShimmer)return "Starry";
|
|
|
|
|
if(Player.ZoneDungeon || Player.ZoneLihzhardTemple)return "Doors";
|
|
|
|
|
if(Player.ZoneJungle)return "Collapse";
|
|
|
|
|
if(Player.ZoneCorrupt)return "Winding";
|
|
|
|
|
if(Player.ZoneCrimson)return "Jaws";
|
|
|
|
|
if(Player.ZoneHallow){
|
|
|
|
|
if(ModContent.GetInstance<TransitionsConfig>().PridefulHallow)return "Prideful";
|
|
|
|
|
return "Loving";
|
|
|
|
|
}
|
|
|
|
|
if(Player.ZoneSnow)return "Wonder";
|
|
|
|
|
if(Player.ZoneBeach)return "Flooding";
|
|
|
|
|
if(Player.ZoneSkyHeight)return "Rising";
|
|
|
|
|
if(Player.ZoneNormalUnderground || Player.ZoneNormalCaverns)return "Circle";
|
|
|
|
|
if(Player.ZoneUnderworldHeight)return "Falling";
|
|
|
|
|
return ModContent.GetInstance<TransitionsConfig>().DefaultTransition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int transitionTicker = 0;
|
2026-04-13 11:40:44 +00:00
|
|
|
public int transitionTime = ModContent.GetInstance<TransitionsConfig>().transitionTime;
|
2026-04-12 20:39:16 +00:00
|
|
|
public string transitionChosen;
|
|
|
|
|
|
|
|
|
|
public override void PreUpdate()
|
|
|
|
|
{
|
|
|
|
|
// Check if appropriate conditions
|
|
|
|
|
if(Main.netMode != NetmodeID.Server){
|
|
|
|
|
// Check if the time is nigh
|
|
|
|
|
if(transitionTicker==0 && Player.dead && Player.respawnTimer<transitionTime/2){
|
|
|
|
|
transitionTicker=transitionTime;
|
|
|
|
|
if(ModContent.GetInstance<TransitionsConfig>().UseBiomeSpecificTransitions){transitionChosen=GetBiomeSpecificTransitions();}
|
|
|
|
|
else{transitionChosen=ModContent.GetInstance<TransitionsConfig>().DefaultTransition;}
|
|
|
|
|
if(!Filters.Scene[transitionChosen].IsActive()){
|
|
|
|
|
Filters.Scene.Activate(transitionChosen, Player.Center).GetShader();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(transitionTicker>0){
|
|
|
|
|
--transitionTicker;
|
|
|
|
|
float progress = ((float)(transitionTime-transitionTicker)/(float)transitionTime)*100f; // 0-100%
|
|
|
|
|
Filters.Scene[transitionChosen].GetShader().UseProgress(progress);
|
|
|
|
|
if(transitionTicker==0){
|
2026-04-13 11:40:44 +00:00
|
|
|
transitionTime=ModContent.GetInstance<TransitionsConfig>().transitionTime;
|
2026-04-12 20:39:16 +00:00
|
|
|
Filters.Scene[transitionChosen].Deactivate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|