Beispiel #1
0
    void ArrangeModeledPart(CreatureBody body)
    {
        if (modeledPart == null)
        {
            return;
        }
        modeledPart.transform.localScale = body.bodyScale;
        modeledPart.volume = volume;
        modeledPart.FixVolume();
        bounds = modeledPart.GetComponentInChildren <MeshRenderer>().bounds;
        foreach (var renderer in GetComponentsInChildren <MeshRenderer>())
        {
            bounds.Encapsulate(renderer.bounds);
        }
        List <ChildPlacement> placements = new List <ChildPlacement>();

        foreach (Transform child in modeledPart.transform)
        {
            BodyPartChildPlaceholder bodyPartChild = child.GetComponent <BodyPartChildPlaceholder>();
            if (bodyPartChild == null)
            {
                continue;
            }
            bool placedPart = false;
            foreach (var placement in placements)
            {
                if (placement.Matches(bodyPartChild))
                {
                    placement.Add(bodyPartChild);
                    placedPart = true;
                }
            }
            if (!placedPart)
            {
                placements.Add(new ChildPlacement(bodyPartChild));
            }
        }

        foreach (Transform child in transform)
        {
            var childPart = child.GetComponent <BodyPart>();
            if (childPart == null)
            {
                continue;
            }
            foreach (var placement in placements)
            {
                if (placement.Matches(childPart))
                {
                    placement.Add(childPart);
                    break;
                }
            }
            childPart.Arrange(body);
        }
        foreach (var placement in placements)
        {
            placement.Arrange();
        }
    }
Beispiel #2
0
    void ArrangeModeledPart(CreatureBody body)
    {
        if (modeledPart == null)
        {
            return;
        }

        var partSize = Vector3.one;

        foreach (var mod in mods)
        {
            var value = 100;
            if (body.unit != null && body.unit.appearance != null)
            {
                value = body.unit.appearance.bp_modifiers[mod.index];
            }
            switch (mod.type)
            {
            case "BROADNESS":
                partSize.x = value / 100f;
                break;

            case "HEIGHT":
                partSize.y = value / 100f;
                break;

            case "LENGTH":
                partSize.z = value / 100f;
                break;

            default:
                break;
            }
        }

        //If the're flagged as small, they don't need to worry about volume. Just need to scale according to the parent.
        if (!flags.small)
        {
            modeledPart.transform.localScale = MultiplyScales(body.bodyScale, partSize);
            modeledPart.volume = volume;
            modeledPart.FixVolume();
        }
        bounds = modeledPart.GetComponentInChildren <MeshRenderer>().bounds;
        foreach (var renderer in GetComponentsInChildren <MeshRenderer>())
        {
            bounds.Encapsulate(renderer.bounds);
        }
        List <ChildPlacement> placements = new List <ChildPlacement>();

        foreach (Transform child in modeledPart.transform)
        {
            BodyPartChildPlaceholder bodyPartChild = child.GetComponent <BodyPartChildPlaceholder>();
            if (bodyPartChild == null)
            {
                continue;
            }
            bool placedPart = false;
            foreach (var placement in placements)
            {
                if (placement.Matches(bodyPartChild))
                {
                    placement.Add(bodyPartChild);
                    placedPart = true;
                }
            }
            if (!placedPart)
            {
                placements.Add(new ChildPlacement(bodyPartChild));
            }
        }

        List <BodyPart> childParts = new List <BodyPart>();

        foreach (Transform child in transform)
        {
            var childPart = child.GetComponent <BodyPart>();
            if (childPart == null)
            {
                continue;
            }
            childParts.Add(childPart);
        }
        foreach (var childPart in childParts)
        {
            if (childPart.flags.small && childPart.modeledPart != null)
            {
                //Its size doesn't matter if it's considered small, so it should just take the scale directly from the parent part.
                //Also, this only applies to parts that actually have models defined. Procedural parts still use the old system.
                childPart.transform.SetParent(modeledPart.transform, false);
            }
            foreach (var placement in placements)
            {
                if (placement.Matches(childPart))
                {
                    placement.Add(childPart);
                    break;
                }
            }
            childPart.Arrange(body);
        }
        foreach (var placement in placements)
        {
            placement.Arrange();
        }
    }
Beispiel #3
0
    void ArrangeModeledPart(CreatureBody body)
    {
        if (modeledPart == null)
        {
            return;
        }

        var partSize = Vector3.one;

        foreach (var mod in mods)
        {
            var value = 100;
            value = mod.value;
            switch (mod.type)
            {
            case "BROADNESS":
                partSize.x = value / 100f;
                break;

            case "HEIGHT":
            case "ROUND_VS_NARROW":
                partSize.y = value / 100f;
                break;

            case "LENGTH":
                partSize.z = value / 100f;
                break;

            case "CLOSE_SET":
                modeledPart.transform.localPosition = new Vector3(Mathf.Abs(transform.localPosition.x * (value / 100f - 1)) / 2.0f, 0, 0);
                break;

            case "SPLAYED_OUT":
                modeledPart.transform.localRotation = Quaternion.Euler(0, -value / 200f * 90, 0);
                break;

            default:
                break;
            }
        }

        //If the're flagged as small, they don't need to worry about volume. Just need to scale according to the parent.
        if (flags.small)
        {
            modeledPart.transform.localScale = partSize;
        }
        if (!flags.small)
        {
            modeledPart.transform.localScale = MultiplyScales(body.bodyScale, partSize);
            modeledPart.volume = volume;
            modeledPart.FixVolume();
        }
        bounds = modeledPart.GetComponentInChildren <MeshRenderer>().bounds;
        foreach (var renderer in GetComponentsInChildren <MeshRenderer>())
        {
            bounds.Encapsulate(renderer.bounds);
        }
        List <ChildPlacement> placements = new List <ChildPlacement>();

        foreach (Transform child in modeledPart.transform)
        {
            BodyPartChildPlaceholder bodyPartChild = child.GetComponent <BodyPartChildPlaceholder>();
            if (bodyPartChild == null)
            {
                continue;
            }
            if (bodyPartChild.category == ":ATTACH:")
            {
                heldItemPoint = child;
            }
            bool placedPart = false;
            foreach (var placement in placements)
            {
                if (placement.Matches(bodyPartChild))
                {
                    placement.Add(bodyPartChild);
                    placedPart = true;
                }
            }
            if (!placedPart)
            {
                placements.Add(new ChildPlacement(bodyPartChild));
            }
        }

        List <BodyPart> childParts = new List <BodyPart>();

        foreach (Transform child in transform)
        {
            var childPart = child.GetComponent <BodyPart>();
            if (childPart == null)
            {
                continue;
            }
            childParts.Add(childPart);
        }
        foreach (var childPart in childParts)
        {
            if (childPart.flags.small && childPart.modeledPart != null)
            {
                //Its size doesn't matter if it's considered small, so it should just take the scale directly from the parent part.
                //Also, this only applies to parts that actually have models defined. Procedural parts still use the old system.
                childPart.transform.SetParent(modeledPart.transform, false);
            }
            bool placed = false;
            foreach (var placement in placements)
            {
                if (placement.Matches(childPart))
                {
                    placement.Add(childPart);
                    placed = true;
                    break;
                }
            }
            if (!placed)
            {
                childPart.gameObject.SetActive(false);
            }
        }
        foreach (var placement in placements)
        {
            placement.Arrange();
        }
        foreach (var childPart in childParts)
        {
            childPart.Arrange(body);
        }
    }