Exemplo n.º 1
0
 public StructurePiece(string templateName, bool exterior, int interiorVariant, bool isMinorStructure, int minorParentNumber, MinorStructure minor)
 {
     TemplateName      = templateName;
     Exterior          = exterior;
     InteriorVariant   = interiorVariant;
     IsMinorStructure  = isMinorStructure;
     MinorParentNumber = minorParentNumber;
     Minor             = minor;
     IsDestroyed       = false;
 }
Exemplo 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;
        }
Exemplo n.º 3
0
        public override void OnEditorRefresh()
        {
            State.MinorStructures.Clear();

            List <ActionNode>            nodes = new List <ActionNode> ();
            List <ActionNodePlaceholder> acps  = new List <ActionNodePlaceholder> ();

            ActionNode            node = null;
            ActionNodePlaceholder acp  = null;

            foreach (Transform child in transform)
            {
                if (child.gameObject.HasComponent <StructureBuilder> () || child.name.Contains("-STR"))
                {
                    MinorStructure ms = new MinorStructure();
                    ms.TemplateName = StructureBuilder.GetTemplateName(child.name);
                    ms.Position     = child.transform.localPosition;
                    ms.Rotation     = child.transform.localRotation.eulerAngles;
                    State.MinorStructures.Add(ms);
                }
                else if (child.gameObject.HasComponent <ActionNode> (out node))
                {
                    if (node.State.Users == ActionNodeUsers.AnyOccupant)
                    {
                        nodes.Add(node);
                    }
                }
                else if (child.gameObject.HasComponent <ActionNodePlaceholder> (out acp))
                {
                    if (acp.SaveToStructure)
                    {
                        acps.Add(acp);
                    }
                }
            }

            ActionNodePlaceholder.LinkNodes(acps, nodes, State.MovementNodes);
        }