Skip to content

Commit

Permalink
Overhauled update
Browse files Browse the repository at this point in the history
  • Loading branch information
nofilenamed committed May 19, 2024
1 parent db2d0f4 commit d4ce151
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using StardewValley;
using StardewValley.Buildings;
using StardewValley.Characters;
using StardewValley.GameData.Buildings;
using StardewValley.Network;

namespace AnimalObserver
Expand Down Expand Up @@ -56,7 +55,7 @@ private void OnButtonsChanged(object sender, ButtonsChangedEventArgs e)
}
}

private static List<FarmAnimal> GetAnimals(object currentLocation)
private static List<FarmAnimal> GetAnimals(GameLocation currentLocation)
{
List<FarmAnimal> list = null;
if (currentLocation is Farm farm)
Expand Down Expand Up @@ -106,11 +105,13 @@ private static Pet GetPet(GameLocation currentLocation)
}


public Vector2 GetOffsetForAnimal(BuildingData data)
public Vector2 GetOffsetForAnimal(Building building)
{
if (data == null)
if (building == null)
return Config.Offsets.Pet;

var data = building.GetData();

if (data.ValidOccupantTypes[0] == "Coop")
{
return Config.Offsets.CoopAnimal;
Expand Down Expand Up @@ -158,6 +159,7 @@ private void OnRenderedWorld(object sender, EventArgs e)
double ms = Game1.currentGameTime.TotalGameTime.TotalMilliseconds;
float yOffsetFactor = 4f * (float)Math.Round(Math.Sin(ms / 250.0), 2);


if (animals != null)
{
bool showProduct = false;
Expand All @@ -177,23 +179,24 @@ private void OnRenderedWorld(object sender, EventArgs e)
{
if (showProduct && !string.IsNullOrEmpty(animal.currentProduce.Value) && animal.isAdult())
{
//Monitor.LogOnce($"{animal.displayName} {animal.currentProduce.Value}", LogLevel.Debug);
switch (animal.currentProduce.Value)
{
case "(O)184"://Milk Cow ID
case "(O)186"://Milk Cow ID
case "184"://Milk Cow ID
case "186"://Milk Cow ID
{
DrawEntity(Game1.objectSpriteSheet, Entities.CowMilk, animal, animal.home, ref yOffsetFactor);
break;
}

case "(O)436"://Milk Goat ID
case "(O)438"://Milk Goat ID
case "436"://Milk Goat ID
case "438"://Milk Goat ID
{
DrawEntity(Game1.objectSpriteSheet, Entities.GoatMilk, animal, animal.home, ref yOffsetFactor);
break;
}

case "(O)430": //Truffle ID
case "430": //Truffle ID
{
if (Config.ShowTruffle)
{
Expand All @@ -202,7 +205,7 @@ private void OnRenderedWorld(object sender, EventArgs e)
break;
}

case "(O)440"://Wool ID
case "440"://Wool ID
{
DrawEntity(Game1.objectSpriteSheet, Entities.Wool, animal, animal.home, ref yOffsetFactor);
break;
Expand Down Expand Up @@ -237,7 +240,7 @@ private void OnRenderedWorld(object sender, EventArgs e)

private void DrawEntity(Texture2D spriteSheet, EntitiesConfig config, Character character, Building building, ref float yOffsetFactor)
{
Vector2 offset = GetOffsetForAnimal(building.GetData());
Vector2 offset = GetOffsetForAnimal(building);
offset += character.position.Value;

offset += new Vector2(character.Sprite.getWidth() / 2, yOffsetFactor);
Expand Down

0 comments on commit d4ce151

Please sign in to comment.