public static float GetBaseRadiusFeet(this CreatureBoardAsset asset) { return(asset.GetBaseDiameterFeet() / 2f); }
private void LayoutFollowTheLeaderLine(CreatureBoardAsset leaderAsset, List <MemberLocation> memberLocations) { float offset = Talespire.Convert.FeetToTiles(leaderAsset.GetBaseDiameterFeet()); Vector3 referencePosition = leaderAsset.PlacedPosition; int cacheIndex = Data.NumFollowTheLeaderCacheEntries - 1; if (cacheIndex < 0) { Talespire.Log.Error($"cacheIndex < 0 !!!"); MoveMembersToPreviousMemberPosition(memberLocations, 0); return; } Vector3 cachedDeltaMove = Data.GetFollowTheLeaderEntryByIndex(cacheIndex); bool outOfCachedLocations = false; int startIndex = 0; for (int i = 0; i < memberLocations.Count; i++) { if (i >= memberLocations.Count) { Talespire.Log.Error($"Index {i} exceeds memberLocations.Count ({memberLocations.Count})"); return; } Talespire.Log.Debug(memberLocations[i]); PositionMember(memberLocations[i], referencePosition, cachedDeltaMove, ref offset); NextMember(i); if (outOfCachedLocations) { break; } } if (outOfCachedLocations) { MoveMembersToPreviousMemberPosition(memberLocations, startIndex); } LookTowards(memberLocations.Select(x => x.Asset).ToList()); // ... void NextMember(int i) { if (i < memberLocations.Count - 1) { // Move down the line the radius of the next member... offset += Talespire.Convert.FeetToTiles(memberLocations[i + 1].Asset.GetBaseRadiusFeet()); } while (offset > cachedDeltaMove.magnitude) { offset -= cachedDeltaMove.magnitude; // To maintain the spacing. // Now we need the next position in the cache!!! referencePosition -= cachedDeltaMove; cacheIndex--; if (cacheIndex < 0) { outOfCachedLocations = true; startIndex = i + 1; break; } cachedDeltaMove = Data.GetFollowTheLeaderEntryByIndex(cacheIndex); } } }