Пример #1
0
        protected override void OnValueChanged(float value)
        {
            GameSettings.Instance.units.scaleUnits = (GameSettings.UnitScale)Mathf.RoundToInt(value);
            oldUnitScale = GameSettings.Instance.units.scaleUnits;
            switch (GameSettings.Instance.units.scaleUnits)
            {
            case GameSettings.UnitScale.Fixed:
                valueLabel.text = "Fixed Size";
                break;

            case GameSettings.UnitScale.Logarithmic:
                valueLabel.text = "Logarithmic Scaling";
                break;

            case GameSettings.UnitScale.Real:
            default:
                valueLabel.text = "Actual Size";
                break;
            }
        }
Пример #2
0
    public void UpdateUnit(UnitDefinition unit)
    {
        bool needsRegen = false;

        if ((MatPairStruct)this.unit.race != unit.race)
        {
            race       = CreatureRaws.Instance[unit.race.mat_type];
            caste      = race.caste[unit.race.mat_index];
            needsRegen = true;
        }
        if (oldWounds != null || unit.wounds != null)
        {
            if (oldWounds == null && unit.wounds != null)
            {
                needsRegen = true;
            }
            else if (oldWounds != null && unit.wounds == null)
            {
                needsRegen = true;
            }
            else if (oldWounds.Count != unit.wounds.Count)
            {
                needsRegen = true;
            }
            else
            {
                for (int i = 0; i < unit.wounds.Count; i++)
                {
                    if (oldWounds[i].severed_part != unit.wounds[i].severed_part)
                    {
                        needsRegen = true;
                        break;
                    }
                    if (oldWounds[i].parts.Count != unit.wounds[i].parts.Count)
                    {
                        needsRegen = true;
                        break;
                    }
                }
            }
        }
        oldWounds = unit.wounds;
        this.unit = unit;
        if (needsRegen || oldChibiSize != GameSettings.Instance.units.chibiness || oldScaleUnits != GameSettings.Instance.units.scaleUnits)
        {
            oldScaleUnits = GameSettings.Instance.units.scaleUnits;
            oldChibiSize  = GameSettings.Instance.units.chibiness;
            MakeBody();
        }

        if (((UnitFlags1)unit.flags1 & UnitFlags1.on_ground) == UnitFlags1.on_ground)
        {
            if (!onGround)
            {
                rootPart.transform.localRotation = Quaternion.Euler(90, 0, 0);
                rootPart.transform.localPosition = new Vector3(0, bounds.max.z, 0);
                onGround = true;
            }
        }
        else
        {
            if (onGround)
            {
                rootPart.transform.localRotation = Quaternion.identity;
                rootPart.transform.localPosition = new Vector3(0, -bounds.min.y, 0);
                onGround = false;
            }
        }
        if (unit.facing != null && GameMap.DFtoUnityDirection(unit.facing).sqrMagnitude > 0 && unit.rider_id < 0)
        {
            transform.rotation = Quaternion.LookRotation(GameMap.DFtoUnityDirection(unit.facing));
        }
        else if (unit.rider_id >= 0)
        {
            transform.rotation = Quaternion.identity;
        }

        if (InventoryChanged(unit.inventory))
        {
            foreach (var part in spawnedParts)
            {
                part.Value.inventory.Clear();
            }
            //Here we add pants first before shirts because otherwise the layering looks bad.
            foreach (var item in unit.inventory)
            {
                if (!ClothingTexture.GetTexture(item.item.type).isDress)
                {
                    AddInventoryItem(item);
                }
            }
            foreach (var item in unit.inventory)
            {
                if (ClothingTexture.GetTexture(item.item.type).isDress)
                {
                    AddInventoryItem(item);
                }
            }
            foreach (var part in spawnedParts)
            {
                part.Value.UpdateItems(unit);
            }
        }
    }