3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
8 internal partial class Planter
10 public Vector2 DrawSize => CalculateSize();
12 private Vector2 CalculateSize()
14 if (GrowableSeeds.All(s => s ==
null)) {
return Vector2.Zero; }
19 for (
int i = 0; i < GrowableSeeds.Length; i++)
21 Growable seed = GrowableSeeds[i];
22 PlantSlot slot = PlantSlots.ContainsKey(i) ? PlantSlots[i] : NullSlot;
23 if (seed ==
null) {
continue; }
25 foreach (VineTile vine
in seed.Vines)
28 worldRect.Location += slot.Offset.ToPoint();
29 worldRect.Location += pos;
34 Vector2 result =
new Vector2(MaxDistance(pos.X, rect.Left, rect.Right) * 2, MaxDistance(pos.Y, rect.Top, rect.Bottom) * 2);
37 static float MaxDistance(
float origin,
float x,
float y)
39 return Math.Max(Math.Abs(origin - x), Math.Abs(origin - y));
43 public void Draw(SpriteBatch spriteBatch,
bool editing,
float itemDepth = -1, Color? overrideColor =
null)
45 for (var i = 0; i < GrowableSeeds.Length; i++)
47 Growable growable = GrowableSeeds[i];
48 PlantSlot slot = PlantSlots.ContainsKey(i) ? PlantSlots[i] : NullSlot;
49 growable?.Draw(spriteBatch,
this, slot.Offset, itemDepth);
virtual Vector2 DrawPosition