Skip to content

Commit f71bb4a

Browse files
committed
Initial commit
Not yet functional.
1 parent b2a5327 commit f71bb4a

8 files changed

+322
-0
lines changed

CustomObjects.cs

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using Microsoft.Xna.Framework;
2+
using StardewValley;
3+
using System.Collections.Generic;
4+
5+
namespace StardewCustoms
6+
{
7+
public static class CustomObjectHandler
8+
{
9+
public static int BaseItemId
10+
{
11+
get { return 921; }
12+
}
13+
14+
private static Dictionary<string, CustomObject> CustomObjects = new Dictionary<string, CustomObject>();
15+
16+
internal static void Setup()
17+
{
18+
//first, create our base object data
19+
Game1.objectInformation.Add(BaseItemId, "CustomItem / 375 / -300 / Basic - 26 / CustomItem / A custom item that isn't loaded properly.");
20+
}
21+
22+
//this is a public API method
23+
public static void RegisterCustomObject(CustomObject customObject)
24+
{
25+
if(customObject != null) {
26+
if (string.IsNullOrWhiteSpace(customObject.ObjectId)) customObject.ObjectId = "?";
27+
if (string.IsNullOrWhiteSpace(customObject.ModId)) customObject.ModId = "?";
28+
CustomObjects[customObject.GlobalId] = customObject;
29+
}
30+
}
31+
}
32+
33+
//this is a class designed to be implemented by other mods
34+
//nearly everything here should be virtual/overrideable
35+
//our base class, handed to the game, will forward most calls to this instance
36+
//(to avoid having people mess with a class that does internal stuff for us)
37+
public class CustomObject
38+
{
39+
public string ObjectId;
40+
public string ModId;
41+
public string GlobalId
42+
{
43+
get { return ModId + ":" + ObjectId; }
44+
}
45+
46+
public CustomObject(string modId, string objectId)
47+
{
48+
ModId = modId;
49+
ObjectId = objectId; //can be anything really, long as its unique. CamelCase recommended.
50+
}
51+
}
52+
53+
public class CustomObjectInstance : Object
54+
{
55+
private CustomObject CustomObjectData;
56+
57+
//deserialization constructor
58+
public CustomObjectInstance()
59+
{
60+
61+
}
62+
63+
//item creation constructor
64+
public CustomObjectInstance(Vector2 location) : base(location, CustomObjectHandler.BaseItemId)
65+
{
66+
67+
}
68+
}
69+
}

