OpenPerpetuum / PerpetuumServer

The Open Perpetuum Project's fork of the Perpetuum Standalone Server
https://openperpetuum.com
Other
44 stars 21 forks source link

Threat refactor #432

Open MikeJeffers opened 2 years ago

MikeJeffers commented 2 years ago

Threats and how they are valued, generated, and manipulated before sending to the threat manager of an NPC are all over the place Some are here: https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Zones/NpcSystem/ThreatManager.cs#L12-L35 But then the relevant amounts and details live elsewhere like: https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Modules/EnergyNeutralizerModule.cs#L51-L52 https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Modules/EnergyTransfererModule.cs#L49 https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Modules/EnergyVampireModule.cs#L60 https://github.com/OpenPerpetuum/PerpetuumServer/blob/Development/src/Perpetuum/Zones/NpcSystem/Npc.cs#L973

And a few other places (use find all references for ThreatType)

It would be a bit easier to track and manage all the bespoke values and modifiers of threat if they were in one place. This will help developers reason about and communicate threat value calculation changes to designers and players.

Ramit110 commented 1 year ago

Would it make sense to have a ThreatBuilder for this? I'm thinking of making the class with a bunch of static methods for things like BuildThreatNeut(int value), BuildThreat(int value), BuildThreatVampire(int value) ect ect for all the places it's used, that way all the threat calculations are all in one class/file.

Ramit110 commented 1 year ago

There's a small bit of duplication in ThreatManager.cs, mentioned in a comment, otherwise code should be acceptable.

56612db2384c5742a73aadcb93d3b4badba8b7f9 and f10d3035f271a64b0c46d55340a2a5aea8d0e352 are the last commit I'll be doing until I get a response XD