#Difference between the ComponentLookup's methods

1 messages · Page 1 of 1 (latest)

oblique heron
#

Hi. Can someone help me with understanding the difference between these ComponentLookup's methods:

  1. GetComponentEnabledRefRO(RW)Optional and GetEnabledRefRO(RW) - screenshot 1
  2. GetRefRO(RW) and GetRefRO(RW)Optional - screenshot 2
    In the 1 screenshot they have exactly the same description, and in the 2 screenshot I just do not understand what does "and a default RefRO (RefRO.IsValid == false)." part mean...
tropic rain
oblique heron
#

No, I mean, what is the difference between all methods in 1 and next what is the difference between 2

tropic rain
#

optional will return default value

#

which returns false on IsValid

#

if component does not exist on entity

#

basically, save you a couple lines instead of you doing if (lookup.HasComponent(entity))...

oblique heron
#

That is true for 1 and 2, right? So if we are talking about IEnableableComponent-s, then IsValid will be false if given entity does not have such Component, right? As well as if we are talking about IComponentData

tropic rain
#

I don't really understand the question

oblique heron
#

And if the entity does not exist anymore it will also give us a IsValid==false

tropic rain
#

if entity is destroyed, it will return invalid ref

oblique heron
#

Ok, understood

#

Thanks

tropic rain
#

if entity does not have component, it will also return invalid ref

oblique heron
#

wait

oblique heron
tropic rain
#

it returns ref to component/enabled state

#

but that is only when you use Optional version

#

non-optional will just crash your game if component is not there