2017-08-23 08:45:30 +08:00
using AdditionalCropsFramework.Framework ;
using Microsoft.Xna.Framework ;
using Microsoft.Xna.Framework.Input ;
using StardewModdingAPI ;
using StardewValley ;
2017-09-12 09:35:31 +08:00
using StardewValley.Menus ;
2018-06-13 09:42:31 +08:00
using StardustCore.Objects.Tools ;
2017-09-05 19:13:42 +08:00
using StardustCore.Serialization ;
2017-08-23 08:45:30 +08:00
using System ;
using System.Collections.Generic ;
2017-09-05 19:13:42 +08:00
using System.IO ;
2017-08-23 08:45:30 +08:00
using System.Linq ;
using System.Text ;
using System.Threading.Tasks ;
2017-09-05 19:13:42 +08:00
2017-08-23 08:45:30 +08:00
namespace AdditionalCropsFramework
{
/ *
Todo : + Reuse Seedbag code from revitalize in this mod . ( Done ! )
+ Make a way to interact with the modded seedbags ( look at revitalize ' s code again ) ( Done ! Fixed with planter boxes )
! Serialize and deserialize the modded crop objects and planter boxes and seed bags that exist in the game . Maybe have a list to keep track of all of them or just iterate through everything in the world ?
+ Make it so I can plant the modded crops . ( DONE ! Fixed in planterboxes )
! Make sure crops grow overnight .
! Add way for crops to be watered and to ensure that there is a graphical update when the crop is being watered .
! Add way to harvest crop from planterbox without removing planterbox .
! Fix invisible planterbox so that it does get removed when planting seeds on tillable soil and keep that soil as HoeDirt instead of reverting to normal . This can also be used to just make the dirt look wet .
2017-09-05 19:13:42 +08:00
! Add in Multiple layers to the Planter Boxes : SoilLayer - > CropLayer - > BoxLayer is the draw order . Mainly for aesthetics . Box on top , dry dirt below , and wet dirt below that .
* * * * /
2017-08-23 08:45:30 +08:00
public class ModCore : Mod
{
public static IModHelper ModHelper ;
2017-09-12 09:35:31 +08:00
public static IMonitor ModMonitor ;
2017-08-23 08:45:30 +08:00
public static readonly List < ModularCropObject > SpringWildCrops = new List < ModularCropObject > ( ) ;
public static readonly List < ModularCropObject > SummerWildCrops = new List < ModularCropObject > ( ) ;
public static readonly List < ModularCropObject > FallWildCrops = new List < ModularCropObject > ( ) ;
public static readonly List < ModularCropObject > WinterWildCrops = new List < ModularCropObject > ( ) ;
2017-09-15 04:49:19 +08:00
public static Framework . Config ModConfig ;
2017-09-05 19:13:42 +08:00
2017-09-13 17:39:50 +08:00
private List < Item > shippingList ;
2017-08-23 08:45:30 +08:00
public override void Entry ( IModHelper helper )
{
ModHelper = helper ;
2017-09-12 09:35:31 +08:00
ModMonitor = this . Monitor ;
2017-09-05 19:13:42 +08:00
StardewModdingAPI . Events . SaveEvents . AfterLoad + = SaveEvents_AfterLoad ;
StardewModdingAPI . Events . SaveEvents . AfterSave + = SaveEvents_AfterSave ;
2017-09-13 17:39:50 +08:00
2017-09-13 07:30:30 +08:00
if ( ! Directory . Exists ( Path . Combine ( ModCore . ModHelper . DirectoryPath , Utilities . EntensionsFolderName ) ) )
{
Directory . CreateDirectory ( Path . Combine ( ModCore . ModHelper . DirectoryPath , Utilities . EntensionsFolderName ) ) ;
}
2017-09-14 04:53:12 +08:00
2017-09-14 08:11:05 +08:00
StardustCore . ModCore . SerializationManager . acceptedTypes . Add ( "AdditionalCropsFramework.PlanterBox" , new SerializerDataNode ( new SerializerDataNode . SerializingFunction ( PlanterBox . Serialize ) , new SerializerDataNode . ParsingFunction ( PlanterBox . ParseIntoInventory ) , new SerializerDataNode . WorldParsingFunction ( PlanterBox . SerializeFromWorld ) , new SerializerDataNode . SerializingToContainerFunction ( PlanterBox . Serialize ) ) ) ; //need serialize, deserialize, and world deserialize functions.
StardustCore . ModCore . SerializationManager . acceptedTypes . Add ( "AdditionalCropsFramework.ModularCropObject" , new SerializerDataNode ( new SerializerDataNode . SerializingFunction ( ModularCropObject . Serialize ) , new SerializerDataNode . ParsingFunction ( ModularCropObject . ParseIntoInventory ) , new SerializerDataNode . WorldParsingFunction ( ModularCropObject . SerializeFromWorld ) , new SerializerDataNode . SerializingToContainerFunction ( ModularCropObject . Serialize ) ) ) ;
StardustCore . ModCore . SerializationManager . acceptedTypes . Add ( "AdditionalCropsFramework.ModularSeeds" , new SerializerDataNode ( new SerializerDataNode . SerializingFunction ( ModularSeeds . Serialize ) , new SerializerDataNode . ParsingFunction ( ModularSeeds . ParseIntoInventory ) , new SerializerDataNode . WorldParsingFunction ( ModularSeeds . SerializeFromWorld ) , new SerializerDataNode . SerializingToContainerFunction ( ModularSeeds . Serialize ) ) ) ;
2017-09-14 04:53:12 +08:00
// StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
2017-09-13 17:39:50 +08:00
this . shippingList = new List < Item > ( ) ;
2017-09-12 09:35:31 +08:00
2017-09-15 04:49:19 +08:00
ModConfig = helper . ReadConfig < Framework . Config > ( ) ;
2017-09-13 17:39:50 +08:00
}
2017-09-12 09:35:31 +08:00
2017-09-13 17:39:50 +08:00
public void dailyUpdates ( )
{
2017-09-14 04:53:12 +08:00
foreach ( var v in StardustCore . ModCore . SerializationManager . trackedObjectList )
2017-09-13 17:39:50 +08:00
{
if ( v is PlanterBox )
{
( v as PlanterBox ) . dayUpdate ( ) ;
}
}
}
2017-08-23 08:45:30 +08:00
2017-09-05 19:13:42 +08:00
private void SaveEvents_AfterSave ( object sender , EventArgs e )
{
2017-09-13 17:39:50 +08:00
dailyUpdates ( ) ;
2017-09-05 19:13:42 +08:00
}
2017-08-23 08:45:30 +08:00
2017-09-14 04:53:12 +08:00
2017-09-05 19:13:42 +08:00
private void SaveEvents_AfterLoad ( object sender , EventArgs e )
{
2017-09-14 04:53:12 +08:00
2017-09-13 17:39:50 +08:00
dailyUpdates ( ) ;
2017-09-05 19:13:42 +08:00
}
2017-08-23 08:45:30 +08:00
}
}