MCPcopy Create free account
hub / github.com/DFHack/dfhack / getOperatorUnit

Function getOperatorUnit

plugins/siege-engine.cpp:761–789  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

759}
760
761static df::unit *getOperatorUnit(df::building_siegeenginest *bld, bool force = false)
762{
763 CHECK_NULL_POINTER(bld);
764
765 auto engine = find_engine(bld);
766 if (!engine)
767 return NULL;
768
769 if (engine->operator_id != -1 &&
770 (world->frame_counter - engine->operator_frame) <= 5)
771 {
772 auto op_unit = df::unit::find(engine->operator_id);
773 if (op_unit)
774 return op_unit;
775 }
776
777 if (force)
778 {
779 color_ostream_proxy out(Core::getInstance().getConsole());
780 out.print("Forced siege operator search\n");
781
782 auto &active = world->units.active;
783 for (size_t i = 0; i < active.size(); i++)
784 if (active[i]->pos == engine->center && Units::isCitizen(active[i]))
785 return active[i];
786 }
787
788 return NULL;
789}
790
791/*
792 * Trajectory raytracing

Callers 1

doCheckMovementMethod · 0.85

Calls 4

find_engineFunction · 0.85
findFunction · 0.50
printMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected