MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / drawRoutine4

Method drawRoutine4

src/Battlescape/UnitSprite.cpp:759–863  ·  view source on GitHub ↗

* Drawing routine for civilians and ethereals. * Very easy: first 8 is standing positions, then 8 walking sequences of 8, finally death sequence of 3 */

Source from the content-addressed store, hash-verified

757 * Very easy: first 8 is standing positions, then 8 walking sequences of 8, finally death sequence of 3
758 */
759void UnitSprite::drawRoutine4()
760{
761 if (_unit->isOut())
762 {
763 // unit is drawn as an item
764 return;
765 }
766
767 Surface *s = 0, *itemA = 0, *itemB = 0;
768 const int stand = 0, walk = 8, die = 72;
769 const int offX[8] = { 8, 10, 7, 4, -9, -11, -7, -3 }; // for the weapons
770 const int offY[8] = { -6, -3, 0, 2, 0, -4, -7, -9 }; // for the weapons
771 const int offX2[8] = { -8, 3, 5, 12, 6, -1, -5, -13 }; // for the weapons
772 const int offY2[8] = { 1, -4, -2, 0, 3, 3, 5, 0 }; // for the weapons
773 const int offX3[8] = { 0, 6, 6, 12, -4, -5, -5, -13 }; // for the left handed rifles
774 const int offY3[8] = { -4, -4, -1, 0, 5, 0, 1, 0 }; // for the left handed rifles
775
776 if (_unit->isOut())
777 {
778 // unit is drawn as an item
779 return;
780 }
781
782 const int unitDir = _unit->getDirection();
783
784 if (_unit->getStatus() == STATUS_COLLAPSING)
785 {
786 s = _unitSurface->getFrame(die + _unit->getFallingPhase());
787 s->blit(this);
788 return;
789 }
790 else if (_unit->getStatus() == STATUS_WALKING)
791 {
792 s = _unitSurface->getFrame(walk + (8 * unitDir) + _unit->getWalkingPhase());
793 }
794 else
795 {
796 s = _unitSurface->getFrame(stand + unitDir);
797 }
798
799 sortRifles();
800
801 if(_itemA && !_itemA->getRules()->isFixed())
802 {
803 // draw handob item
804 if (_unit->getStatus() == STATUS_AIMING && _itemA->getRules()->isTwoHanded())
805 {
806 int dir = (unitDir + 2)%8;
807 itemA = _itemSurfaceA->getFrame(_itemA->getRules()->getHandSprite() + dir);
808 itemA->setX(offX[unitDir]);
809 itemA->setY(offY[unitDir]);
810 }
811 else
812 {
813 if(_itemA->getSlot()->getId() == "STR_RIGHT_HAND")
814 {
815 itemA = _itemSurfaceA->getFrame(_itemA->getRules()->getHandSprite() + unitDir);
816 itemA->setX(0);

Callers

nothing calls this directly

Calls 15

isOutMethod · 0.80
getFrameMethod · 0.80
getFallingPhaseMethod · 0.80
getWalkingPhaseMethod · 0.80
isFixedMethod · 0.80
isTwoHandedMethod · 0.80
getHandSpriteMethod · 0.80
getDirectionMethod · 0.45
getStatusMethod · 0.45
blitMethod · 0.45
getRulesMethod · 0.45
setXMethod · 0.45

Tested by

no test coverage detected