Skip to content

Can we get a "TimedStateBase"? #61

@ManuelRauber

Description

@ManuelRauber

Hi,

Thanks for UnityHFSM. I like it, and it gets better with each release. 👍

I prefer developing custom states to separate things instead of using the State class.

However, the State class has a nice timer built in, whereas the StateBase does not. Sure, I can create my own base class that just includes the timer but not the exact constructor definition that State has.

I think it would be nice, if that base class with a timer could be provided by UnityHFSM directly, something like:

// Pseudo-Code'ish
public class StateBaseWithTimer<...> : StateBase<...> {
  public ITimer timer;

  constructor(needsExitTime, isGhostState) {
    this.timer = new Timer();
  }

  public override void OnEnter()
  {
    timer.Reset();
  }
}

This class then could be used by State as well.

And yes, I could inherit from State as well, but then I get the all the conditional delegate invokes that I won't use because I override OnLogic in my class.

Having the StateBaseWithTimer would fill a little gap, at least for me. :-)

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions