Ejemplo n.º 1
0
        public IEnumerator Initialize(Structure parentStructure, StructureTemplate template, StructureLoadPriority priority)
        {                       //if we're still doing another job (for some reason) wait for it to finish
            while (State != BuilderState.Dormant)
            {
                yield return(null);
            }

            Template = template;
            State    = BuilderState.Initialized;
            Priority = priority;

            gHelperTransform = gameObject.FindOrCreateChild("StructureBuilderHelper_" + name);

            ParentStructure = parentStructure;
            if (ParentStructure == null)
            {
                Debug.LogError("Parent structure null in builder, proceeding normally");
                State = BuilderState.Error;
                yield break;
            }
            if (ParentStructure.worlditem.Group == null)
            {
                Debug.Log("Parent structure worlditem group was null, proceeding normally");
                State = BuilderState.Error;
                yield break;
            }
            if (ParentStructure.StructureGroup == null)
            {
                Debug.Log("Parent structure StructureGroup was null, waiting until group exists");
                State = BuilderState.Error;
                yield break;
            }
            StructureBase  = parentStructure.StructureGroup.gameObject;
            StructureChunk = parentStructure.worlditem.Group.GetParentChunk();
            InteriorVariants.Clear();
            InteriorVariants.Add(ParentStructure.State.BaseInteriorVariant);
            InteriorVariants.AddRange(ParentStructure.State.AdditionalInteriorVariants);

            yield break;
        }
Ejemplo n.º 2
0
        public IEnumerator Initialize(MinorStructure minorParent, StructureTemplate template, StructureLoadPriority priority)
        {               //if we're still doing another job (for some reason) wait for it to finish
            while (State != BuilderState.Dormant)
            {
                yield return(null);
            }

            gHelperTransform = gameObject.FindOrCreateChild("StructureBuilderHelper_" + name);

            try {
                MinorParent    = minorParent;
                Template       = template;
                State          = BuilderState.Initialized;
                Priority       = priority;
                StructureChunk = MinorParent.Chunk;
                StructureBase  = MinorParent.StructureOwner.gameObject;
            } catch (Exception e) {
                Debug.LogException(e);
                State = BuilderState.Error;
            }
            yield break;
        }