mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-22 20:08:34 +01:00
clean up example mod
This commit is contained in:
parent
7767cd7f18
commit
f19ae32543
3 changed files with 13 additions and 10 deletions
|
@ -21,12 +21,12 @@ public class CustomTable : Furniture {
|
||||||
|
|
||||||
public override void OnAdded() {
|
public override void OnAdded() {
|
||||||
base.OnAdded();
|
base.OnAdded();
|
||||||
ExampleMod.Logger.Info("We were added at " + this.Position);
|
ExampleMod.Logger.Info("The custom table was added at " + this.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemoved() {
|
public override void OnRemoved() {
|
||||||
base.OnRemoved();
|
base.OnRemoved();
|
||||||
ExampleMod.Logger.Info("We were removed from " + this.Position);
|
ExampleMod.Logger.Info("The custom table was removed from " + this.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate is called when this object is loaded from disk
|
// validate is called when this object is loaded from disk
|
||||||
|
|
|
@ -70,18 +70,17 @@ public class ExampleMod : Mod {
|
||||||
// adding a simple action: sitting down in the grass, which also gives us a nice emotion modifier
|
// 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(SitDownOnGrassAction)) {
|
||||||
// we set this action to be executable only on grass tiles, not on other ground
|
// we set this action to be executable only on grass tiles, not on other ground
|
||||||
CanExecute = (info, automatic) => {
|
CanExecute = (actionInfo, automatic) => {
|
||||||
if (!info.Map.IsInBounds(info.ActionLocation.ToPoint()))
|
if (!actionInfo.Map.IsInBounds(actionInfo.ActionLocation.ToPoint()))
|
||||||
return ActionType.CanExecuteResult.Hidden;
|
|
||||||
var tile = info.Map.GetTile(info.ActionLocation.ToPoint());
|
|
||||||
if (tile.Name.StartsWith("Grass"))
|
|
||||||
return ActionType.CanExecuteResult.Valid;
|
|
||||||
// hidden means the action won't be displayed in the ring menu
|
|
||||||
return ActionType.CanExecuteResult.Hidden;
|
return ActionType.CanExecuteResult.Hidden;
|
||||||
|
var tile = actionInfo.Map.GetTile(actionInfo.ActionLocation.ToPoint());
|
||||||
|
// hidden means the action won't be displayed in the ring menu, Valid means the player (or AI) is able to enqueue and execute it
|
||||||
|
return tile.Name.StartsWith("Grass") ? ActionType.CanExecuteResult.Valid : ActionType.CanExecuteResult.Hidden;
|
||||||
},
|
},
|
||||||
Ai = {
|
Ai = {
|
||||||
// we allow the action to be done even if the solved needs aren't low enough on a person
|
// we allow the action to be done even if the solved needs aren't low enough on a person
|
||||||
CanDoRandomly = true,
|
CanDoRandomly = true,
|
||||||
|
// the solved needs indicate when the AI should mark this action as important, they don't actually have to match the action's behavior
|
||||||
SolvedNeeds = new[] {NeedType.Energy},
|
SolvedNeeds = new[] {NeedType.Energy},
|
||||||
// make people more likely to sit down in the grass if they're uncomfortable
|
// make people more likely to sit down in the grass if they're uncomfortable
|
||||||
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
|
PassivePriority = p => p.Emotion == EmotionType.Uncomfortable ? 150 : 25
|
||||||
|
@ -89,6 +88,8 @@ public class ExampleMod : Mod {
|
||||||
// since this action doesn't use objects (like chairs etc.), we set a texture to display instead
|
// since this action doesn't use objects (like chairs etc.), we set a texture to display instead
|
||||||
Texture = this.uiTextures[1, 0]
|
Texture = this.uiTextures[1, 0]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// we use this emotion modifier in SitDownOnGrassAction
|
||||||
GrassSittingModifier = EmotionModifier.Register(
|
GrassSittingModifier = EmotionModifier.Register(
|
||||||
new EmotionModifier("ExampleMod.GrassSitting", this.uiTextures[1, 0], EmotionType.Happy));
|
new EmotionModifier("ExampleMod.GrassSitting", this.uiTextures[1, 0], EmotionType.Happy));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ public class SitDownOnGrassAction : MultiAction {
|
||||||
protected override IEnumerable<Action> CreateFirstActions() {
|
protected override IEnumerable<Action> CreateFirstActions() {
|
||||||
// we want to walk to the location clicked, so we use the current action info
|
// we want to walk to the location clicked, so we use the current action info
|
||||||
yield return ActionType.GoHere.Construct(this.Info);
|
yield return ActionType.GoHere.Construct(this.Info);
|
||||||
|
|
||||||
|
// if multiple things should be done before starting this action, they can all be returned here
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void AndThenInitialize() {
|
protected override void AndThenInitialize() {
|
||||||
|
|
Loading…
Reference in a new issue