internal void UpdateCreature(UnitDefinition unit) { if (!inited) { InitProperties(); } if (!localInited) { InitLocal(); } this.unit = unit; if (DFConnection.Instance.CreatureRaws != null) { creatureRaw = DFConnection.Instance.CreatureRaws[unit.race.mat_type]; } else { return; //can't work without raws } casteRaw = creatureRaw.caste[unit.race.mat_index]; if (unit.profession_color != null) { professionColor = new Color(unit.profession_color.red / 255.0f, unit.profession_color.green / 255.0f, unit.profession_color.blue / 255.0f, 0.5f); } else { professionColor = new Color(1, 1, 1, 0.5f); } var layers = LayeredSpriteManager.Instance.GetCreatureSprite(unit); //no size info indicates that the unit was only given the most basic data. if (layers != null && unit.size_info != null) { layeredSprite.SpriteCollection = layers; layeredSprite.enabled = true; legacySprite.gameObject.SetActive(false); layeredSprite.UpdateLayers(unit, creatureRaw, casteRaw); } else { layeredSprite.SpriteCollection = null; layeredSprite.enabled = false; legacySprite.gameObject.SetActive(true); UpdateTileCreature(); } }
internal void UpdateCreature(UnitDefinition unit) { if (!inited) { InitProperties(); } if (!localInited) { InitLocal(); } this.unit = unit; if (DFConnection.Instance.CreatureRaws != null) { creatureRaw = DFConnection.Instance.CreatureRaws[unit.race.mat_type]; } else { return; //can't work without raws } casteRaw = creatureRaw.caste[unit.race.mat_index]; if (unit.profession_color != null) { professionColor = new Color(unit.profession_color.red / 255.0f, unit.profession_color.green / 255.0f, unit.profession_color.blue / 255.0f, 0.5f); } else { professionColor = new Color(1, 1, 1, 0.5f); } var layers = LayeredSpriteManager.Instance.GetCreatureSprite(unit); if (layers != null) { layeredSprite.SpriteCollection = layers; layeredSprite.enabled = true; legacySprite.enabled = false; layeredSprite.UpdateLayers(unit, creatureRaw, casteRaw); } else { layeredSprite.SpriteCollection = layers; layeredSprite.enabled = false; legacySprite.enabled = true; UpdateTileCreature(); } }
internal void UpdateCreature(UnitDefinition unit) { if (!inited) { InitProperties(); } if (!localInited) { InitLocal(); } this.unit = unit; if (DFConnection.Instance.CreatureRaws != null) { creatureRaw = DFConnection.Instance.CreatureRaws[unit.race.mat_type]; } else { return; //can't work without raws } casteRaw = creatureRaw.caste[unit.race.mat_index]; if (unit.profession_color != null) { professionColor = new Color(unit.profession_color.red / 255.0f, unit.profession_color.green / 255.0f, unit.profession_color.blue / 255.0f, 0.5f); } else { professionColor = new Color(1, 1, 1, 0.5f); } var layers = LayeredSpriteManager.Instance.GetCreatureSprite(unit); //no size info indicates that the unit was only given the most basic data. if (layers != null && unit.size_info != null) { layeredSprite.SpriteCollection = layers; layeredSprite.enabled = true; legacySprite.gameObject.SetActive(false); layeredSprite.UpdateLayers(unit, creatureRaw, casteRaw); var group = GetComponentInChildren <LODGroup>(); if (group != null) { var lods = new LOD[1]; lods[0] = new LOD(0.05f, GetComponentsInChildren <SpriteRenderer>()); group.SetLODs(lods); group.RecalculateBounds(); } } else { layeredSprite.SpriteCollection = null; layeredSprite.enabled = false; legacySprite.gameObject.SetActive(true); UpdateTileCreature(); var group = GetComponentInChildren <LODGroup>(); if (group != null) { var lods = new LOD[1]; lods[0] = new LOD(0.05f, GetComponentsInChildren <MeshRenderer>()); group.SetLODs(lods); group.RecalculateBounds(); } } }