public override bool Matches(State other) { ButtonPlanningState otherButton = other as ButtonPlanningState; if (otherButton == null) { // Maybe log that you're comparing a state of a different type? // Maybe handle this logic in base class, and rely on IEquatable in most cases (neat!) return(false); } return(IsPressed == otherButton.IsPressed); }
public IList <Step> GetPossibleActions(World world, Agent agent) { IList <Step> actions = new List <Step>(); // We only care about this butotn's state ButtonPlanningState buttonState = world.GetState(gameObject.name) as ButtonPlanningState; Vector3 buttonPos = transform.position; // If button can move, this must be in world if (!buttonState.IsPressed && agent.CanPath(world, buttonState.Position)) { Step act = new PressButtonStep(this, agent, world); actions.Add(act); Debug.Log("Adding press " + gameObject.name + " action"); } return(actions); }
public ButtonPlanningState(ButtonPlanningState buttonState) { Name = buttonState.Name; this.IsPressed = buttonState.IsPressed; }