Got sitting working as a test! Next: Make some chairs!
This commit is contained in:
parent
3369c11cb9
commit
8530a9ea03
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Happy Birthday",
|
"Name": "Happy Birthday",
|
||||||
"Author": "Alpha_Omegasis",
|
"Author": "Alpha_Omegasis",
|
||||||
"Version": "1.8.0",
|
"Version": "1.8.2",
|
||||||
"MinimumApiVersion": "1.15",
|
"MinimumApiVersion": "1.15",
|
||||||
"Description": "Adds the farmer's birthday to the game.",
|
"Description": "Adds the farmer's birthday to the game.",
|
||||||
"UniqueID": "Omegasis.HappyBirthday",
|
"UniqueID": "Omegasis.HappyBirthday",
|
||||||
|
|
|
@ -53,6 +53,9 @@ namespace Revitalize.Framework.Objects
|
||||||
this.location = Game1.player.currentLocation;
|
this.location = Game1.player.currentLocation;
|
||||||
}
|
}
|
||||||
this.info.lightManager.toggleLights(this.location, this);
|
this.info.lightManager.toggleLights(this.location, this);
|
||||||
|
|
||||||
|
Revitalize.ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using StardewValley;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Player.Managers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TODO:
|
||||||
|
/// Make chair
|
||||||
|
/// animate player better
|
||||||
|
/// have it where when player is sitting on chair it is passable so it can't be destoryed underneath
|
||||||
|
/// </summary>
|
||||||
|
public class SittingInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// If the player is currently sitting.
|
||||||
|
/// </summary>
|
||||||
|
public bool isSitting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How long a Farmer has sat (in milliseconds)
|
||||||
|
/// </summary>
|
||||||
|
private int elapsedTime;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets how long the farmer has sat (in milliseconds).
|
||||||
|
/// </summary>
|
||||||
|
public int ElapsedTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return elapsedTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keeps trck of time elapsed.
|
||||||
|
/// </summary>
|
||||||
|
GameTime timer;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default amount of time a player has to sit to recover some energy/health
|
||||||
|
/// </summary>
|
||||||
|
private int _sittingSpan;
|
||||||
|
/// <summary>
|
||||||
|
/// A modified version of how long a player has to sit to recover energy/health;
|
||||||
|
/// </summary>
|
||||||
|
public int SittingSpan
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _sittingSpan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor.
|
||||||
|
/// </summary>
|
||||||
|
public SittingInfo()
|
||||||
|
{
|
||||||
|
timer = Game1.currentGameTime;
|
||||||
|
this._sittingSpan = 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the sitting info.
|
||||||
|
/// </summary>
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
if (Game1.activeClickableMenu != null) return;
|
||||||
|
|
||||||
|
if (Game1.player.isMoving())
|
||||||
|
{
|
||||||
|
isSitting = false;
|
||||||
|
elapsedTime = 0;
|
||||||
|
}
|
||||||
|
if (isSitting && Game1.player.CanMove)
|
||||||
|
{
|
||||||
|
showSitting();
|
||||||
|
if (timer == null) timer = Game1.currentGameTime;
|
||||||
|
elapsedTime += timer.ElapsedGameTime.Milliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elapsedTime >= SittingSpan)
|
||||||
|
{
|
||||||
|
elapsedTime %= SittingSpan;
|
||||||
|
Game1.player.health++;
|
||||||
|
Game1.player.Stamina++;
|
||||||
|
}
|
||||||
|
Revitalize.ModCore.log(elapsedTime);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showSitting()
|
||||||
|
{
|
||||||
|
switch (Game1.player.FacingDirection)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
Game1.player.FarmerSprite.setCurrentSingleFrame(113, (short)32000, false, false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, false);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Game1.player.FarmerSprite.setCurrentSingleFrame(107, (short)32000, false, false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Game1.player.FarmerSprite.setCurrentSingleFrame(106, (short)32000, false, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sit(StardewValley.Object obj,Vector2 offset)
|
||||||
|
{
|
||||||
|
this.isSitting = true;
|
||||||
|
Game1.player.Position = (obj.TileLocation * Game1.tileSize + offset);
|
||||||
|
Game1.player.position.Y += Game1.tileSize/2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Revitalize.Framework.Player.Managers;
|
||||||
|
using StardewValley;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Player
|
||||||
|
{
|
||||||
|
public class PlayerInfo
|
||||||
|
{
|
||||||
|
public SittingInfo sittingInfo;
|
||||||
|
|
||||||
|
public PlayerInfo()
|
||||||
|
{
|
||||||
|
sittingInfo = new SittingInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
sittingInfo.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ using System.IO;
|
||||||
using Revitalize.Framework.Crafting;
|
using Revitalize.Framework.Crafting;
|
||||||
using StardewValley.Objects;
|
using StardewValley.Objects;
|
||||||
using Revitalize.Framework.Illuminate;
|
using Revitalize.Framework.Illuminate;
|
||||||
|
using Revitalize.Framework.Player;
|
||||||
|
|
||||||
namespace Revitalize
|
namespace Revitalize
|
||||||
{
|
{
|
||||||
|
@ -88,6 +89,7 @@ namespace Revitalize
|
||||||
|
|
||||||
public static Dictionary<string, CustomObject> customObjects;
|
public static Dictionary<string, CustomObject> customObjects;
|
||||||
|
|
||||||
|
public static PlayerInfo playerInfo;
|
||||||
|
|
||||||
public override void Entry(IModHelper helper)
|
public override void Entry(IModHelper helper)
|
||||||
{
|
{
|
||||||
|
@ -101,6 +103,7 @@ namespace Revitalize
|
||||||
ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
|
ModHelper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
|
||||||
ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged;
|
ModHelper.Events.GameLoop.TimeChanged += GameLoop_TimeChanged;
|
||||||
ModHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;
|
ModHelper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked;
|
||||||
|
playerInfo = new PlayerInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +121,7 @@ namespace Revitalize
|
||||||
private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
|
private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
|
||||||
{
|
{
|
||||||
DarkerNight.SetDarkerColor();
|
DarkerNight.SetDarkerColor();
|
||||||
|
playerInfo.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e)
|
private void GameLoop_TimeChanged(object sender, StardewModdingAPI.Events.TimeChangedEventArgs e)
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
<Compile Include="Framework\Objects\CustomObject.cs" />
|
<Compile Include="Framework\Objects\CustomObject.cs" />
|
||||||
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
|
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
|
||||||
<Compile Include="Framework\Objects\MultiTiledObject.cs" />
|
<Compile Include="Framework\Objects\MultiTiledObject.cs" />
|
||||||
|
<Compile Include="Framework\Player\Managers\SittingInfo.cs" />
|
||||||
|
<Compile Include="Framework\Player\PlayerInfo.cs" />
|
||||||
<Compile Include="Framework\Utilities\InventoryManager.cs" />
|
<Compile Include="Framework\Utilities\InventoryManager.cs" />
|
||||||
<Compile Include="ModCore.cs" />
|
<Compile Include="ModCore.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
Loading…
Reference in New Issue