fixed the example action breaking when clicking out of bounds

This commit is contained in:
Ell 2021-06-29 13:40:31 +02:00
parent 31e9187f90
commit 6ba84e6c33

View file

@ -67,6 +67,8 @@ namespace ExampleMod {
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
CanExecute = (info, automatic) => {
if (!info.Map.IsInBounds(info.ActionLocation.ToPoint()))
return ActionType.CanExecuteResult.Hidden;
var tile = info.Map.GetTile(info.ActionLocation.ToPoint());
if (tile.Name.StartsWith("Grass"))
return ActionType.CanExecuteResult.Valid;