mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add getWalkingSpriteIds method
This commit is contained in:
parent
2232ce5ff8
commit
8b310ae5e0
|
@ -2648,6 +2648,11 @@ 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 =
|
||||
|
|
|
@ -1020,6 +1020,7 @@
|
|||
<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" />
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
/*****************************************************************************
|
||||
* 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,6 +61,7 @@ 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:
|
||||
|
@ -115,6 +116,8 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<uint32_t> getWalkingSpriteIds() const;
|
||||
|
||||
DukValue destination_get() const
|
||||
{
|
||||
auto ctx = GetContext()->GetScriptEngine().GetContext();
|
||||
|
|
Loading…
Reference in New Issue