gwnavgamekit/gamekitcrowddispersiontraverselogic.h Source File

gamekitcrowddispersiontraverselogic.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 
9 #ifndef Navigation_GameKitCrowdDispersionTraverseLogic_H
10 #define Navigation_GameKitCrowdDispersionTraverseLogic_H
11 
12 
14 
18 
19 
20 
21 namespace Kaim
22 {
23 
24 class Bot;
25 class ScopedDisplayList;
26 class PositionOnLivePath;
27 
29 {
33 };
34 
35 class GameKitCrowdDispersionTraverseLogicData : public RefCountBase<GameKitCrowdDispersionTraverseLogicData, MemStat_GameKit>
36 {
37 public:
40  GameKitCrowdDispersionTraverseLogicData(GameKitCrowdDispersionNavTagHashMap* crowdDispersionHashMap, KyFloat32 alternativePathCheckDistance, KyFloat32 consideredUsedDistance);
41  ~GameKitCrowdDispersionTraverseLogicData();
42 
43  void SendVisualDebug(ScopedDisplayList& displayList);
44 
46  // Following functions are expected to be called from the logic of the game Bot
47  // An example of these functions is made by CrowdDispersionBot::UpdateLogic() in Tutorial_GameKit.cpp
48 
49  // Globally update the Data, it _must_ be called each frame!
50  GameKitCrowdDispersionLogicAction UpdateBotLogic(Bot* navBot);
51 
52  // Must be called before recomputing a Path to the same destination, typically when UpdateBotLogic returns GameKitCrowdDispersionLogic_RecomputePath,
53  // or if a followed target moved only slightly so that a new path should continue to consider the choice made so far in terms of dispersion
54  void OnBotLogicRecomputePathToSimilarDestination() { UnregisterFromApproachingNavTag(); }
55 
56  // Must be called before recomputing a Path to a new destination, typically when a new Target is selected by your own Bot logic.
57  void OnBotLogicComputePathToBrandNewDestination() { Clear(); }
58 
59 
60 private:
61  class ApproachingNavTagInfo
62  {
63  public:
64  ApproachingNavTagInfo(const GameKitCrowdDispersionNavTagId& navTagId = GameKitCrowdDispersionNavTagId(), KyFloat32 squareDistance2d = 0.0f);
65 
66  public:
67  GameKitCrowdDispersionNavTagId m_navTagId;
68  KyFloat32 m_squareDistance2d;
69  };
70 
71  ApproachingNavTagInfo GetApproachingNavTagID(const PositionOnLivePath& progressOnLivePath);
72 
73  KyResult RegisterToApproachingNavTag(const GameKitCrowdDispersionNavTagId& navTagID);
74 
75  void UseApproachingNavTag();
76 
77  void UnregisterFromApproachingNavTag();
78 
79  bool WasNavTagIdDiscarded(const GameKitCrowdDispersionNavTagId& navTagID);
80 
81  void Clear();
82 
83 public:
84  bool m_triggerAvoidance;
85  Ptr<GameKitCrowdDispersionNavTagHashMap> m_crowdDispersionNavTagMap;
86  KyFloat32 m_alternativePathCheckDistance;
87  KyFloat32 m_consideredUsedDistance;
88  GameKitCrowdDispersionInput m_input;
89  GameKitCrowdDispersionInput m_registeredApproachingInput;
90  GameKitCrowdDispersionNavTagId m_approachingNavTagID;
91  bool m_isUsingApproachingNavTagID;
92  KyArray<GameKitCrowdDispersionNavTagId> m_discardedNavTagIDs;
93 
94 };
95 
96 
97 
98 class GameKitCrowdDispersionTraverseLogic : public TraverseLogicWithCostMultiplerPerNavTag<LogicDoNotUseCanEnterNavTag>
99 {
100 public:
101  static KyFloat32 GetHeuristicFromDistanceToDest(void* traverseLogicUserData, KyFloat32 distance3DToDestination);
102 
103  static bool CanTraverseNavTag(void* traverseLogicUserData, const NavTag& navTag, KyFloat32* costMultiplier);
104 
105 };
106 
107 
108 }
109 
110 #endif
No action has to be taken.
Definition: gamekitcrowddispersiontraverselogic.h:30
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Definition: gamekitcrowddispersion.h:20
GameKitCrowdDispersionLogicAction
Definition: gamekitcrowddispersiontraverselogic.h:28
A path must be recomputed in order to find an alternative.
Definition: gamekitcrowddispersiontraverselogic.h:31
If a path is being computed due to GameKitCrowdDispersionLogic_RecomputePath, it should be cancelled ...
Definition: gamekitcrowddispersiontraverselogic.h:32
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43