private void TidySegment(TexturedTileSegment segment, Dictionary <int, int> reindexMap) { for (int i = segment.Textures.Count - 1; i > 0; i--) //ignore the first = the largest { AbstractIndexedTRTexture texture = segment.Textures[i]; AbstractIndexedTRTexture candidateTexture = null; for (int j = 0; j < segment.Textures.Count; j++) { if (i == j) { continue; } AbstractIndexedTRTexture texture2 = segment.Textures[j]; if (texture.Equals(texture2)) { candidateTexture = texture2; break; } } if (candidateTexture != null) { reindexMap[texture.Index] = candidateTexture.Index; texture.Invalidate(); segment.Textures.RemoveAt(i); } } }
public TexturedTileSegment(AbstractIndexedTRTexture initialTexture, Bitmap bitmap) : base(initialTexture.Bounds) { Bitmap = bitmap; Textures = new List <AbstractIndexedTRTexture>(); AddTexture(initialTexture); }
public AbstractIndexedTRTexture GetTexture(int textureIndex) { for (int i = 0; i < Textures.Count; i++) { AbstractIndexedTRTexture texture = Textures[i]; if (texture.Index == textureIndex) { return(texture); } } return(null); }
private void NotifyTextureWatcher() { if (PositionMonitor == null) { return; } // Notify if anything has been removed first if (EntitiesToRemove != null) { PositionMonitor.EntityTexturesRemoved(new List <TR2Entities>(EntitiesToRemove)); } // If the monitor isn't interested in any new entities, skip the actual processing Dictionary <TR2Entities, List <int> > watchedTextures = PositionMonitor.GetMonitoredTextureIndices(); if (watchedTextures.Count == 0) { return; } Dictionary <TR2Entities, List <PositionedTexture> > textureResults = new Dictionary <TR2Entities, List <PositionedTexture> >(); foreach (TRModelDefinition definition in _importSegments.Keys) { // Does this definition have any entities we are interested in? List <TR2Entities> entities = new List <TR2Entities>(); if (watchedTextures.ContainsKey(definition.Alias)) { entities.Add(definition.Alias); } foreach (TR2Entities spriteEntity in definition.SpriteSequences.Keys) { if (watchedTextures.ContainsKey(spriteEntity)) { entities.Add(spriteEntity); } } if (entities.Count == 0) { continue; } foreach (TR2Entities entity in entities) { foreach (int watchedIndex in watchedTextures[entity]) { foreach (TexturedTileSegment segment in _importSegments[definition]) { AbstractIndexedTRTexture texture = segment.GetTexture(watchedIndex); if (texture == null) { continue; } if (!textureResults.ContainsKey(entity)) { textureResults[entity] = new List <PositionedTexture>(); } textureResults[entity].Add(new PositionedTexture(texture)); break; } } } } PositionMonitor.MonitoredTexturesPositioned(textureResults); }
public void AddTexture(AbstractIndexedTRTexture texture) { Textures.Add(texture); }