void Start() { myRenderer = GetComponent <MeshRenderer>(); actor = GetComponent <GridActor>(); inventory = GetComponent <InventoryComponent>(); if (actor && inventory) { inventoryObserver = new SimpleObserver <InventoryUpdateEvent>(inventory, (update) => { if (update.Type == InventoryUpdateEvent.UpdateType.Added) { OnItemAdded(); } else if (update.Type == InventoryUpdateEvent.UpdateType.Removed) { OnItemRemoved(); } }); ItemMap.RegisterInventory(inventory, actor.Position); transform.position = actor.Position + new Vector3(.25f, -.25f, .25f); Item mainItem = inventory.GetMostCommonItem(); visualizer = GetComponent <BlockVisualizer>(); visualizer.RenderBlock(mainItem.GetTexturePosition()); } cameraObserver = new SimpleObserver <CameraController>(Camera.main.GetComponent <CameraController>(), (c) => { if (this.myRenderer && actor) { this.myRenderer.enabled = c.PositionShouldBeVisible(actor.Position); } }); }
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()); } }
void Start() { logger = new LilLogger(gameObject.name); visualizer = GetComponent <BlockVisualizer>(); if (visualizer) { visualizer.RenderBlock(plannedBlock); } else { logger.Log("No BlockVisualizer found on BlockBuildGhoster", LogLevel.Warning); } oldMousePos = Input.mousePosition; }