Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
WorkshopPublishingIndicator.cs
Go to the documentation of this file.
8
10
12{
13 private float _displayUpPercent;
14
15 private int _frameCounter;
16
18
20
22
23 public void Hide()
24 {
26 _frameCounter = 0;
29 }
30
31 public void Draw(SpriteBatch spriteBatch)
32 {
34 if (workshop == null)
35 {
36 return;
37 }
38 AWorkshopProgressReporter progressReporter = workshop.ProgressReporter;
39 bool hasOngoingTasks = progressReporter.HasOngoingTasks;
40 bool num = _displayUpPercent == 1f;
41 _displayUpPercent = MathHelper.Clamp(_displayUpPercent + (float)hasOngoingTasks.ToDirectionInt() / 60f, 0f, 1f);
42 bool flag = _displayUpPercent == 1f;
43 if (num && !flag)
44 {
46 }
47 if (_displayUpPercent == 0f)
48 {
49 return;
50 }
51 if (_indicatorTexture == null)
52 {
53 _indicatorTexture = Main.Assets.Request<Texture2D>("Images/UI/Workshop/InProgress", (AssetRequestMode)1);
54 }
56 int num2 = 6;
58 int num3 = 5;
59 int num4 = _frameCounter / num3 % num2;
60 Vector2 vector = Main.ScreenSize.ToVector2() + new Vector2(-40f, 40f);
61 Vector2 value2 = vector + new Vector2(0f, -80f);
62 Vector2 position = Vector2.Lerp(vector, value2, _displayUpPercent);
63 Rectangle rectangle = value.Frame(1, 6, 0, num4);
64 Vector2 origin = rectangle.Size() / 2f;
65 spriteBatch.Draw(value, position, rectangle, Color.White, 0f, origin, 1f, SpriteEffects.None, 0f);
66 if (progressReporter.TryGetProgress(out var progress) && !float.IsNaN(progress))
67 {
68 string text = progress.ToString("P");
70 int num5 = 1;
71 Vector2 origin2 = value3.MeasureString(text) * num5 * new Vector2(0.5f, 1f);
72 Utils.DrawBorderStringFourWay(spriteBatch, value3, text, position.X, position.Y - 10f, Color.White, Color.Black, origin2, num5);
73 }
74 if (num4 == 3 && _frameCounter % num3 == 0)
75 {
77 {
81 }
82 if (hasOngoingTasks)
83 {
84 float volumeScale = Utils.Remap(_timesSoundWasPlayed, 0f, 10f, 1f, 0f);
85 SoundEngine.PlaySound(21, -1, -1, 1, volumeScale);
87 }
88 }
89 }
90}
void Draw(Texture2D texture, Vector2 position, Color color)
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static void PlaySound(int type, Vector2 position, int style=1)
static Asset< DynamicSpriteFont > ItemStack
Definition FontAssets.cs:8
static Microsoft.Xna.Framework.Point ScreenSize
Definition Main.cs:2925
static IAssetRepository Assets
Definition Main.cs:209
static Terraria.Social.Base.WorkshopSocialModule Workshop
Definition SocialAPI.cs:24
static float Remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped=true)
Definition Utils.cs:233
static void DrawBorderStringFourWay(SpriteBatch sb, DynamicSpriteFont font, string text, float x, float y, Color textColor, Color borderColor, Vector2 origin, float scale=1f)
Definition Utils.cs:1857
static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Definition Vector2.cs:227