Skip to content

Conversation

MasonDestro
Copy link

@MasonDestro MasonDestro commented Jun 10, 2025

PR Details

Like the Entity Entity { get; } already in Stride.BepuPhysics.Components.ISimulationUpdate
Allow flexible processing Processor to visit public properties of EntityComponent like EntityProcessor<TComponent, TData>

It's common to get data from other components of the same entity in game dev, e.g.
Health, MoveSpeed are properties of reusable component Unit, another reusable component UnitMove need to get MoveSpeed from Unit. Also, there could be an EffectContainer contains effects may change speed like Frozen or SpeedUp that UnitMove need to get.

in EntityProcessor, it can do such things through EntityComponent.Entity.Get<T>() while traversing ComponentDatas.Values, but it's not a default feature for IComponent and IProcessor of flexible processing.
So I add getter to IComponent and remove the Entity Entity { get; } in ISimulationUpdate since it's the only one built-in component inherits IComponent.

Related Issue

none

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

Like the `Entity Entity { get; }` already in Stride.BepuPhysics.Components.ISimulationUpdate
@Kryptos-FR Kryptos-FR requested a review from Eideren June 10, 2025 15:17
@Kryptos-FR
Copy link
Member

Do we want all implementations of IComponent to have an Entity? If not (for more flexibility or other reasons), then it cannot be promoted to the base interface. Just because the current implementation has it doesn't mean all (including future one) will.

Pinging @Eideren since they worked on that "flexible processing" part (cf #2331).

@MasonDestro MasonDestro changed the title feat: IComponent can visit EntityComponent properties feat: IComponent can access EntityComponent properties Jun 11, 2025
@Eideren
Copy link
Collaborator

Eideren commented Jun 11, 2025

I don't understand what this PR tries to achieve - the interface as is is not supposed to be consumed by anything besides the internals of stride - the processor of a given IComponent should process the interface as its derived type, not the generic IComponent type.
Could you show us a concrete example were this would be useful ?

@Eideren Eideren marked this pull request as draft August 27, 2025 15:19
@Eideren
Copy link
Collaborator

Eideren commented Aug 27, 2025

Converting this to draft while the contributor gets back to us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants