gwnavgamekit/gamekitcrowddispersiontraverselogic.h Source File

gamekitcrowddispersiontraverselogic.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
10 
14 
15 namespace Kaim
16 {
17 
18 class Bot;
19 class DisplayList;
20 class PositionOnLivePath;
21 
24 {
28 };
29 
30 class GameKitCrowdDispersionTraverseLogicData : public RefCountBase<GameKitCrowdDispersionTraverseLogicData, MemStat_GameKit>
31 {
32 public:
35  GameKitCrowdDispersionTraverseLogicData(GameKitCrowdDispersionNavTagHashMap* crowdDispersionHashMap, KyFloat32 alternativePathCheckDistance, KyFloat32 consideredUsedDistance);
36  ~GameKitCrowdDispersionTraverseLogicData();
37 
38  void SendVisualDebug(DisplayList& displayList);
39 
41 
42  // Following functions are expected to be called from the logic of the game Bot
43  // An example of these functions is made by CrowdDispersionBot::UpdateLogic() in Tutorial_GameKit.cpp
44 
45  // Globally update the Data, it _must_ be called each frame!
46  GameKitCrowdDispersionLogicAction UpdateBotLogic(Bot* navBot);
47 
48  // Must be called before recomputing a Path to the same destination, typically when UpdateBotLogic returns GameKitCrowdDispersionLogic_RecomputePath,
49  // 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
50  void OnBotLogicRecomputePathToSimilarDestination() { UnregisterFromApproachingNavTag(); }
51 
52  // Must be called before recomputing a Path to a new destination, typically when a new Target is selected by your own Bot logic.
53  void OnBotLogicComputePathToBrandNewDestination() { Clear(); }
54 
55 
56 private:
57  class ApproachingNavTagInfo
58  {
59  public:
60  ApproachingNavTagInfo(const GameKitCrowdDispersionNavTagId& navTagId = GameKitCrowdDispersionNavTagId(), KyFloat32 squareDistance2d = 0.0f);
61 
62  public:
63  GameKitCrowdDispersionNavTagId m_navTagId;
64  KyFloat32 m_squareDistance2d;
65  };
66 
67  ApproachingNavTagInfo GetApproachingNavTagID(const PositionOnLivePath& progressOnLivePath);
68 
69  KyResult RegisterToApproachingNavTag(const GameKitCrowdDispersionNavTagId& navTagID);
70 
71  void UseApproachingNavTag();
72 
73  void UnregisterFromApproachingNavTag();
74 
75  bool WasNavTagIdDiscarded(const GameKitCrowdDispersionNavTagId& navTagID);
76 
77  void Clear();
78 
79 public:
80  bool m_triggerAvoidance;
81  Ptr<GameKitCrowdDispersionNavTagHashMap> m_crowdDispersionNavTagMap;
82  KyFloat32 m_alternativePathCheckDistance;
83  KyFloat32 m_consideredUsedDistance;
84  GameKitCrowdDispersionInput m_input;
85  GameKitCrowdDispersionInput m_registeredApproachingInput;
86  GameKitCrowdDispersionNavTagId m_approachingNavTagID;
87  bool m_isUsingApproachingNavTagID;
88  KyArray<GameKitCrowdDispersionNavTagId> m_discardedNavTagIDs;
89 
90 };
91 
92 
93 
94 class GameKitCrowdDispersionTraverseLogic : public TraverseLogicWithCostPerNavTag<LogicDoNotUseCanEnterNavTag>
95 {
96 public:
97  static KyFloat32 GetHeuristicFromDistanceToDest(void* traverseLogicUserData, KyFloat32 distance3DToDestination);
98 
99  static bool CanTraverseNavTag(void* traverseLogicUserData, const NavTag& navTag, KyFloat32* costMultiplier);
100 
101 };
102 
103 
104 }
105 
No action has to be taken.
Definition: gamekitcrowddispersiontraverselogic.h:25
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
GameKitCrowdDispersionLogicAction
GameKitCrowdDispersionLogicAction.
Definition: gamekitcrowddispersiontraverselogic.h:23
A path must be recomputed in order to find an alternative.
Definition: gamekitcrowddispersiontraverselogic.h:26
If a path is being computed due to GameKitCrowdDispersionLogic_RecomputePath, it should be cancelled ...
Definition: gamekitcrowddispersiontraverselogic.h:27
float KyFloat32
float
Definition: types.h:32