void ResetBuilding() { // Reset the selector parent. this.ReleaseSelector(); // Set state to selecting. this.state = ConstructionState.SELECTING; // Hide all used tiles. this.HideAllUsedTiles(); // Reset object. this.selectedBuilding.Reset(); // Turn off building menu. Close menu if object has been deleted. if (this.selectedBuilding != null) { this.buildingMenu.Show(this.selectedBuilding, this.state); this.BindSelector(this.selectedBuilding); } else { this.buildingMenu.Close(); } }
void LiftBuilding(Building b) { this.state = ConstructionState.PLACING; // Disable all further construction. foreach (A_TouchDrag button in this.constructionButtons) { button.eventTrigger.enabled = false; } // Set the given building's used tiles as not used. foreach (IntVector2 v in b.UsedTileLocations) { this.tc.SetTileInUse(v, false); } // Show used tiles. this.ShowAllUsedTiles(); // Lift the building. b.LiftUp(); // Show the placing building menu. this.buildingMenu.Show(b, this.state); }
public void SpawnBuilding(int index) { if (gameRules.waveStatus || !CheckBuildingValidity(index) || !CheckRessourcesAvailability(index)) { return; } if (constructionState == ConstructionState.Positioning) { Destroy(selectedBuilding.gameObject); } else { constructionState = ConstructionState.Positioning; } Tile tile = rayCast.GetNearestTileFromCursor(); if (tile != null) { defaultSpawnPosition = tile.tileCenter.position; } selectedBuilding = Instantiate(playerData.availableBuildings[index]); selectedBuilding.Move(defaultSpawnPosition); return; }
private bool TryCreateSetup(TKey key, out ConstructionState state) { if (Storage.ContainsKey(key)) { state = null; return(false); } state = new ConstructionState(); if (States.TryAdd(key, state)) { if (Storage.ContainsKey(key)) { TryCreateTeardown(key, state); return(false); } return(true); } else { state.Dispose(); return(false); } }
public override void OnBehaviourEnter() { switch (state) { case WorkerState.Construction: constructionState = ConstructionState.Idle; break; case WorkerState.Harvesting: if (ressourceInventory.currentRessourceTransportLoad < ressourceInventory.ressourceTransportLoad) { harvestingState = HarvestingState.Idle; } else { harvestingState = HarvestingState.TransportingRessourceToHarvester; Vector3 targetPosition = assignedHarvester.transform.position + (entity.transform.position - assignedHarvester.transform.position).normalized * assignedHarvester.width / 2; movement.MoveTo(targetPosition); } break; case WorkerState.Depositing: state = WorkerState.Idle; break; } }
public void Show(Building b, ConstructionState state) { this.target = b; this.buildingName.text = b.buildingName; switch (state) { case ConstructionState.NO_SELECTION: this.selectingPanel.SetActive(false); this.placingPanel.SetActive(false); this.editingPanel.SetActive(true); break; case ConstructionState.PLACING: this.selectingPanel.SetActive(false); this.placingPanel.SetActive(true); this.editingPanel.SetActive(false); break; case ConstructionState.SELECTING: this.selectingPanel.SetActive(true); this.placingPanel.SetActive(false); this.editingPanel.SetActive(false); break; default: break; } this.parentMenu.gameObject.SetActive(true); }
public BuildingItem(BuildingItemType itemtype) { _itemType = itemtype; _constructionState = ConstructionState.InProgress; //TODO: set initial values - is there anything else that needs to be set? }
public void SetConstructionMode(ConstructionState state) { if (mode != state) { previousMode = mode; mode = state; } }
private void TryCreateTeardown(TKey key, ConstructionState state) { if (States.TryRemove(key, out state)) { state.Set(); state.Dispose(); } }
public FacilityConstructionEventDto(FacilityConstructionEvent fce) { date = CareerLog.UTToDate(fce.UT).ToString("o"); facility = fce.Facility; newLevel = fce.NewLevel; cost = fce.Cost; state = fce.State; }
private void Start() { worldData = FindObjectOfType <TileMapGenerator>().worldData; city = FindObjectOfType <CityController>(); buildingsData = new BuildingsData <Building>(worldData, () => GenerateTerrainPlaceability(worldData)); state = ConstructionState.None; cam = Camera.main; }
public FacilityConstructionEvent(FacilityConstructionEventDto f) { Date = f.Date; Facility = f.Facility; NewLevel = f.NewLevel; Cost = f.Cost; State = f.State; }
/// <summary> /// Resets the current state and deletes all instances of old state. /// </summary> private void CleanUp() { if (instance != null) { Destroy(instance); } state = ConstructionState.None; placeable = null; }
public void AssignToConstruction(EC_Base assignedBase) { if (state == WorkerState.Idle) { PlayerManager.Instance.RemoveIdleWorker(this); } this.assignedBase = assignedBase; state = WorkerState.Construction; constructionState = ConstructionState.Idle; nextScanTime = Time.time; ChangeAcessories(); }
public Round(RoundParameters parameters, WasabiRandom random) { Parameters = parameters; CoinjoinState = new ConstructionState(Parameters); AmountCredentialIssuer = new(new(random), random, Parameters.MaxAmountCredentialValue); VsizeCredentialIssuer = new(new(random), random, Parameters.MaxVsizeCredentialValue); AmountCredentialIssuerParameters = AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); VsizeCredentialIssuerParameters = VsizeCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); InputRegistrationTimeFrame = TimeFrame.Create(Parameters.StandardInputRegistrationTimeout).StartNow(); ConnectionConfirmationTimeFrame = TimeFrame.Create(Parameters.ConnectionConfirmationTimeout); OutputRegistrationTimeFrame = TimeFrame.Create(Parameters.OutputRegistrationTimeout); TransactionSigningTimeFrame = TimeFrame.Create(Parameters.TransactionSigningTimeout); Id = CalculateHash(); }
public IEnumerator PlaceBuilding() { selectedBuilding.GetComponent <NavMeshObstacle>().enabled = true; yield return(null); if (gameRules.RefreshWavePath()) { playerData.ressources -= selectedBuilding.ressourceCost; onPlayerRessourceChange.Raise(); selectedBuilding.Initialize(); selectedBuilding = null; constructionState = ConstructionState.Off; } else { selectedBuilding.GetComponent <NavMeshObstacle>().enabled = false; messageLog.AddMessage("Do not block the path", true); } }
/// <summary> /// Initiates the placement of placeables. /// </summary> /// <param name="placeable"> Placeable to use for placement </param> public void StartPlacement(IPlaceable <Building> placeable) { CleanUp(); this.placeable = placeable; state = ConstructionState.Placing; var pos = CoordinateConverter.ToVector3Int(CoordinateConverter.GetCurrentMouseTilePosition(cam)); instance = Instantiate(placeable.GetObject(), pos, Quaternion.identity, transform); instance.GetComponent <Building>().enabled = false; spriteRenderers = instance.GetComponentsInChildren <SpriteRenderer>(); // Make instance be in the foreground. for (int i = 0; i < spriteRenderers.Length; i++) { spriteRenderers[i].sortingOrder += 20; } onStateChanged?.Invoke(); }
public Round(RoundParameters roundParameters) { RoundParameters = roundParameters; var allowedAmounts = new MoneyRange(roundParameters.MinRegistrableAmount, RoundParameters.MaxRegistrableAmount); var txParams = new MultipartyTransactionParameters(roundParameters.FeeRate, allowedAmounts, allowedAmounts, roundParameters.Network); CoinjoinState = new ConstructionState(txParams); InitialInputVsizeAllocation = CoinjoinState.Parameters.MaxTransactionSize - MultipartyTransactionParameters.SharedOverhead; MaxRegistrableVsize = Math.Min(InitialInputVsizeAllocation / RoundParameters.MaxInputCountByRound, (int)ProtocolConstants.MaxVsizeCredentialValue); MaxVsizeAllocationPerAlice = MaxRegistrableVsize; AmountCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, MaxRegistrableAmount); VsizeCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, MaxRegistrableVsize); AmountCredentialIssuerParameters = AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); VsizeCredentialIssuerParameters = VsizeCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); Id = CalculateHash(); }
void PlaceBuilding(Building b) { if (this.CanBuildingBePlaced(b)) { // Hide all used tiles. this.HideAllUsedTiles(); // Re-enable touchdrag buttons. foreach (TouchDrag_Button tdb in this.constructionButtons) { tdb.eventTrigger.enabled = true; } // Add the placed building to the list if necessary. if (!this.placedBuildings.Contains(b)) { this.placedBuildings.Add(b); Debug.Log("created new building"); } // Set tiles as in-use. foreach (IntVector2 v in b.UsedTileLocations) { this.tc.SetTileInUse(v, true); } // Set state to selecting. this.state = ConstructionState.SELECTING; // Reset object. //temp.PlaceDown (); this.selectedBuilding.PlaceDown(); // Turn off building menu. this.buildingMenu.Show(b, this.state); } else { Debug.Log("cannot place building in location"); } }
public bool TryCreate(TKey key, Func <TValue> creator) { ConstructionState state; if (Storage.ContainsKey(key)) { return(false); } state = new ConstructionState(); if (States.TryAdd(key, state)) { try { if (Storage.ContainsKey(key)) { return(false); } var result = creator(); if (!Storage.TryAdd(key, result)) { throw new InvalidOperationException("Cache entry was created by someone else while construction lock was held"); } return(true); } finally { States.TryRemove(key, out state); state.Set(); state.Dispose(); } } else { state.Dispose(); } return(false); }
public Round(RoundParameters roundParameters) { RoundParameters = roundParameters; var allowedAmounts = new MoneyRange(roundParameters.MinRegistrableAmount, RoundParameters.MaxRegistrableAmount); var txParams = new MultipartyTransactionParameters(roundParameters.FeeRate, roundParameters.CoordinationFeeRate, allowedAmounts, allowedAmounts, roundParameters.Network); CoinjoinState = new ConstructionState(txParams); InitialInputVsizeAllocation = CoinjoinState.Parameters.MaxTransactionSize - MultipartyTransactionParameters.SharedOverhead; MaxVsizeCredentialValue = Math.Min(InitialInputVsizeAllocation / RoundParameters.MaxInputCountByRound, (int)ProtocolConstants.MaxVsizeCredentialValue); MaxVsizeAllocationPerAlice = MaxVsizeCredentialValue; AmountCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, MaxAmountCredentialValue); VsizeCredentialIssuer = new(new(RoundParameters.Random), RoundParameters.Random, MaxVsizeCredentialValue); AmountCredentialIssuerParameters = AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); VsizeCredentialIssuerParameters = VsizeCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(); InputRegistrationTimeFrame = TimeFrame.Create(RoundParameters.StandardInputRegistrationTimeout).StartNow(); ConnectionConfirmationTimeFrame = TimeFrame.Create(RoundParameters.ConnectionConfirmationTimeout); OutputRegistrationTimeFrame = TimeFrame.Create(RoundParameters.OutputRegistrationTimeout); TransactionSigningTimeFrame = TimeFrame.Create(RoundParameters.TransactionSigningTimeout); }
void CreateBuilding(GameObject prefab) { if (prefab.GetComponent <Building>() != null) { // Set state to placing. this.state = ConstructionState.PLACING; // Instantiate object. GameObject objectToCreate = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity) as GameObject; // Create a new building from touchdrag data. Building b = objectToCreate.GetComponent <Building> (); // Select new building and set base tile to (0, 0). this.SelectBuilding(b); b.SetBaseTile(this.tc.GetTile(new IntVector2(0, 0))); // Show which tiles are being used. this.ShowAllUsedTiles(); // Open menu for the building. this.buildingMenu.Show(b, this.state); } }
public void AddFacilityConstructionEvent(SpaceCenterFacility facility, int newLevel, double cost, ConstructionState state) { if (!IsEnabled) { return; } _facilityConstructions.Add(new FacilityConstructionEvent(Planetarium.GetUniversalTime()) { Facility = facility, NewLevel = newLevel, Cost = cost, State = state }); }
/// <summary> /// Called every frame from Robot.update() if it's the current state (top of the stack) /// </summary> /// <param name="r">The robot to update</param> public override void update(Robot r) { bool finished = false; //////////////////////////////////////////////////////////////////////////////////////// // Initialize variables if necessary when first enter state //////////////////////////////////////////////////////////////////////////////////////// if (!initialized) { initialized = true; state = ConstructionState.WAITING_FOR_INITIALIZATION; if (initialCommand.text.StartsWith(MessageConstructionStart.TAG)) { MessageConstructionStart msgData; if (MessageConstructionStart.TryParse(initialCommand.text, out msgData)) { waitQueue = msgData.waitQueue; r.pushState(new RobotStateQueue(new Queue <Vector2>(waitQueue), 1.5f)); state = ConstructionState.QUEUING; r.pushState(new RobotStateSleep(2 * r.id)); } else { Log.a(LogTag.ROBOT, "Failed to parse " + MessageConstructionStart.TAG + " data."); finished = true; } } else { Log.a(LogTag.ROBOT, "Failed to parse initial MessageConstructionStart"); finished = true; } } //////////////////////////////////////////////////////////////////////////////////////// // Reset variables if robot is returning from another state //////////////////////////////////////////////////////////////////////////////////////// if (resume) { resume = false; Log.d(LogTag.ROBOT, "Robot " + r.id + " is returning to construction (satellite)"); switch (state) // resuming from this state { case ConstructionState.QUEUING: { state = ConstructionState.FRONT_OF_QUEUE; Comm.directMessage(r.id, Comm.SATELLITE, "construction\nrequest_task"); break; } case ConstructionState.FINISHED: { finished = true; break; } default: { break; } } } //////////////////////////////////////////////////////////////////////////////////////// // Update //////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////// // Process messages: TODO //////////////////////////////////////////////////////////////////////////////////////// int count = r.unhandledMessages.Count; for (int i = 0; i < count; ++i) { bool handledMessage = false; CommMessage msg = r.unhandledMessages.Dequeue(); // TODO: this if-block is more repugnant than someone kicking a puppy if (msg.text.StartsWith("construction")) { handledMessage = true; if (msg.text.StartsWith(MessageConstructionStart.TAG)) { MessageConstructionStart msgData; if (MessageConstructionStart.TryParse(msg.text, out msgData)) { if (state == ConstructionState.WAITING_FOR_INITIALIZATION) { waitQueue = msgData.waitQueue; r.pushState(new RobotStateQueue(new Queue <Vector2>(waitQueue), 2f)); state = ConstructionState.QUEUING; } else { Log.e(LogTag.ROBOT, "Received " + MessageConstructionStart.TAG + " message outside of WAITING_FOR_INITIALIZATION state"); } } else { Log.a(LogTag.ROBOT, "Failed to parse " + MessageConstructionStart.TAG + " data."); } } else if (msg.text.StartsWith(MessageConstructionTask.TAG)) { MessageConstructionTask msgData; if (MessageConstructionTask.TryParse(msg.text, out msgData)) { if (state == ConstructionState.FRONT_OF_QUEUE) { Queue <Vector2> startToPlacementPerimeter; Queue <Vector2> placementToEndPerimeter; calculateBreakPosition(msgData.constructionPerimeter, msgData.resourcePlacement, out startToPlacementPerimeter, out placementToEndPerimeter); if (msgData.lastTask) { r.pushState(new RobotStateMove(new Vector2(r.id * -1.5f, 31))); state = ConstructionState.FINISHED; } else { r.pushState(new RobotStateQueue(new Queue <Vector2>(waitQueue), 2f)); state = ConstructionState.QUEUING; } r.pushState(new RobotStateQueue(placementToEndPerimeter, 2f)); r.pushState(new RobotStatePlaceResource(msgData.resourcePlacement)); r.pushState(new RobotStateQueue(startToPlacementPerimeter, 2f)); r.pushState(new RobotStateMove(msgData.resourceOrigin + new Vector2(0, -10))); r.pushState(new RobotStateRetrieveResource(msgData.resourceOrigin)); } else { Log.e(LogTag.ROBOT, "Received " + MessageConstructionTask.TAG + " message outside of FRONT_OF_QUEUE state"); } } else { Log.a(LogTag.ROBOT, "Failed to parse " + MessageConstructionTask.TAG + " data."); } } else if (msg.text == "construction/finished") { r.pushState(new RobotStateMove(new Vector2(r.id * -1.5f, 31))); state = ConstructionState.FINISHED; } else { Log.a(LogTag.ROBOT, "Unknown construction message:\n" + msg.text); } } if (!handledMessage) // didn't process message, leave for next state { r.unhandledMessages.Enqueue(msg); } } //////////////////////////////////////////////////////////////////////////////////////// // "Clean up" robot state //////////////////////////////////////////////////////////////////////////////////////// if (finished) { Log.d(LogTag.ROBOT, "Robot " + r.id + " has finished construction (satellite)."); // Pop state off the stack r.popState(); } }
public void AddFacilityConstructionEvent(SpaceCenterFacility facility, int newLevel, double cost, ConstructionState state) { if (CareerEventScope.ShouldIgnore || !IsEnabled) { return; } _facilityConstructions.Add(new FacilityConstructionEvent(KSPUtils.GetUT()) { Facility = facility, NewLevel = newLevel, Cost = cost, State = state }); }
/// <summary> /// Start selling mode. /// </summary> public void StartSelling() { CleanUp(); state = ConstructionState.Selling; onStateChanged?.Invoke(); }
protected override void Update() { switch (state) { case WorkerState.Idle: if (Time.time > nextIdleMovementTime) { nextIdleMovementTime = Time.time + idleMovementInterval; Vector3 wanderPoint = UnityEngine.Random.insideUnitSphere * 4; wanderPoint.y = entity.transform.position.y; wanderPoint += entity.transform.forward * 4 + entity.transform.position; Vector3 basePosition = BuildingSystem.Instance.playersBaseLocation.position; //if he would stray off to far, bring him back to base if (Vector3.Distance(basePosition, wanderPoint) > maxDistanceToBaseForWander) { wanderPoint += (basePosition - wanderPoint) / 4; } movement.MoveTo(wanderPoint); } break; case WorkerState.Construction: switch (constructionState) { case ConstructionState.Idle: //if idle /first get nearest Building which needs construction, if there is no we just chill beside the base if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (BuildingSystem.Instance.AreThereBuildingsToConstruct()) { standingBesideBaseAndWaiting = false; BuildingInConstruction nearestBuildingToConstruct = null; float nearestDistance = Mathf.Infinity; foreach (BuildingInConstruction building in BuildingSystem.Instance.GetBuildingsWaitingForConstruction()) { float currentDistance = (building.transform.position - entity.transform.position).sqrMagnitude; if (currentDistance < nearestDistance) { nearestDistance = currentDistance; nearestBuildingToConstruct = building; } } assignedBuildingToBuild = nearestBuildingToConstruct; //we move to a position from where we can build, not to a position inside the building Vector3 targetPosition = nearestBuildingToConstruct.transform.position + (entity.transform.position - nearestBuildingToConstruct.transform.position).normalized * nearestBuildingToConstruct.width / 2; movement.MoveTo(targetPosition); constructionState = ConstructionState.MovingToBuilding; } else if (!standingBesideBaseAndWaiting) { Vector3 positonToMoveTo = UnityEngine.Random.insideUnitSphere * 8; positonToMoveTo += BuildingSystem.Instance.playersBaseLocation.position; standingBesideBaseAndWaiting = true; movement.MoveTo(positonToMoveTo); } } break; case ConstructionState.MovingToBuilding: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (assignedBuildingToBuild != null) { if (Vector3.Distance(entity.transform.position, assignedBuildingToBuild.transform.position) < assignedBuildingToBuild.width + constructionRange) { movement.Stop(); constructionState = ConstructionState.Constructing; constructionTool.StartAnimation(); nextConstructionTime = Time.time + constructionInterval; } } else { constructionState = ConstructionState.Idle; } } break; case ConstructionState.Constructing: if (Time.time > nextConstructionTime) { //check if it istn completed yet if (assignedBuildingToBuild != null) { nextConstructionTime = Time.time + constructionInterval; assignedBuildingToBuild.Construct(constructionPoints); } else { constructionState = ConstructionState.Idle; constructionTool.StopAnimation(); } } break; } break; case WorkerState.Harvesting: switch (harvestingState) { case HarvestingState.Idle: //check if there are some ressources in the area - should it check with physics check or get the nearest from the ressourcesmanager? if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; HashSet <Ressource> ressources = RessourcesManager.Instance.GetRessources(assignedHarvesterType); if (ressources.Count > 0) { standingBesideHarvesterAndWaiting = false; Ressource nearestRessource = null; float nearestDistance = Mathf.Infinity; foreach (Ressource ressource in ressources) { float currentDistance = (ressource.transform.position - assignedHarvester.transform.position).sqrMagnitude; if (currentDistance < nearestDistance) { nearestDistance = currentDistance; nearestRessource = ressource; } } currentSelectedRessource = nearestRessource; Vector3 targetPosition = currentSelectedRessource.transform.position + (entity.transform.position - currentSelectedRessource.transform.position).normalized * currentSelectedRessource.width / 2; movement.MoveTo(targetPosition); harvestingState = HarvestingState.MovingToRessource; } else if (!standingBesideHarvesterAndWaiting) { Vector3 positonToMoveTo = UnityEngine.Random.insideUnitSphere * 5; positonToMoveTo += assignedHarvester.transform.position; standingBesideHarvesterAndWaiting = true; movement.MoveTo(positonToMoveTo); } } break; case HarvestingState.MovingToRessource: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (currentSelectedRessource != null) { if (Vector3.Distance(entity.transform.position, currentSelectedRessource.transform.position) < currentSelectedRessource.width) { movement.Stop(); harvestingState = HarvestingState.GatheringRessource; //activate the tool if (assignedHarvesterType == RessourceType.fer) { ferHarvestingTool.StartAnimation(); } else if (assignedHarvesterType == RessourceType.mer) { merHarvestingTool.StartAnimation(); } nextRessourceGatheringTime = Time.time + ressourceGatherInterval; } } else { harvestingState = HarvestingState.Idle; ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); } } break; case HarvestingState.GatheringRessource: if (Time.time > nextRessourceGatheringTime) { //check if it istn completed yet if (currentSelectedRessource != null) { nextRessourceGatheringTime = Time.time + ressourceGatherInterval; //gather but check how much will fit if (ressourceInventory.currentRessourceTransportLoad + ressourceGatheringPower > ressourceInventory.ressourceTransportLoad) { ressourceInventory.AddRessource(currentSelectedRessource.type, currentSelectedRessource.TakeRessource(ressourceInventory.ressourceTransportLoad - ressourceInventory.currentRessourceTransportLoad)); } else { ressourceInventory.AddRessource(currentSelectedRessource.type, currentSelectedRessource.TakeRessource(ressourceGatheringPower)); } //if the sack is full, go back if (ressourceInventory.currentRessourceTransportLoad == ressourceInventory.ressourceTransportLoad) { Vector3 targetPosition = assignedHarvester.transform.position + (entity.transform.position - assignedHarvester.transform.position).normalized * assignedHarvester.width / 2; movement.MoveTo(targetPosition); // movement.MoveTo(assignedHarvester.transform.position); harvestingState = HarvestingState.TransportingRessourceToHarvester; ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); } } else { ferHarvestingTool.StopAnimation(); merHarvestingTool.StopAnimation(); if (ressourceInventory.currentRessourceTransportLoad > 0) { Vector3 targetPosition = assignedHarvester.transform.position + (entity.transform.position - assignedHarvester.transform.position).normalized * assignedHarvester.width / 2; movement.MoveTo(targetPosition); //movement.MoveTo(assignedHarvester.transform.position); harvestingState = HarvestingState.TransportingRessourceToHarvester; } else { harvestingState = HarvestingState.Idle; } } } break; case HarvestingState.TransportingRessourceToHarvester: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (Vector3.Distance(entity.transform.position, assignedHarvester.transform.position) < assignedHarvester.width) { movement.Stop(); assignedHarvester.DepotRessource(ressourceInventory.currentRessourceTransportLoad); ressourceInventory.Clear(); if (currentSelectedRessource != null) { harvestingState = HarvestingState.MovingToRessource; movement.MoveTo(currentSelectedRessource.transform.position); } else { harvestingState = HarvestingState.Idle; } } } break; } break; case WorkerState.Depositing: if (Time.time > nextScanTime) { nextScanTime = Time.time + scanInterval; if (despositionBuilding != null) { if (Vector3.Distance(entity.transform.position, despositionBuilding.transform.position) < despositionBuilding.width) { despositionBuilding.GetComponent <IDepositioneable <B_Worker> >().DepositionWorker(this); } } else { AssignToIdle(); } } break; } }
public void RevertToPreviousConstructionMode() { mode = previousMode; }