Example #1
0
        private static int PrepareDefinitions(string sceneName)
        {
            int count = 0;

            RepairableContainerDefinition[] repairableContainerDefinition = definitions.GetDefinitions(sceneName);
            Log("Found " + repairableContainerDefinition.Length + " definitions for scene " + sceneName);

            foreach (RepairableContainerDefinition eachDefinition in repairableContainerDefinition)
            {
                GameObject target = FindGameObject(eachDefinition.Target.Path, eachDefinition.Target.Position);
                if (target == null)
                {
                    Log("Could not find target of definition for " + eachDefinition.Target.Path + " @" + eachDefinition.Target.Position.ToString("F3"));
                    continue;
                }

                GameObject template = FindGameObject(eachDefinition.Template.Path, eachDefinition.Template.Position);
                if (template == null)
                {
                    Log("Could not find template of definition for " + eachDefinition.Target.Path + " @" + eachDefinition.Target.Position.ToString("F3"));
                    continue;
                }

                Container container = template.GetComponent <Container>();
                if (container == null)
                {
                    Log("Could not find container of definition for " + eachDefinition.Target.Path + " @" + eachDefinition.Target.Position.ToString("F3"));
                    continue;
                }

                if ("CabinetDoor" == eachDefinition.Type)
                {
                    RepairableCabinetDoor.Prepare(target, container, eachDefinition.Reference);
                    count++;
                }
                else if ("Drawer" == eachDefinition.Type)
                {
                    RepairableDrawer.Prepare(target, container, eachDefinition.Reference);
                    count++;
                }
                else
                {
                    Log("Unsupported type '" + eachDefinition.Type + "'");
                }
            }

            return(count);
        }
Example #2
0
        private static int PrepareDoors(Scene scene)
        {
            int count = 0;

            foreach (GameObject eachRepairableCabinetDoor in GetSceneObjects(scene, RepairableCabinetDoor.FilterInstance))
            {
                Container template = FindContainerTemplate(eachRepairableCabinetDoor);
                if (template != null)
                {
                    RepairableCabinetDoor.Prepare(eachRepairableCabinetDoor, template);
                    count++;
                }
            }

            return(count);
        }