public override void Tick(float deltaTime) { for (int i = 0; i < filters.Length; i++) { // cache variables Filter filter = filters[i]; InventoryComponent invComp = filter.inventoryComponent; InputComponent inputComp = filter.inputComponent; InteractorComponent interactorComp = filter.interactorComponent; MovementComponent movComp = filter.movementComponent; // ----- logic ----- CheckDistanceToInteractable(filter); FindVisibleTargets(); // no longer used--------------------------- InteractMode previous = interactorComp.interactMode; if (inputComp.GetKeyDown(KeyCode.Alpha1)) { // move set none if previous was new to SetInteractMode interactorComp.SetInteractMode(InteractMode.PlacingPlanks); if (previous == InteractMode.PlacingPlanks) { interactorComp.SetInteractMode(InteractMode.None); } } else if (inputComp.GetKeyDown(KeyCode.Alpha2)) { interactorComp.SetInteractMode(InteractMode.Combat); if (previous == InteractMode.Combat) { interactorComp.SetInteractMode(InteractMode.None); } } //-------------------------------------------------- if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1")) { //AttemptWorldInteract(interactorComp, player.inventoryComponent, inputComp.worldInteractMask); //interactorComp.SetInteractMode(InteractMode.Object); } else if (inputComp.GetKeyDown(KeyCode.Escape)) { interactorComp.interactMode = InteractMode.None; CartComponent tc = (CartComponent)interactorComp.currentInteractable; if (tc) { tc.isTraveling = true; } } if (Vector3.Distance(filter.gameObject.transform.position, transportableComponent.transform.position) < 6f || Vector3.Distance(filter.gameObject.transform.position, travelComponent.transform.position) < 6f && lightComponent.IsLightEnabled()) { goapSystem?.SetLightState(true); } else { goapSystem?.SetLightState(false); } if (Vector3.Distance(filter.gameObject.transform.position, transportableComponent.transform.position) < 3f) { if (inputComp.GetKeyDown(KeyCode.B) || inputComp.GetButtonDown("Fire3")) { //bookGO.SetActive(!bookGO.activeSelf); movComp.alive = false; } else { movComp.alive = true; } if (inputComp.GetKeyDown(KeyCode.M) || inputComp.GetButtonDown("Fire2")) { //mapGO.SetActive(!mapGO.activeSelf); } if (inputComp.GetKeyDown(KeyCode.E) || inputComp.GetButtonDown("Fire1")) { //if (invComp.treeResources > 0) //{ // //craftingSystem?.CraftPotion1(); // //craftGO.SetActive(!craftGO.activeSelf); //} } } else { /*toggleMapGO.SetActive(false); * toggleBookGO.SetActive(false); * craftGO.SetActive(false);*/ } isCombat = interactorComp.interactMode == InteractMode.Combat; actorLocation = interactorComp.gameObject.transform.position; if (interactorComp.interactMode == InteractMode.PlacingPlanks) { isPlacingPlanks = true; if (isPlacingPlanks) { // Don't LogWarning this unity I'm sure you have your reasons but I don't like them. } // TODO remaing at last possible location if impossible position plankPlaceLocation = inputComp.GetMouseHoverTransformPosition(inputComp.objectPlaceMask); plankPlaceLocation.y = 0f; //if (inputComp.GetMouseButtonDown(0)) //{ // PlacePlank(invComp); //} } else { isPlacingPlanks = false; if (inputComp.GetMouseButtonDown(0)) { inputComp.GetMouseWorldLocation(out RaycastHit hit); } } } if (Vector3.Distance(lightComponent.transform.position, transportableComponent.transform.position) < 7 && !lightComponent.IsLightEnabled()) //Magic number. Remove this { //lightComponent.currentFuel = lightComponent.maxFuel; } }