To me, that looks pretty dumb. There’s got to be a smarter way to do this! I found Math.Sign, but that’s not what I’m looking for, that’s just to get the sign of a number.
Not sure I understand exactly what you’re asking. But there’s not really anything wrong with doing code like what you show, assuming you have a function in which can either add or subtract.
There are probably ways to condence it a bit but it’d also make it less obvious what you’re doing so just keep it as is.
What’s the overall purpose? Do you need more operations? Who or what does influence the decision which operator to use?
You could outsource this into a helper method with a parameter which indicates the operation to execute, or abstract that all by using delegates or your own interface like ‘IBinaryOperation’.
Under certain conditions, you could assign a new delegate or a different implementation to the variable that holds an operation instance.
If it’s just about Plus and Minus, I’d just to do it the way you’ve already done it.
And I often have to change the sign before DodgeDistance into a + or -. That’s why I was concerned with my method of handling that, but I guess there’s not much to improve.