Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomEntryIcon.cs
Go to the documentation of this file.
1using System;
6
8
10{
12
14
16
17 private Func<bool> _unlockCondition;
18
19 public CustomEntryIcon(string nameLanguageKey, string texturePath, Func<bool> unlockCondition)
20 {
21 _text = Language.GetText(nameLanguageKey);
22 _textureAsset = Main.Assets.Request<Texture2D>(texturePath, (AssetRequestMode)1);
23 _unlockCondition = unlockCondition;
25 }
26
31
32 public void Update(BestiaryUICollectionInfo providedInfo, Rectangle hitbox, EntryIconDrawSettings settings)
33 {
34 UpdateUnlockState(GetUnlockState(providedInfo));
35 }
36
37 public void Draw(BestiaryUICollectionInfo providedInfo, SpriteBatch spriteBatch, EntryIconDrawSettings settings)
38 {
39 Rectangle iconbox = settings.iconbox;
40 spriteBatch.Draw(_textureAsset.Value, iconbox.Center.ToVector2() + Vector2.One, _sourceRectangle, Color.White, 0f, _sourceRectangle.Size() / 2f, 1f, SpriteEffects.None, 0f);
41 }
42
43 public string GetHoverText(BestiaryUICollectionInfo providedInfo)
44 {
45 if (GetUnlockState(providedInfo))
46 {
47 return _text.Value;
48 }
49 return "???";
50 }
51
52 private void UpdateUnlockState(bool state)
53 {
54 _sourceRectangle = _textureAsset.Frame(2, 1, state.ToInt());
56 }
57
58 public bool GetUnlockState(BestiaryUICollectionInfo providedInfo)
59 {
60 return providedInfo.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;
61 }
62}
void Draw(Texture2D texture, Vector2 position, Color color)
CustomEntryIcon(string nameLanguageKey, string texturePath, Func< bool > unlockCondition)
void Draw(BestiaryUICollectionInfo providedInfo, SpriteBatch spriteBatch, EntryIconDrawSettings settings)
string GetHoverText(BestiaryUICollectionInfo providedInfo)
bool GetUnlockState(BestiaryUICollectionInfo providedInfo)
void Update(BestiaryUICollectionInfo providedInfo, Rectangle hitbox, EntryIconDrawSettings settings)
static LocalizedText GetText(string key)
Definition Language.cs:10
static IAssetRepository Assets
Definition Main.cs:209
void Inflate(int horizontalAmount, int verticalAmount)
Definition Rectangle.cs:84