Skip to content

Commit 1654687

Browse files
committed
rework module; add FX
1 parent dea07e6 commit 1654687

8 files changed

Lines changed: 153 additions & 78 deletions

File tree

GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,8 @@ friend class Drawable; // for selection/deselection transactions
618618
virtual void DEBUG_addFloatingText(const AsciiString& text,const Coord3D * pos, Color color);
619619
#endif
620620

621+
const SpecialPowerTemplate* getTargetDesignatorPower();
622+
621623
protected:
622624
// snapshot methods
623625
virtual void crc( Xfer *xfer );
@@ -687,8 +689,8 @@ friend class Drawable; // for selection/deselection transactions
687689
void handleBuildPlacements( void ); ///< handle updating of placement icons based on mouse pos
688690
void handleRadiusCursor(); ///< handle updating of "radius cursors" that follow the mouse pos
689691

690-
void showDesignatorDecals(const SpecialPowerTemplate* powerTemplate);
691-
void hideDesignatorDecals(void);
692+
//void showDesignatorDecals(const SpecialPowerTemplate* powerTemplate);
693+
//void hideDesignatorDecals(void);
692694

693695
void incrementSelectCount( void ) { ++m_selectCount; } ///< Increase by one the running total of "selected" drawables
694696
void decrementSelectCount( void ) { --m_selectCount; } ///< Decrease by one the running total of "selected" drawables
@@ -973,7 +975,7 @@ friend class Drawable; // for selection/deselection transactions
973975
DrawableID m_soloNexusSelectedDrawableID; ///< The drawable of the nexus, if only one angry mob is selected, otherwise, null
974976

975977
// UI Decals
976-
Bool m_showDesignatorDecals;
978+
//Bool m_showDesignatorDecals;
977979
const CommandButton* m_designatorCommand;
978980

979981

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadiusDecalBehavior.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class RadiusDecalBehavior : public UpdateModule, public UpgradeMux
116116

117117
virtual Bool isSubObjectsUpgrade() { return false; }
118118

119-
private:
120119

121120
RadiusDecal m_radiusDecal;
122121

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerDesignatorUpdate.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// FORWARD REFERENCES /////////////////////////////////////////////////////////
3737
class SpecialPowerTemplate;
3838
class Thing;
39+
class FXList;
3940

4041
//-------------------------------------------------------------------------------------------------
4142
class SpecialPowerDesignatorUpdateModuleData : public RadiusDecalBehaviorModuleData
@@ -46,6 +47,7 @@ class SpecialPowerDesignatorUpdateModuleData : public RadiusDecalBehaviorModuleD
4647
Bool m_alwaysShowDecal;
4748
ObjectStatusTypes m_triggerStatusType;
4849
UnsignedInt m_triggerStatusTime;
50+
const FXList* m_triggerFX;
4951

5052
SpecialPowerDesignatorUpdateModuleData();
5153

@@ -77,7 +79,7 @@ class SpecialPowerDesignatorUpdate : public RadiusDecalBehavior
7779

7880
Bool isValidDesignatorForSpecialPower(const SpecialPowerTemplate* templ);
7981

80-
void setActive(bool status);
82+
//void setActive(bool status);
8183

8284
void triggerSpecialPower();
8385

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ class SpecialPowerModule : public BehaviorModule,
170170
void resolveSpecialPower( void );
171171
void aboutToDoSpecialPower( const Coord3D *location );
172172

173+
void handleTargetDesignator(const Coord3D* location);
174+
173175
UnsignedInt m_availableOnFrame; ///< on this frame, this special power is available
174176
Int m_pausedCount; ///< Reference count of sources pausing me
175177
UnsignedInt m_pausedOnFrame;

GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,9 +1582,9 @@ Bool ActionManager::canDoSpecialPowerAtLocation( const Object *obj, const Coord3
15821582
PartitionFilterAlive filterAlive;
15831583
PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
15841584
PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterMapStatus, &filterKindOf, NULL };
1585-
Real max_scan_range = 2000.0f; //Should be all units on screen + margin
1585+
Real MAX_SCAN_RANGE = 5000.0f; //TODO: GlobalData?
15861586
// scan objects in our region
1587-
ObjectIterator* iter = ThePartitionManager->iterateObjectsInRange(loc, max_scan_range, FROM_CENTER_2D, filters);
1587+
ObjectIterator* iter = ThePartitionManager->iterateObjectsInRange(loc, MAX_SCAN_RANGE, FROM_CENTER_2D, filters);
15881588
Object* obj2;
15891589
MemoryPoolObjectHolder hold(iter);
15901590
for (obj2 = iter->first(); obj2; obj2 = iter->next()) {

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ InGameUI::InGameUI()
11021102

11031103
m_tooltipsDisabledUntil = 0;
11041104

1105-
m_showDesignatorDecals = FALSE;
1105+
//m_showDesignatorDecals = FALSE;
11061106
m_designatorCommand = NULL;
11071107

11081108
// init hint lists
@@ -3251,15 +3251,15 @@ void InGameUI::setGUICommand( const CommandButton *command )
32513251

32523252
// Target designator checks
32533253
if (m_designatorCommand && m_designatorCommand != m_pendingGUICommand) {
3254-
hideDesignatorDecals();
3254+
//hideDesignatorDecals();
32553255
m_designatorCommand = NULL;
32563256
}
32573257

32583258
if (command && BitIsSet(command->getOptions(), COMMAND_OPTION_NEED_TARGET)) {
32593259
const SpecialPowerTemplate* sp = command->getSpecialPowerTemplate();
32603260
if (sp != nullptr && sp->isNeedsTargetDesignator()) {
3261-
m_showDesignatorDecals = TRUE;
3262-
showDesignatorDecals(command->getSpecialPowerTemplate());
3261+
/* m_showDesignatorDecals = TRUE;
3262+
showDesignatorDecals(command->getSpecialPowerTemplate());*/
32633263
m_designatorCommand = command;
32643264
}
32653265
}
@@ -6495,47 +6495,57 @@ void InGameUI::drawPlayerInfoList()
64956495

64966496

64976497
// -------------
6498-
void InGameUI::showDesignatorDecals(const SpecialPowerTemplate* powerTemplate) {
6499-
6500-
static NameKeyType key_SpecialPowerDesignatorUpdate = NAMEKEY("SpecialPowerDesignatorUpdate");
6501-
6502-
PartitionFilterSamePlayer filterPlayer(ThePlayerList->getLocalPlayer());
6503-
PartitionFilterAlive filterAlive;
6504-
PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
6505-
PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterKindOf, NULL };
6506-
// scan objects on entire map
6507-
ObjectIterator* iter = ThePartitionManager->iterateAllObjects(filters);
6508-
Object* obj;
6509-
MemoryPoolObjectHolder hold(iter);
6510-
for (obj = iter->first(); obj; obj = iter->next()) {
6511-
6512-
SpecialPowerDesignatorUpdate* update = (SpecialPowerDesignatorUpdate*)obj->findUpdateModule(key_SpecialPowerDesignatorUpdate);
6513-
if (update) {
6514-
if (update->isValidDesignatorForSpecialPower(powerTemplate)) {
6515-
update->setActive(true);
6516-
}
6517-
}
6518-
}
6519-
}
6520-
6521-
void InGameUI::hideDesignatorDecals() { //const SpecialPowerTemplate *powerTemplate) {
6522-
//ThePlayerList->getLocalPlayer()->iterateObjects( hideDesignatorDecal, &powerTemplate );
6523-
6524-
static NameKeyType key_SpecialPowerDesignatorUpdate = NAMEKEY("SpecialPowerDesignatorUpdate");
6525-
6526-
PartitionFilterSamePlayer filterPlayer(ThePlayerList->getLocalPlayer());
6527-
PartitionFilterAlive filterAlive;
6528-
PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
6529-
PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterKindOf, NULL };
6530-
// scan objects on entire map
6531-
ObjectIterator* iter = ThePartitionManager->iterateAllObjects(filters);
6532-
Object* obj;
6533-
MemoryPoolObjectHolder hold(iter);
6534-
for (obj = iter->first(); obj; obj = iter->next()) {
6498+
// -------------
6499+
const SpecialPowerTemplate* InGameUI::getTargetDesignatorPower()
6500+
{
6501+
if (m_designatorCommand != nullptr)
6502+
return m_designatorCommand->getSpecialPowerTemplate();
65356503

6536-
SpecialPowerDesignatorUpdate* update = (SpecialPowerDesignatorUpdate*)obj->findUpdateModule(key_SpecialPowerDesignatorUpdate);
6537-
if (update) {
6538-
update->setActive(false);
6539-
}
6540-
}
6504+
return nullptr;
65416505
}
6506+
// -------------
6507+
// -------------
6508+
//void InGameUI::showDesignatorDecals(const SpecialPowerTemplate* powerTemplate) {
6509+
//
6510+
// static NameKeyType key_SpecialPowerDesignatorUpdate = NAMEKEY("SpecialPowerDesignatorUpdate");
6511+
//
6512+
// PartitionFilterSamePlayer filterPlayer(ThePlayerList->getLocalPlayer());
6513+
// PartitionFilterAlive filterAlive;
6514+
// PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
6515+
// PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterKindOf, NULL };
6516+
// // scan objects on entire map
6517+
// ObjectIterator* iter = ThePartitionManager->iterateAllObjects(filters);
6518+
// Object* obj;
6519+
// MemoryPoolObjectHolder hold(iter);
6520+
// for (obj = iter->first(); obj; obj = iter->next()) {
6521+
//
6522+
// SpecialPowerDesignatorUpdate* update = (SpecialPowerDesignatorUpdate*)obj->findUpdateModule(key_SpecialPowerDesignatorUpdate);
6523+
// if (update) {
6524+
// if (update->isValidDesignatorForSpecialPower(powerTemplate)) {
6525+
// update->setActive(true);
6526+
// }
6527+
// }
6528+
// }
6529+
//}
6530+
//
6531+
//void InGameUI::hideDesignatorDecals() { //const SpecialPowerTemplate *powerTemplate) {
6532+
// //ThePlayerList->getLocalPlayer()->iterateObjects( hideDesignatorDecal, &powerTemplate );
6533+
//
6534+
// static NameKeyType key_SpecialPowerDesignatorUpdate = NAMEKEY("SpecialPowerDesignatorUpdate");
6535+
//
6536+
// PartitionFilterSamePlayer filterPlayer(ThePlayerList->getLocalPlayer());
6537+
// PartitionFilterAlive filterAlive;
6538+
// PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
6539+
// PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterKindOf, NULL };
6540+
// // scan objects on entire map
6541+
// ObjectIterator* iter = ThePartitionManager->iterateAllObjects(filters);
6542+
// Object* obj;
6543+
// MemoryPoolObjectHolder hold(iter);
6544+
// for (obj = iter->first(); obj; obj = iter->next()) {
6545+
//
6546+
// SpecialPowerDesignatorUpdate* update = (SpecialPowerDesignatorUpdate*)obj->findUpdateModule(key_SpecialPowerDesignatorUpdate);
6547+
// if (update) {
6548+
// update->setActive(false);
6549+
// }
6550+
// }
6551+
//}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@
4848
#include "GameLogic/Module/UpdateModule.h"
4949
#include "GameLogic/Module/SpecialPowerModule.h"
5050
#include "GameLogic/Module/SpecialPowerUpdateModule.h"
51+
#include "GameLogic/Module/SpecialPowerDesignatorUpdate.h"
5152
#include "GameLogic/ScriptEngine.h"
53+
#include "GameLogic/PartitionManager.h"
5254

