I was looking for a way to detect if a given year is leap or not (along with some other useful date functions) but found none, so I tried to make a custom action:
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("Date")]
[Tooltip("Determines if a given year is leap or not")]
public class LeapYear : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Stores the year to test as an int")]
public FsmFloat yearToCheck;
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("Shows if the year is leap as TRUE")]
public FsmBool isLeapYear;
public override void Reset()
{
yearToCheck = null;
isLeapYear = null;
}
public override void OnEnter()
{
if ((yearToCheck % 4 == 0) && !(yearToCheck % 100 == 0) || (yearToCheck % 400 == 0))
isLeapYear = true;
else
isLeapYear = false;
Finish ();
}
}
}
It seems, however, that the mod operator is not supported... Any ideas?
Thank you.