use simpler file and class naming for the example mod

This commit is contained in:
Ell 2022-11-22 19:25:15 +01:00
parent 438d203bc9
commit 0ba898838a
4 changed files with 10 additions and 10 deletions

View file

@ -20,7 +20,7 @@ public class ExampleMod : Mod {
// the logger that we can use to log info about this mod
public static Logger Logger { get; private set; }
public static ModOptions Options { get; private set; }
public static ExampleModOptions Options { get; private set; }
public static EmotionModifier GrassSittingModifier { get; private set; }
@ -40,7 +40,7 @@ public class ExampleMod : Mod {
FurnitureType.Register(new FurnitureType.TypeSettings("ExampleMod.CustomTable", new Point(1, 1), ObjectCategory.Table, 150, ColorScheme.SimpleWood) {
// specify the type that should be constructed when this furniture type is placed
// if this is not specified, the Furniture class is used, which is used for furniture without special animations or data
ConstructedType = typeof(CustomTable),
ConstructedType = typeof(ExampleModTable),
// specifying icons for custom clothes and furniture is optional, but using the mod's icon helps users recognize a mod's features
Icon = this.Icon,
// allow chairs and plates to be slotted into and onto the table
@ -71,7 +71,7 @@ public class ExampleMod : Mod {
};
// adding a simple action: sitting down in the grass, which also gives us a nice emotion modifier
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(SitDownOnGrassAction)) {
ActionType.Register(new ActionType.TypeSettings("ExampleMod.SitOnGrass", ObjectCategory.Ground, typeof(ExampleModGrassSitAction)) {
// we set this action to be executable only on grass tiles, not on other ground
CanExecute = (actionInfo, _) => {
if (!actionInfo.Map.IsInBounds(actionInfo.ActionLocation.ToPoint()))
@ -102,7 +102,7 @@ public class ExampleMod : Mod {
public override void Initialize(Logger logger, RawContentManager content, RuntimeTexturePacker texturePacker, ModInfo info) {
ExampleMod.Logger = logger;
ExampleMod.Options = info.LoadOptions(() => new ModOptions());
ExampleMod.Options = info.LoadOptions(() => new ExampleModOptions());
// loads a texture atlas with the given amount of separate texture regions in the x and y axes
// we submit it to the texture packer to increase rendering performance. The callback is invoked once packing is completed

View file

@ -10,9 +10,9 @@ namespace ExampleMod;
// we use a multi action because we want to walk to the location, and then execute the main sitting part
// see CustomTable for information on how to store custom action-specific information to disk as well
public class SitDownOnGrassAction : MultiAction {
public class ExampleModGrassSitAction : MultiAction {
public SitDownOnGrassAction(ActionType type, ActionInfo info) : base(type, info) {}
public ExampleModGrassSitAction(ActionType type, ActionInfo info) : base(type, info) {}
protected override IEnumerable<Action> CreateFirstActions() {
// we want to walk to the location clicked, so we use the current action info

View file

@ -1,7 +1,7 @@
namespace ExampleMod;
// these options are saved and loaded in ExampleMod
public class ModOptions {
public class ExampleModOptions {
public float DarkShirtSpeedIncrease = 2;

View file

@ -6,15 +6,15 @@ using TinyLife.World;
namespace ExampleMod;
// note that having a custom class for a furniture item like this is entirely optional
// but it allows for additional functionalities as displayed in this example
public class CustomTable : Furniture {
// but it allows for additional functionalities as displayed in this example
public class ExampleModTable : Furniture {
// anything whose base classes have the DataContract attribute automatically gets saved and loaded to and from disk
// this means that you can add custom DataMember members to have them saved and loaded
[DataMember]
public float TestValue;
public CustomTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
public ExampleModTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
this.TestValue = Furniture.Random.NextSingle();
}