The fit calculation function. It should be noted that this is a recursive function - if the local fit has projected fits, this function will be called for those projected fits to be calculated. Args: targetFit: If this is set, signals that
(self, targetFit=None, type=CalcType.LOCAL)
| 978 | value.victim_fit.calculated = False |
| 979 | |
| 980 | def calculateModifiedAttributes(self, targetFit=None, type=CalcType.LOCAL): |
| 981 | """ |
| 982 | The fit calculation function. It should be noted that this is a recursive function - if the local fit has |
| 983 | projected fits, this function will be called for those projected fits to be calculated. |
| 984 | |
| 985 | Args: |
| 986 | targetFit: |
| 987 | If this is set, signals that we are currently calculating a remote fit (projected or command) that |
| 988 | should apply it's remote effects to the targetFit. If None, signals that we are currently calcing the |
| 989 | local fit |
| 990 | type: |
| 991 | The type of calculation our current iteration is in. This helps us determine the interactions between |
| 992 | fits that rely on others for proper calculations |
| 993 | """ |
| 994 | pyfalog.info("Starting fit calculation on: {0}, calc: {1}", repr(self), CalcType(type).name) |
| 995 | |
| 996 | # If we are projecting this fit onto another one, collect the projection info for later use |
| 997 | |
| 998 | # We also deal with self-projection here by setting self as a copy (to get a new fit object) to apply onto original fit |
| 999 | # First and foremost, if we're looking at a local calc, reset the calculated state of fits that this fit affects |
| 1000 | # Thankfully, due to the way projection mechanics currently work, we don't have to traverse down a projection |
| 1001 | # tree to (resetting the first degree of projection will suffice) |
| 1002 | if targetFit is None: |
| 1003 | # This resets all fits that local projects onto, allowing them to recalc when loaded |
| 1004 | self.__resetDependentCalcs() |
| 1005 | |
| 1006 | # For fits that are under local's Command, we do the same thing |
| 1007 | for value in list(self.boostedOnto.values()): |
| 1008 | # apparently this is a thing that happens when removing a command fit from a fit and then switching to |
| 1009 | # that command fit. Same as projected clears, figure out why. |
| 1010 | if value.boosted_fit: |
| 1011 | value.boosted_fit.__resetDependentCalcs() |
| 1012 | |
| 1013 | if targetFit and type == CalcType.PROJECTED: |
| 1014 | pyfalog.debug("Calculating projections from {0} to target {1}", repr(self), repr(targetFit)) |
| 1015 | projectionInfo = self.getProjectionInfo(targetFit.ID) |
| 1016 | |
| 1017 | # Start applying any command fits that we may have. |
| 1018 | # We run the command calculations first so that they can calculate fully and store the command effects on the |
| 1019 | # target fit to be used later on in the calculation. This does not apply when we're already calculating a |
| 1020 | # command fit. |
| 1021 | if type != CalcType.COMMAND and self.commandFits and not self.__calculated: |
| 1022 | for fit in self.commandFits: |
| 1023 | commandInfo = fit.getCommandInfo(self.ID) |
| 1024 | # Continue loop if we're trying to apply ourselves or if this fit isn't active |
| 1025 | if not commandInfo.active or self == commandInfo.booster_fit: |
| 1026 | continue |
| 1027 | |
| 1028 | commandInfo.booster_fit.calculateModifiedAttributes(self, CalcType.COMMAND) |
| 1029 | |
| 1030 | # If we're not explicitly asked to project fit onto something, |
| 1031 | # set self as target fit |
| 1032 | if targetFit is None: |
| 1033 | targetFit = self |
| 1034 | |
| 1035 | # If fit is calculated and we have nothing to do here, get out |
| 1036 | |
| 1037 | # A note on why we only do this for local fits. There may be |