SK equivalent to TSubclassOf and BlueprintPure


#1

Hi, I wanted to know if there’s an equivalent for the C++ TSubclassOf in SK (I know about <ClassName> but the blueprint node won’t show a class argument for the node.
I also wanted to know if there’s anything like BlueprintPure in C++ for SK (I know about &blueprint but it generate a BlueprintCallable, not want I want)?


#2

If I understand you correctly, and you are just looking for Sk methods then you would use:

if object.subclass_of?(TestClass)
  [println("It's a subclass")]

// These can also be found in the Object class:
if object.class_of?(TestClass)
  [println("It's the same class or a subclass")]
if object.superclass_of?(TestClass)
  [println("It's a superclass")]

This answer might be related too:

No. Sk does not have anything like BlueprintPure. We might add something akin to a const in the future.

What are you trying to do? Are you trying to call into C++ or have C++ call into Sk?


#3

I’m trying to do something akin to this:

bool ATestCharacter::HasWeapon(const TSubclassOf<class ADFNDBaseWeapon>& TestWeapon) const {
	for (ADFNDBaseWeapon* Weapon : Weapons) {
		if (TestWeapon->GetClass( ) == *TestWeapon)
			return true;
	}
	return false;
}

but in SK but i can’t seem to find a way to expose to blueprint properly here’s my SK code

&blueprint
(<EntityClass> test_weapon) Boolean [
  @weapons.any? [item.class_of?(test_weapon)]
]

here’s the node from the C++ code:

and here’s the SK node

I want to get the same node in SK as i do in C++ is it even possible? (I don’t care whether it’s a BlueprintPure or BlueprintCallable as long as I can pass a class directly.

I’m sorry I can’t seem to find the proper ways to explain myself in english, seems my brain is already sleeping but I hope its clearer now?

P.S. thx for the fast answer, wasn’t expecting that


#4

Sk does not currently support TSubClassOf. However, just using EntityClass (without angle brackets) as the input type should work and be completely safe since all you do is comparing pointers.

&blueprint
(EntityClass test_weapon_class) Boolean [
  @weapons.any? [item.static_class = test_weapon_class]
]

Note that this code is not aware of potential inheritance between weapons since it compares class pointers directly.


#5

I just found MathLib.class_is_child_of() which might be what you are looking for.

&blueprint
(EntityClass weapon_class) Boolean [
  @weapons.any? [MathLib.class_is_child_of(item.static_class weapon_class)]
]

Didn’t expect to find it there, though UE4 has many things stuffed into MathLib. :madsci:


#6

Note that in the latest ver. 3.0.5546 update, wrapper methods were added to EntityClass including:

  • entity_class_of?()
  • entity_subclass_of?()
  • entity_superclass_of?()
  • equal?() or =
  • not_equal?() or ~=

So you can now write the above as:

&blueprint
(EntityClass weapon_class) Boolean [
  @weapons.any? [item.static_class.entity_subclass_of?(weapon_class)]
]