5355
#include "GameClient/Eva.h"
5456
#include "GameClient/InGameUI.h"
@@ -500,6 +502,8 @@ void SpecialPowerModule::triggerSpecialPower( const Coord3D *location )
500502

501503
aboutToDoSpecialPower( location ); // do BEFORE recharge
502504

505+
handleTargetDesignator(location);
506+
503507
createViewObject(location);
504508

505509
// we won't be able to use the power for X number of frames now
@@ -553,7 +557,6 @@ void SpecialPowerModule::markSpecialPowerTriggered( const Coord3D *location )
553557
triggerSpecialPower( location );
554558
}
555559

556-
557560
//-------------------------------------------------------------------------------------------------
558561
//-------------------------------------------------------------------------------------------------
559562
void SpecialPowerModule::aboutToDoSpecialPower( const Coord3D *location )
@@ -948,6 +951,58 @@ UnsignedInt SpecialPowerModule::getReadyFrame( void ) const
948951
}
949952
}
950953

954+
//-------------------------------------------------------------------------------------------------
955+
//-------------------------------------------------------------------------------------------------
956+
void SpecialPowerModule::handleTargetDesignator(const Coord3D* loc)
957+
{
958+
const SpecialPowerModuleData* data = getSpecialPowerModuleData();
959+
if (!data->m_specialPowerTemplate->isNeedsTargetDesignator())
960+
return;
961+
962+
// Get closest Target designator object
963+
static NameKeyType key_SpecialPowerDesignatorUpdate = NAMEKEY("SpecialPowerDesignatorUpdate");
964+
965+
//Iterate over all object and find this module!
966+
Object* obj = getObject();
967+
968+
//PartitionFilterRelationship relationship( obj, PartitionFilterRelationship::ALLOW_ALLIES );
969+
PartitionFilterSamePlayer filterPlayer(obj->getControllingPlayer());
970+
PartitionFilterSameMapStatus filterMapStatus(obj);
971+
PartitionFilterAlive filterAlive;
972+
PartitionFilterAcceptByKindOf filterKindOf(MAKE_KINDOF_MASK(KINDOF_TARGET_DESIGNATOR), KINDOFMASK_NONE);
973+
PartitionFilter* filters[] = { &filterPlayer, &filterAlive, &filterMapStatus, &filterKindOf, NULL };
974+
Real MAX_SCAN_RANGE = 5000.0f; //TODO: GlobalData?
975+
// scan objects in our region
976+
ObjectIterator* iter = ThePartitionManager->iterateObjectsInRange(loc, MAX_SCAN_RANGE, FROM_CENTER_2D, filters);
977+
Object* obj2;
978+
//Object* closestObj = nullptr;
979+
SpecialPowerDesignatorUpdate* closestObjUpdate = nullptr;
980+
MemoryPoolObjectHolder hold(iter);
981+
Real minDistSqr = INFINITY;
982+
for (obj2 = iter->first(); obj2; obj2 = iter->next()) {
983+
984+
SpecialPowerDesignatorUpdate* update = (SpecialPowerDesignatorUpdate*)obj2->findUpdateModule(key_SpecialPowerDesignatorUpdate);
985+
if (update) {
986+
if (update->isValidDesignatorForSpecialPower(data->m_specialPowerTemplate)) {
987+
988+
Real distSqr = ThePartitionManager->getDistanceSquared(obj2, loc, FROM_CENTER_2D);
989+
Real radius = update->getDesignatorRadius();
990+
if (distSqr <= (radius * radius) && minDistSqr) {
991+
if (distSqr < minDistSqr) {
992+
//closestObj = obj2;
993+
closestObjUpdate = update;
994+
minDistSqr = distSqr;
995+
}
996+
}
997+
}
998+
}
999+
}
1000+
if (closestObjUpdate != nullptr)
1001+
closestObjUpdate->triggerSpecialPower();
1002+
1003+
}
1004+
1005+
9511006
// ------------------------------------------------------------------------------------------------
9521007
/** CRC */
9531008
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)