Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 |
//============================================================================= // NavigationPoint. // // NavigationPoints are organized into a network to provide AIControllers // the capability of determining paths to arbitrary destinations in a level // // Copyright 1998-2011 Epic Games, Inc. All Rights Reserved. //============================================================================= class NavigationPoint extends Actor hidecategories(Lighting,LightColor,Force) dependson(ReachSpec) ClassGroup(Navigation) native; const INFINITE_PATH_COST = 10000000; //------------------------------------------------------------------------------ // NavigationPoint variables var transient bool bEndPoint; // used by C++ navigation code var transient bool bTransientEndPoint; // set right before a path finding attempt, cleared afterward. var transient bool bHideEditorPaths; // don't show paths to this node in the editor var transient bool bCanReach; // used during paths review in editor /** structure for inserting things into the navigation octree */ struct native NavigationOctreeObject { /** the bounding box to use */ var Box BoundingBox; /** cached center of that box */ var vector BoxCenter; /** if this object is in the octree, pointer to the node it's in, otherwise NULL */ var native transient const pointer OctreeNode{class FNavigationOctreeNode}; /** UObject that owns the entry in the octree */ var noexport const Object Owner; /** bitfield representing common classes of Owner so we can avoid casts */ var noexport const byte OwnerType; structcpptext { enum ENavOctreeObjectType { NAV_NavigationPoint = 0x01, NAV_ReachSpec = 0x02, }; private: UObject* Owner; BYTE OwnerType; public: /** constructor, makes sure OctreeNode is NULL */ FNavigationOctreeObject() : OctreeNode(NULL), Owner(NULL), OwnerType(0) {} /** destructor, removes us from the octree if we're still there */ ~FNavigationOctreeObject(); /** sets the object's owner and initializes the OwnerType for fast cast to common types */ void SetOwner(UObject* InOwner); /** sets the object's bounding box * if the object is currently in the octree, re-adds it * @param InBoundingBox the new bounding box to use */ void SetBox(const FBox& InBoundingBox); /** overlap check function called after the axis aligned bounding box check succeeds * allows for more precise checks for certain object types * @param TestBox the box to check * @return true if the box doesn't overlap this object, false if it does */ UBOOL OverlapCheck(const FBox& TestBox); /** templated accessor to Owner, to avoid casting for common cases * @note T must be UObject or a subclass, or this function will not compile */ template<class T> FORCEINLINE T* GetOwner() { return Cast<T>(Owner); } //@note the specializations for this template are in UnPath.h because they must be outside the struct definition void Serialize(FArchive& Ar); } }; var native transient const NavigationOctreeObject NavOctreeObject; var() bool bBlocked; // this node is currently unuseable var() bool bOneWayPath; // reachspecs from this path only in the direction the path is facing (180 degrees) var bool bNeverUseStrafing; // shouldn't use bAdvancedTactics going to this point var bool bAlwaysUseStrafing; // shouldn't use bAdvancedTactics going to this point var const bool bForceNoStrafing;// override any LD changes to bNeverUseStrafing var const bool bAutoBuilt; // placed during execution of "PATHS BUILD" var bool bSpecialMove; // if true, pawn will call SuggestMovePreparation() when moving toward this node var bool bNoAutoConnect; // don't connect this path to others except with special conditions (used by LiftCenter, for example) var const bool bNotBased; // used by path builder - if true, no error reported if node doesn't have a valid base var const bool bPathsChanged; // used for incremental path rebuilding in the editor var bool bDestinationOnly; // used by path building - means no automatically generated paths are sourced from this node var bool bSourceOnly; // used by path building - means this node is not the destination of any automatically generated path var bool bSpecialForced; // paths that are forced should call the SpecialCost() and SuggestMovePreparation() functions var bool bMustBeReachable; // used for PathReview code var bool bBlockable; // true if path can become blocked (used by pruning during path building) var bool bFlyingPreferred; // preferred by flying creatures var bool bMayCausePain; // set in C++ if in PhysicsVolume that may cause pain var transient bool bAlreadyVisited; // internal use var() bool bVehicleDestination; // if true, forced paths to this node will have max width to accomodate vehicles var() bool bMakeSourceOnly; var bool bMustTouchToReach; // if true. reach tests are based on whether pawn can move to overlap this NavigationPoint (only valid if bCollideActors=true) /** whether walking on (being based on) this NavigationPoint counts as reaching it */ var bool bCanWalkOnToReach; /** if true, attempt to build long range (> MAXPATHDIST) paths to/from this node */ var bool bBuildLongPaths; /** indicates vehicles cannot use this node */ var(VehicleUsage) bool bBlockedForVehicles; /** vehicles with bUsePreferredVehiclePaths set (large vehicles, usually) will prioritize using these nodes */ var(VehicleUsage) bool bPreferredVehiclePath; var() editinline const editconst duplicatetransient array<ReachSpec> PathList; //index of reachspecs (used by C++ Navigation code) /** List of navigation points to prevent paths being built to */ var editoronly duplicatetransient array<ActorReference> EditorProscribedPaths; /** List of navigation points to force paths to be built to */ var editoronly duplicatetransient array<ActorReference> EditorForcedPaths; /** List of volumes containing this navigation point relevant for gameplay */ var() const editconst array<ActorReference> Volumes; var int visitedWeight; var const int bestPathWeight; var const private NavigationPoint nextNavigationPoint; var const NavigationPoint nextOrdered; // for internal use during route searches var const NavigationPoint prevOrdered; // for internal use during route searches var const NavigationPoint previousPath; var int Cost; // added cost to visit this pathnode var() int ExtraCost; // Extra weight added by level designer var transient int TransientCost; // added right before a path finding attempt, cleared afterward. var transient int FearCost; // extra weight diminishing over time (used for example, to mark path where bot died) /** Mapping of Cost/Description for costs of this node */ struct native DebugNavCost { var string Desc; var int Cost; structcpptext { /** constructors */ FDebugNavCost() {} FDebugNavCost(EEventParm) { appMemzero(this, sizeof(FDebugNavCost)); } UBOOL operator==(const FDebugNavCost& Other) { return (Other.Cost == Cost && Other.Desc == Desc); } } }; var transient array<DebugNavCost> CostArray; var DroppedPickup InventoryCache; // used to point to dropped weapons var float InventoryDist; var const float LastDetourWeight; var CylinderComponent CylinderComponent; /** path size of the largest ReachSpec in this node's PathList */ var() editconst const Cylinder MaxPathSize; /** GUID used for linking paths across levels */ var() editconst const duplicatetransient guid NavGuid; /** Normal editor sprite */ var const transient SpriteComponent GoodSprite; /** Used to draw bad collision intersection in editor */ var const transient SpriteComponent BadSprite; /** Does this nav point point to others in separate levels? */ var const bool bHasCrossLevelPaths; /** Which navigation network does this navigation point connect to? */ var() editconst const int NetworkID; /** Pawn that is currently anchor to this navigation point */ var transient Pawn AnchoredPawn; /** Last time a pawn was anchored to this navigation point - set when Pawn chooses a new anchor */ var transient float LastAnchoredPawnTime; /** whether we need to save this in checkpoints because it has been modified by Kismet */ var transient bool bShouldSaveForCheckpoint; struct CheckpointRecord { var bool bDisabled; var bool bBlocked; }; cpptext { virtual UClass* GetReachSpecClass( ANavigationPoint* Nav, UClass* DefaultReachSpecClass ) { return DefaultReachSpecClass; } virtual void ClearPaths(); virtual void FindBase(); virtual void PostScriptDestroyed(); protected: virtual void UpdateComponentsInternal(UBOOL bCollisionUpdate = FALSE); public: void PostEditMove(UBOOL bFinished); void Spawned(); void UpdateMaxPathSize(); UBOOL FindAlternatePath(UReachSpec* StraightPath, INT AccumulatedDistance); virtual UBOOL ShouldBeBased(); /** Checks to make sure the navigation is at a valid point */ virtual void Validate(); #if WITH_EDITOR virtual void CheckForErrors(); /** * Sets the network ID for this nav and all connected navs. */ virtual void SetNetworkID(INT InNetworkID); static void BuildNetworkIDs(); virtual void ReviewPath(APawn* Scout); virtual UBOOL CheckSatisfactoryConnection(ANavigationPoint* Other); void CleanUpPruned(); INT PrunePaths(); // more aggressive (and expensive) path pruning routine ( should only be called from editor ) INT AggressivePrunePaths(); INT SecondPassAggressivePrunePaths(); virtual UBOOL CanPrunePath(INT index) { return TRUE; } virtual void AddForcedSpecs( AScout *Scout ); virtual UReachSpec* ForcePathTo(ANavigationPoint *Nav, AScout *Scout = NULL, UClass* ReachSpecClass = NULL ); virtual UBOOL ProscribePathTo(ANavigationPoint *Nav, AScout *Scout = NULL); /** builds long range paths (> MAXPATHDIST) between this node and all other reachable nodes * for which a straight path would be significantly shorter or the only way to reach that node * done in a separate pass at the end because it's expensive and so we want to early out in the maximum number * of cases (e.g. if suitable short range paths already get there) */ void AddLongPaths(AScout* Scout, UBOOL bOnlyChanged); virtual void addReachSpecs(class AScout *Scout, UBOOL bOnlyChanged=0); virtual INT AddMyMarker(AActor *S); /** returns whether a ReachSpec can be built from this node to Nav * @param Nav the NavigationPoint to check if we can build a path to * @param bCheckDistance whether or not we should check if Nav is close enough (MAXPATHDIST) * @return true if a ReachSpec can be built from this node to Nav, false otherwise */ virtual UBOOL CanConnectTo(ANavigationPoint* Nav, UBOOL bCheckDistance); virtual void OnAddToPrefab(); #endif virtual void InitForPathFinding() {}; virtual void ClearForPathFinding(); UBOOL CanReach(ANavigationPoint *Dest, FLOAT Dist, UBOOL bUseFlag, UBOOL bAllowFlying); virtual class APickupFactory* GetAPickupFactory() { return NULL; } virtual void SetVolumes(const TArray<class AVolume*>& Volumes); virtual void SetVolumes(); virtual UBOOL ReachedBy(APawn* P, const FVector& TestPosition, const FVector& Dest); virtual UBOOL TouchReachSucceeded(APawn *P, const FVector& TestPosition); virtual UBOOL GetUpDir( FVector &V ) { return 0; } virtual void AddToNavigationOctree(); virtual void RemoveFromNavigationOctree(); virtual UBOOL PlaceScout(class AScout *Scout); /** returns the position the AI should move toward to reach this actor */ FVector GetDestination(AController* C); /** sorts the PathList by distance, shortest first */ void SortPathList(); /** * Fills the array of any nav references needing to be fixed up. */ virtual void GetActorReferences(TArray<FActorReference*> &ActorRefs, UBOOL bIsRemovingLevel); virtual void ClearCrossLevelReferences(); virtual FGuid* GetGuid() { return &NavGuid; } virtual ANavigationPoint* SpecifyEndAnchor(APawn* RouteFinder); /** * Works through the component arrays marking entries as pending kill so references to them * will be NULL'ed. * * @param bAllowComponentOverride Whether to allow component to override marking the setting */ virtual void MarkComponentsAsPendingKill(UBOOL bAllowComponentOverride = FALSE); } native function GetBoundingCylinder(out float CollisionRadius, out float CollisionHeight) const; native final function ReachSpec GetReachSpecTo( NavigationPoint Nav, optional class<ReachSpec> SpecClass ); /** returns whether this NavigationPoint is valid to be considered as an Anchor (start or end) for pathfinding by the given Pawn * @param P the Pawn doing pathfinding * @return whether or not we can be an anchor */ native function bool IsUsableAnchorFor( Pawn P ); /** returns whether this NavigationPoint is a teleporter that can teleport the given Actor */ native function bool CanTeleport(Actor A); event int SpecialCost(Pawn Seeker, ReachSpec Path); // Accept an actor that has teleported in. // used for random spawning and initial placement of creatures event bool Accept( actor Incoming, actor Source ) { local bool bResult; // Move the actor here. bResult = Incoming.SetLocation( Location ); if (bResult) { Incoming.Velocity = vect(0,0,0); Incoming.SetRotation(Rotation); } Incoming.PlayTeleportEffect(true, false); return bResult; } /* DetourWeight() value of this path to take a quick detour (usually 0, used when on route to distant objective, but want to grab inventory for example) */ event float DetourWeight(Pawn Other,float PathWeight); /* SuggestMovePreparation() Optionally tell Pawn any special instructions to prepare for moving to this goal (called by Pawn.PrepareForMove() if this node's bSpecialMove==true */ event bool SuggestMovePreparation( Pawn Other ) { // If special move was taken to get to this link return Other.SpecialMoveTo(Other.Anchor, self, Other.Controller.MoveTarget); } /* ProceedWithMove() Called by Controller to see if move is now possible when a mover reports to the waiting pawn that it has completed its move */ function bool ProceedWithMove(Pawn Other) { return true; } /** * Returns the nearest valid navigation point to the given actor. */ static final function NavigationPoint GetNearestNavToActor(Actor ChkActor, optional class<NavigationPoint> RequiredClass,optional array<NavigationPoint> ExcludeList,optional float MinDist) { local NavigationPoint Nav, BestNav; local float Dist, BestDist; if (ChkActor != None) { // iterate through all points in the level foreach ChkActor.WorldInfo.AllNavigationPoints(class'NavigationPoint',Nav) { // if no filter class specified, and // if nav is available to the check actor, and // if the nav isn't part of the excluded list, if ((RequiredClass == None || Nav.class == RequiredClass) && ExcludeList.Find(Nav) == INDEX_NONE) { // pick the closest Dist = VSize(Nav.Location-ChkActor.Location); if (Dist > MinDist) { if (BestNav == None || Dist < BestDist) { BestNav = Nav; BestDist = Dist; } } } } } return BestNav; } /** * Returns the nearest valid navigation point to the given point. */ static final function NavigationPoint GetNearestNavToPoint(Actor ChkActor,vector ChkPoint, optional class<NavigationPoint> RequiredClass,optional array<NavigationPoint> ExcludeList) { local NavigationPoint Nav, BestNav; local float Dist, BestDist; if (ChkActor != None) { // iterate through all points in the level foreach ChkActor.WorldInfo.AllNavigationPoints(class'NavigationPoint',Nav) { // if no filter class specified, and // if nav is available to the check actor, and // if the nav isn't part of the excluded list, if ((RequiredClass == None || Nav.class == RequiredClass) && ExcludeList.Find(Nav) == INDEX_NONE) { // pick the closest Dist = VSize(Nav.Location-ChkPoint); if (BestNav == None || Dist < BestDist) { BestNav = Nav; BestDist = Dist; } } } } return BestNav; } /** * Returns all navigation points near the ChkPoint specified by Radius. */ static native final function bool GetAllNavInRadius( Actor ChkActor, Vector ChkPoint, float Radius, out array<NavigationPoint> out_NavList, optional bool bSkipBlocked, optional int inNetworkID=-1, optional Cylinder MinSize ); /** Returns if this navigation point is on a different network than the given */ native final function bool IsOnDifferentNetwork( NavigationPoint Nav ); /** * Toggle the blocked state of a navigation point. */ function OnToggle(SeqAct_Toggle inAction) { if (inAction.InputLinks[0].bHasImpulse) { bBlocked = false; } else if (inAction.InputLinks[1].bHasImpulse) { bBlocked = true; } else if (inAction.InputLinks[2].bHasImpulse) { bBlocked = !bBlocked; } WorldInfo.Game.NotifyNavigationChanged(self); bShouldSaveForCheckpoint = true; } simulated event ShutDown() { Super.ShutDown(); bBlocked = TRUE; WorldInfo.Game.NotifyNavigationChanged(self); bShouldSaveForCheckpoint = true; } function bool ShouldSaveForCheckpoint() { return bShouldSaveForCheckpoint; } function CreateCheckpointRecord(out CheckpointRecord Record) { Record.bBlocked = bBlocked; } function ApplyCheckpointRecord(const out CheckpointRecord Record) { bBlocked = Record.bBlocked; bShouldSaveForCheckpoint = true; } /** @return Debug abbrev for hud printing */ simulated event string GetDebugAbbrev() { return "NP?"; } defaultproperties { Begin Object Class=SpriteComponent Name=Sprite Sprite=Texture2D'EditorResources.S_NavP' HiddenGame=true HiddenEditor=false AlwaysLoadOnClient=False AlwaysLoadOnServer=False End Object Components.Add(Sprite) GoodSprite=Sprite Begin Object Class=SpriteComponent Name=Sprite2 Sprite=Texture2D'EditorResources.Bad' HiddenGame=true HiddenEditor=true AlwaysLoadOnClient=False AlwaysLoadOnServer=False Scale=0.25 End Object Components.Add(Sprite2) BadSprite=Sprite2 Begin Object Class=ArrowComponent Name=Arrow ArrowColor=(R=150,G=200,B=255) ArrowSize=0.5 bTreatAsASprite=True HiddenGame=true AlwaysLoadOnClient=False AlwaysLoadOnServer=False End Object Components.Add(Arrow) Begin Object Class=CylinderComponent Name=CollisionCylinder LegacyClassName=NavigationPoint_NavigationPointCylinderComponent_Class CollisionRadius=+0050.000000 CollisionHeight=+0050.000000 End Object CollisionComponent=CollisionCylinder CylinderComponent=CollisionCylinder Components.Add(CollisionCylinder) Begin Object Class=PathRenderingComponent Name=PathRenderer End Object Components.Add(PathRenderer) bMayCausePain=true bStatic=true bNoDelete=true bHidden=FALSE bCollideWhenPlacing=true bMustTouchToReach=true bBuildLongPaths=true bCollideActors=false // default to no network id NetworkID=-1 // NavigationPoints are generally server side only so we don't need to worry about client simulation bForceAllowKismetModification=true } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |