Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor + features #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions ChildBedConfig/BuildingExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using StardewValley;
using xTile.Tiles;

namespace ChildBedConfig
{
static class BuildingExtensions
{
internal static void RemoveCrib(this GameLocation building)
{
building.removeTiles("Buildings", 15, 3, 17, 5); //Get rid of the tiles from the building layer
building.removeTiles("Front", 15, 2, 17, 4); //Get rid of the tiles from the front layer

int wallpaper = building.getTileIndexAt(18, 3, "Buildings"); //get the wallpaper id so we can plaster it onto the tiles we're adding
int flooring = building.getTileIndexAt(19, 3, "Back"); //get the flooring id too

StaticTile WallpaperTile = new StaticTile(building.Map.GetLayer("Buildings"), building.Map.GetTileSheet("walls_and_floors"), BlendMode.Alpha, wallpaper);
StaticTile FlooringTile = new StaticTile(building.Map.GetLayer("Back"), building.Map.GetTileSheet("walls_and_floors"), BlendMode.Alpha, flooring);

//Add wall tiles to 15 3, 16 3, and 17 3 on the Buildings layer, which were previously occupied by the crib
building.Map.GetLayer("Buildings").Tiles[15, 3] = WallpaperTile;
building.Map.GetLayer("Buildings").Tiles[16, 3] = WallpaperTile;
building.Map.GetLayer("Buildings").Tiles[17, 3] = WallpaperTile;

//Add fooring tiles to the back layer where the crib was -- we'll have a weird black line there otherwise
building.Map.GetLayer("Back").Tiles[15, 3] = FlooringTile;
building.Map.GetLayer("Back").Tiles[16, 3] = FlooringTile;
building.Map.GetLayer("Back").Tiles[17, 3] = FlooringTile;
}

internal static void RemoveLeftBed(this GameLocation building)
{
removeTiles(building, "Buildings", 22, 4, 23, 6); //Get rid of the tiles from the building layer
removeTiles(building, "Front", 22, 3, 23, 5); //Get rid of the tiles from the front layer
}

internal static void RemoveRightBed(this GameLocation building)
{
removeTiles(building, "Buildings", 26, 4, 27, 6); //Get rid of the tiles from the building layer
removeTiles(building, "Front", 26, 3, 27, 5); //Get rid of the tiles from the front layer
}

private static void removeTiles(this GameLocation location, string layer, int startX, int startY, int endX, int endY)
{
for (int x = startX; x <= endX; x++)
{
for (int y = startY; y <= endY; y++)
{
location.removeTile(x, y, layer);
}
}
}
}
}
29 changes: 10 additions & 19 deletions ChildBedConfig/ChildBedConfig.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -33,6 +34,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Stardew Valley">
<HintPath>..\..\..\..\..\..\Steam\steamapps\common\Stardew Valley\Stardew Valley.exe</HintPath>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>..\..\..\..\..\..\Steam\steamapps\common\Stardew Valley\StardewModdingAPI.exe</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -43,37 +50,21 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BuildingExtensions.cs" />
<Compile Include="ModConfig.cs" />
<Compile Include="ModEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="assets\married\Bed1.tbin" />
<None Include="assets\married\Bed1_Bed2.tbin" />
<None Include="assets\married\Bed2.tbin" />
<None Include="assets\married\Crib.tbin" />
<None Include="assets\married\Crib_Bed1.tbin" />
<None Include="assets\married\Crib_Bed2.tbin" />
<None Include="assets\married\None.tbin" />
<None Include="assets\single\Bed1.tbin" />
<None Include="assets\single\Bed1_Bed2.tbin" />
<None Include="assets\single\Bed2.tbin" />
<None Include="assets\single\Crib.tbin" />
<None Include="assets\single\Crib_Bed1.tbin" />
<None Include="assets\single\Crib_Bed2.tbin" />
<None Include="assets\single\None.tbin" />
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\analyzers\dotnet\cs\StardewModdingAPI.ModBuildConfig.Analyzer.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.3.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.2.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.3.1.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>
69 changes: 17 additions & 52 deletions ChildBedConfig/ModConfig.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace ChildBedConfig
{
Expand All @@ -11,68 +7,37 @@ class ModConfig
/*****************************/
/** Properties **/
/*****************************/
public List<Farmer> Farmers { get; set; }
//public List<Farmer> Farmers { get; set; }

/*****************************/
/** Public methods **/
/*****************************/
///<summary>Constructor, set up the example of the config for players to follow</summary>
public ModConfig()
{
Farmer Default = new Farmer();
Farmers = new List<Farmer>();
Farmers.Add(Default);
}
public List<Farm> Farms { get; set; } = new List<Farm>() { };
}

/// <summary>
/// Class for the farm -- we have a list of them in the config
/// </summary>
class Farm
{
public string FarmName { get; set; } = "";
public Dictionary<string, Farmer> FarmerInfo { get; set; } = new Dictionary<string, Farmer>() { };
}

/// <summary>
/// Class for the farmer -- we have a list of them in the config
/// Class for the farmer -- we have a list of them in the Farm object in the config
/// </summary>
class Farmer
{
/*****************************/
/** Properties **/
/*****************************/
///<summary>Name of the farmer</summary>
public string CharacterName { get; set; }

///<summary>Determines whether or not to show the crib</summary>
public bool ShowHomeCrib { get; set; }
public bool ShowCrib { get; set; } = true;

///<summary>Determines whether or not to show the bed closest to the crib</summary>
public bool ShowHomeBed1 { get; set; }
public bool ShowLeftBed { get; set; } = true;

///<summary>Determines whether or not to show the bed furthest from the crib</summary>
public bool ShowHomeBed2 { get; set; }

//This is all the same as the above, it just affects the cabins
public bool ShowCabinCrib { get; set; }
public bool ShowCabinBed1 { get; set; }
public bool ShowCabinBed2 { get; set; }

/*****************************/
/** Public methods **/
/*****************************/
public Farmer()
{
CharacterName = "NoName";
ShowHomeCrib = true;
ShowHomeBed1 = true;
ShowHomeBed2 = true;
ShowCabinCrib = true;
ShowCabinBed1 = true;
ShowCabinBed2 = true;
}

public Farmer(string name, bool showCrib, bool showBed1, bool showBed2, bool showCabinCrib, bool showCabinBed1, bool showCabinBed2)
{
CharacterName = name;
ShowHomeCrib = showCrib;
ShowHomeBed1 = showBed1;
ShowHomeBed2 = showBed2;
ShowCabinCrib = showCabinCrib;
ShowCabinBed1 = showCabinBed1;
ShowCabinBed2 = showCabinBed2;
}
public bool ShowRightBed { get; set; } = true;

}
}
Loading