Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
NPCHeadRenderer.cs
Go to the documentation of this file.
5
7
9{
11
13
14 public bool IsReady => false;
15
16 public NPCHeadRenderer(Asset<Texture2D>[] matchingArray)
17 {
18 _matchingArray = matchingArray;
19 Reset();
20 }
21
22 public void Reset()
23 {
25 }
26
27 public void DrawWithOutlines(Entity entity, int headId, Vector2 position, Color color, float rotation, float scale, SpriteEffects effects)
28 {
29 if (_contents[headId] == null)
30 {
32 _contents[headId].SetTexture(_matchingArray[headId].Value);
33 }
34 NPCHeadDrawRenderTargetContent nPCHeadDrawRenderTargetContent = _contents[headId];
35 if (nPCHeadDrawRenderTargetContent.IsReady)
36 {
37 RenderTarget2D target = nPCHeadDrawRenderTargetContent.GetTarget();
38 Main.spriteBatch.Draw(target, position, null, color, rotation, ((Texture2D)target).Size() / 2f, scale, effects, 0f);
39 }
40 else
41 {
42 nPCHeadDrawRenderTargetContent.Request();
43 }
44 }
45
46 public void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
47 {
48 for (int i = 0; i < _contents.Length; i++)
49 {
50 if (_contents[i] != null && !_contents[i].IsReady)
51 {
52 _contents[i].PrepareRenderTarget(device, spriteBatch);
53 }
54 }
55 }
56}
void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
NPCHeadDrawRenderTargetContent[] _contents
NPCHeadRenderer(Asset< Texture2D >[] matchingArray)
void PrepareRenderTarget(GraphicsDevice device, SpriteBatch spriteBatch)
void DrawWithOutlines(Entity entity, int headId, Vector2 position, Color color, float rotation, float scale, SpriteEffects effects)
static SpriteBatch spriteBatch
Definition Main.cs:974