public int GetFrameCount(PortraitType portraitType, Characteristic characteristic) { int nbTiles = 0; if (characteristic == DefaultCharacteristics.EYE_COLOR) { nbTiles = portraitType.EyeColours.Count; } else if (characteristic == DefaultCharacteristics.HAIR_COLOR) { nbTiles = portraitType.HairColours.Count; } else { foreach (Layer layer in portraitType.Layers.Where(layer => layer.Characteristic == characteristic)) { if (Sprites.TryGetValue(layer.Name, out SpriteDef def)) { nbTiles = def.FrameCount; break; } else { logger.LogError("Sprite not found for layer " + layer); } } } return(nbTiles); }
public void SetPortraitType(PortraitType portraitType) { this.portraitType = portraitType; if (portraitType.Name.Contains("male")) { this.sex = Sex.MALE; } else if (portraitType.Name.Contains("female")) { this.sex = Sex.FEMALE; } }
/// <summary> /// Returns a new PortraitTytpe, with the clothing layers of basePortraitType overriden by clothingPortraitType /// </summary> public static PortraitType Merge(this PortraitType basePortraitType, PortraitType clothingPortraitType) { var mergedPortraitType = new PortraitType { EffectFile = basePortraitType.EffectFile, HairColourIndex = basePortraitType.HairColourIndex, HairColours = basePortraitType.HairColours, HeadgearThatHidesHair = basePortraitType.HeadgearThatHidesHair, EyeColours = basePortraitType.EyeColours, EyeColourIndex = basePortraitType.EyeColourIndex, Name = basePortraitType.Name + "/" + clothingPortraitType.Name, Layers = new List <Layer>(basePortraitType.Layers.Count) }; foreach (Layer baseLayer in basePortraitType.Layers) { var mergeLayer = baseLayer; if (baseLayer.CultureIndex != -1) { var overrideLayer = clothingPortraitType.GetCultureLayer(baseLayer.CultureIndex); if (overrideLayer != null) { logger.LogDebug("Overriding layer {0} with {1}", baseLayer, overrideLayer); mergeLayer = new Layer { Characteristic = baseLayer.Characteristic, CultureIndex = baseLayer.CultureIndex, IsEye = baseLayer.IsEye, IsHair = baseLayer.IsHair, Name = overrideLayer.Name, Offset = baseLayer.Offset }; } } mergedPortraitType.Layers.Add(mergeLayer); } return(mergedPortraitType); }
public int GetFrameCount(PortraitType portraitType, Characteristic characteristic) { int nbTiles = 0; if (characteristic == Characteristic.EYE_COLOR) { nbTiles = portraitType.EyeColours.Count; } else if (characteristic == Characteristic.HAIR_COLOR) { nbTiles = portraitType.HairColours.Count; } else { foreach (Layer layer in portraitType.Layers) { if (layer.Characteristic == characteristic) { if (Sprites.ContainsKey(layer.Name)) { Sprite sprite = Sprites[layer.Name]; if (sprite != null) { nbTiles = sprite.FrameCount; break; } } else { logger.Error("Sprite not found for layer " + layer); } } } } return(nbTiles); }