Quantcast
Viewing all articles
Browse latest Browse all 387

Programming • C++ help needed: add filter for potential effect targets

I would like to get rid of the second round of application of effects (that is a ApplyMeterEffectsAndUpdateMeters) in order to restrict weird effect interactions.
We currently need it this round in order to initialize newly created objects (either through effects in the first round or through production).

I am looking at the restrict-the-targets way, which is the first one the following ways to implement initialisation without a full second effect application:
  • restrict-the-targets: filter the scopes in the second round to newly created objects. So old objects would not be be affected by newly created ones.
  • restrict-the-effects: make initialization a "phase" after production, so only effects for that phase would be applied; contents would be need to be explicit about the initialization. I think this means basically all object meter effects.
  • for objects created by production we could also move the effect application, but this wont solve the issues for objects created by effects. That would give a 1-turn delay to the effects of production meters, but i think that would be acceptible in this case - industry/research takes a while to show its result. I am not sure if moving the creation effects to the beginning of scripting via priority would work or not (because of caching etc).
It seems a good place would be to filter potential_targets in Universe::GetEffectsAndTargets

Code:

auto potential_targets{context.ContextObjects().findRaw<const UniverseObject>(target_object_ids)}; 
would it be acceptable to add a method to the context <const UniverseObject>(target_object_ids)} to get those potential targets (like context.ContextObjects().findTargets(target_object_ids) ) or should I add a Universe::ApplyAllEffectsAndUpdateMetersToNewlyCreatedObjects (and pass another flag argument to Universe::GetEffectsAndTargets). Or is there a better place to add such filtering?

edit: ...i found a second variant of ApplyMeterEffectsAndUpdateMeters which takes target ids as argument; it is used in EncyclopediaDetailPanel.. i will try that one first. Image may be NSFW.
Clik here to view.
:mrgreen:


edit2: this was surprisingly easy PR-4968

Statistics: Posted by Ophiuchus — Mon Jul 01, 2024 8:28 am



Viewing all articles
Browse latest Browse all 387

Trending Articles