mirror of https://github.com/OpenRCT2/OpenRCT2.git
Implement ScGuest::animation_set, animationOffset_set
This commit is contained in:
parent
480c23005a
commit
bdca891c9d
|
@ -205,8 +205,8 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScGuest::thoughts_get, nullptr, "thoughts");
|
||||
dukglue_register_property(ctx, &ScGuest::items_get, nullptr, "items");
|
||||
dukglue_register_property(ctx, &ScGuest::availableAnimations_get, nullptr, "availableAnimations");
|
||||
dukglue_register_property(ctx, &ScGuest::animation_get, nullptr, "animation");
|
||||
dukglue_register_property(ctx, &ScGuest::animationOffset_get, nullptr, "animationOffset");
|
||||
dukglue_register_property(ctx, &ScGuest::animation_get, &ScGuest::animation_set, "animation");
|
||||
dukglue_register_property(ctx, &ScGuest::animationOffset_get, &ScGuest::animationOffset_set, "animationOffset");
|
||||
dukglue_register_property(ctx, &ScGuest::animationLength_get, nullptr, "animationLength");
|
||||
dukglue_register_method(ctx, &ScGuest::has_item, "hasItem");
|
||||
dukglue_register_method(ctx, &ScGuest::give_item, "giveItem");
|
||||
|
@ -847,6 +847,25 @@ namespace OpenRCT2::Scripting
|
|||
return std::string(action);
|
||||
}
|
||||
|
||||
void ScGuest::animation_set(std::string groupKey)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
|
||||
auto newType = availableGuestAnimations.TryGet(groupKey);
|
||||
if (newType == std::nullopt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* peep = GetGuest();
|
||||
peep->ActionSpriteType = *newType;
|
||||
peep->ActionFrame = 0;
|
||||
|
||||
auto& animationGroup = GetPeepAnimation(peep->SpriteType, peep->ActionSpriteType);
|
||||
peep->ActionSpriteImageOffset = animationGroup.frame_offsets[peep->ActionFrame];
|
||||
peep->UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
uint8_t ScGuest::animationOffset_get() const
|
||||
{
|
||||
auto* peep = GetGuest();
|
||||
|
@ -858,6 +877,19 @@ namespace OpenRCT2::Scripting
|
|||
return peep->ActionSpriteImageOffset;
|
||||
}
|
||||
|
||||
void ScGuest::animationOffset_set(uint8_t offset)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
|
||||
auto* peep = GetGuest();
|
||||
|
||||
auto& animationGroup = GetPeepAnimation(peep->SpriteType, peep->ActionSpriteType);
|
||||
auto length = animationGroup.frame_offsets.size();
|
||||
|
||||
peep->ActionFrame = offset % length;
|
||||
peep->UpdateCurrentActionSpriteType();
|
||||
}
|
||||
|
||||
uint8_t ScGuest::animationLength_get() const
|
||||
{
|
||||
auto* peep = GetGuest();
|
||||
|
|
|
@ -175,7 +175,9 @@ namespace OpenRCT2::Scripting
|
|||
|
||||
std::vector<std::string> availableAnimations_get() const;
|
||||
std::string animation_get() const;
|
||||
void animation_set(std::string groupKey);
|
||||
uint8_t animationOffset_get() const;
|
||||
void animationOffset_set(uint8_t offset);
|
||||
uint8_t animationLength_get() const;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue