Terraria 1.4.0.5 Source Code
This commit is contained in:
commit
05205f009e
1059 changed files with 563450 additions and 0 deletions
1219
GameContent/Skies/AmbientSky.cs
Normal file
1219
GameContent/Skies/AmbientSky.cs
Normal file
File diff suppressed because it is too large
Load diff
72
GameContent/Skies/BlizzardSky.cs
Normal file
72
GameContent/Skies/BlizzardSky.cs
Normal file
|
@ -0,0 +1,72 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.BlizzardSky
|
||||
// Assembly: Terraria, Version=1.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;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class BlizzardSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
private float _opacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
if (this._isLeaving)
|
||||
{
|
||||
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity >= 0.0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
this._opacity = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity <= 1.0)
|
||||
return;
|
||||
this._opacity = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
|
||||
return;
|
||||
float num = Math.Min(1f, Main.cloudAlpha * 2f);
|
||||
Color color = new Color(new Vector4(1f) * Main.ColorOfTheSkies.ToVector4()) * this._opacity * 0.7f * num;
|
||||
spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._opacity = 0.0f;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
}
|
||||
}
|
241
GameContent/Skies/CreditsRoll/Actions.cs
Normal file
241
GameContent/Skies/CreditsRoll/Actions.cs
Normal file
|
@ -0,0 +1,241 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRoll.Actions
|
||||
// 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.Skies.CreditsRoll
|
||||
{
|
||||
public class Actions
|
||||
{
|
||||
public class NPCs
|
||||
{
|
||||
public interface INPCAction : ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
}
|
||||
|
||||
public class Fade : Actions.NPCs.INPCAction, ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
private int _duration;
|
||||
private int _alphaPerFrame;
|
||||
private float _delay;
|
||||
|
||||
public Fade(int alphaPerFrame)
|
||||
{
|
||||
this._duration = 0;
|
||||
this._alphaPerFrame = alphaPerFrame;
|
||||
}
|
||||
|
||||
public Fade(int alphaPerFrame, int duration)
|
||||
{
|
||||
this._duration = duration;
|
||||
this._alphaPerFrame = alphaPerFrame;
|
||||
}
|
||||
|
||||
public void BindTo(NPC obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => this._duration;
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
|
||||
public void ApplyTo(NPC obj, float localTimeForObj)
|
||||
{
|
||||
if ((double) localTimeForObj < (double) this._delay)
|
||||
return;
|
||||
if (this._duration == 0)
|
||||
{
|
||||
obj.alpha = Utils.Clamp<int>(obj.alpha + this._alphaPerFrame, 0, (int) byte.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
float num = localTimeForObj - this._delay;
|
||||
if ((double) num > (double) this._duration)
|
||||
num = (float) this._duration;
|
||||
obj.alpha = Utils.Clamp<int>(obj.alpha + (int) num * this._alphaPerFrame, 0, (int) byte.MaxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Move : Actions.NPCs.INPCAction, ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
private Vector2 _offsetPerFrame;
|
||||
private int _duration;
|
||||
private float _delay;
|
||||
|
||||
public Move(Vector2 offsetPerFrame, int durationInFrames)
|
||||
{
|
||||
this._offsetPerFrame = offsetPerFrame;
|
||||
this._duration = durationInFrames;
|
||||
}
|
||||
|
||||
public void BindTo(NPC obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => this._duration;
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
|
||||
public void ApplyTo(NPC obj, float localTimeForObj)
|
||||
{
|
||||
if ((double) localTimeForObj < (double) this._delay)
|
||||
return;
|
||||
float num = localTimeForObj - this._delay;
|
||||
if ((double) num > (double) this._duration)
|
||||
num = (float) this._duration;
|
||||
NPC npc = obj;
|
||||
npc.position = npc.position + this._offsetPerFrame * num;
|
||||
obj.velocity = this._offsetPerFrame;
|
||||
if ((double) this._offsetPerFrame.X == 0.0)
|
||||
return;
|
||||
obj.direction = obj.spriteDirection = (double) this._offsetPerFrame.X > 0.0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class Wait : Actions.NPCs.INPCAction, ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
private int _duration;
|
||||
private float _delay;
|
||||
|
||||
public Wait(int durationInFrames) => this._duration = durationInFrames;
|
||||
|
||||
public void BindTo(NPC obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => this._duration;
|
||||
|
||||
public void ApplyTo(NPC obj, float localTimeForObj)
|
||||
{
|
||||
if ((double) localTimeForObj < (double) this._delay)
|
||||
return;
|
||||
obj.velocity = Vector2.Zero;
|
||||
}
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
}
|
||||
|
||||
public class LookAt : Actions.NPCs.INPCAction, ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
private int _direction;
|
||||
private float _delay;
|
||||
|
||||
public LookAt(int direction) => this._direction = direction;
|
||||
|
||||
public void BindTo(NPC obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => 0;
|
||||
|
||||
public void ApplyTo(NPC obj, float localTimeForObj)
|
||||
{
|
||||
if ((double) localTimeForObj < (double) this._delay)
|
||||
return;
|
||||
obj.direction = obj.spriteDirection = this._direction;
|
||||
}
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
}
|
||||
|
||||
public class PartyHard : Actions.NPCs.INPCAction, ICreditsRollSegmentAction<NPC>
|
||||
{
|
||||
public void BindTo(NPC obj)
|
||||
{
|
||||
obj.ForcePartyHatOn = true;
|
||||
obj.UpdateAltTexture();
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => 0;
|
||||
|
||||
public void ApplyTo(NPC obj, float localTimeForObj)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetDelay(float delay)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Sprites
|
||||
{
|
||||
public interface ISpriteAction : ICreditsRollSegmentAction<Segments.LooseSprite>
|
||||
{
|
||||
}
|
||||
|
||||
public class Fade :
|
||||
Actions.Sprites.ISpriteAction,
|
||||
ICreditsRollSegmentAction<Segments.LooseSprite>
|
||||
{
|
||||
private int _duration;
|
||||
private float _opacityTarget;
|
||||
private float _delay;
|
||||
|
||||
public Fade(float opacityTarget)
|
||||
{
|
||||
this._duration = 0;
|
||||
this._opacityTarget = opacityTarget;
|
||||
}
|
||||
|
||||
public Fade(float opacityTarget, int duration)
|
||||
{
|
||||
this._duration = duration;
|
||||
this._opacityTarget = opacityTarget;
|
||||
}
|
||||
|
||||
public void BindTo(Segments.LooseSprite obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => this._duration;
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
|
||||
public void ApplyTo(Segments.LooseSprite obj, float localTimeForObj)
|
||||
{
|
||||
if ((double) localTimeForObj < (double) this._delay)
|
||||
return;
|
||||
if (this._duration == 0)
|
||||
{
|
||||
obj.CurrentOpacity = this._opacityTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
float t = localTimeForObj - this._delay;
|
||||
if ((double) t > (double) this._duration)
|
||||
t = (float) this._duration;
|
||||
obj.CurrentOpacity = MathHelper.Lerp(obj.CurrentOpacity, this._opacityTarget, Utils.GetLerpValue(0.0f, (float) this._duration, t, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Wait :
|
||||
Actions.Sprites.ISpriteAction,
|
||||
ICreditsRollSegmentAction<Segments.LooseSprite>
|
||||
{
|
||||
private int _duration;
|
||||
private float _delay;
|
||||
|
||||
public Wait(int durationInFrames) => this._duration = durationInFrames;
|
||||
|
||||
public void BindTo(Segments.LooseSprite obj)
|
||||
{
|
||||
}
|
||||
|
||||
public int ExpectedLengthOfActionInFrames => this._duration;
|
||||
|
||||
public void ApplyTo(Segments.LooseSprite obj, float localTimeForObj)
|
||||
{
|
||||
double delay = (double) this._delay;
|
||||
}
|
||||
|
||||
public void SetDelay(float delay) => this._delay = delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
GameContent/Skies/CreditsRoll/CreditsRollInfo.cs
Normal file
18
GameContent/Skies/CreditsRoll/CreditsRollInfo.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRoll.CreditsRollInfo
|
||||
// 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.Skies.CreditsRoll
|
||||
{
|
||||
public struct CreditsRollInfo
|
||||
{
|
||||
public SpriteBatch SpriteBatch;
|
||||
public Vector2 AnchorPositionOnScreen;
|
||||
public int TimeInAnimation;
|
||||
}
|
||||
}
|
15
GameContent/Skies/CreditsRoll/ICreditsRollSegment.cs
Normal file
15
GameContent/Skies/CreditsRoll/ICreditsRollSegment.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRoll.ICreditsRollSegment
|
||||
// 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.Skies.CreditsRoll
|
||||
{
|
||||
public interface ICreditsRollSegment
|
||||
{
|
||||
float DedicatedTimeNeeded { get; }
|
||||
|
||||
void Draw(ref CreditsRollInfo info);
|
||||
}
|
||||
}
|
19
GameContent/Skies/CreditsRoll/ICreditsRollSegmentAction`1.cs
Normal file
19
GameContent/Skies/CreditsRoll/ICreditsRollSegmentAction`1.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRoll.ICreditsRollSegmentAction`1
|
||||
// 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.Skies.CreditsRoll
|
||||
{
|
||||
public interface ICreditsRollSegmentAction<T>
|
||||
{
|
||||
void BindTo(T obj);
|
||||
|
||||
int ExpectedLengthOfActionInFrames { get; }
|
||||
|
||||
void ApplyTo(T obj, float localTimeForObj);
|
||||
|
||||
void SetDelay(float delay);
|
||||
}
|
||||
}
|
256
GameContent/Skies/CreditsRoll/Segments.cs
Normal file
256
GameContent/Skies/CreditsRoll/Segments.cs
Normal file
|
@ -0,0 +1,256 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRoll.Segments
|
||||
// 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;
|
||||
using System.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.Localization;
|
||||
using Terraria.UI.Chat;
|
||||
|
||||
namespace Terraria.GameContent.Skies.CreditsRoll
|
||||
{
|
||||
public class Segments
|
||||
{
|
||||
private const float PixelsToRollUpPerFrame = 0.5f;
|
||||
|
||||
public class LocalizedTextSegment : ICreditsRollSegment
|
||||
{
|
||||
private const int PixelsForALine = 120;
|
||||
private LocalizedText _text;
|
||||
private float _timeToShowPeak;
|
||||
|
||||
public float DedicatedTimeNeeded => 240f;
|
||||
|
||||
public LocalizedTextSegment(float timeInAnimation, string textKey)
|
||||
{
|
||||
this._text = Language.GetText(textKey);
|
||||
this._timeToShowPeak = timeInAnimation;
|
||||
}
|
||||
|
||||
public void Draw(ref CreditsRollInfo info)
|
||||
{
|
||||
float num1 = 400f;
|
||||
float num2 = 400f;
|
||||
int timeInAnimation = info.TimeInAnimation;
|
||||
float num3 = Utils.GetLerpValue(this._timeToShowPeak - num1, this._timeToShowPeak, (float) timeInAnimation, true) * Utils.GetLerpValue(this._timeToShowPeak + num2, this._timeToShowPeak, (float) timeInAnimation, true);
|
||||
if ((double) num3 <= 0.0)
|
||||
return;
|
||||
float num4 = this._timeToShowPeak - (float) timeInAnimation;
|
||||
Vector2 position = info.AnchorPositionOnScreen + new Vector2(0.0f, num4 * 0.5f);
|
||||
float Hue = (float) ((double) this._timeToShowPeak / 100.0 % 1.0);
|
||||
if ((double) Hue < 0.0)
|
||||
++Hue;
|
||||
Color rgb = Main.hslToRgb(Hue, 1f, 0.5f);
|
||||
string text = this._text.Value;
|
||||
Vector2 origin = FontAssets.DeathText.Value.MeasureString(text) * 0.5f;
|
||||
float num5 = (float) (1.0 - (1.0 - (double) num3) * (1.0 - (double) num3));
|
||||
ChatManager.DrawColorCodedStringShadow(info.SpriteBatch, FontAssets.DeathText.Value, text, position, rgb * num5 * num5 * 0.25f, 0.0f, origin, Vector2.One);
|
||||
ChatManager.DrawColorCodedString(info.SpriteBatch, FontAssets.DeathText.Value, text, position, Color.White * num5, 0.0f, origin, Vector2.One);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class ACreditsRollSegmentWithActions<T> : ICreditsRollSegment
|
||||
{
|
||||
private int _dedicatedTimeNeeded;
|
||||
private int _lastDedicatedTimeNeeded;
|
||||
protected int _targetTime;
|
||||
private List<ICreditsRollSegmentAction<T>> _actions = new List<ICreditsRollSegmentAction<T>>();
|
||||
|
||||
public float DedicatedTimeNeeded => (float) this._dedicatedTimeNeeded;
|
||||
|
||||
public ACreditsRollSegmentWithActions(int targetTime)
|
||||
{
|
||||
this._targetTime = targetTime;
|
||||
this._dedicatedTimeNeeded = 0;
|
||||
}
|
||||
|
||||
protected void ProcessActions(T obj, float localTimeForObject)
|
||||
{
|
||||
for (int index = 0; index < this._actions.Count; ++index)
|
||||
this._actions[index].ApplyTo(obj, localTimeForObject);
|
||||
}
|
||||
|
||||
public Segments.ACreditsRollSegmentWithActions<T> Then(
|
||||
ICreditsRollSegmentAction<T> act)
|
||||
{
|
||||
this.Bind(act);
|
||||
act.SetDelay((float) this._dedicatedTimeNeeded);
|
||||
this._actions.Add(act);
|
||||
this._lastDedicatedTimeNeeded = this._dedicatedTimeNeeded;
|
||||
this._dedicatedTimeNeeded += act.ExpectedLengthOfActionInFrames;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Segments.ACreditsRollSegmentWithActions<T> With(
|
||||
ICreditsRollSegmentAction<T> act)
|
||||
{
|
||||
this.Bind(act);
|
||||
act.SetDelay((float) this._lastDedicatedTimeNeeded);
|
||||
this._actions.Add(act);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected abstract void Bind(ICreditsRollSegmentAction<T> act);
|
||||
|
||||
public abstract void Draw(ref CreditsRollInfo info);
|
||||
}
|
||||
|
||||
public class NPCSegment : Segments.ACreditsRollSegmentWithActions<NPC>
|
||||
{
|
||||
private NPC _npc;
|
||||
private Vector2 _anchorOffset;
|
||||
private Vector2 _normalizedOriginForHitbox;
|
||||
|
||||
public NPCSegment(
|
||||
int targetTime,
|
||||
int npcId,
|
||||
Vector2 anchorOffset,
|
||||
Vector2 normalizedNPCHitboxOrigin)
|
||||
: base(targetTime)
|
||||
{
|
||||
this._npc = new NPC();
|
||||
this._npc.SetDefaults(npcId);
|
||||
this._npc.IsABestiaryIconDummy = true;
|
||||
this._anchorOffset = anchorOffset;
|
||||
this._normalizedOriginForHitbox = normalizedNPCHitboxOrigin;
|
||||
}
|
||||
|
||||
protected override void Bind(ICreditsRollSegmentAction<NPC> act) => act.BindTo(this._npc);
|
||||
|
||||
public override void Draw(ref CreditsRollInfo info)
|
||||
{
|
||||
if ((double) info.TimeInAnimation > (double) this._targetTime + (double) this.DedicatedTimeNeeded)
|
||||
return;
|
||||
this.ResetNPCAnimation(ref info);
|
||||
this.ProcessActions(this._npc, (float) (info.TimeInAnimation - this._targetTime));
|
||||
if (this._npc.alpha >= (int) byte.MaxValue)
|
||||
return;
|
||||
this._npc.FindFrame();
|
||||
Main.instance.DrawNPCDirect(info.SpriteBatch, this._npc, this._npc.behindTiles, Vector2.Zero);
|
||||
}
|
||||
|
||||
private void ResetNPCAnimation(ref CreditsRollInfo info)
|
||||
{
|
||||
this._npc.position = info.AnchorPositionOnScreen + this._anchorOffset - this._npc.Size * this._normalizedOriginForHitbox;
|
||||
this._npc.alpha = 0;
|
||||
this._npc.velocity = Vector2.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public class LooseSprite
|
||||
{
|
||||
private DrawData _originalDrawData;
|
||||
public DrawData CurrentDrawData;
|
||||
public float CurrentOpacity;
|
||||
|
||||
public LooseSprite(DrawData data)
|
||||
{
|
||||
this._originalDrawData = data;
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
this.CurrentDrawData = this._originalDrawData;
|
||||
this.CurrentOpacity = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public class SpriteSegment : Segments.ACreditsRollSegmentWithActions<Segments.LooseSprite>
|
||||
{
|
||||
private Segments.LooseSprite _sprite;
|
||||
private Vector2 _anchorOffset;
|
||||
|
||||
public SpriteSegment(int targetTime, DrawData data, Vector2 anchorOffset)
|
||||
: base(targetTime)
|
||||
{
|
||||
this._sprite = new Segments.LooseSprite(data);
|
||||
this._anchorOffset = anchorOffset;
|
||||
}
|
||||
|
||||
protected override void Bind(
|
||||
ICreditsRollSegmentAction<Segments.LooseSprite> act)
|
||||
{
|
||||
act.BindTo(this._sprite);
|
||||
}
|
||||
|
||||
public override void Draw(ref CreditsRollInfo info)
|
||||
{
|
||||
if ((double) info.TimeInAnimation > (double) this._targetTime + (double) this.DedicatedTimeNeeded)
|
||||
return;
|
||||
this.ResetSpriteAnimation(ref info);
|
||||
this.ProcessActions(this._sprite, (float) (info.TimeInAnimation - this._targetTime));
|
||||
DrawData currentDrawData = this._sprite.CurrentDrawData;
|
||||
currentDrawData.position += info.AnchorPositionOnScreen;
|
||||
currentDrawData.color *= this._sprite.CurrentOpacity;
|
||||
currentDrawData.Draw(info.SpriteBatch);
|
||||
}
|
||||
|
||||
private void ResetSpriteAnimation(ref CreditsRollInfo info) => this._sprite.Reset();
|
||||
}
|
||||
|
||||
public class EmoteSegment : ICreditsRollSegment
|
||||
{
|
||||
private int _targetTime;
|
||||
private Vector2 _offset;
|
||||
private SpriteEffects _effect;
|
||||
private int _emoteId;
|
||||
|
||||
public float DedicatedTimeNeeded { get; private set; }
|
||||
|
||||
public EmoteSegment(
|
||||
int emoteId,
|
||||
int targetTime,
|
||||
int timeToPlay,
|
||||
Vector2 position,
|
||||
SpriteEffects drawEffect)
|
||||
{
|
||||
this._emoteId = emoteId;
|
||||
this._targetTime = targetTime;
|
||||
this._effect = drawEffect;
|
||||
this._offset = position;
|
||||
this.DedicatedTimeNeeded = (float) timeToPlay;
|
||||
}
|
||||
|
||||
public void Draw(ref CreditsRollInfo info)
|
||||
{
|
||||
int num = info.TimeInAnimation - this._targetTime;
|
||||
if (num < 0 || (double) num >= (double) this.DedicatedTimeNeeded)
|
||||
return;
|
||||
Vector2 position = (info.AnchorPositionOnScreen + this._offset).Floor();
|
||||
bool flag = num < 6 || (double) num >= (double) this.DedicatedTimeNeeded - 6.0;
|
||||
Texture2D texture2D = TextureAssets.Extra[48].Value;
|
||||
Rectangle rectangle = texture2D.Frame(8, 38, flag ? 0 : 1);
|
||||
Vector2 origin = new Vector2((float) (rectangle.Width / 2), (float) rectangle.Height);
|
||||
SpriteEffects effect = this._effect;
|
||||
info.SpriteBatch.Draw(texture2D, position, new Rectangle?(rectangle), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
if (flag)
|
||||
return;
|
||||
switch (this._emoteId)
|
||||
{
|
||||
case 87:
|
||||
case 89:
|
||||
if (effect.HasFlag((Enum) SpriteEffects.FlipHorizontally))
|
||||
{
|
||||
effect &= ~SpriteEffects.FlipHorizontally;
|
||||
position.X += 4f;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
info.SpriteBatch.Draw(texture2D, position, new Rectangle?(this.GetFrame(num % 20)), Color.White, 0.0f, origin, 1f, effect, 0.0f);
|
||||
}
|
||||
|
||||
private Rectangle GetFrame(int wrappedTime)
|
||||
{
|
||||
int num = wrappedTime >= 10 ? 1 : 0;
|
||||
return TextureAssets.Extra[48].Value.Frame(8, 38, this._emoteId % 4 * 2 + num, this._emoteId / 4 + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
81
GameContent/Skies/CreditsRollSky.cs
Normal file
81
GameContent/Skies/CreditsRollSky.cs
Normal file
|
@ -0,0 +1,81 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.CreditsRollSky
|
||||
// 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.Collections.Generic;
|
||||
using Terraria.DataStructures;
|
||||
using Terraria.GameContent.Skies.CreditsRoll;
|
||||
using Terraria.Graphics.Effects;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class CreditsRollSky : CustomSky
|
||||
{
|
||||
private int _endTime;
|
||||
private int _currentTime;
|
||||
private List<ICreditsRollSegment> _segments;
|
||||
|
||||
public void EnsureSegmentsAreMade()
|
||||
{
|
||||
this._segments = new List<ICreditsRollSegment>();
|
||||
new string[1][0] = "Now, this is a story all about how";
|
||||
Segments.ACreditsRollSegmentWithActions<NPC> segmentWithActions1 = new Segments.NPCSegment(0, 22, new Vector2(-300f, 0.0f), new Vector2(0.5f, 1f)).Then((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Fade((int) byte.MaxValue)).With((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Fade(-5, 51)).Then((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Move(new Vector2(1f, 0.0f), 60));
|
||||
Segments.ACreditsRollSegmentWithActions<Segments.LooseSprite> segmentWithActions2 = new Segments.SpriteSegment(0, new DrawData(TextureAssets.Extra[156].Value, Vector2.Zero, new Rectangle?(), Color.White, 0.0f, TextureAssets.Extra[156].Size() / 2f, 0.25f, SpriteEffects.None, 0), new Vector2(-100f, 0.0f)).Then((ICreditsRollSegmentAction<Segments.LooseSprite>) new Actions.Sprites.Fade(0.0f, 0)).Then((ICreditsRollSegmentAction<Segments.LooseSprite>) new Actions.Sprites.Fade(1f, 60)).Then((ICreditsRollSegmentAction<Segments.LooseSprite>) new Actions.Sprites.Wait(60)).Then((ICreditsRollSegmentAction<Segments.LooseSprite>) new Actions.Sprites.Fade(0.0f, 60));
|
||||
int num = 60;
|
||||
Segments.EmoteSegment emoteSegment = new Segments.EmoteSegment(3, (int) segmentWithActions1.DedicatedTimeNeeded, num, new Vector2(-254f, -38f), SpriteEffects.FlipHorizontally);
|
||||
segmentWithActions1.Then((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Wait(num)).Then((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Wait(60)).With((ICreditsRollSegmentAction<NPC>) new Actions.NPCs.Fade(5, 51));
|
||||
this._segments.Add((ICreditsRollSegment) segmentWithActions1);
|
||||
this._segments.Add((ICreditsRollSegment) emoteSegment);
|
||||
this._segments.Add((ICreditsRollSegment) segmentWithActions2);
|
||||
foreach (ICreditsRollSegment segment in this._segments)
|
||||
this._endTime += (int) segment.DedicatedTimeNeeded;
|
||||
this._endTime += 300;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
++this._currentTime;
|
||||
int num = 0;
|
||||
foreach (ICreditsRollSegment segment in this._segments)
|
||||
num += (int) segment.DedicatedTimeNeeded;
|
||||
if (this._currentTime < num + 1)
|
||||
return;
|
||||
this._currentTime = 0;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
float num = 4.5f;
|
||||
if ((double) num < (double) minDepth || (double) num > (double) maxDepth)
|
||||
return;
|
||||
CreditsRollInfo info = new CreditsRollInfo()
|
||||
{
|
||||
SpriteBatch = spriteBatch,
|
||||
AnchorPositionOnScreen = Main.ScreenSize.ToVector2() / 2f,
|
||||
TimeInAnimation = this._currentTime
|
||||
};
|
||||
for (int index = 0; index < this._segments.Count; ++index)
|
||||
this._segments[index].Draw(ref info);
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._currentTime < this._endTime;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._currentTime = 0;
|
||||
this.EnsureSegmentsAreMade();
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._currentTime = 0;
|
||||
this.EnsureSegmentsAreMade();
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._currentTime = 0;
|
||||
}
|
||||
}
|
230
GameContent/Skies/LanternSky.cs
Normal file
230
GameContent/Skies/LanternSky.cs
Normal file
|
@ -0,0 +1,230 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.LanternSky
|
||||
// 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.Events;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class LanternSky : CustomSky
|
||||
{
|
||||
private bool _active;
|
||||
private bool _leaving;
|
||||
private float _opacity;
|
||||
private Asset<Texture2D> _texture;
|
||||
private LanternSky.Lantern[] _lanterns;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _lanternsDrawing;
|
||||
private const float slowDown = 0.5f;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._texture = TextureAssets.Extra[134];
|
||||
this.GenerateLanterns(false);
|
||||
}
|
||||
|
||||
private void GenerateLanterns(bool onlyMissing)
|
||||
{
|
||||
if (!onlyMissing)
|
||||
this._lanterns = new LanternSky.Lantern[Main.maxTilesY / 4];
|
||||
for (int i = 0; i < this._lanterns.Length; ++i)
|
||||
{
|
||||
if (!onlyMissing || !this._lanterns[i].Active)
|
||||
{
|
||||
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
|
||||
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
|
||||
this._lanterns[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
|
||||
this.ResetLantern(i);
|
||||
this._lanterns[i].Active = true;
|
||||
}
|
||||
}
|
||||
this._lanternsDrawing = this._lanterns.Length;
|
||||
}
|
||||
|
||||
public void ResetLantern(int i)
|
||||
{
|
||||
this._lanterns[i].Depth = (float) ((1.0 - (double) i / (double) this._lanterns.Length) * 4.40000009536743 + 1.60000002384186);
|
||||
this._lanterns[i].Speed = (float) (-1.5 - 2.5 * this._random.NextDouble());
|
||||
this._lanterns[i].Texture = this._texture.Value;
|
||||
this._lanterns[i].Variant = this._random.Next(3);
|
||||
this._lanterns[i].TimeUntilFloat = (int) ((double) (2000 + this._random.Next(1200)) * 2.0);
|
||||
this._lanterns[i].TimeUntilFloatMax = this._lanterns[i].TimeUntilFloat;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
this._opacity = Utils.Clamp<float>(this._opacity + (float) LanternNight.LanternsUp.ToDirectionInt() * 0.01f, 0.0f, 1f);
|
||||
for (int i = 0; i < this._lanterns.Length; ++i)
|
||||
{
|
||||
if (this._lanterns[i].Active)
|
||||
{
|
||||
float num1 = Main.windSpeedCurrent;
|
||||
if ((double) num1 == 0.0)
|
||||
num1 = 0.1f;
|
||||
float num2 = (float) Math.Sin((double) this._lanterns[i].Position.X / 120.0) * 0.5f;
|
||||
this._lanterns[i].Position.Y += num2 * 0.5f;
|
||||
this._lanterns[i].Position.Y += this._lanterns[i].FloatAdjustedSpeed * 0.5f;
|
||||
this._lanterns[i].Position.X += (float) ((0.100000001490116 + (double) num1) * (3.0 - (double) this._lanterns[i].Speed) * 0.5 * ((double) i / (double) this._lanterns.Length + 1.5) / 2.5);
|
||||
this._lanterns[i].Rotation = (float) ((double) num2 * ((double) num1 < 0.0 ? -1.0 : 1.0) * 0.5);
|
||||
this._lanterns[i].TimeUntilFloat = Math.Max(0, this._lanterns[i].TimeUntilFloat - 1);
|
||||
if ((double) this._lanterns[i].Position.Y < 300.0)
|
||||
{
|
||||
if (!this._leaving)
|
||||
{
|
||||
this.ResetLantern(i);
|
||||
this._lanterns[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) (Main.worldSurface * 16.0 + 1600.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
this._lanterns[i].Active = false;
|
||||
--this._lanternsDrawing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this._active = true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if (Main.gameMenu && this._active)
|
||||
{
|
||||
this._active = false;
|
||||
this._leaving = false;
|
||||
for (int index = 0; index < this._lanterns.Length; ++index)
|
||||
this._lanterns[index].Active = false;
|
||||
}
|
||||
if ((double) Main.screenPosition.Y > Main.worldSurface * 16.0 || Main.gameMenu || (double) this._opacity <= 0.0)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._lanterns.Length; ++index)
|
||||
{
|
||||
float depth = this._lanterns[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
if (this._lanterns[index].Active)
|
||||
{
|
||||
Color opacity = new Color(250, 120, 60, 120);
|
||||
float alpha = 1f;
|
||||
if ((double) this._lanterns[index].Depth > 5.0)
|
||||
alpha = 0.3f;
|
||||
else if ((double) this._lanterns[index].Depth > 4.5)
|
||||
alpha = 0.4f;
|
||||
else if ((double) this._lanterns[index].Depth > 4.0)
|
||||
alpha = 0.5f;
|
||||
else if ((double) this._lanterns[index].Depth > 3.5)
|
||||
alpha = 0.6f;
|
||||
else if ((double) this._lanterns[index].Depth > 3.0)
|
||||
alpha = 0.7f;
|
||||
else if ((double) this._lanterns[index].Depth > 2.5)
|
||||
alpha = 0.8f;
|
||||
else if ((double) this._lanterns[index].Depth > 2.0)
|
||||
alpha = 0.9f;
|
||||
opacity = new Color((int) ((double) opacity.R * (double) alpha), (int) ((double) opacity.G * (double) alpha), (int) ((double) opacity.B * (double) alpha), (int) ((double) opacity.A * (double) alpha));
|
||||
Vector2 depthScale = new Vector2(1f / this._lanterns[index].Depth, 0.9f / this._lanterns[index].Depth);
|
||||
depthScale *= 1.2f;
|
||||
Vector2 position = (this._lanterns[index].Position - vector2) * depthScale + vector2 - Main.screenPosition;
|
||||
position.X = (float) (((double) position.X + 500.0) % 4000.0);
|
||||
if ((double) position.X < 0.0)
|
||||
position.X += 4000f;
|
||||
position.X -= 500f;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
this.DrawLantern(spriteBatch, this._lanterns[index], opacity, depthScale, position, alpha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLantern(
|
||||
SpriteBatch spriteBatch,
|
||||
LanternSky.Lantern lantern,
|
||||
Color opacity,
|
||||
Vector2 depthScale,
|
||||
Vector2 position,
|
||||
float alpha)
|
||||
{
|
||||
float y = ((float) ((double) Main.GlobalTimeWrappedHourly % 6.0 / 6.0 * 6.28318548202515)).ToRotationVector2().Y;
|
||||
float num1 = (float) ((double) y * 0.200000002980232 + 0.800000011920929);
|
||||
Color color = new Color((int) byte.MaxValue, (int) byte.MaxValue, (int) byte.MaxValue, 0) * this._opacity * alpha * num1 * 0.4f;
|
||||
for (float num2 = 0.0f; (double) num2 < 1.0; num2 += 0.3333333f)
|
||||
{
|
||||
Vector2 vector2 = new Vector2(0.0f, 2f).RotatedBy(6.28318548202515 * (double) num2 + (double) lantern.Rotation) * y;
|
||||
spriteBatch.Draw(lantern.Texture, position + vector2, new Rectangle?(lantern.GetSourceRectangle()), color, lantern.Rotation, lantern.GetSourceRectangle().Size() / 2f, depthScale.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
spriteBatch.Draw(lantern.Texture, position, new Rectangle?(lantern.GetSourceRectangle()), opacity * this._opacity, lantern.Rotation, lantern.GetSourceRectangle().Size() / 2f, depthScale.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
if (this._active)
|
||||
{
|
||||
this._leaving = false;
|
||||
this.GenerateLanterns(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.GenerateLanterns(false);
|
||||
this._active = true;
|
||||
this._leaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._leaving = true;
|
||||
|
||||
public override bool IsActive() => this._active;
|
||||
|
||||
public override void Reset() => this._active = false;
|
||||
|
||||
private struct Lantern
|
||||
{
|
||||
private const int MAX_FRAMES_X = 3;
|
||||
public int Variant;
|
||||
public int TimeUntilFloat;
|
||||
public int TimeUntilFloatMax;
|
||||
private Texture2D _texture;
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public float Rotation;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Speed;
|
||||
public bool Active;
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width / 3;
|
||||
this.FrameHeight = value.Height;
|
||||
}
|
||||
}
|
||||
|
||||
public float FloatAdjustedSpeed => this.Speed * ((float) this.TimeUntilFloat / (float) this.TimeUntilFloatMax);
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(this.FrameWidth * this.Variant, 0, this.FrameWidth, this.FrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
277
GameContent/Skies/MartianSky.cs
Normal file
277
GameContent/Skies/MartianSky.cs
Normal file
|
@ -0,0 +1,277 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.MartianSky
|
||||
// Assembly: Terraria, Version=1.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;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class MartianSky : CustomSky
|
||||
{
|
||||
private MartianSky.Ufo[] _ufos;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _maxUfos;
|
||||
private bool _active;
|
||||
private bool _leaving;
|
||||
private int _activeUfos;
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
int activeUfos = this._activeUfos;
|
||||
for (int index = 0; index < this._ufos.Length; ++index)
|
||||
{
|
||||
MartianSky.Ufo ufo = this._ufos[index];
|
||||
if (ufo.IsActive)
|
||||
{
|
||||
++ufo.Frame;
|
||||
if (!ufo.Update())
|
||||
{
|
||||
if (!this._leaving)
|
||||
{
|
||||
ufo.AssignNewBehavior();
|
||||
}
|
||||
else
|
||||
{
|
||||
ufo.IsActive = false;
|
||||
--activeUfos;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._ufos[index] = ufo;
|
||||
}
|
||||
if (!this._leaving && activeUfos != this._maxUfos)
|
||||
{
|
||||
this._ufos[activeUfos].IsActive = true;
|
||||
this._ufos[activeUfos++].AssignNewBehavior();
|
||||
}
|
||||
this._active = !this._leaving || (uint) activeUfos > 0U;
|
||||
this._activeUfos = activeUfos;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) Main.screenPosition.Y > 10000.0)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._ufos.Length; ++index)
|
||||
{
|
||||
float depth = this._ufos[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Color color = new Color(Main.ColorOfTheSkies.ToVector4() * 0.9f + new Vector4(0.1f));
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_2 = new Vector2(1f / this._ufos[index].Depth, 0.9f / this._ufos[index].Depth);
|
||||
Vector2 position = (this._ufos[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
if (this._ufos[index].IsActive && rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
spriteBatch.Draw(this._ufos[index].Texture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), color * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
|
||||
if (this._ufos[index].GlowTexture != null)
|
||||
spriteBatch.Draw(this._ufos[index].GlowTexture, position, new Rectangle?(this._ufos[index].GetSourceRectangle()), Color.White * this._ufos[index].Opacity, this._ufos[index].Rotation, Vector2.Zero, vector2_2.X * 5f * this._ufos[index].Scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateUfos()
|
||||
{
|
||||
this._maxUfos = (int) (256.0 * (double) ((float) Main.maxTilesX / 4200f));
|
||||
this._ufos = new MartianSky.Ufo[this._maxUfos];
|
||||
int num1 = this._maxUfos >> 4;
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
double num2 = (double) index / (double) num1;
|
||||
this._ufos[index] = new MartianSky.Ufo(TextureAssets.Extra[5].Value, (float) (Main.rand.NextDouble() * 4.0 + 6.59999990463257));
|
||||
this._ufos[index].GlowTexture = TextureAssets.GlowMask[90].Value;
|
||||
}
|
||||
for (int index = num1; index < this._ufos.Length; ++index)
|
||||
{
|
||||
double num3 = (double) (index - num1) / (double) (this._ufos.Length - num1);
|
||||
this._ufos[index] = new MartianSky.Ufo(TextureAssets.Extra[6].Value, (float) (Main.rand.NextDouble() * 5.0 + 1.60000002384186));
|
||||
this._ufos[index].Scale = 0.5f;
|
||||
this._ufos[index].GlowTexture = TextureAssets.GlowMask[91].Value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._activeUfos = 0;
|
||||
this.GenerateUfos();
|
||||
Array.Sort<MartianSky.Ufo>(this._ufos, (Comparison<MartianSky.Ufo>) ((ufo1, ufo2) => ufo2.Depth.CompareTo(ufo1.Depth)));
|
||||
this._active = true;
|
||||
this._leaving = false;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._leaving = true;
|
||||
|
||||
public override bool IsActive() => this._active;
|
||||
|
||||
public override void Reset() => this._active = false;
|
||||
|
||||
private abstract class IUfoController
|
||||
{
|
||||
public abstract void InitializeUfo(ref MartianSky.Ufo ufo);
|
||||
|
||||
public abstract bool Update(ref MartianSky.Ufo ufo);
|
||||
}
|
||||
|
||||
private class ZipBehavior : MartianSky.IUfoController
|
||||
{
|
||||
private Vector2 _speed;
|
||||
private int _ticks;
|
||||
private int _maxTicks;
|
||||
|
||||
public override void InitializeUfo(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
|
||||
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
|
||||
ufo.Opacity = 0.0f;
|
||||
float num1 = (float) (MartianSky.Ufo.Random.NextDouble() * 5.0 + 10.0);
|
||||
double num2 = MartianSky.Ufo.Random.NextDouble() * 0.600000023841858 - 0.300000011920929;
|
||||
ufo.Rotation = (float) num2;
|
||||
if (MartianSky.Ufo.Random.Next(2) == 0)
|
||||
num2 += 3.14159274101257;
|
||||
this._speed = new Vector2((float) Math.Cos(num2) * num1, (float) Math.Sin(num2) * num1);
|
||||
this._ticks = 0;
|
||||
this._maxTicks = MartianSky.Ufo.Random.Next(400, 500);
|
||||
}
|
||||
|
||||
public override bool Update(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
if (this._ticks < 10)
|
||||
ufo.Opacity += 0.1f;
|
||||
else if (this._ticks > this._maxTicks - 10)
|
||||
ufo.Opacity -= 0.1f;
|
||||
ufo.Position += this._speed;
|
||||
if (this._ticks == this._maxTicks)
|
||||
return false;
|
||||
++this._ticks;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private class HoverBehavior : MartianSky.IUfoController
|
||||
{
|
||||
private int _ticks;
|
||||
private int _maxTicks;
|
||||
|
||||
public override void InitializeUfo(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
ufo.Position.X = (float) MartianSky.Ufo.Random.NextDouble() * (float) (Main.maxTilesX << 4);
|
||||
ufo.Position.Y = (float) (MartianSky.Ufo.Random.NextDouble() * 5000.0);
|
||||
ufo.Opacity = 0.0f;
|
||||
ufo.Rotation = 0.0f;
|
||||
this._ticks = 0;
|
||||
this._maxTicks = MartianSky.Ufo.Random.Next(120, 240);
|
||||
}
|
||||
|
||||
public override bool Update(ref MartianSky.Ufo ufo)
|
||||
{
|
||||
if (this._ticks < 10)
|
||||
ufo.Opacity += 0.1f;
|
||||
else if (this._ticks > this._maxTicks - 10)
|
||||
ufo.Opacity -= 0.1f;
|
||||
if (this._ticks == this._maxTicks)
|
||||
return false;
|
||||
++this._ticks;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private struct Ufo
|
||||
{
|
||||
private const int MAX_FRAMES = 3;
|
||||
private const int FRAME_RATE = 4;
|
||||
public static UnifiedRandom Random = new UnifiedRandom();
|
||||
private int _frame;
|
||||
private Texture2D _texture;
|
||||
private MartianSky.IUfoController _controller;
|
||||
public Texture2D GlowTexture;
|
||||
public Vector2 Position;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Depth;
|
||||
public float Scale;
|
||||
public float Opacity;
|
||||
public bool IsActive;
|
||||
public float Rotation;
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frame;
|
||||
set => this._frame = value % 12;
|
||||
}
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width;
|
||||
this.FrameHeight = value.Height / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public MartianSky.IUfoController Controller
|
||||
{
|
||||
get => this._controller;
|
||||
set
|
||||
{
|
||||
this._controller = value;
|
||||
value.InitializeUfo(ref this);
|
||||
}
|
||||
}
|
||||
|
||||
public Ufo(Texture2D texture, float depth = 1f)
|
||||
{
|
||||
this._frame = 0;
|
||||
this.Position = Vector2.Zero;
|
||||
this._texture = texture;
|
||||
this.Depth = depth;
|
||||
this.Scale = 1f;
|
||||
this.FrameWidth = texture.Width;
|
||||
this.FrameHeight = texture.Height / 3;
|
||||
this.GlowTexture = (Texture2D) null;
|
||||
this.Opacity = 0.0f;
|
||||
this.Rotation = 0.0f;
|
||||
this.IsActive = false;
|
||||
this._controller = (MartianSky.IUfoController) null;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 4 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
|
||||
public bool Update() => this.Controller.Update(ref this);
|
||||
|
||||
public void AssignNewBehavior()
|
||||
{
|
||||
switch (MartianSky.Ufo.Random.Next(2))
|
||||
{
|
||||
case 0:
|
||||
this.Controller = (MartianSky.IUfoController) new MartianSky.ZipBehavior();
|
||||
break;
|
||||
case 1:
|
||||
this.Controller = (MartianSky.IUfoController) new MartianSky.HoverBehavior();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
GameContent/Skies/MoonLordSky.cs
Normal file
109
GameContent/Skies/MoonLordSky.cs
Normal file
|
@ -0,0 +1,109 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.MoonLordSky
|
||||
// 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;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class MoonLordSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private int _moonLordIndex = -1;
|
||||
private bool _forPlayer;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public MoonLordSky(bool forPlayer) => this._forPlayer = forPlayer;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (!this._forPlayer)
|
||||
return;
|
||||
if (this._isActive)
|
||||
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
else
|
||||
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
|
||||
}
|
||||
|
||||
private float GetIntensity()
|
||||
{
|
||||
if (this._forPlayer)
|
||||
return this._fadeOpacity;
|
||||
if (!this.UpdateMoonLordIndex())
|
||||
return 0.0f;
|
||||
float x = 0.0f;
|
||||
if (this._moonLordIndex != -1)
|
||||
x = Vector2.Distance(Main.player[Main.myPlayer].Center, Main.npc[this._moonLordIndex].Center);
|
||||
return 1f - Utils.SmoothStep(3000f, 6000f, x);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor)
|
||||
{
|
||||
float intensity = this.GetIntensity();
|
||||
return new Color(Vector4.Lerp(new Vector4(0.5f, 0.8f, 1f, 1f), inColor.ToVector4(), 1f - intensity));
|
||||
}
|
||||
|
||||
private bool UpdateMoonLordIndex()
|
||||
{
|
||||
if (this._moonLordIndex >= 0 && Main.npc[this._moonLordIndex].active && Main.npc[this._moonLordIndex].type == 398)
|
||||
return true;
|
||||
int num = -1;
|
||||
for (int index = 0; index < Main.npc.Length; ++index)
|
||||
{
|
||||
if (Main.npc[index].active && Main.npc[index].type == 398)
|
||||
{
|
||||
num = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this._moonLordIndex = num;
|
||||
return num != -1;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth < 0.0 || (double) minDepth >= 0.0)
|
||||
return;
|
||||
float intensity = this.GetIntensity();
|
||||
spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * intensity);
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => 1f - this._fadeOpacity;
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._isActive = true;
|
||||
if (this._forPlayer)
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
else
|
||||
this._fadeOpacity = 1f;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args)
|
||||
{
|
||||
this._isActive = false;
|
||||
if (this._forPlayer)
|
||||
return;
|
||||
this._fadeOpacity = 0.0f;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._isActive = false;
|
||||
this._fadeOpacity = 0.0f;
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
}
|
||||
}
|
123
GameContent/Skies/NebulaSky.cs
Normal file
123
GameContent/Skies/NebulaSky.cs
Normal file
|
@ -0,0 +1,123 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.NebulaSky
|
||||
// Assembly: Terraria, Version=1.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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class NebulaSky : CustomSky
|
||||
{
|
||||
private NebulaSky.LightPillar[] _pillars;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Asset<Texture2D> _planetTexture;
|
||||
private Asset<Texture2D> _bgTexture;
|
||||
private Asset<Texture2D> _beamTexture;
|
||||
private Asset<Texture2D>[] _rockTextures;
|
||||
private bool _isActive;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = Main.Assets.Request<Texture2D>("Images/Misc/NebulaSky/Planet", (AssetRequestMode) 1);
|
||||
this._bgTexture = Main.Assets.Request<Texture2D>("Images/Misc/NebulaSky/Background", (AssetRequestMode) 1);
|
||||
this._beamTexture = Main.Assets.Request<Texture2D>("Images/Misc/NebulaSky/Beam", (AssetRequestMode) 1);
|
||||
this._rockTextures = new Asset<Texture2D>[3];
|
||||
for (int index = 0; index < this._rockTextures.Length; ++index)
|
||||
this._rockTextures[index] = Main.Assets.Request<Texture2D>("Images/Misc/NebulaSky/Rock_" + (object) index, (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (this._isActive)
|
||||
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
else
|
||||
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture.Value, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture.Value, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width() >> 1), (float) (this._planetTexture.Height() >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._pillars.Length; ++index)
|
||||
{
|
||||
float depth = this._pillars[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
for (int index1 = num1; index1 < num2; ++index1)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._pillars[index1].Depth, 0.9f / this._pillars[index1].Depth);
|
||||
Vector2 position = (this._pillars[index1].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
float num4 = vector2_4.X * 450f;
|
||||
spriteBatch.Draw(this._beamTexture.Value, position, new Rectangle?(), Color.White * 0.2f * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, new Vector2(num4 / 70f, num4 / 45f), SpriteEffects.None, 0.0f);
|
||||
int index2 = 0;
|
||||
for (float num5 = 0.0f; (double) num5 <= 1.0; num5 += 0.03f)
|
||||
{
|
||||
float num6 = (float) (1.0 - ((double) num5 + (double) Main.GlobalTimeWrappedHourly * 0.0199999995529652 + Math.Sin((double) index1)) % 1.0);
|
||||
spriteBatch.Draw(this._rockTextures[index2].Value, position + new Vector2((float) (Math.Sin((double) num5 * 1582.0) * ((double) num4 * 0.5) + (double) num4 * 0.5), num6 * 2000f), new Rectangle?(), Color.White * num6 * num3 * this._fadeOpacity, num6 * 20f, new Vector2((float) (this._rockTextures[index2].Width() >> 1), (float) (this._rockTextures[index2].Height() >> 1)), 0.9f, SpriteEffects.None, 0.0f);
|
||||
index2 = (index2 + 1) % this._rockTextures.Length;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._pillars = new NebulaSky.LightPillar[40];
|
||||
for (int index = 0; index < this._pillars.Length; ++index)
|
||||
{
|
||||
this._pillars[index].Position.X = (float) ((double) index / (double) this._pillars.Length * ((double) Main.maxTilesX * 16.0 + 20000.0) + (double) this._random.NextFloat() * 40.0 - 20.0 - 20000.0);
|
||||
this._pillars[index].Position.Y = (float) ((double) this._random.NextFloat() * 200.0 - 2000.0);
|
||||
this._pillars[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 7.0);
|
||||
}
|
||||
Array.Sort<NebulaSky.LightPillar>(this._pillars, new Comparison<NebulaSky.LightPillar>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(NebulaSky.LightPillar pillar1, NebulaSky.LightPillar pillar2) => pillar2.Depth.CompareTo(pillar1.Depth);
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct LightPillar
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
}
|
||||
}
|
||||
}
|
213
GameContent/Skies/PartySky.cs
Normal file
213
GameContent/Skies/PartySky.cs
Normal file
|
@ -0,0 +1,213 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.PartySky
|
||||
// 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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class PartySky : CustomSky
|
||||
{
|
||||
public static bool MultipleSkyWorkaroundFix;
|
||||
private bool _active;
|
||||
private bool _leaving;
|
||||
private float _opacity;
|
||||
private Asset<Texture2D>[] _textures;
|
||||
private PartySky.Balloon[] _balloons;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _balloonsDrawing;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._textures = new Asset<Texture2D>[3];
|
||||
for (int index = 0; index < this._textures.Length; ++index)
|
||||
this._textures[index] = TextureAssets.Extra[69 + index];
|
||||
this.GenerateBalloons(false);
|
||||
}
|
||||
|
||||
private void GenerateBalloons(bool onlyMissing)
|
||||
{
|
||||
if (!onlyMissing)
|
||||
this._balloons = new PartySky.Balloon[Main.maxTilesY / 4];
|
||||
for (int i = 0; i < this._balloons.Length; ++i)
|
||||
{
|
||||
if (!onlyMissing || !this._balloons[i].Active)
|
||||
{
|
||||
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
|
||||
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
|
||||
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
|
||||
this.ResetBalloon(i);
|
||||
this._balloons[i].Active = true;
|
||||
}
|
||||
}
|
||||
this._balloonsDrawing = this._balloons.Length;
|
||||
}
|
||||
|
||||
public void ResetBalloon(int i)
|
||||
{
|
||||
this._balloons[i].Depth = (float) ((double) i / (double) this._balloons.Length * 1.75 + 1.60000002384186);
|
||||
this._balloons[i].Speed = (float) (-1.5 - 2.5 * this._random.NextDouble());
|
||||
this._balloons[i].Texture = this._textures[this._random.Next(2)].Value;
|
||||
this._balloons[i].Variant = this._random.Next(3);
|
||||
if (this._random.Next(30) != 0)
|
||||
return;
|
||||
this._balloons[i].Texture = this._textures[2].Value;
|
||||
}
|
||||
|
||||
private bool IsNearParty() => (double) Main.player[Main.myPlayer].townNPCs > 0.0 || Main.SceneMetrics.PartyMonolithCount > 0;
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (!PartySky.MultipleSkyWorkaroundFix && Main.dayRate == 0)
|
||||
return;
|
||||
PartySky.MultipleSkyWorkaroundFix = false;
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
this._opacity = Utils.Clamp<float>(this._opacity + (float) this.IsNearParty().ToDirectionInt() * 0.01f, 0.0f, 1f);
|
||||
for (int i = 0; i < this._balloons.Length; ++i)
|
||||
{
|
||||
if (this._balloons[i].Active)
|
||||
{
|
||||
++this._balloons[i].Frame;
|
||||
this._balloons[i].Position.Y += this._balloons[i].Speed;
|
||||
this._balloons[i].Position.X += Main.windSpeedCurrent * (3f - this._balloons[i].Speed);
|
||||
if ((double) this._balloons[i].Position.Y < 300.0)
|
||||
{
|
||||
if (!this._leaving)
|
||||
{
|
||||
this.ResetBalloon(i);
|
||||
this._balloons[i].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) (Main.worldSurface * 16.0 + 1600.0));
|
||||
if (this._random.Next(30) == 0)
|
||||
this._balloons[i].Texture = this._textures[2].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._balloons[i].Active = false;
|
||||
--this._balloonsDrawing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._balloonsDrawing == 0)
|
||||
this._active = false;
|
||||
this._active = true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if (Main.gameMenu && this._active)
|
||||
{
|
||||
this._active = false;
|
||||
this._leaving = false;
|
||||
for (int index = 0; index < this._balloons.Length; ++index)
|
||||
this._balloons[index].Active = false;
|
||||
}
|
||||
if ((double) Main.screenPosition.Y > Main.worldSurface * 16.0 || Main.gameMenu || (double) this._opacity <= 0.0)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._balloons.Length; ++index)
|
||||
{
|
||||
float depth = this._balloons[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
if (this._balloons[index].Active)
|
||||
{
|
||||
Color color = new Color(Main.ColorOfTheSkies.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
|
||||
float num3 = 1f;
|
||||
if ((double) this._balloons[index].Depth > 3.0)
|
||||
num3 = 0.6f;
|
||||
else if ((double) this._balloons[index].Depth > 2.5)
|
||||
num3 = 0.7f;
|
||||
else if ((double) this._balloons[index].Depth > 2.0)
|
||||
num3 = 0.8f;
|
||||
else if ((double) this._balloons[index].Depth > 1.5)
|
||||
num3 = 0.9f;
|
||||
float num4 = num3 * 0.9f;
|
||||
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
|
||||
Vector2 vector2_2 = new Vector2(1f / this._balloons[index].Depth, 0.9f / this._balloons[index].Depth);
|
||||
Vector2 position = (this._balloons[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
position.X = (float) (((double) position.X + 500.0) % 4000.0);
|
||||
if ((double) position.X < 0.0)
|
||||
position.X += 4000f;
|
||||
position.X -= 500f;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._balloons[index].Texture, position, new Rectangle?(this._balloons[index].GetSourceRectangle()), color * this._opacity, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
if (this._active)
|
||||
{
|
||||
this._leaving = false;
|
||||
this.GenerateBalloons(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.GenerateBalloons(false);
|
||||
this._active = true;
|
||||
this._leaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._leaving = true;
|
||||
|
||||
public override bool IsActive() => this._active;
|
||||
|
||||
public override void Reset() => this._active = false;
|
||||
|
||||
private struct Balloon
|
||||
{
|
||||
private const int MAX_FRAMES_X = 3;
|
||||
private const int MAX_FRAMES_Y = 3;
|
||||
private const int FRAME_RATE = 14;
|
||||
public int Variant;
|
||||
private Texture2D _texture;
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Speed;
|
||||
public bool Active;
|
||||
private int _frameCounter;
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width / 3;
|
||||
this.FrameHeight = value.Height / 3;
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frameCounter;
|
||||
set => this._frameCounter = value % 42;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(this.FrameWidth * this.Variant, this._frameCounter / 14 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
73
GameContent/Skies/SandstormSky.cs
Normal file
73
GameContent/Skies/SandstormSky.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SandstormSky
|
||||
// Assembly: Terraria, Version=1.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;
|
||||
using Terraria.GameContent.Events;
|
||||
using Terraria.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SandstormSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
private float _opacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
if (this._isLeaving)
|
||||
{
|
||||
this._opacity -= (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity >= 0.0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
this._opacity = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._opacity += (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._opacity <= 1.0)
|
||||
return;
|
||||
this._opacity = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) minDepth >= 1.0 && (double) maxDepth != 3.40282346638529E+38)
|
||||
return;
|
||||
float num = Math.Min(1f, Sandstorm.Severity * 1.5f);
|
||||
Color color = new Color(new Vector4(0.85f, 0.66f, 0.33f, 1f) * 0.8f * Main.ColorOfTheSkies.ToVector4()) * this._opacity * num;
|
||||
spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
this._opacity = 0.0f;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
}
|
||||
}
|
196
GameContent/Skies/SlimeSky.cs
Normal file
196
GameContent/Skies/SlimeSky.cs
Normal file
|
@ -0,0 +1,196 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SlimeSky
|
||||
// Assembly: Terraria, Version=1.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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SlimeSky : CustomSky
|
||||
{
|
||||
private Asset<Texture2D>[] _textures;
|
||||
private SlimeSky.Slime[] _slimes;
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private int _slimesRemaining;
|
||||
private bool _isActive;
|
||||
private bool _isLeaving;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._textures = new Asset<Texture2D>[4];
|
||||
for (int index = 0; index < 4; ++index)
|
||||
this._textures[index] = Main.Assets.Request<Texture2D>("Images/Misc/Sky_Slime_" + (object) (index + 1), (AssetRequestMode) 1);
|
||||
this.GenerateSlimes();
|
||||
}
|
||||
|
||||
private void GenerateSlimes()
|
||||
{
|
||||
this._slimes = new SlimeSky.Slime[Main.maxTilesY / 6];
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
int maxValue = (int) ((double) Main.screenPosition.Y * 0.7 - (double) Main.screenHeight);
|
||||
int minValue = (int) ((double) maxValue - Main.worldSurface * 16.0);
|
||||
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), (float) this._random.Next(minValue, maxValue));
|
||||
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
|
||||
this._slimes[index].Texture = this._textures[this._random.Next(2)].Value;
|
||||
if (this._random.Next(60) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[3].Value;
|
||||
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth += 0.5f;
|
||||
}
|
||||
else if (this._random.Next(30) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[2].Value;
|
||||
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
|
||||
}
|
||||
this._slimes[index].Active = true;
|
||||
}
|
||||
this._slimesRemaining = this._slimes.Length;
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (Main.gamePaused || !Main.hasFocus)
|
||||
return;
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
if (this._slimes[index].Active)
|
||||
{
|
||||
++this._slimes[index].Frame;
|
||||
this._slimes[index].Position.Y += this._slimes[index].Speed;
|
||||
if ((double) this._slimes[index].Position.Y > Main.worldSurface * 16.0)
|
||||
{
|
||||
if (!this._isLeaving)
|
||||
{
|
||||
this._slimes[index].Depth = (float) ((double) index / (double) this._slimes.Length * 1.75 + 1.60000002384186);
|
||||
this._slimes[index].Position = new Vector2((float) (this._random.Next(0, Main.maxTilesX) * 16), -100f);
|
||||
this._slimes[index].Texture = this._textures[this._random.Next(2)].Value;
|
||||
this._slimes[index].Speed = (float) (5.0 + 3.0 * this._random.NextDouble());
|
||||
if (this._random.Next(60) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[3].Value;
|
||||
this._slimes[index].Speed = (float) (6.0 + 3.0 * this._random.NextDouble());
|
||||
this._slimes[index].Depth += 0.5f;
|
||||
}
|
||||
else if (this._random.Next(30) == 0)
|
||||
{
|
||||
this._slimes[index].Texture = this._textures[2].Value;
|
||||
this._slimes[index].Speed = (float) (6.0 + 2.0 * this._random.NextDouble());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._slimes[index].Active = false;
|
||||
--this._slimesRemaining;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this._slimesRemaining != 0)
|
||||
return;
|
||||
this._isActive = false;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) Main.screenPosition.Y > 10000.0 || Main.gameMenu)
|
||||
return;
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._slimes.Length; ++index)
|
||||
{
|
||||
float depth = this._slimes[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
Vector2 vector2_1 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
if (this._slimes[index].Active)
|
||||
{
|
||||
Color color = new Color(Main.ColorOfTheSkies.ToVector4() * 0.9f + new Vector4(0.1f)) * 0.8f;
|
||||
float num3 = 1f;
|
||||
if ((double) this._slimes[index].Depth > 3.0)
|
||||
num3 = 0.6f;
|
||||
else if ((double) this._slimes[index].Depth > 2.5)
|
||||
num3 = 0.7f;
|
||||
else if ((double) this._slimes[index].Depth > 2.0)
|
||||
num3 = 0.8f;
|
||||
else if ((double) this._slimes[index].Depth > 1.5)
|
||||
num3 = 0.9f;
|
||||
float num4 = num3 * 0.8f;
|
||||
color = new Color((int) ((double) color.R * (double) num4), (int) ((double) color.G * (double) num4), (int) ((double) color.B * (double) num4), (int) ((double) color.A * (double) num4));
|
||||
Vector2 vector2_2 = new Vector2(1f / this._slimes[index].Depth, 0.9f / this._slimes[index].Depth);
|
||||
Vector2 position = (this._slimes[index].Position - vector2_1) * vector2_2 + vector2_1 - Main.screenPosition;
|
||||
position.X = (float) (((double) position.X + 500.0) % 4000.0);
|
||||
if ((double) position.X < 0.0)
|
||||
position.X += 4000f;
|
||||
position.X -= 500f;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._slimes[index].Texture, position, new Rectangle?(this._slimes[index].GetSourceRectangle()), color, 0.0f, Vector2.Zero, vector2_2.X * 2f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this.GenerateSlimes();
|
||||
this._isActive = true;
|
||||
this._isLeaving = false;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isLeaving = true;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive;
|
||||
|
||||
private struct Slime
|
||||
{
|
||||
private const int MAX_FRAMES = 4;
|
||||
private const int FRAME_RATE = 6;
|
||||
private Texture2D _texture;
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameHeight;
|
||||
public int FrameWidth;
|
||||
public float Speed;
|
||||
public bool Active;
|
||||
private int _frame;
|
||||
|
||||
public Texture2D Texture
|
||||
{
|
||||
get => this._texture;
|
||||
set
|
||||
{
|
||||
this._texture = value;
|
||||
this.FrameWidth = value.Width;
|
||||
this.FrameHeight = value.Height / 4;
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame
|
||||
{
|
||||
get => this._frame;
|
||||
set => this._frame = value % 24;
|
||||
}
|
||||
|
||||
public Rectangle GetSourceRectangle() => new Rectangle(0, this._frame / 6 * this.FrameHeight, this.FrameWidth, this.FrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
126
GameContent/Skies/SolarSky.cs
Normal file
126
GameContent/Skies/SolarSky.cs
Normal file
|
@ -0,0 +1,126 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.SolarSky
|
||||
// Assembly: Terraria, Version=1.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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class SolarSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Asset<Texture2D> _planetTexture;
|
||||
private Asset<Texture2D> _bgTexture;
|
||||
private Asset<Texture2D> _meteorTexture;
|
||||
private bool _isActive;
|
||||
private SolarSky.Meteor[] _meteors;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = Main.Assets.Request<Texture2D>("Images/Misc/SolarSky/Planet", (AssetRequestMode) 1);
|
||||
this._bgTexture = Main.Assets.Request<Texture2D>("Images/Misc/SolarSky/Background", (AssetRequestMode) 1);
|
||||
this._meteorTexture = Main.Assets.Request<Texture2D>("Images/Misc/SolarSky/Meteor", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
float num = 1200f;
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
this._meteors[index].Position.X -= num * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
this._meteors[index].Position.Y += num * (float) gameTime.ElapsedGameTime.TotalSeconds;
|
||||
if ((double) this._meteors[index].Position.Y > Main.worldSurface * 16.0)
|
||||
{
|
||||
this._meteors[index].Position.X = this._meteors[index].StartX;
|
||||
this._meteors[index].Position.Y = -10000f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture.Value, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture.Value, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width() >> 1), (float) (this._planetTexture.Height() >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
float depth = this._meteors[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._meteors[index].Depth, 0.9f / this._meteors[index].Depth);
|
||||
Vector2 position = (this._meteors[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
int num4 = this._meteors[index].FrameCounter / 3;
|
||||
this._meteors[index].FrameCounter = (this._meteors[index].FrameCounter + 1) % 12;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
spriteBatch.Draw(this._meteorTexture.Value, position, new Rectangle?(new Rectangle(0, num4 * (this._meteorTexture.Height() / 4), this._meteorTexture.Width(), this._meteorTexture.Height() / 4)), Color.White * num3 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f * this._meteors[index].Scale, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._meteors = new SolarSky.Meteor[150];
|
||||
for (int index = 0; index < this._meteors.Length; ++index)
|
||||
{
|
||||
float num = (float) index / (float) this._meteors.Length;
|
||||
this._meteors[index].Position.X = (float) ((double) num * ((double) Main.maxTilesX * 16.0) + (double) this._random.NextFloat() * 40.0 - 20.0);
|
||||
this._meteors[index].Position.Y = (float) ((double) this._random.NextFloat() * -(Main.worldSurface * 16.0 + 10000.0) - 10000.0);
|
||||
this._meteors[index].Depth = this._random.Next(3) == 0 ? (float) ((double) this._random.NextFloat() * 5.0 + 4.80000019073486) : (float) ((double) this._random.NextFloat() * 3.0 + 1.79999995231628);
|
||||
this._meteors[index].FrameCounter = this._random.Next(12);
|
||||
this._meteors[index].Scale = (float) ((double) this._random.NextFloat() * 0.5 + 1.0);
|
||||
this._meteors[index].StartX = this._meteors[index].Position.X;
|
||||
}
|
||||
Array.Sort<SolarSky.Meteor>(this._meteors, new Comparison<SolarSky.Meteor>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(SolarSky.Meteor meteor1, SolarSky.Meteor meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Meteor
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int FrameCounter;
|
||||
public float Scale;
|
||||
public float StartX;
|
||||
}
|
||||
}
|
||||
}
|
134
GameContent/Skies/StardustSky.cs
Normal file
134
GameContent/Skies/StardustSky.cs
Normal file
|
@ -0,0 +1,134 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.StardustSky
|
||||
// Assembly: Terraria, Version=1.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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class StardustSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Asset<Texture2D> _planetTexture;
|
||||
private Asset<Texture2D> _bgTexture;
|
||||
private Asset<Texture2D>[] _starTextures;
|
||||
private bool _isActive;
|
||||
private StardustSky.Star[] _stars;
|
||||
private float _fadeOpacity;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = Main.Assets.Request<Texture2D>("Images/Misc/StarDustSky/Planet", (AssetRequestMode) 1);
|
||||
this._bgTexture = Main.Assets.Request<Texture2D>("Images/Misc/StarDustSky/Background", (AssetRequestMode) 1);
|
||||
this._starTextures = new Asset<Texture2D>[2];
|
||||
for (int index = 0; index < this._starTextures.Length; ++index)
|
||||
this._starTextures[index] = Main.Assets.Request<Texture2D>("Images/Misc/StarDustSky/Star " + (object) index, (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
if (this._isActive)
|
||||
this._fadeOpacity = Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
else
|
||||
this._fadeOpacity = Math.Max(0.0f, this._fadeOpacity - 0.01f);
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture.Value, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0) * this._fadeOpacity));
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture.Value, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width() >> 1), (float) (this._planetTexture.Height() >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
int num1 = -1;
|
||||
int num2 = 0;
|
||||
for (int index = 0; index < this._stars.Length; ++index)
|
||||
{
|
||||
float depth = this._stars[index].Depth;
|
||||
if (num1 == -1 && (double) depth < (double) maxDepth)
|
||||
num1 = index;
|
||||
if ((double) depth > (double) minDepth)
|
||||
num2 = index;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (num1 == -1)
|
||||
return;
|
||||
float num3 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = num1; index < num2; ++index)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._stars[index].Depth, 1.1f / this._stars[index].Depth);
|
||||
Vector2 position = (this._stars[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
float num4 = (float) Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTimeWrappedHourly + (double) this._stars[index].SinOffset) * this._stars[index].AlphaAmplitude + this._stars[index].AlphaAmplitude;
|
||||
float num5 = (float) (Math.Sin((double) this._stars[index].AlphaFrequency * (double) Main.GlobalTimeWrappedHourly * 5.0 + (double) this._stars[index].SinOffset) * 0.100000001490116 - 0.100000001490116);
|
||||
float num6 = MathHelper.Clamp(num4, 0.0f, 1f);
|
||||
Texture2D texture = this._starTextures[this._stars[index].TextureIndex].Value;
|
||||
spriteBatch.Draw(texture, position, new Rectangle?(), Color.White * num3 * num6 * 0.8f * (1f - num5) * this._fadeOpacity, 0.0f, new Vector2((float) (texture.Width >> 1), (float) (texture.Height >> 1)), (float) (((double) vector2_4.X * 0.5 + 0.5) * ((double) num6 * 0.300000011920929 + 0.699999988079071)), SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
int num1 = 200;
|
||||
int num2 = 10;
|
||||
this._stars = new StardustSky.Star[num1 * num2];
|
||||
int index1 = 0;
|
||||
for (int index2 = 0; index2 < num1; ++index2)
|
||||
{
|
||||
float num3 = (float) index2 / (float) num1;
|
||||
for (int index3 = 0; index3 < num2; ++index3)
|
||||
{
|
||||
float num4 = (float) index3 / (float) num2;
|
||||
this._stars[index1].Position.X = (float) ((double) num3 * (double) Main.maxTilesX * 16.0);
|
||||
this._stars[index1].Position.Y = (float) ((double) num4 * (Main.worldSurface * 16.0 + 2000.0) - 1000.0);
|
||||
this._stars[index1].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 1.5);
|
||||
this._stars[index1].TextureIndex = this._random.Next(this._starTextures.Length);
|
||||
this._stars[index1].SinOffset = this._random.NextFloat() * 6.28f;
|
||||
this._stars[index1].AlphaAmplitude = this._random.NextFloat() * 5f;
|
||||
this._stars[index1].AlphaFrequency = this._random.NextFloat() + 1f;
|
||||
++index1;
|
||||
}
|
||||
}
|
||||
Array.Sort<StardustSky.Star>(this._stars, new Comparison<StardustSky.Star>(this.SortMethod));
|
||||
}
|
||||
|
||||
private int SortMethod(StardustSky.Star meteor1, StardustSky.Star meteor2) => meteor2.Depth.CompareTo(meteor1.Depth);
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Star
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int TextureIndex;
|
||||
public float SinOffset;
|
||||
public float AlphaFrequency;
|
||||
public float AlphaAmplitude;
|
||||
}
|
||||
}
|
||||
}
|
122
GameContent/Skies/VortexSky.cs
Normal file
122
GameContent/Skies/VortexSky.cs
Normal file
|
@ -0,0 +1,122 @@
|
|||
// Decompiled with JetBrains decompiler
|
||||
// Type: Terraria.GameContent.Skies.VortexSky
|
||||
// Assembly: Terraria, Version=1.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.Graphics.Effects;
|
||||
using Terraria.Utilities;
|
||||
|
||||
namespace Terraria.GameContent.Skies
|
||||
{
|
||||
public class VortexSky : CustomSky
|
||||
{
|
||||
private UnifiedRandom _random = new UnifiedRandom();
|
||||
private Asset<Texture2D> _planetTexture;
|
||||
private Asset<Texture2D> _bgTexture;
|
||||
private Asset<Texture2D> _boltTexture;
|
||||
private Asset<Texture2D> _flashTexture;
|
||||
private bool _isActive;
|
||||
private int _ticksUntilNextBolt;
|
||||
private float _fadeOpacity;
|
||||
private VortexSky.Bolt[] _bolts;
|
||||
|
||||
public override void OnLoad()
|
||||
{
|
||||
this._planetTexture = Main.Assets.Request<Texture2D>("Images/Misc/VortexSky/Planet", (AssetRequestMode) 1);
|
||||
this._bgTexture = Main.Assets.Request<Texture2D>("Images/Misc/VortexSky/Background", (AssetRequestMode) 1);
|
||||
this._boltTexture = Main.Assets.Request<Texture2D>("Images/Misc/VortexSky/Bolt", (AssetRequestMode) 1);
|
||||
this._flashTexture = Main.Assets.Request<Texture2D>("Images/Misc/VortexSky/Flash", (AssetRequestMode) 1);
|
||||
}
|
||||
|
||||
public override void Update(GameTime gameTime)
|
||||
{
|
||||
this._fadeOpacity = !this._isActive ? Math.Max(0.0f, this._fadeOpacity - 0.01f) : Math.Min(1f, 0.01f + this._fadeOpacity);
|
||||
if (this._ticksUntilNextBolt <= 0)
|
||||
{
|
||||
this._ticksUntilNextBolt = this._random.Next(1, 5);
|
||||
int index = 0;
|
||||
while (this._bolts[index].IsAlive && index != this._bolts.Length - 1)
|
||||
++index;
|
||||
this._bolts[index].IsAlive = true;
|
||||
this._bolts[index].Position.X = (float) ((double) this._random.NextFloat() * ((double) Main.maxTilesX * 16.0 + 4000.0) - 2000.0);
|
||||
this._bolts[index].Position.Y = this._random.NextFloat() * 500f;
|
||||
this._bolts[index].Depth = (float) ((double) this._random.NextFloat() * 8.0 + 2.0);
|
||||
this._bolts[index].Life = 30;
|
||||
}
|
||||
--this._ticksUntilNextBolt;
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
{
|
||||
if (this._bolts[index].IsAlive)
|
||||
{
|
||||
--this._bolts[index].Life;
|
||||
if (this._bolts[index].Life <= 0)
|
||||
this._bolts[index].IsAlive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override Color OnTileColor(Color inColor) => new Color(Vector4.Lerp(inColor.ToVector4(), Vector4.One, this._fadeOpacity * 0.5f));
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
|
||||
{
|
||||
if ((double) maxDepth >= 3.40282346638529E+38 && (double) minDepth < 3.40282346638529E+38)
|
||||
{
|
||||
spriteBatch.Draw(TextureAssets.BlackTile.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.Black * this._fadeOpacity);
|
||||
spriteBatch.Draw(this._bgTexture.Value, new Rectangle(0, Math.Max(0, (int) ((Main.worldSurface * 16.0 - (double) Main.screenPosition.Y - 2400.0) * 0.100000001490116)), Main.screenWidth, Main.screenHeight), Color.White * Math.Min(1f, (float) (((double) Main.screenPosition.Y - 800.0) / 1000.0)) * this._fadeOpacity);
|
||||
Vector2 vector2_1 = new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Vector2 vector2_2 = 0.01f * (new Vector2((float) Main.maxTilesX * 8f, (float) Main.worldSurface / 2f) - Main.screenPosition);
|
||||
spriteBatch.Draw(this._planetTexture.Value, vector2_1 + new Vector2(-200f, -200f) + vector2_2, new Rectangle?(), Color.White * 0.9f * this._fadeOpacity, 0.0f, new Vector2((float) (this._planetTexture.Width() >> 1), (float) (this._planetTexture.Height() >> 1)), 1f, SpriteEffects.None, 1f);
|
||||
}
|
||||
float num1 = Math.Min(1f, (float) (((double) Main.screenPosition.Y - 1000.0) / 1000.0));
|
||||
Vector2 vector2_3 = Main.screenPosition + new Vector2((float) (Main.screenWidth >> 1), (float) (Main.screenHeight >> 1));
|
||||
Rectangle rectangle = new Rectangle(-1000, -1000, 4000, 4000);
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
{
|
||||
if (this._bolts[index].IsAlive && (double) this._bolts[index].Depth > (double) minDepth && (double) this._bolts[index].Depth < (double) maxDepth)
|
||||
{
|
||||
Vector2 vector2_4 = new Vector2(1f / this._bolts[index].Depth, 0.9f / this._bolts[index].Depth);
|
||||
Vector2 position = (this._bolts[index].Position - vector2_3) * vector2_4 + vector2_3 - Main.screenPosition;
|
||||
if (rectangle.Contains((int) position.X, (int) position.Y))
|
||||
{
|
||||
Texture2D texture = this._boltTexture.Value;
|
||||
int life = this._bolts[index].Life;
|
||||
if (life > 26 && life % 2 == 0)
|
||||
texture = this._flashTexture.Value;
|
||||
float num2 = (float) life / 30f;
|
||||
spriteBatch.Draw(texture, position, new Rectangle?(), Color.White * num1 * num2 * this._fadeOpacity, 0.0f, Vector2.Zero, vector2_4.X * 5f, SpriteEffects.None, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetCloudAlpha() => (float) ((1.0 - (double) this._fadeOpacity) * 0.300000011920929 + 0.699999988079071);
|
||||
|
||||
public override void Activate(Vector2 position, params object[] args)
|
||||
{
|
||||
this._fadeOpacity = 1f / 500f;
|
||||
this._isActive = true;
|
||||
this._bolts = new VortexSky.Bolt[500];
|
||||
for (int index = 0; index < this._bolts.Length; ++index)
|
||||
this._bolts[index].IsAlive = false;
|
||||
}
|
||||
|
||||
public override void Deactivate(params object[] args) => this._isActive = false;
|
||||
|
||||
public override void Reset() => this._isActive = false;
|
||||
|
||||
public override bool IsActive() => this._isActive || (double) this._fadeOpacity > 1.0 / 1000.0;
|
||||
|
||||
private struct Bolt
|
||||
{
|
||||
public Vector2 Position;
|
||||
public float Depth;
|
||||
public int Life;
|
||||
public bool IsAlive;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue