private void SetupRequests() { if (data.spawnedRequests == null) { data.spawnedRequests = new List <Guid>(); foreach (var ingredient in data.blueprint.RequiredItems) { for (int ii = 0; ii < ingredient.Item2; ii++) { MoveItemRequest newReq = new MoveItemRequest(ingredient.Item1, actor.Position, actor.Guid); data.spawnedRequests.Add(newReq.Guid); MoveItemRequestPool.Instance.PostRequest( newReq ); } } } foreach (var requestGuid in data.spawnedRequests) { requestObservers.Add(new SimpleKeyObserver <RequestPoolUpdateEvent <MoveItemRequest>, Guid>(MoveItemRequestPool.Instance, requestGuid, (reqUpdate) => { if (reqUpdate.Type == RequestPoolUpdateEvent <MoveItemRequest> .EventType.Cancelled) { GameObject.Destroy(gameObject); } if (reqUpdate.Type == RequestPoolUpdateEvent <MoveItemRequest> .EventType.Finished) { data.spawnedRequests.Remove(reqUpdate.Request.Guid); } } )); } }
public FindItemState(GridActor actor, MoveItemRequest request, LilLogger logger) { this.actor = actor; this.request = request; this.logger = logger; logger.Log("Initialized my FindItemState with request " + request); }
void Start() { inventory = GetComponent <InventoryComponent>(); if (inventory) { inventoryObserver = new SimpleObserver <InventoryUpdateEvent>(inventory, OnInventoryUpdate); } actor = GetComponent <GridActor>(); if (actor) { transform.position = actor.Position; } if (!data.hasSpawnedRequest) { MoveItemRequest req = new MoveItemRequest(data.itemRequired, actor.Position, actor.Guid); data.requestGuid = req.Guid; MoveItemRequestPool.Instance.PostRequest(req); data.hasSpawnedRequest = true; } myObserver = new SimpleObserver <RequestPoolUpdateEvent <MoveItemRequest> >(MoveItemRequestPool.Instance, (updateEvent) => { if (updateEvent.Type == RequestPoolUpdateEvent <MoveItemRequest> .EventType.Cancelled && updateEvent.Request.Guid.Equals(data.requestGuid)) { data.requestFinished = true; GameObject.Destroy(gameObject); } }); BlockVisualizer visualizer = GetComponent <BlockVisualizer>(); if (visualizer) { visualizer.RenderBlock(GetBlock()); } }
public WalkToTargetState(GridActor actor, MoveItemRequest request, Item item, LilLogger logger) : base(actor, 100, 1) { this.actor = actor; this.request = request; this.item = item; this.logger = logger; logger.Log("Initialized my WalkToTargetState with request " + request); }
public WalkToItemState(GridActor actor, MoveItemRequest request, Vector3Int target, LilLogger logger) : base(actor, 100) { this.actor = actor; this.request = request; this.target = target; this.logger = logger; logger.Log("Initialized my WalkToItemState with request " + request); }
public FindItemState(GridActor actor, IGenericSaveData saveData, LilLogger logger) : base(((SaveData)saveData).parent) { this.actor = actor; this.logger = logger; SaveData save = saveData as SaveData; this.request = save.request; logger.Log("Loaded my FindItemState with request " + request); }
public WalkToTargetState(GridActor actor, IGenericSaveData saveData, LilLogger logger) : base(actor, ((SaveData)saveData).parent) { this.actor = actor; this.logger = logger; SaveData save = saveData as SaveData; this.request = save.request; this.item = save.item; logger.Log("Loaded my WalkToTargetState with request " + request); }
public void MoveItemAcrossInventory(MarketMoveItemRequestParams request) { if (MoveItemRequest != null) { MoveItemRequest.Invoke(request); } else { request.Callback.SafeRaise(new MarketMoveItemResponse( "Not implemented in the game side. Subscribe to IMarketWidget change event")); } }
public MoveItemJob(GridActor actor, MoveItemRequest request, LilLogger logger) { this.logger = logger; logger.Log("Started a MoveItemJob"); machine = new StateMachine(new FindItemState(actor, request, logger)); }