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 |
// ============================================================================ // JBTagNavigation // Copyright 2003 by Mychaeel <mychaeel@planetjailbreak.com> // $Id: JBTagNavigation.uc,v 1.9 2004-05-25 16:51:42 mychaeel Exp $ // // Caches information about an actor used for navigational purposes. // ============================================================================ class JBTagNavigation extends JBTag notplaceable; // ============================================================================ // Types // ============================================================================ struct TInfoDistance { var NavigationPoint NavigationPointTo; // target navigation point var float Distance; // distance to that navigation point }; // ============================================================================ // Variables // ============================================================================ var private array<TInfoDistance> ListInfoDistance; // cached distance values var private Controller Controller; // used for path finding // ============================================================================ // Internal // ============================================================================ static function JBTagNavigation FindFor(Actor Keeper) { return JBTagNavigation(InternalFindFor(Keeper)); } static function JBTagNavigation SpawnFor(Actor Keeper) { return JBTagNavigation(InternalSpawnFor(Keeper)); } // ============================================================================ // CalcDistance // // Calculates the traveling distance between two given actors. Expensive on // the first call for a given set of two actors, but results are cached for // subsequent calls. // ============================================================================ static function float CalcDistance(NavigationPoint NavigationPointFrom, NavigationPoint NavigationPointTo) { local int iDistance; local float Distance; local Actor ActorFrom; local Actor ActorTo; local Controller Controller; local JBTagNavigation TagNavigationFrom; if (NavigationPointFrom == NavigationPointTo) return 0.0; if (NavigationPointFrom == None || NavigationPointTo == None) return -1.0; // error TagNavigationFrom = SpawnFor(NavigationPointFrom); // retrieves existing tag for (iDistance = 0; iDistance < TagNavigationFrom.ListInfoDistance.Length; iDistance++) if (TagNavigationFrom.ListInfoDistance[iDistance].NavigationPointTo == NavigationPointTo) return TagNavigationFrom.ListInfoDistance[iDistance].Distance; ActorFrom = NavigationPointFrom; ActorTo = NavigationPointTo; if (JBGameObjective(ActorFrom) != None) ActorFrom = JBGameObjective(ActorFrom).TriggerRelease; if (JBGameObjective(ActorTo) != None) ActorTo = JBGameObjective(ActorTo ).TriggerRelease; Distance = VSize(ActorFrom.Location - ActorTo.Location); Controller = TagNavigationFrom.GetController(); if (Controller == None || Controller.Pawn == None) return Distance; Controller.Pawn.SetLocation(ActorFrom.Location); Controller.Pawn.SetRotation(ActorFrom.Rotation); if (Controller.FindPathToward(ActorTo) != None) Distance = Controller.RouteDist; Controller.Pawn.SetPhysics(PHYS_None); // may be set to falling iDistance = TagNavigationFrom.ListInfoDistance.Length; TagNavigationFrom.ListInfoDistance.Insert(iDistance, 1); TagNavigationFrom.ListInfoDistance[iDistance].NavigationPointTo = NavigationPointTo; TagNavigationFrom.ListInfoDistance[iDistance].Distance = Distance; return Distance; } // ============================================================================ // GetController // // Returns a reference to a controller with a scout pawn. Tries to find an // existing controller and pawn first before spawning a new one. // ============================================================================ private function Controller GetController() { local JBTagNavigation thisTagNavigation; if (Controller != None && Controller.Pawn != None) return Controller; foreach DynamicActors(Class'JBTagNavigation', thisTagNavigation) if (thisTagNavigation.Controller != None) { Controller = thisTagNavigation.Controller; break; } if (Controller == None) Controller = Spawn(Class'ScriptedTriggerController'); if (Controller.Pawn == None) Controller.Possess(Spawn(Class'JBScout')); if (Controller.Pawn == None) Log(Level.TimeSeconds @ "Unable to spawn JBScout at" @ Controller.Location); return Controller; } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |