//nvm can't help myself // IT WORKS! // right, except due to annoying float problems it still ends up slightly off. // I think I'll need to move everything to decimal or even just ints with larger ranges private float adjustNeed(NeedNames need, bool worsening) { if (worsening) { if (needsCollections[need][NeedTraits.OptimumValue] > needsCollections[need][NeedTraits.WorstValue]) // if worsening is downwards { if (needStates[need] > needsCollections[need][NeedTraits.WorstValue]) { return(needsCollections[need][NeedTraits.DecayRate] * -1.0f); // Provide a negative number to worsen down. } else { return(0.0f); } } else // if worsening is upwards { if (needStates[need] < needsCollections[need][NeedTraits.WorstValue]) { return(needsCollections[need][NeedTraits.DecayRate]); } else { return(0.0f); } } } else { if (needsCollections[need][NeedTraits.OptimumValue] < needsCollections[need][NeedTraits.WorstValue]) // if improving is downwards { if (needStates[need] > needsCollections[need][NeedTraits.OptimumValue]) { return(needsCollections[need][NeedTraits.DecayRate] * -1.0f); // Provide a negative number to improve down to. } else { return(0.0f); } } else // if improving is upwards { if (needStates[need] < needsCollections[need][NeedTraits.OptimumValue]) { return(needsCollections[need][NeedTraits.DecayRate]); // Provide a negative number to worsen down. } else { return(0.0f); } } } }
// I should have another method or fix/extend the one below to from a given need, find out which is the most relevent job. // There might be wisdom in changing this from void to a return type of state or task, to help keep track of things though unsure of how to do so currently. private void ChooseTask(bool isInTaskCurrently = false) // I changed the name because the pawn might remain in a given task/state upon evaluation { var chosenNeed = EvaluateNeeds(needStates, isInTaskCurrently); //Ideally I should use some sort of match function here but I'm too lazt atm if (chosenNeed == NeedNames.Rest) { GD.Print("choose rest"); currentTargetNeed = NeedNames.Rest; var taskResult = Rest(); } else { GD.Print("choose walk"); currentTargetNeed = NeedNames.Boredom; var taskResult = Wander(); Task task = DelayedReadyWorkAround("blah"); } }