Skip to content
Snippets Groups Projects
Commit 321c3be0 authored by Rojikku98's avatar Rojikku98
Browse files

Added OnUnitDestroyed and OnUnitCreated

parent e132326a
No related branches found
No related tags found
1 merge request!6Replays
...@@ -102,6 +102,8 @@ PYBIND11_MODULE(library, m) ...@@ -102,6 +102,8 @@ PYBIND11_MODULE(library, m)
.def("get_player_race", &IDAReplayObserver::GetPlayerRace,"player_id"_a) .def("get_player_race", &IDAReplayObserver::GetPlayerRace,"player_id"_a)
.def("get_replay_path", &IDAReplayObserver::GetReplayPath) .def("get_replay_path", &IDAReplayObserver::GetReplayPath)
.def("get_result_for_player", &IDAReplayObserver::GetResultForPlayer, "player_id"_a) .def("get_result_for_player", &IDAReplayObserver::GetResultForPlayer, "player_id"_a)
.def("on_unit_destroyed", &IDAReplayObserver::OnReplayUnitDestroyed, "unit"_a)
.def("on_unit_created", &IDAReplayObserver::OnReplayUnitCreated, "unit"_a)
; ;
......
...@@ -95,6 +95,27 @@ public: ...@@ -95,6 +95,27 @@ public:
); );
} }
void OnReplayUnitDestroyed(const ReplayUnit *unit) override
{
PYBIND11_OVERLOAD_NAME(
void,
IDAReplayObserver,
"on_unit_destroyed",
OnReplayUnitDestroyed,
unit
);
}
void OnReplayUnitCreated(const ReplayUnit *unit) override
{
PYBIND11_OVERLOAD_NAME(
void,
IDAReplayObserver,
"on_unit_created",
OnReplayUnitCreated,
unit
);
}
}; };
// The functions below are all defined in different .cpp files, in order // The functions below are all defined in different .cpp files, in order
......
#include "IDAReplayObserver.h" #include "IDAReplayObserver.h"
#include "Util.h" #include "Util.h"
#include <pybind11/pybind11.h>
void IDAReplayObserver::setUnits() void IDAReplayObserver::setUnits()
{ {
...@@ -32,13 +34,33 @@ void IDAReplayObserver::OnGameEnd() ...@@ -32,13 +34,33 @@ void IDAReplayObserver::OnGameEnd()
void IDAReplayObserver::OnUnitDestroyed(const sc2::Unit* unit) void IDAReplayObserver::OnUnitDestroyed(const sc2::Unit* unit)
{ {
ReplayUnit unitInformation = ReplayUnit(unit, *this); ReplayUnit unitInformation = ReplayUnit(unit, *this);
OnUnitInfomationDestroyed(&unitInformation); OnReplayUnitDestroyed(&unitInformation);
} }
void IDAReplayObserver::OnUnitInfomationDestroyed(const ReplayUnit *) void IDAReplayObserver::OnReplayUnitDestroyed(const ReplayUnit *)
{ {
} }
void IDAReplayObserver::OnUnitCreated(const sc2::Unit * unit)
{
ReplayUnit unitInformation = ReplayUnit(unit, *this);
std::cout << "OnUnitCreated" << std::endl;
OnReplayUnitCreated(&unitInformation);
}
void IDAReplayObserver::OnReplayUnitCreated(const ReplayUnit *)
{
}
void IDAReplayObserver::OnBuildingConstructionComplete(const sc2::Unit *unit)
{
ReplayUnit unitInformation = ReplayUnit(unit, *this);
std::cout << "OnBuildingConstructionComplete" << std::endl;
OnReplayUnitCreated(&unitInformation);
}
ReplayUnit IDAReplayObserver::GetUnit(const CCUnitID tag) const ReplayUnit IDAReplayObserver::GetUnit(const CCUnitID tag) const
......
...@@ -20,7 +20,10 @@ public: ...@@ -20,7 +20,10 @@ public:
void OnStep() override; void OnStep() override;
void OnGameEnd() override; void OnGameEnd() override;
void OnUnitDestroyed(const sc2::Unit*) override; void OnUnitDestroyed(const sc2::Unit*) override;
void OnUnitInfomationDestroyed(const ReplayUnit*); virtual void OnReplayUnitDestroyed(const ReplayUnit*);
void OnUnitCreated(const sc2::Unit*);
virtual void OnReplayUnitCreated(const ReplayUnit*);
void OnBuildingConstructionComplete(const sc2::Unit*);
ReplayUnit GetUnit(const CCUnitID tag) const; ReplayUnit GetUnit(const CCUnitID tag) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment