Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'OnNotContaining' StatusEffect ActionType. #14261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jade-Harleyy
Copy link

@Jade-Harleyy Jade-Harleyy commented Jul 6, 2024

Adds a new StatusEffect ActionType called OnNotContaining that is the opposite of OnContaining.

@PanmanS
Copy link

PanmanS commented Jul 6, 2024

Truly the best cooking

Copy link
Collaborator

@Regalis11 Regalis11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spotted one issue that seems like it could have some negative performance implications.

I'm also fairly sure this doesn't work properly: the effects are executed in Update, but there's no guarantee that the item is active (= that Update gets called) when it has these types of effects active. See line 656 for example, on which the component may get deactivated.

I think performance also needs to be taken into account here: having these sorts of effects should not force the component to always stay active, but the component should only be forced active if any of these effects can currently execute.


for (int i = 0; i < slotRestrictions.Length; i++)
{
foreach (StatusEffect effect in slotRestrictions[i].ContainableItems.SelectMany(ci => ci.StatusEffects.Where(se => se.type == ActionType.OnNotContaining && Inventory.GetItemsAt(i).None(ci.MatchesItem))))
Copy link
Collaborator

@Regalis11 Regalis11 Jul 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generates a ton of garbage due to the captured variables. Particularly bad in this case, because this executes potentially tons of times per frame.

@Regalis11 Regalis11 added Code Programming task Modding Modding-related feature request or issue, or a bug that only occurs with mods Waiting Cannot be worked on/reviewed/tested at the moment for some reason labels Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Programming task Modding Modding-related feature request or issue, or a bug that only occurs with mods Waiting Cannot be worked on/reviewed/tested at the moment for some reason
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants