mirror of https://github.com/OpenRCT2/OpenRCT2.git
Move ScLitter to its own files
This commit is contained in:
parent
2e951877cb
commit
371bbc0675
|
@ -779,6 +779,8 @@
|
|||
D7B575F07C4D4E42887C72AA /* ScPeep.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */; };
|
||||
7A06F880718F49CA9FB71F52 /* ScStaff.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */; };
|
||||
9DF65BAE250C4307AE5794DB /* ScStaff.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C30AB6C640464647ABE90EC4 /* ScStaff.hpp */; };
|
||||
8E6484F6C43644F4B644D361 /* ScLitter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 36C67B84754D4FEFA3678AA9 /* ScLitter.cpp */; };
|
||||
359328A3A65D49578912CA40 /* ScLitter.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C30388F4F6D34DF59EF7072C /* ScLitter.hpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
|
@ -1860,6 +1862,8 @@
|
|||
2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScPeep.hpp; path = src/openrct2/scripting/bindings/entity/ScPeep.hpp; sourceTree = SOURCE_ROOT; };
|
||||
3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScStaff.cpp; path = src/openrct2/scripting/bindings/entity/ScStaff.cpp; sourceTree = SOURCE_ROOT; };
|
||||
C30AB6C640464647ABE90EC4 /* ScStaff.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScStaff.hpp; path = src/openrct2/scripting/bindings/entity/ScStaff.hpp; sourceTree = SOURCE_ROOT; };
|
||||
36C67B84754D4FEFA3678AA9 /* ScLitter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScLitter.cpp; path = src/openrct2/scripting/bindings/entity/ScLitter.cpp; sourceTree = SOURCE_ROOT; };
|
||||
C30388F4F6D34DF59EF7072C /* ScLitter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ScLitter.hpp; path = src/openrct2/scripting/bindings/entity/ScLitter.hpp; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
@ -3380,6 +3384,8 @@
|
|||
2B63F2F751A3427C9CE9B214 /* ScPeep.hpp */,
|
||||
3EFAF58A62B44C4B887559B7 /* ScStaff.cpp */,
|
||||
C30AB6C640464647ABE90EC4 /* ScStaff.hpp */,
|
||||
36C67B84754D4FEFA3678AA9 /* ScLitter.cpp */,
|
||||
C30388F4F6D34DF59EF7072C /* ScLitter.hpp */,
|
||||
);
|
||||
name = entity;
|
||||
sourceTree = "<group>";
|
||||
|
@ -3581,6 +3587,7 @@
|
|||
428B1DADD66C4829894AD0A1 /* ScGuest.hpp in Headers */,
|
||||
D7B575F07C4D4E42887C72AA /* ScPeep.hpp in Headers */,
|
||||
9DF65BAE250C4307AE5794DB /* ScStaff.hpp in Headers */,
|
||||
359328A3A65D49578912CA40 /* ScLitter.hpp in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -4389,6 +4396,7 @@
|
|||
73FB2E7C254144D9BAE4925A /* ScVehicle.cpp in Sources */,
|
||||
BC39D70B9A2249E4B14E99FA /* ScGuest.cpp in Sources */,
|
||||
7A06F880718F49CA9FB71F52 /* ScStaff.cpp in Sources */,
|
||||
8E6484F6C43644F4B644D361 /* ScLitter.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -406,6 +406,7 @@
|
|||
<ClInclude Include="scenario\ScenarioRepository.h" />
|
||||
<ClInclude Include="scenario\ScenarioSources.h" />
|
||||
<ClInclude Include="scripting\bindings\entity\ScGuest.hpp" />
|
||||
<ClInclude Include="scripting\bindings\entity\ScLitter.hpp" />
|
||||
<ClInclude Include="scripting\bindings\entity\ScPeep.hpp" />
|
||||
<ClInclude Include="scripting\bindings\entity\ScStaff.hpp" />
|
||||
<ClInclude Include="scripting\bindings\entity\ScVehicle.hpp" />
|
||||
|
@ -854,6 +855,7 @@
|
|||
<ClCompile Include="scenario\ScenarioRepository.cpp" />
|
||||
<ClCompile Include="scenario\ScenarioSources.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScGuest.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScLitter.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScStaff.cpp" />
|
||||
<ClCompile Include="scripting\bindings\entity\ScVehicle.cpp" />
|
||||
<ClCompile Include="scripting\HookEngine.cpp" />
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
# include "Duktape.hpp"
|
||||
# include "bindings/entity/ScEntity.hpp"
|
||||
# include "bindings/entity/ScGuest.hpp"
|
||||
# include "bindings/entity/ScLitter.hpp"
|
||||
# include "bindings/entity/ScPeep.hpp"
|
||||
# include "bindings/entity/ScStaff.hpp"
|
||||
# include "bindings/game/ScCheats.hpp"
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
# include "../../../Context.h"
|
||||
# include "../../../common.h"
|
||||
# include "../../../peep/Peep.h"
|
||||
# include "../../../peep/Staff.h"
|
||||
# include "../../../util/Util.h"
|
||||
# include "../../../world/EntityList.h"
|
||||
# include "../../../world/Litter.h"
|
||||
# include "../../../world/Sprite.h"
|
||||
# include "../../Duktape.hpp"
|
||||
# include "../../ScriptEngine.h"
|
||||
# include "../ride/ScRide.hpp"
|
||||
|
||||
# include <algorithm>
|
||||
# include <string_view>
|
||||
|
@ -210,71 +207,6 @@ namespace OpenRCT2::Scripting
|
|||
}
|
||||
};
|
||||
|
||||
static const DukEnumMap<Litter::Type> LitterTypeMap({
|
||||
{ "vomit", Litter::Type::Vomit },
|
||||
{ "vomit_alt", Litter::Type::VomitAlt },
|
||||
{ "empty_can", Litter::Type::EmptyCan },
|
||||
{ "rubbish", Litter::Type::Rubbish },
|
||||
{ "burger_box", Litter::Type::BurgerBox },
|
||||
{ "empty_cup", Litter::Type::EmptyCup },
|
||||
{ "empty_box", Litter::Type::EmptyBox },
|
||||
{ "empty_bottle", Litter::Type::EmptyBottle },
|
||||
{ "empty_bowl_red", Litter::Type::EmptyBowlRed },
|
||||
{ "empty_drink_carton", Litter::Type::EmptyDrinkCarton },
|
||||
{ "empty_juice_cup", Litter::Type::EmptyJuiceCup },
|
||||
{ "empty_bowl_blue", Litter::Type::EmptyBowlBlue },
|
||||
});
|
||||
|
||||
class ScLitter : public ScEntity
|
||||
{
|
||||
public:
|
||||
ScLitter(uint16_t Id)
|
||||
: ScEntity(Id)
|
||||
{
|
||||
}
|
||||
|
||||
static void Register(duk_context* ctx)
|
||||
{
|
||||
dukglue_set_base_class<ScEntity, ScLitter>(ctx);
|
||||
dukglue_register_property(ctx, &ScLitter::litterType_get, &ScLitter::litterType_set, "litterType");
|
||||
dukglue_register_property(ctx, &ScLitter::creationTick_get, nullptr, "creationTick");
|
||||
}
|
||||
|
||||
private:
|
||||
Litter* GetLitter() const
|
||||
{
|
||||
return ::GetEntity<Litter>(_id);
|
||||
}
|
||||
|
||||
std::string litterType_get() const
|
||||
{
|
||||
auto* litter = GetLitter();
|
||||
auto it = LitterTypeMap.find(litter->SubType);
|
||||
if (it == LitterTypeMap.end())
|
||||
return "";
|
||||
return std::string{ it->first };
|
||||
}
|
||||
|
||||
void litterType_set(const std::string& litterType)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
|
||||
auto it = LitterTypeMap.find(litterType);
|
||||
if (it == LitterTypeMap.end())
|
||||
return;
|
||||
auto* litter = GetLitter();
|
||||
litter->SubType = it->second;
|
||||
}
|
||||
|
||||
uint32_t creationTick_get() const
|
||||
{
|
||||
auto* litter = GetLitter();
|
||||
if (litter == nullptr)
|
||||
return 0;
|
||||
return litter->creationTick;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2021 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "ScLitter.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
static const DukEnumMap<Litter::Type> LitterTypeMap({
|
||||
{ "vomit", Litter::Type::Vomit },
|
||||
{ "vomit_alt", Litter::Type::VomitAlt },
|
||||
{ "empty_can", Litter::Type::EmptyCan },
|
||||
{ "rubbish", Litter::Type::Rubbish },
|
||||
{ "burger_box", Litter::Type::BurgerBox },
|
||||
{ "empty_cup", Litter::Type::EmptyCup },
|
||||
{ "empty_box", Litter::Type::EmptyBox },
|
||||
{ "empty_bottle", Litter::Type::EmptyBottle },
|
||||
{ "empty_bowl_red", Litter::Type::EmptyBowlRed },
|
||||
{ "empty_drink_carton", Litter::Type::EmptyDrinkCarton },
|
||||
{ "empty_juice_cup", Litter::Type::EmptyJuiceCup },
|
||||
{ "empty_bowl_blue", Litter::Type::EmptyBowlBlue },
|
||||
});
|
||||
|
||||
ScLitter::ScLitter(uint16_t Id)
|
||||
: ScEntity(Id)
|
||||
{
|
||||
}
|
||||
|
||||
void ScLitter::Register(duk_context* ctx)
|
||||
{
|
||||
dukglue_set_base_class<ScEntity, ScLitter>(ctx);
|
||||
dukglue_register_property(ctx, &ScLitter::litterType_get, &ScLitter::litterType_set, "litterType");
|
||||
dukglue_register_property(ctx, &ScLitter::creationTick_get, nullptr, "creationTick");
|
||||
}
|
||||
|
||||
Litter* ScLitter::GetLitter() const
|
||||
{
|
||||
return ::GetEntity<Litter>(_id);
|
||||
}
|
||||
|
||||
std::string ScLitter::litterType_get() const
|
||||
{
|
||||
auto* litter = GetLitter();
|
||||
auto it = LitterTypeMap.find(litter->SubType);
|
||||
if (it == LitterTypeMap.end())
|
||||
return "";
|
||||
return std::string{ it->first };
|
||||
}
|
||||
|
||||
void ScLitter::litterType_set(const std::string& litterType)
|
||||
{
|
||||
ThrowIfGameStateNotMutable();
|
||||
|
||||
auto it = LitterTypeMap.find(litterType);
|
||||
if (it == LitterTypeMap.end())
|
||||
return;
|
||||
auto* litter = GetLitter();
|
||||
litter->SubType = it->second;
|
||||
}
|
||||
|
||||
uint32_t ScLitter::creationTick_get() const
|
||||
{
|
||||
auto* litter = GetLitter();
|
||||
if (litter == nullptr)
|
||||
return 0;
|
||||
return litter->creationTick;
|
||||
}
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
|
@ -0,0 +1,36 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2021 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.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef ENABLE_SCRIPTING
|
||||
|
||||
# include "ScEntity.hpp"
|
||||
|
||||
namespace OpenRCT2::Scripting
|
||||
{
|
||||
class ScLitter : public ScEntity
|
||||
{
|
||||
public:
|
||||
ScLitter(uint16_t Id);
|
||||
|
||||
static void Register(duk_context* ctx);
|
||||
|
||||
private:
|
||||
Litter* GetLitter() const;
|
||||
|
||||
std::string litterType_get() const;
|
||||
void litterType_set(const std::string& litterType);
|
||||
|
||||
uint32_t creationTick_get() const;
|
||||
};
|
||||
|
||||
} // namespace OpenRCT2::Scripting
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue