public static void Init() { if (_Instance != null) { return; } GameObject go = GameObject.Find(DATA_MAPPING_NAME); #if UNITY_EDITOR if (go == null) { FCgDebug.LogError("MCgDataMapping.Init: Failed to find GameObject with name: " + DATA_MAPPING_NAME); } #endif // #if UNITY_EDITOR _Instance = go.GetComponent <MCgDataMapping>(); #if UNITY_EDITOR if (_Instance == null) { FCgDebug.LogError("MCgDataMapping.Init: GameObject: " + DATA_MAPPING_NAME + " does not have a component of type MCgDataMapping."); } #endif // #if UNITY_EDITOR _Instance.Init_Internal(); }
public bool DeAllocate(EnumType e, int index) { Dictionary <int, ObjectType> pool = null; if (!ActiveObjects.TryGetValue(e, out pool)) { FCgDebug.LogError(this.GetType().Name + ".DeAllocate: Object of Type: " + EnumTypeToString(e) + " at " + index + " is already deallocated."); return(false); } if (pool.ContainsKey(index)) { ObjectType o = pool[index]; LogTransaction(); o.DeAllocate <EnumType, ObjectType, PayloadType, CacheType>(); ActiveObjects[e].Remove(index); // OnDeAllocate+Event return(true); } FCgDebug.LogError(this.GetType().Name + ".DeAllocate: Object of Type: " + EnumTypeToString(e) + " at " + index + " is already deallocated."); return(false); }
protected ObjectType Allocate(EnumType e) { List <ObjectType> pool = null; Pools.TryGetValue(e, out pool); int size = EMPTY; PoolSizes.TryGetValue(e, out size); if (!PoolSizes.TryGetValue(e, out size)) { FCgDebug.LogError(this.GetType().Name + ".Allocate: Pool: " + EnumTypeToString(e) + " is exhausted."); return(null); } for (int i = 0; i < size; ++i) { int index = PoolIndices[e]; index = (index + 1) % size; PoolIndices[e] = index; ObjectType o = pool[index]; if (!o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().bAllocated) { o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().bAllocated = true; return(o); } } FCgDebug.LogError(this.GetType().Name + ".Allocate: Pool: " + EnumTypeToString(e) + " is exhausted."); return(null); }
protected void OnFinishedLoadingAssetReference(AsyncOperation operation) { ResourceRequest request = (ResourceRequest)operation; List <string> assetReferences = AssetReferencesQueue[FIRST]; string assetReference = assetReferences[AssetReferencesLoadedCount]; if (request.asset == null) { FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference: Failed to load asset at: " + assetReference); return; } LoadedAssets.Add(request.asset); int lastCount = AssetReferencesLoadedCount; ++AssetReferencesLoadedCount; // Get Memory loaded and the time it took int bytes = (int)Profiler.GetRuntimeMemorySizeLong(request.asset); float kilobytes = FCgCommon.BytesToKilobytes(bytes); float megabytes = FCgCommon.BytesToMegabytes(bytes); ResourceSizeLoaded.Bytes += bytes; ResourceSizeLoaded.Kilobytes += kilobytes; ResourceSizeLoaded.Megabytes += megabytes; float currentTime = Time.realtimeSinceStartup; float loadingTime = currentTime - LoadingStartTime; if (LogLoading.Log()) { FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference: Finished Loading " + assetReference + ". " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes) in " + loadingTime + " seconds."); } // Broadcast the event to anyone listening AssetReferenceLoadedCache.Reference = assetReference; AssetReferenceLoadedCache.Count = lastCount; AssetReferenceLoadedCache.Size.Bytes = bytes; AssetReferenceLoadedCache.Size.Kilobytes = kilobytes; AssetReferenceLoadedCache.Size.Megabytes = megabytes; AssetReferenceLoadedCache.Time = loadingTime; OnFinishedLoadingAssetReference_Event.Broadcast(AssetReferenceLoadedCache); // FirstToLast, Queue the NEXT Asset for Async Load if (AssetReferencesLoadedCount < assetReferences.Capacity) { if (LogLoading.Log()) { FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference: Requesting Load of " + assetReferences[AssetReferencesLoadedCount]); } OnStartLoadingAssetReference_Event.Broadcast(assetReferences[AssetReferencesLoadedCount]); ResourceRequest r = Resources.LoadAsync(assetReferences[AssetReferencesLoadedCount]); r.completed += OnFinishedLoadingAssetReference; } LoadingStartTime = currentTime; }
protected void OnFinishedLoadingAssetReference_Bulk(AsyncOperation operation) { ResourceRequest request = (ResourceRequest)operation; #if UNITY_EDITOR string assetReference = AssetDatabase.GetAssetPath(request.asset); #endif // #if UNITY_EDITOR if (request.asset == null) { #if UNITY_EDITOR FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference_Bulk: Failed to load asset at: " + assetReference); #else FCgDebug.LogError("FCgManager_Loading.OnFinishedLoadingAssetReference_Bulk: Failed to load asset"); #endif // #if UNITY_EDITOR return; } LoadedAssets.Add(request.asset); int lastCount = AssetReferencesLoadedCount; ++AssetReferencesLoadedCount; // Get Memory loaded and the time it took int bytes = (int)Profiler.GetRuntimeMemorySizeLong(request.asset); float kilobytes = FCgCommon.BytesToKilobytes(bytes); float megabytes = FCgCommon.BytesToMegabytes(bytes); ResourceSizeLoaded.Bytes += bytes; ResourceSizeLoaded.Kilobytes += kilobytes; ResourceSizeLoaded.Megabytes += megabytes; float currentTime = Time.realtimeSinceStartup; float loadingTime = currentTime - LoadingStartTime; if (LogLoading.Log()) { #if UNITY_EDITOR FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference_Bulk: Finished Loading " + assetReference + ". " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes)."); #else FCgDebug.Log("FCsManager_Loading.OnFinishedLoadingAssetReference_Bulk: Finished Loading an asset. " + megabytes + " mb (" + kilobytes + " kb, " + bytes + " bytes)."); #endif // #if UNITY_EDITOR } #if UNITY_EDITOR // Broadcast the event to anyone listening AssetReferenceLoadedCache.Reference = assetReference; AssetReferenceLoadedCache.Count = lastCount; AssetReferenceLoadedCache.Size.Bytes = bytes; AssetReferenceLoadedCache.Size.Kilobytes = kilobytes; AssetReferenceLoadedCache.Size.Megabytes = megabytes; AssetReferenceLoadedCache.Time = loadingTime; OnFinishedLoadingAssetReference_Event.Broadcast(AssetReferenceLoadedCache); #endif // #if UNITY_EDITOR }
public void OnUpdate(float deltaTime) { // If Queue Empty, EXIT if (AssetReferencesQueue.Capacity == EMPTY) { return; } List <string> assetReferences = AssetReferencesQueue[FIRST]; if (AsyncOrders[FIRST] == ECgLoadAsyncOrder.Bulk) { OnLoadProgressUpdated_Event.Broadcast((float)AssetReferencesLoadedCount / (float)assetReferences.Capacity); } // If Still Loading, EXIT if (AssetReferencesLoadedCount < assetReferences.Capacity) { return; } float currentTime = Time.realtimeSinceStartup; float loadingTime = currentTime - LoadingTotalStartTime; // All AssetReferences are LOADED if (LogLoading.Log()) { // FirstToLast if (AsyncOrders[FIRST] == ECgLoadAsyncOrder.FirstToLast) { FCgDebug.Log("FCsManager_Loading.OnUpdate: Finished Loading " + AssetReferencesLoadedCount + " Assets. " + ResourceSizeLoaded.ToString_Megabytes() + " in " + loadingTime + " seconds"); } // None | Bulk else { FCgDebug.Log("FCsManager_Loading.OnUpdate: Finished Loading " + AssetReferencesLoadedCount + " Assets in " + loadingTime + " seconds"); } } AsyncOrders.RemoveAt(FIRST); AssetReferencesQueue.RemoveAt(FIRST); OnFinishedLoadingAssetReferences_Events[FIRST].Broadcast(LoadedAssets, loadingTime); OnFinishedLoadingAssetReferences_Events.RemoveAt(FIRST); OnFinishedLoadingAssetReferences_Event.Broadcast(LoadedAssets, loadingTime); // Assume the Callback holds onto the references for LoadedAssets LoadedAssets.Clear(); // If Queue is NOT Empty, Load the next batch of AssetReferences if (AssetReferencesQueue.Capacity != EMPTY) { LoadAssetReferences_Internal(AssetReferencesQueue[FIRST], AsyncOrders[FIRST]); } }
// TODO: Need to actually do Loading for cache "miss" public MCgData LoadData(FECgAssetType assetType, string shortCode) { if (Map[assetType].ContainsKey(shortCode)) { return(Map[assetType][shortCode]); } FCgDebug.LogWarning("MCgDataMapping.LoadData: No " + assetType.Name + " with ShortCode: " + shortCode); return(null); }
public void Init() { // TODO: Search for the Prefab rather than the Scene EmptyGameObject = GameObject.Find(EMPTY_GAME_OBJECT_NAME); #if UNITY_EDITOR if (EmptyGameObject == null) { FCgDebug.LogError("FCgManager_Prefab.Init: Failed to find EmptyGameObject named " + EMPTY_GAME_OBJECT_NAME + ". needs to exist in the level in order to create other objects."); } #endif // #if UNITY_EDITOR }
public void LoadAssetReferences_Internal(List <string> assetReferences, ECgLoadAsyncOrder asyncOrder) { AssetReferencesLoadedCount = 0; ResourceSizeLoaded.Reset(); // Start Loading - Load All References int size = assetReferences.Capacity; OnStartLoadingAssetReferences_Event.Broadcast(size); OnStartLoadProgress_Event.Broadcast(size); if (LogLoading.Log()) { FCgDebug.Log("FCgManager_Loading.LoadAssetReferences_Internal: Requesting Load of " + size + " Assets"); // None | Bulk if (asyncOrder == ECgLoadAsyncOrder.None || asyncOrder == ECgLoadAsyncOrder.Bulk) { for (int i = 0; i < size; ++i) { FCgDebug.Log("FCsManager_Loading.LoadAssetReferences_Internal: Requesting Load of " + assetReferences[i]); } } } // Start the Async Load // FirstToLast if (asyncOrder == ECgLoadAsyncOrder.FirstToLast) { if (LogLoading.Log()) { FCgDebug.Log("FCsManager_Loading.LoadAssetReferences_Internal: Requesting Load of " + assetReferences[FIRST]); } OnStartLoadingAssetReference_Event.Broadcast(assetReferences[FIRST]); ResourceRequest r = Resources.LoadAsync(assetReferences[FIRST]); r.completed += OnFinishedLoadingAssetReference; } // Bulk else { for (int i = 0; i < size; ++i) { ResourceRequest r = Resources.LoadAsync(assetReferences[i]); r.completed += OnFinishedLoadingAssetReference_Bulk; } } LoadingStartTime = Time.realtimeSinceStartup; LoadingTotalStartTime = LoadingStartTime; }
public FCgTraceRequest AllocateRequest() { for (byte i = 0; i < REQUEST_SIZE; ++i) { RequestIndex = (byte)((RequestIndex + 1) % REQUEST_SIZE); FCgTraceRequest request = Requests[RequestIndex]; if (!request.bAllocated) { request.bAllocated = true; return(request); } } FCgDebug.LogError("FCsManager_Trace.AllocateRequest: Pool is exhausted"); return(null); }
public FCgTraceResponse AllocateResponse() { for (byte i = 0; i < RESPONSE_SIZE; ++i) { ResponseIndex = (byte)((ResponseIndex + 1) % RESPONSE_SIZE); FCgTraceResponse response = Responses[ResponseIndex]; if (!response.bAllocated) { response.bAllocated = true; return(response); } } FCgDebug.LogError("FCsManager_Trace::AllocateResponse: Pool is exhausted"); return(null); }
public static void Init(Type type) { if (_Instance != null) { return; } if (!type.IsSubclassOf(typeof(FCgBlockchain))) { FCgDebug.Log("FCgBlockchain.Init: Passed in Type of " + type.GetType().Name + " is NOT a SubclassOf FCgBlockchain"); return; } ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes); _Instance = (ICgBlockchain)constructor.Invoke(Type.EmptyTypes); }
private bool ProcessRequest(FCgTraceRequest request) { /* * if (CsCVarDrawManagerTraceRequests->GetInt() == CS_CVAR_DRAW) * { * // Sphere around Start * DrawDebugSphere(GetWorld(), Request->Start, 16.0f, 16, FColor::Green, false, 0.1f, 0, 1.0f); * // Line from Start to End * DrawDebugLine(GetWorld(), Request->Start, Request->End, FColor::Red, false, 0.1f, 0, 1.0f); * } */ request.bProcessing = true; // Test (Check) if (request.Method == ECgTraceMethod.Test) { FCgDebug.LogWarning("FCsManager_Trace.ProcessRequest: There is NO Async Trace " + request.Method.ToString() + " Method. Use TraceMethod: Single or Multi."); request.Reset(); return(false); } // Line if (request.Type == ECgTraceType.Line) { request.ScheduleCommand(); return(true); } // Sweep (Cast) else if (request.Type == ECgTraceType.Sweep) { FCgDebug.LogWarning("FCsManager_Trace.ProcessRequest: There is NO Async Sweep (Cast) Trace Method. Use TraceType: Line."); request.Reset(); return(false); } // Overlap else if (request.Type == ECgTraceType.Overlap) { FCgDebug.LogWarning("FCsManager_Trace.ProcessRequest: There is NO Async Overlap (Cast) Trace Method. Use TraceType: Overlap."); request.Reset(); return(false); } return(true); }
public PayloadType AllocatePayload() { int count = Payloads.Count; for (int i = 0; i < count; ++i) { int index = (PayloadIndex + i) % count; PayloadType payload = Payloads[index]; if (!payload.bAllocated) { payload.bAllocated = true; return(payload); } } FCgDebug.LogError(this.GetType().Name + ".AllocatePayload: Pool is exhausted."); return(default(PayloadType)); }
public static void Init(Type type) { if (_Instance != null) { return; } if (!type.IsSubclassOf(typeof(TCgManager_PooledObjects_Map <FECgProcess, FCgProcess, FCgProcessPayload>))) { FCgDebug.Log("ICgManager_Process.Init: Passed in Type of " + type.GetType().Name + " is NOT a SubclassOf TCgManager_PooledObjects_Map<ECgProcess, FCgProcess, FCgProcessPayload>"); return; } GameObject go = new GameObject("Manager_Process"); _Instance = go.AddComponent <ICgManager_Process>(); _Instance.Internal = (FCgManager_Process)type.GetConstructor(Type.EmptyTypes).Invoke(Type.EmptyTypes); _Instance.Internal.OnAddToPool_Event.Add(_Instance.OnAddToPool); }
public virtual void PlaySound(FECgWeaponFireMode fireMode, FECgWeaponSound soundType, MonoBehaviour owner, Vector3 location) { FCgSoundElement soundElement = GetSound(fireMode, soundType); if (soundElement.Get() == null) { FCgDebug.LogWarning("MCsData_ProjectileWeapon.PlaySound: Attempting to Play a NULL Sound."); return; } //ICgManager_Sound manager_sound = ICgManager_Sound.Get(); /* * FCsSoundPayload* Payload = Manager_Sound->AllocatePayload(); * Payload->Set(SoundElement); * Payload->Owner = InOwner; * Payload->Location = Location; * * Manager_Sound->Play(Payload); */ }
public static void Init(Type type) { if (_Instance != null) { return; } if (!type.IsSubclassOf(typeof(TCgManager_PooledMonoObjects_Map <FECgProjectileType, MCgProjectile, FCgProjectilePayload, FCgProjectileCache>))) { FCgDebug.Log("ICgManager_Projectile.Init: Passed in Type of " + type.GetType().Name + " is NOT a SubclassOf TCgManager_PooledMonoObjects_Map<FECgProjectileType, MCgProjectile, FCgProjectilePayload, FCgProjectileCache>"); return; } GameObject go = MonoBehaviour.Instantiate(FCgManager_Prefab.Get().EmptyGameObject); _Instance = go.AddComponent <ICgManager_Projectile>(); go.name = "ICgManager_Projectile"; _Instance.Internal = (FCgManager_Projectile)type.GetConstructor(Type.EmptyTypes).Invoke(Type.EmptyTypes); _Instance.Internal.OnAddToPool_Event.Add(_Instance.OnAddToPool); _Instance.Internal.ConstructObject.Unbind(); _Instance.Internal.ConstructObject.Bind(_Instance.ConstructObject); }
public bool HasCompleted() { // Frame // Time if (bWaitForTime) { if (WaitForTimeType != null) { WaitForTime = WaitForTimeType.Get(); if (WaitForTime < 0.0f) { WaitForTime = 0.0f; WaitForTimeType = null; FCgDebug.LogWarning("FCgGizmoDrawRequest.HasCompleted: WaitForTimeType of type 'FCgGizmoDrawRequest.FTimeType' is used for WaitForTime. WaitForTimeType value must be >= 0.0f."); } } return(WaitForTimeTimer >= WaitForTime); } // Flag return(true); }
public virtual void AddToActivePool(EnumType e, ObjectType o) { if (o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().Index == INDEX_NONE) { FCgDebug.LogError(this.GetType().Name + ".AddToActivePool: Object of Type: " + EnumTypeToString(e) + " was NOT added to any pool. Call AddToPool first."); return; } o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().bAllocated = true; Dictionary <int, ObjectType> pool = null; if (ActiveObjects.TryGetValue(e, out pool)) { ActiveObjects[e].Add(o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().Index, o); } else { pool = new Dictionary <int, ObjectType>(); pool.Add(o.GetCache <EnumType, ObjectType, PayloadType, CacheType>().Index, o); ActiveObjects.Add(e, pool); } // }
public FCgTraceResponse Trace(FCgTraceRequest request) { request.StartTime = FCgManager_Time.Get().GetTimeSinceStart(TimeType); bool addPending = !request.bForce && TraceCountThisFrame >= RequestsProcessedPerTick; // TODO: Print warning for a normal trace moved to Async if (addPending && !request.bAsync) { request.Reset(); FCgDebug.LogWarning("FCsManager_Trace.Trace: Reached maximum RequestsProcessedPerTick: " + RequestsProcessedPerTick + " and Request is NOT Async. Abandoning Request."); return(null); } // Async if (request.bAsync || addPending) { // if NOT Pending, Start Async if (!addPending) { // if Successful in processing Request, EXIT if (ProcessRequest(request)) { AddPendingRequest(request); IncrementTraceCount(request); return(null); } } // ADD Pending Request AddPendingRequest(request); return(null); } // Normal else { #if UNITY_EDITOR if (DrawRequests.Draw()) { // Sphere around Start FCgManager_GizmoDraw.Get().DrawSphere(request.Start, 0.16f, Color.green, 0.1f); // Line from Start to End FCgManager_GizmoDraw.Get().DrawLine(request.Start, request.End, Color.red, 0.1f); } #endif // #if UNITY_EDITOR FCgTraceResponse response = AllocateResponse(); response.ElapsedTime = 0.0f; // Line if (request.Type == ECgTraceType.Line) { // Test if (request.Method == ECgTraceMethod.Test) { // Linecast response.bResult = Physics.Linecast(request.Start, request.End, request.LayerMask); } // Single else if (request.Method == ECgTraceMethod.Single) { FCgDebug.LogWarning("FCsManager_Trace.Trace: Line Trace Single is NOT supported. Use TraceMethod: Test or Multi. Abandoning Request."); } // Multi else if (request.Method == ECgTraceMethod.Multi) { // RaycastNonAlloc Vector3 v = request.End - request.Start; float distance = v.magnitude; Vector3 dir = distance > 0.0f ? v / distance : Vector3.zero; float EXTEND = 0.1f; response.OutHitCount = Physics.RaycastNonAlloc(request.Start, dir, response.OutHitBuffer, distance + EXTEND, request.LayerMask); response.ResolveHitBuffers(request.StartTime, request.Start, request.End); } } // Sweep else if (request.Type == ECgTraceType.Sweep) { // Test if (request.Method == ECgTraceMethod.Test) { // Box if (request.Shape == ECgCollisionShape.Box) { // CheckBox response.bResult = Physics.CheckBox(request.BoxParams.Center, request.BoxParams.HalfExtents, request.BoxParams.Orientation, request.LayerMask); } // Sphere else if (request.Shape == ECgCollisionShape.Sphere) { // CheckSphere response.bResult = Physics.CheckSphere(request.SphereParams.Position, request.SphereParams.Radius, request.LayerMask); } // Capsule else if (request.Shape == ECgCollisionShape.Capsule) { // CheckCapsule response.bResult = Physics.CheckCapsule(request.CapsuleParams.Start, request.CapsuleParams.End, request.CapsuleParams.Radius, request.LayerMask); } } // Single else if (request.Method == ECgTraceMethod.Single) { FCgDebug.LogWarning("FCsManager_Trace.Trace: Sweep Trace Single is NOT supported. Use TraceMethod: Test or Multi. Abandoning Request."); } // Multi else if (request.Method == ECgTraceMethod.Multi) { // Box if (request.Shape == ECgCollisionShape.Box) { // BoxCastNonAlloc Vector3 v = request.End - request.Start; float distance = v.magnitude; Vector3 dir = distance > 0.0f ? v / distance : Vector3.zero; float EXTEND = 0.1f; response.OutHitCount = Physics.BoxCastNonAlloc(request.BoxParams.Center, request.BoxParams.HalfExtents, dir, response.OutHitBuffer, request.BoxParams.Orientation, distance + EXTEND, request.LayerMask); response.ResolveHitBuffers(request.StartTime, request.Start, request.End); } // Sphere else if (request.Shape == ECgCollisionShape.Sphere) { // SphereCastNonAlloc Vector3 v = request.End - request.Start; float distance = v.magnitude; Vector3 dir = distance > 0.0f ? v / distance : Vector3.zero; float EXTEND = 0.1f; response.OutHitCount = Physics.SphereCastNonAlloc(request.Start, request.SphereParams.Radius, dir, response.OutHitBuffer, distance + EXTEND, request.LayerMask); response.ResolveHitBuffers(request.StartTime, request.Start, request.End); } // Capsule else if (request.Shape == ECgCollisionShape.Capsule) { // CapsuleCastNonAlloc Vector3 v = request.End - request.Start; float distance = v.magnitude; Vector3 dir = distance > 0.0f ? v / distance : Vector3.zero; float EXTEND = 0.1f; response.OutHitCount = Physics.CapsuleCastNonAlloc(request.CapsuleParams.Start, request.CapsuleParams.End, request.CapsuleParams.Radius, dir, response.OutHitBuffer, distance + EXTEND, request.LayerMask); response.ResolveHitBuffers(request.StartTime, request.Start, request.End); } } } // Overlap else if (request.Type == ECgTraceType.Overlap) { // Test if (request.Method == ECgTraceMethod.Test) { FCgDebug.LogWarning("FCsManager_Trace.Trace: Overlap Trace Test is NOT supported. Use TraceMethod: Multi. Abandoning Request."); } // Single else if (request.Method == ECgTraceMethod.Single) { FCgDebug.LogWarning("FCsManager_Trace.Trace: Overlap Trace Single is NOT supported. Use TraceMethod: Multi. Abandoning Request."); } // Multi else if (request.Method == ECgTraceMethod.Multi) { // Box if (request.Shape == ECgCollisionShape.Box) { // OverlapBoxNonAlloc response.OutOverlapCount = Physics.OverlapBoxNonAlloc(request.BoxParams.Center, request.BoxParams.HalfExtents, response.OutOverlapBuffer, request.BoxParams.Orientation, request.LayerMask); response.ResolveOverlapBuffers(request.StartTime); } // Sphere else if (request.Shape == ECgCollisionShape.Sphere) { // OverlapSphereNonAlloc response.OutOverlapCount = Physics.OverlapSphereNonAlloc(request.SphereParams.Position, request.SphereParams.Radius, response.OutOverlapBuffer, request.LayerMask); response.ResolveOverlapBuffers(request.StartTime); } // Capsule else if (request.Shape == ECgCollisionShape.Capsule) { // CapsuleCastNonAlloc response.OutOverlapCount = Physics.OverlapCapsuleNonAlloc(request.CapsuleParams.Start, request.CapsuleParams.End, request.CapsuleParams.Radius, response.OutOverlapBuffer, request.LayerMask); response.ResolveOverlapBuffers(request.StartTime); } } } IncrementTraceCount(request); request.Reset(); #if UNITY_EDITOR if (DrawResponses.Draw()) { if (response.bResult) { // Sphere around Start FCgManager_GizmoDraw.Get().DrawSphere(response.OutHits[FIRST].TraceStart, 0.16f, Color.green, 0.1f); // Line from Start to End FCgManager_GizmoDraw.Get().DrawLine(response.OutHits[FIRST].TraceStart, response.OutHits[FIRST].Location, Color.red, 0.1f); } } #endif // #if UNITY_EDITOR return(response); } }
private void OnBeginPlay_Handle_Pawns() { MCgPawn[] pawns = FindObjectsOfType <MCgPawn>(); foreach (MCgPawn p in pawns) { // Auto Possess if (p.bAutoPossess) { bool possessed = false; // Players // Auto Assign Controller if (p.ControllerIndex <= AUTO_ASSIGN_CONTROLLER) { foreach (MCgPlayerController pc in PlayerControllers) { if (pc.Pawn != null) { pc.Possess(p); possessed = true; break; } } if (!possessed) { FCgDebug.LogWarning("MCgGameInstance.OnBeginPlay_Handle_Pawns: Failed to AutoPossess Pawn: " + p.name + " of type: " + p.GetType().ToString()); } } // Search for controller with matching index else { if (p.ControllerIndex >= PlayerControllers.Count) { FCgDebug.LogWarning("MGgGameInstance.OnBeginPlay_Handle_Pawns: Failed to AutoPossess Pawn: " + p.name + " of type: " + p.GetType().ToString() + ". No PlayerController found with index: " + p.ControllerIndex); } else { int index = p.ControllerIndex; if (PlayerControllers[index].Pawn != null) { FCgDebug.LogWarning("MGgGameInstance.OnBeginPlay_Handle_Pawns: Failed to AutoPossess Pawn: " + p.name + " of type: " + p.GetType().ToString()); FCgDebug.LogWarning("MGgGameInstance.OnBeginPlay_Handle_Pawns: PlayerController with index: " + index + " is already possessing Pawn: " + PlayerControllers[index].Pawn.name); } else { PlayerControllers[index].Possess(p); } } } // TODO: AI } p.bPlacedInWorld = true; p.Init(); } }