mirror of https://github.com/OpenRCT2/OpenRCT2.git
Replace getWalkingSpriteIds with getAnimationSpriteIds
This commit is contained in:
parent
8b310ae5e0
commit
f4cc60d974
|
@ -2648,11 +2648,6 @@ declare global {
|
|||
* @param value Whether to set or clear the flag.
|
||||
*/
|
||||
setFlag(key: PeepFlags, value: boolean): void;
|
||||
|
||||
/**
|
||||
* Gets an array of sprite ids representing the peep's walking animation.
|
||||
*/
|
||||
getWalkingSpriteIds(): number[];
|
||||
}
|
||||
|
||||
type PeepFlags =
|
||||
|
@ -2687,6 +2682,34 @@ declare global {
|
|||
*/
|
||||
type PeepType = "guest" | "staff";
|
||||
|
||||
type GuestAnimation =
|
||||
"walking" |
|
||||
"checkTime" |
|
||||
"watchRide" |
|
||||
"eatFood" |
|
||||
"shakeHead" |
|
||||
"emptyPockets" |
|
||||
"holdMat" |
|
||||
"sittingIdle" |
|
||||
"sittingEatFood" |
|
||||
"sittingLookAroundLeft" |
|
||||
"sittingLookAroundRight" |
|
||||
"hanging" |
|
||||
"wow" |
|
||||
"throwUp" |
|
||||
"jump" |
|
||||
"drowning" |
|
||||
"joy" |
|
||||
"readMap" |
|
||||
"wave" |
|
||||
"wave2" |
|
||||
"takePhoto" |
|
||||
"clap" |
|
||||
"disgust" |
|
||||
"drawPicture" |
|
||||
"beingWatched" |
|
||||
"withdrawMoney";
|
||||
|
||||
/**
|
||||
* Represents a guest.
|
||||
*/
|
||||
|
@ -2828,12 +2851,17 @@ declare global {
|
|||
/**
|
||||
* The animations available to this guest.
|
||||
*/
|
||||
readonly availableAnimations: string[];
|
||||
readonly availableAnimations: GuestAnimation[];
|
||||
|
||||
/**
|
||||
* Gets an array of sprite ids representing a particular guest animation.
|
||||
*/
|
||||
getAnimationSpriteIds(animation: GuestAnimation, rotation: number): number[];
|
||||
|
||||
/**
|
||||
* The animation the guest is currently exhibiting.
|
||||
*/
|
||||
animation: string;
|
||||
animation: GuestAnimation;
|
||||
|
||||
/**
|
||||
* The frame offset in the current animation.
|
||||
|
@ -3138,6 +3166,26 @@ declare global {
|
|||
"sheriff" |
|
||||
"pirate";
|
||||
|
||||
type StaffAnimation =
|
||||
"walking" |
|
||||
"watchRide" |
|
||||
"wave" |
|
||||
"hanging" |
|
||||
"staffMower" |
|
||||
"staffSweep" |
|
||||
"drowning" |
|
||||
"staffAnswerCall" |
|
||||
"staffAnswerCall2" |
|
||||
"staffCheckboard" |
|
||||
"staffFix" |
|
||||
"staffFix2" |
|
||||
"staffFixGround" |
|
||||
"staffFix3" |
|
||||
"staffWatering" |
|
||||
"joy" |
|
||||
"staffEmptyBin" |
|
||||
"wave2";
|
||||
|
||||
/**
|
||||
* Represents a staff member.
|
||||
*/
|
||||
|
@ -3175,12 +3223,17 @@ declare global {
|
|||
/**
|
||||
* The animations available to this staff member.
|
||||
*/
|
||||
readonly availableAnimations: string[];
|
||||
readonly availableAnimations: StaffAnimation[];
|
||||
|
||||
/**
|
||||
* Gets an array of sprite ids representing a particular staff animation.
|
||||
*/
|
||||
getAnimationSpriteIds(animation: StaffAnimation, rotation: number): number[];
|
||||
|
||||
/**
|
||||
* The animation the staff member is currently exhibiting.
|
||||
*/
|
||||
animation: string;
|
||||
animation: StaffAnimation;
|
||||
|
||||
/**
|
||||
* The frame offset in the current animation.
|
||||
|
|
|
@ -1020,7 +1020,6 @@
|
|||
<ClCompile Include="scenes\title\TitleSequenceManager.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScLitter.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScPeep.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScVehicle.cpp" />
|
||||
<ClCompile Include="scripting\bindings\network\ScNetwork.cpp" />
|
||||
|
|
|
@ -208,6 +208,7 @@ namespace OpenRCT2::Scripting
|
|||
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::getAnimationSpriteIds, "getAnimationSpriteIds");
|
||||
dukglue_register_method(ctx, &ScGuest::has_item, "hasItem");
|
||||
dukglue_register_method(ctx, &ScGuest::give_item, "giveItem");
|
||||
dukglue_register_method(ctx, &ScGuest::remove_item, "removeItem");
|
||||
|
@ -835,6 +836,34 @@ namespace OpenRCT2::Scripting
|
|||
return availableAnimations;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> ScGuest::getAnimationSpriteIds(std::string groupKey, uint8_t rotation) const
|
||||
{
|
||||
std::vector<uint32_t> spriteIds{};
|
||||
|
||||
auto animationType = availableGuestAnimations.TryGet(groupKey);
|
||||
if (animationType == std::nullopt)
|
||||
{
|
||||
return spriteIds;
|
||||
}
|
||||
|
||||
auto peep = GetPeep();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
auto& animationGroup = GetPeepAnimation(peep->SpriteType, *animationType);
|
||||
for (auto frameOffset : animationGroup.frame_offsets)
|
||||
{
|
||||
auto imageId = animationGroup.base_image;
|
||||
if (animationType != PeepActionSpriteType::Ui)
|
||||
imageId += rotation + frameOffset * 4;
|
||||
else
|
||||
imageId += frameOffset;
|
||||
|
||||
spriteIds.push_back(imageId);
|
||||
}
|
||||
}
|
||||
return spriteIds;
|
||||
}
|
||||
|
||||
std::string ScGuest::animation_get() const
|
||||
{
|
||||
auto* peep = GetGuest();
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
# include "../../../entity/Guest.h"
|
||||
# include "ScPeep.hpp"
|
||||
|
||||
enum class PeepActionSpriteType : uint8_t;
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
static const DukEnumMap<ShopItem> ShopItemMap({
|
||||
|
@ -174,6 +176,7 @@ namespace OpenRCT2::Scripting
|
|||
void remove_all_items() const;
|
||||
|
||||
std::vector<std::string> availableAnimations_get() const;
|
||||
std::vector<uint32_t> getAnimationSpriteIds(std::string groupKey, uint8_t rotation) const;
|
||||
std::string animation_get() const;
|
||||
void animation_set(std::string groupKey);
|
||||
uint8_t animationOffset_get() const;
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2024 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "ScPeep.hpp"
|
||||
|
||||
# include "../../../peep/PeepAnimationData.h"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
// TODO: move other method implementations from ScPeep.hpp here.
|
||||
|
||||
std::vector<uint32_t> ScPeep::getWalkingSpriteIds() const
|
||||
{
|
||||
std::vector<uint32_t> spriteIds{};
|
||||
auto peep = GetPeep();
|
||||
if (peep != nullptr)
|
||||
{
|
||||
auto& animationGroup = GetPeepAnimation(peep->SpriteType, PeepActionSpriteType::None);
|
||||
for (auto frameOffset : animationGroup.frame_offsets)
|
||||
{
|
||||
constexpr auto rotation = 1;
|
||||
spriteIds.push_back(animationGroup.base_image + rotation + frameOffset * 4);
|
||||
}
|
||||
}
|
||||
return spriteIds;
|
||||
}
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
|
@ -61,7 +61,6 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScPeep::energyTarget_get, &ScPeep::energyTarget_set, "energyTarget");
|
||||
dukglue_register_method(ctx, &ScPeep::getFlag, "getFlag");
|
||||
dukglue_register_method(ctx, &ScPeep::setFlag, "setFlag");
|
||||
dukglue_register_method(ctx, &ScPeep::getWalkingSpriteIds, "getWalkingSpriteIds");
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -116,8 +115,6 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<uint32_t> getWalkingSpriteIds() const;
|
||||
|
||||
DukValue destination_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
|
|
@ -76,6 +76,7 @@ namespace OpenRCT2::Scripting
|
|||
dukglue_register_property(ctx, &ScStaff::animation_get, &ScStaff::animation_set, "animation");
|
||||
dukglue_register_property(ctx, &ScStaff::animationOffset_get, &ScStaff::animationOffset_set, "animationOffset");
|
||||
dukglue_register_property(ctx, &ScStaff::animationLength_get, nullptr, "animationLength");
|
||||
dukglue_register_method(ctx, &ScStaff::getAnimationSpriteIds, "getAnimationSpriteIds");
|
||||
}
|
||||
|
||||
Staff* ScStaff::GetStaff() const
|
||||
|
@ -321,6 +322,38 @@ namespace OpenRCT2::Scripting
|
|||
return availableAnimations;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> ScStaff::getAnimationSpriteIds(std::string groupKey, uint8_t rotation) const
|
||||
{
|
||||
std::vector<uint32_t> spriteIds{};
|
||||
|
||||
auto* peep = GetStaff();
|
||||
if (peep == nullptr)
|
||||
{
|
||||
return spriteIds;
|
||||
}
|
||||
|
||||
auto& animationGroups = animationsByStaffType(peep->AssignedStaffType);
|
||||
auto animationType = animationGroups.TryGet(groupKey);
|
||||
if (animationType == std::nullopt)
|
||||
{
|
||||
return spriteIds;
|
||||
}
|
||||
|
||||
auto& animationGroup = GetPeepAnimation(peep->SpriteType, *animationType);
|
||||
for (auto frameOffset : animationGroup.frame_offsets)
|
||||
{
|
||||
auto imageId = animationGroup.base_image;
|
||||
if (animationType != PeepActionSpriteType::Ui)
|
||||
imageId += rotation + frameOffset * 4;
|
||||
else
|
||||
imageId += frameOffset;
|
||||
|
||||
spriteIds.push_back(imageId);
|
||||
}
|
||||
|
||||
return spriteIds;
|
||||
}
|
||||
|
||||
std::string ScStaff::animation_get() const
|
||||
{
|
||||
auto* peep = GetStaff();
|
||||
|
|
|
@ -69,6 +69,7 @@ namespace OpenRCT2::Scripting
|
|||
void orders_set(uint8_t value);
|
||||
|
||||
const DukEnumMap<PeepActionSpriteType>& animationsByStaffType(StaffType staffType) const;
|
||||
std::vector<uint32_t> getAnimationSpriteIds(std::string groupKey, uint8_t rotation) const;
|
||||
std::vector<std::string> availableAnimations_get() const;
|
||||
std::string animation_get() const;
|
||||
void animation_set(std::string groupKey);
|
||||
|
|
Loading…
Reference in New Issue