public void RegisterWorker(AIProjectWorker worker) { worker.SetProject(this); assignedWorkers.Add(worker); OnNewWorker(worker); }
public override void FinishedWork(AIProjectWork work, AIProjectWorker worker) { GameManager.pointObjectManager.EraseObject(work.cubePoint); RemoveMineralFromDivision(((MiningWork)work).pointValue); base.FinishedWork(work, worker); WorldInterface.RequestPointDataRelated(work.cubePoint, 2.0f, DeliverPointValue); if (workQueue.Count==0) { PendingOfflineTimer = 5.0f; DebugOutput.Shout("Pending Offlining Mining Project in " + PendingOfflineTimer.ToString()+" seconds"); TimerSystem.AddSimpleUpdate(UpdateOfflineTimer); } }
public virtual void FindWorkForWorker(AIProjectWorker worker) { AIProjectWork closestWork = null; float closestDistance = float.MaxValue; for(int i = 0;i < workQueue.Count;i++) { if(workQueue[i].assignedWorker == null) { float sqrdistance = (workQueue[i].cubePoint-worker.transform.position).sqrMagnitude; if( sqrdistance < closestDistance) { closestDistance = sqrdistance; closestWork = workQueue[i]; } } } if (closestWork != null) { worker.SetActiveWork(closestWork); return; } }
public virtual void FinishedWork(AIProjectWork work,AIProjectWorker worker) { workQueue.Remove(work); FindWorkForWorker(worker); }
public static void RegisterWorker(AIProjectWorker worker) { //worker.SetProject(GetProjectByDistance(worker)); if (idleWorkers == null) { idleWorkers = new List<AIProjectWorker>(); } idleWorkers.Add(worker); if (projectsDictionary != null) { if (projectsDictionary.Keys.Count > 0) { ParseWorkers(); } } }
public static AIProject GetProjectByDistance(AIProjectWorker worker) { for(int i = 0 ; i < worker.typeData.workTypeIDs.Count;i++) { List<AIProject> projects = getProjects(worker.typeData.workTypeIDs[i]); if(projects != null) { AIProject closestProject = null; float distanceToClosest = float.MaxValue; for(int j = 0;j < projects.Count;j++) { if (projects[j].needWorker()) { float sqrdistance = (worker.transform.position - projects[j].position).sqrMagnitude; if (sqrdistance < distanceToClosest) { closestProject = projects[j]; distanceToClosest = sqrdistance; } } } if (closestProject != null) { return closestProject; } } } return null; }
protected virtual void OnNewWorker(AIProjectWorker worker) { FindWorkForWorker(worker); }
protected override void OnNewWorker(AIProjectWorker worker) { DebugOutput.Shout("We have a new Worker for this project"); base.OnNewWorker(worker); }