Properties/AssemblyInfo.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("StardewCustoms")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("StardewCustoms")]
13+
[assembly: AssemblyCopyright("Copyright © 2017")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("d4ebb0f3-14d7-43cd-be40-a59daaa8e240")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

README.MD

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# StardewCustoms
2+
3+
[![Github All Releases](https://img.shields.io/github/downloads/atom/atom/total.svg)]()
4+
[![GitHub issues](https://img.shields.io/github/issues/badges/shields.svg)]()
5+
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)]()
6+
7+
--------------------------------
8+
9+
An SMAPI mod for modders, to simplify the addition of custom content. Notably it focuses primarily on ease of use, with flexibility being directly second.
10+
11+
##### _This is an early work-in-progress. As such it may or may not work as intended, and is not yet recommended for production use whatsoever. Please stay tuned._
12+
13+
###### Features:
14+
* Still working on basic item support
15+
16+
###### Future plans/ideas (subject to change):
17+
18+
* Custom machines, with custom recipes and animations
19+
* Custom maps (using something like Tiled)
20+
* Custom weapons/armors
21+
* Custom forage items
22+
* Custom quest items/quests
23+
* Custom NPCs
24+
* Custom ResourceClumps and LargeTerrainFeatures
25+
* Custom Crops
26+
* Custom TV stations
27+
* NPC Schedule modifications
28+
29+
-----
30+
31+
### Usage (for players):
32+
33+
This mod may be a prerequisite for a mod you'd like to play. If so, simply install this mod normally into your SMAPI _/mods/_ folder, and you should be good to go.
34+
35+
-----
36+
37+
### Usage (for modders):
38+
39+
You will need to ensure that your mod can access this one. I'm still working on the details of dependant mods in SMAPI, and will post more details here as I learn them. But regardless, you will need to add a reference to this mod's DLL to your project, though ideally you should _not_ need to include this mod inside your own mod's folder.
40+
41+
You will need to create an instance of StardewCustoms.CustomObject. If the instance members don't provide the functionality you need, you can extend the class and override any of its virtual methods to push the boundaries even further.
42+
43+
```C#
44+
StardewCustoms.CustomObject myObject = new StardewCustoms.CustomObject("exampleMod", "myObject");
45+
```
46+
47+
Notably CustomObject does _not_ extend StardewValley.Object; the behind-the-scenes of this middleware are rather complex and quite potentially subject to change, should future updates of either the game or this mod break the current design. So instead CustomObject is our own specification, and efforts will be made to preserve the integrity of this data structure across updates.
48+
49+
Once you have your CustomObject instance, you will need to register the object, by calling
50+
51+
```C#
52+
StardewCustoms.CustomObjectHandler.registerCustomObject(myObject);
53+
```
54+
55+
-----
56+
57+
### License:
58+
All code and content hereunder, notably excluding any bundled dependencies (detailed below), is licensed under the MIT open source license.
59+
60+
Copyright © 2017 avarisc
61+
62+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
63+
64+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
65+
66+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
67+
68+
-----
69+
70+
### Dependencies:
71+
72+
* [Harmony](https://github.com/pardeike/Harmony) [included as binary, as I couldn't find a NuGet package] [MIT Licensed]
73+
* [SMAPI](https://github.com/Pathoschild/SMAPI/) [not included] [LGPL licensed]
74+
75+
-----
76+
### Contributing:
77+
78+
Want to contribute? Comment or submit a pull request - as time permits, I'll review and implement (or work with you to do so).

StardewCustoms.csproj

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>StardewCustoms</RootNamespace>
11+
<AssemblyName>StardewCustoms</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<NuGetPackageImportStamp>
15+
</NuGetPackageImportStamp>
16+
<TargetFrameworkProfile />
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="CustomObjects.cs" />
47+
<Compile Include="StardewCustomsMod.cs" />
48+
<Compile Include="Properties\AssemblyInfo.cs" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<None Include="manifest.json" />
52+
<None Include="packages.config" />
53+
</ItemGroup>
54+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
55+
<Import Project="packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
56+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
57+
<PropertyGroup>
58+
<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>
59+
</PropertyGroup>
60+
<Error Condition="!Exists('packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Pathoschild.Stardew.ModBuildConfig.1.7.1\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
61+
</Target>
62+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
63+
Other similar extension points exist, see Microsoft.Common.targets.
64+
<Target Name="BeforeBuild">
65+
</Target>
66+
<Target Name="AfterBuild">
67+
</Target>
68+
-->
69+
</Project>

StardewCustoms.sln

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.25420.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewCustoms", "StardewCustoms.csproj", "{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D4EBB0F3-14D7-43CD-BE40-A59DAAA8E240}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

StardewCustomsMod.cs

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using StardewModdingAPI;
2+
3+
namespace StardewCustoms
4+
{
5+
public class StardewCustomsMod : Mod
6+
{
7+
internal static StardewCustomsMod instance;
8+
9+
public override void Entry(IModHelper helper)
10+
{
11+
Log("StardewCustoms is operational.");
12+
13+
//store a static instance handle to the mod
14+
instance = this;
15+
16+
//setup custom object support
17+
CustomObjectHandler.Setup();
18+
19+
//to create a custom item:
20+
//create a new instance of CustomObject, make sure to at least provide all the constructor variables
21+
//then call CustomObjectHandler.RegisterCustomObject({custom instance})
22+
23+
24+
}
25+
26+
public static void Log(string message)
27+
{
28+
instance.Monitor.Log(message);
29+
}
30+
}
31+
}

manifest.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Name": "StardewCustoms",
3+
"Author": "avarisc",
4+
"Version": {
5+
"MajorVersion": 0,
6+
"MinorVersion": 0,
7+
"PatchVersion": 1,
8+
"Build": null
9+
},
10+
"Description": "Simplifies the creation of custom content.",
11+
"UniqueID": "avarisc.StardewCustoms",
12+
"EntryDll": "StardewCustoms.dll"
13+
}

packages.config

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Pathoschild.Stardew.ModBuildConfig" version="1.7.1" targetFramework="net452" />
4+
</packages>

0 commit comments

Comments
 (0)