Esempio n. 1
0
        public void Initialize(RemoteFortressReader.BuildingInstance buildingInput)
        {
            if (originalBuilding != null &&
                originalBuilding.active == buildingInput.active &&
                originalBuilding.items.Count == buildingInput.items.Count &&
                originalBuilding.pos_x_min == buildingInput.pos_x_min &&
                originalBuilding.pos_y_min == buildingInput.pos_y_min)
            {
                return; //There's nothing changed.
            }
            originalBuilding = buildingInput;

            foreach (var part in parts)
            {
                part.UpdatePart(buildingInput);
            }

            DFHack.DFCoord pos = new DFHack.DFCoord(
                (buildingInput.pos_x_min + buildingInput.pos_x_max) / 2,
                (buildingInput.pos_y_min + buildingInput.pos_y_max) / 2,
                buildingInput.pos_z_max);

            if (MapDataStore.Main[pos] != null && rotationType != RotationType.BuildingDirection)
            {
                transform.localRotation = MeshContent.TranslateRotation(rotationType, MapDataStore.Main[pos]);
            }
        }
Esempio n. 2
0
        public void Initialize(BuildingInstance buildingInput)
        {
            DFHack.DFCoord pos = new DFHack.DFCoord(
                (buildingInput.pos_x_min + buildingInput.pos_x_max) / 2,
                (buildingInput.pos_y_min + buildingInput.pos_y_max) / 2,
                buildingInput.pos_z_max);

            //always update building rotation because that depends on outside stuff
            if (MapDataStore.Main[pos] != null && rotationType != RotationType.BuildingDirection)
            {
                transform.localRotation = MeshContent.TranslateRotation(rotationType, MapDataStore.Main[pos]);
            }

            if (originalBuilding != null &&
                originalBuilding.active == buildingInput.active &&
                originalBuilding.items.Count == buildingInput.items.Count &&
                originalBuilding.pos_x_min == buildingInput.pos_x_min &&
                originalBuilding.pos_y_min == buildingInput.pos_y_min)
            {
                return; //There's nothing changed.
            }
            originalBuilding = buildingInput;

            foreach (var part in parts)
            {
                part.UpdatePart(buildingInput);
            }


            var group = GetComponent <LODGroup>();

            if (group == null)
            {
                group = gameObject.AddComponent <LODGroup>();
                var lods = new LOD[1];
                lods[0] = new LOD(0.05f, GetComponentsInChildren <MeshRenderer>());
                group.SetLODs(lods);
                group.RecalculateBounds();
            }

            UpdateTilePositions(buildingInput);

            foreach (var item in GetComponentsInChildren <Collider>())
            {
                if (item.GetComponent <BuildingSelect>() == null)
                {
                    item.gameObject.AddComponent <BuildingSelect>().root = this;
                }
            }
        }