Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreachable Job Fix #1580

Merged
merged 26 commits into from
Nov 8, 2016
Merged

Conversation

Geoffrotism
Copy link
Contributor

@Geoffrotism Geoffrotism commented Oct 25, 2016

Fixes #1536, #1545, #1602
Fixes when characters cant reach jobs and go into infinite loops.

  • Figure out why jobs arent readded to the queue when a path changing event occurs.
  • Fix: Half of jobs being created in unreachable areas are "deleted".
  • Address characters going to pick up inventory before realizing there isnt a path to the job site.
  • Small bug where characters aren't picking up build jobs that had inventory requirements that were unreachable.
  • Fix: drag and drop jobs getting deleted.
    To recreate: add build wall job somewhere (reachable). then add a stack of steel (unreachable). queue job to deconstruct wall (to make steel reachable). Wall should be deconstructed but the current characters will not do the build job (new characters that spawn in will pick it up though).

@dusho
Copy link
Contributor

dusho commented Oct 26, 2016

true, there is something weird.. some jobs got lost
image
EDIT: actually you have problem with how you enqueue the unreachable jobs, not all get in

Commented more.
Changed the Character.JobState to null instead of idle when unable to find a job. reduces time between job calculations for unreachable jobs.
@Geoffrotism
Copy link
Contributor Author

Geoffrotism commented Oct 27, 2016

I was a dummy. Was removing a job from the JobQueue when using the Enqueue method. should be all fixed. Just need to do stylecop. @dusho @koosemose Is there anything else I should address with jobs in this PR? For instance handling the saving and loading of jobs?

@Geoffrotism Geoffrotism changed the title [WIP] Unreachable Job Fix Unreachable Job Fix [Feedback] Oct 27, 2016
@koosemose
Copy link
Collaborator

Just focus on the main point of the PR. We can do saving/loading of jobs in another PR

@Geoffrotism Geoffrotism changed the title Unreachable Job Fix [Feedback] [WIP] Unreachable Job Fix [Feedback] Oct 27, 2016
@Geoffrotism Geoffrotism changed the title [WIP] Unreachable Job Fix [Feedback] Unreachable Job Fix [Feedback] Oct 27, 2016
@Geoffrotism Geoffrotism changed the title Unreachable Job Fix [Feedback] Unreachable Job Fix Oct 27, 2016
@Geoffrotism
Copy link
Contributor Author

Ready for testing.
Note: if you do stuff with unreachable stockpiles there will be a huge FPS problem but this is due to pathfinding AFAIK.

@koosemose
Copy link
Collaborator

First issue I notice, is that they still go to pick up the inventory before abandoning the job, and are now stuck with that inventory. Aside from the being stuck with inventory issue (which is separate from this), could you look into having them figure out they can't get to the job before getting inventory for it?

@Geoffrotism
Copy link
Contributor Author

Geoffrotism commented Oct 28, 2016

sure can. although that would require two calculations for movement. One from character to job site. the other from character to pickup location.

@koosemose
Copy link
Collaborator

Not optimal, of course. But it works for now.

@bjubes bjubes changed the title Unreachable Job Fix [Conflicts] Unreachable Job Fix Nov 2, 2016
@bjubes
Copy link
Collaborator

bjubes commented Nov 2, 2016

Remove [Conflicts] from the title when you fix the merge conflicts.

…upine into Pathfinding_Optimization

# Conflicts:
#	Assets/Scripts/Models/Buildable/FurnitureManager.cs
…upine into Pathfinding_Optimization

# Conflicts:
#	Assets/Resources/Prefab.meta
@Geoffrotism Geoffrotism changed the title [Conflicts] Unreachable Job Fix Unreachable Job Fix Nov 2, 2016
@koosemose
Copy link
Collaborator

You've got failures, it looks like you had conflicts in Prefab.meta, and still have the HEAD>>> and such lines in it, guessing from the errors reported.

Fixed Merge Conflict
Added handling for characters that can't reach inventory.
@koosemose
Copy link
Collaborator

Now your builds failing with the following error:

Assets/Scripts/State/JobState.cs(69,29): error CS1061: Type `Job' does not contain a definition for `charsCantReach' and no extension method `charsCantReach' of type `Job' could be found (are you missing a using directive or an assembly reference?)

@Geoffrotism
Copy link
Contributor Author

Almost done with this PR, some things to note.

  • Unreachable inventory creates a HUGE slowdown, especially since stockpiles are separate tiles (so the original base does 6 path finding calculations for unreachable hauling jobs.)
  • Some of the perceivable lag is due to the IdleState where characters only try to pick up the job after a random amount of time between 0.5f and 2f.

The last thing to do is fix a bug described in the OP.

@Geoffrotism
Copy link
Contributor Author

All done, terrible lag for unreachables though due to using dykjstra over the whole map, switching to A* pathfinding to nearest inventory, bi-directional searching, and metastockpiles will help with that though.

@bjubes
Copy link
Collaborator

bjubes commented Nov 6, 2016

You have merge conflicts. hopefully the mdb file wont give you trouble. I don't know why git doesn't just overwrite the meta files like it usually does.

@bjubes bjubes changed the title Unreachable Job Fix [Conflicts] Unreachable Job Fix Nov 6, 2016
@BraedonWooding
Copy link
Collaborator

I got these exact conflicts like 10s ago, I fixed it by merging in upstream like you normally would then just press clear errors in the Unity Console, and then just commit the changes, you shouldn't need to make any changes, the clear error is just to make sure it doesn't have any access errors and it should overwrite the metas/mdb files (thus fixing the conflict), then just push 😃

…upine into Pathfinding_Optimization

# Conflicts:
#	Assets/Plugins/Net20/Newtonsoft.Json.dll.mdb
#	Assets/Plugins/Net20/Newtonsoft.Json.dll.mdb.meta
#	Assets/Plugins/x86_64/fmod.dll.meta
@Geoffrotism
Copy link
Contributor Author

fixed conflicts, ty @BraedonWooding

@Geoffrotism Geoffrotism changed the title [Conflicts] Unreachable Job Fix Unreachable Job Fix Nov 6, 2016
@bjubes bjubes merged commit 07b1e81 into TeamPorcupine:master Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants