2020-11-25 00:33:47 +01:00
|
|
|
using System;
|
2021-06-26 15:49:37 +02:00
|
|
|
using System.Runtime.Serialization;
|
2020-11-25 00:33:47 +01:00
|
|
|
using TinyLife.Objects;
|
|
|
|
using TinyLife.World;
|
|
|
|
|
2021-12-25 18:05:47 +01:00
|
|
|
namespace ExampleMod;
|
2021-06-26 15:49:37 +02:00
|
|
|
|
2021-12-23 23:23:56 +01:00
|
|
|
// note that having a custom class for a furniture item like this is entirely optional
|
2022-11-22 19:25:15 +01:00
|
|
|
// but it allows for additional functionalities as displayed in this example
|
|
|
|
public class ExampleModTable : Furniture {
|
2021-12-23 23:23:56 +01:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2022-11-22 19:25:15 +01:00
|
|
|
public ExampleModTable(Guid id, FurnitureType type, int[] colors, Map map, Vector2 pos) : base(id, type, colors, map, pos) {
|
2022-06-15 10:53:51 +02:00
|
|
|
this.TestValue = Furniture.Random.NextSingle();
|
2020-11-25 00:33:47 +01:00
|
|
|
}
|
2021-12-23 23:23:56 +01:00
|
|
|
|
|
|
|
public override void OnAdded() {
|
|
|
|
base.OnAdded();
|
2022-03-21 18:56:23 +01:00
|
|
|
ExampleMod.Logger.Info("The custom table was added at " + this.Position);
|
2021-12-23 23:23:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnRemoved() {
|
|
|
|
base.OnRemoved();
|
2022-03-21 18:56:23 +01:00
|
|
|
ExampleMod.Logger.Info("The custom table was removed from " + this.Position);
|
2021-12-23 23:23:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// validate is called when this object is loaded from disk
|
|
|
|
// returning false causes the object to be marked as invalid and removed
|
|
|
|
public override bool Validate() {
|
|
|
|
return base.Validate() && this.TestValue <= 1;
|
|
|
|
}
|
|
|
|
|
2022-06-17 18:05:34 +02:00
|
|
|
}
|