mirror of
https://github.com/Ellpeck/TinyLifeExampleMod.git
synced 2024-11-22 12:03:28 +01:00
fixed the example action breaking when clicking out of bounds
This commit is contained in:
parent
31e9187f90
commit
6ba84e6c33
1 changed files with 2 additions and 0 deletions
|
@ -67,6 +67,8 @@ namespace ExampleMod {
|
||||||
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 = (info, automatic) => {
|
||||||
|
if (!info.Map.IsInBounds(info.ActionLocation.ToPoint()))
|
||||||
|
return ActionType.CanExecuteResult.Hidden;
|
||||||
var tile = info.Map.GetTile(info.ActionLocation.ToPoint());
|
var tile = info.Map.GetTile(info.ActionLocation.ToPoint());
|
||||||
if (tile.Name.StartsWith("Grass"))
|
if (tile.Name.StartsWith("Grass"))
|
||||||
return ActionType.CanExecuteResult.Valid;
|
return ActionType.CanExecuteResult.Valid;
|
||||||
|
|
Loading…
Reference in a new issue