public LumberjackStockpilingState(LumberjackStateMachine owner, LumberjackBehaviour inParentBehaviour, Inventory.Writer inInventory) : base(owner) { parentBehaviour = inParentBehaviour; inventory = inInventory; }
public static void RemoveFromInventory(this Inventory.Writer inventory, int quantity) { inventory.Send(new Inventory.Update().SetResources(Mathf.Max(0, inventory.Data.resources - quantity))); }
public LumberjackStateMachine(LumberjackBehaviour behaviour, TargetNavigationBehaviour navigation, Inventory.Writer inventory, TargetNavigation.Writer targetNavigation, NPCLumberjack.Writer inNpcLumberjack, TeamAssignment.Reader teamAssignment) { npcLumberjack = inNpcLumberjack; var idleState = new LumberjackIdleState(this, behaviour, teamAssignment, inventory); var moveToTargetState = new LumberjackMoveToTargetState(this, behaviour, targetNavigation, navigation); var harvestingState = new LumberjackHarvestingState(this, behaviour, inventory); var stockPilingState = new LumberjackStockpilingState(this, behaviour, inventory); var onFireState = new LumberjackOnFireState(this, navigation, targetNavigation); var stateList = new Dictionary <LumberjackFSMState.StateEnum, IFsmState> { { LumberjackFSMState.StateEnum.IDLE, idleState }, { LumberjackFSMState.StateEnum.MOVING_TO_TARGET, moveToTargetState }, { LumberjackFSMState.StateEnum.HARVESTING, harvestingState }, { LumberjackFSMState.StateEnum.STOCKPILING, stockPilingState }, { LumberjackFSMState.StateEnum.ON_FIRE, onFireState } }; SetStates(stateList); var allowedTransitions = new Dictionary <LumberjackFSMState.StateEnum, IList <LumberjackFSMState.StateEnum> >(); allowedTransitions.Add(LumberjackFSMState.StateEnum.IDLE, new List <LumberjackFSMState.StateEnum> { LumberjackFSMState.StateEnum.MOVING_TO_TARGET, LumberjackFSMState.StateEnum.ON_FIRE }); allowedTransitions.Add(LumberjackFSMState.StateEnum.MOVING_TO_TARGET, new List <LumberjackFSMState.StateEnum> { LumberjackFSMState.StateEnum.IDLE, LumberjackFSMState.StateEnum.HARVESTING, LumberjackFSMState.StateEnum.STOCKPILING, LumberjackFSMState.StateEnum.ON_FIRE }); allowedTransitions.Add(LumberjackFSMState.StateEnum.HARVESTING, new List <LumberjackFSMState.StateEnum> { LumberjackFSMState.StateEnum.IDLE, LumberjackFSMState.StateEnum.ON_FIRE }); allowedTransitions.Add(LumberjackFSMState.StateEnum.STOCKPILING, new List <LumberjackFSMState.StateEnum> { LumberjackFSMState.StateEnum.IDLE, LumberjackFSMState.StateEnum.ON_FIRE }); allowedTransitions.Add(LumberjackFSMState.StateEnum.ON_FIRE, new List <LumberjackFSMState.StateEnum> { LumberjackFSMState.StateEnum.IDLE, LumberjackFSMState.StateEnum.ON_FIRE }); SetTransitions(allowedTransitions); }
public static void AddToInventory(this Inventory.Writer inventory, int quantity) { inventory.Send(new Inventory.Update().SetResources(inventory.Data.resources + quantity)); }