Skip to content

Commit

Permalink
Update appearance name before reassemble callback
Browse files Browse the repository at this point in the history
  • Loading branch information
psiberx committed Aug 20, 2024
1 parent 1bf1dd2 commit c3ebfc8
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 7 deletions.
51 changes: 51 additions & 0 deletions scripts/Base/Addons/gameLightComponent.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
@addField(gameLightComponent)
native let emissiveOnly: Bool;

@addField(gameLightComponent)
native let materialZone: gameEMaterialZone;

@addField(gameLightComponent)
native let meshBrokenAppearance: CName;

@addField(gameLightComponent)
native let onStrength: Float;

@addField(gameLightComponent)
native let turnOnByDefault: Bool;

@addField(gameLightComponent)
native let turnOnTime: Float;

@addField(gameLightComponent)
native let turnOnCurve: CName;

@addField(gameLightComponent)
native let turnOffTime: Float;

@addField(gameLightComponent)
native let turnOffCurve: CName;

@addField(gameLightComponent)
native let loopTime: Float;

@addField(gameLightComponent)
native let loopCurve: CName;

@addField(gameLightComponent)
native let synchronizedLoop: Bool;

@addField(gameLightComponent)
native let isDestructible: Bool;

@addField(gameLightComponent)
native let colliderName: CName;

@addField(gameLightComponent)
native let colliderTag: CName;

@addField(gameLightComponent)
native let destructionEffect: ResourceAsyncRef; // raRef<worldEffect>

@addField(gameLightComponent)
native let genericCurveSetOverride: ResourceRef; // rRef<CurveSet>

13 changes: 7 additions & 6 deletions src/App/Callback/Controllers/EntityReassembleHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,21 @@ class EntityReassembleHook
return !IsHooked<Raw::Entity::Reassemble>() || Unhook<Raw::Entity::Reassemble>();
}

inline static void OnReassemble(Red::Entity* aEntity, uintptr_t, uint64_t, uint64_t,
inline static void OnReassemble(Red::Entity* aEntity, uintptr_t a2, Red::CName aNewAppearance, uint64_t a4,
Red::DynArray<Red::Handle<Red::IComponent>>& aNewComponents,
Red::Handle<Red::ent::EntityParametersStorage>& aEntityParams)
{
auto storage = Raw::Entity::ComponentsStorage(aEntity);
auto compCount = storage->components.size;
aEntity->appearanceName = aNewAppearance;

auto compCount = aEntity->components.size;

CallbackSystem::Get()->DispatchNativeEvent<EntityLifecycleEvent>(EventName, Red::AsWeakHandle(aEntity));

if (compCount != storage->components.size)
if (compCount != aEntity->components.size)
{
while (compCount < storage->components.size)
while (compCount < aEntity->components.size)
{
aNewComponents.PushBack(storage->components[compCount]);
aNewComponents.PushBack(aEntity->components[compCount]);
++compCount;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Red/Entity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ constexpr auto OnAssemble = Core::RawFunc<

constexpr auto Reassemble = Core::RawFunc<
/* addr = */ Red::AddressLib::Entity_Reassemble,
/* type = */ void (*)(Red::Entity* aEntity, uintptr_t, uint64_t, uint64_t,
/* type = */ void (*)(Red::Entity* aEntity, uintptr_t a2, Red::CName aNewAppearance, uint64_t a4,
Red::DynArray<Red::Handle<Red::IComponent>>& aNewComponents,
Red::Handle<Red::ent::EntityParametersStorage>& aEntityParams)>();

Expand Down

0 comments on commit c3ebfc8

Please sign in to comment.