Ejemplo n.º 1
0
 public void OnEnterDungeon()
 {
     ////Debug.Log ("DUNGEONBUILDER: Entering dungeon");
     DungeonGroup.Load();
     CreateDungeonModules();
     LinkOcclusionGroups();
 }
Ejemplo n.º 2
0
        public IEnumerator LoadGroupsOverTime()
        {
            Debug.Log("Superloading path " + GroupPath);
            if (string.IsNullOrEmpty(GroupPath))
            {
                Debug.Log("Path was empty!");
                OnFinish();
                yield break;
            }
            GroupsToLoad = WIGroup.SplitPath(GroupPath);
            //pop the first - it will be the root
            GroupsToLoad.Pop();
            LastGroupLoaded = WIGroups.Get.Root;
            LastGroupLoaded.Load();
            if (GroupsToLoad.Count > 0)
            {
                NextGroupToLoad = GroupsToLoad.Peek();
                //start at the root and then load the groups all the way down
                //we'll keep loading groups until we've loaded everything in the stack
                while (GroupsToLoad.Count > 0)
                {
                    State = "Loading group";
                    WIGroup nextGroup = null;
                    while (!LastGroupLoaded.Is(WIGroupLoadState.Loaded) || !LastGroupLoaded.GetChildGroup(out nextGroup, NextGroupToLoad))
                    {
                        Debug.Log("Last group " + LastGroupLoaded.name + " loaded? " + LastGroupLoaded.Is(WIGroupLoadState.Loaded).ToString() + "\n" +
                                  "Child group available? " + LastGroupLoaded.GetChildGroup(out nextGroup, NextGroupToLoad).ToString());
                        State = "Waiting for child group " + NextGroupToLoad;
                        Ticks++;
                        yield return(null);
                    }
                    //now that it has its child items, tell it to load its child groups
                    LastGroupLoaded = nextGroup;
                    GroupsToLoad.Pop();
                    if (GroupsToLoad.Count > 0)
                    {
                        NextGroupToLoad = GroupsToLoad.Peek();
                        Ticks++;
                        yield return(null);
                    }
                }

                yield return(null);

                //now we search the group to see if it holds the child item we're looking for
                while (!LastGroupLoaded.FindChildItem(ChildItemFileName, out LoadedWorldItem))
                {
                    //LastGroupLoaded.State = WIGroupState.ForceLoad;
                    Ticks++;
                    State = "Waiting for child item " + ChildItemFileName;
                    yield return(null);
                }
            }
            //finished!
            OnFinish();

            yield break;
        }
Ejemplo n.º 3
0
 public void CreateDungeonGroup()
 {
     if (!HasDungeonGroup)
     {
         //create a dungeon group in the chunk's WI/BG group
         WIGroup belowGroundWorldItems = ParentChunk.Transforms.BelowGroundWorldItems.GetComponent <WIGroup> ();
         DungeonGroup = WIGroups.GetOrAdd(name, belowGroundWorldItems, null);
         DungeonGroup.Load();
     }
 }
Ejemplo n.º 4
0
        public IEnumerator LoadChunkGroups()
        {
            ChunkGroup.Load();

            while (!ChunkGroup.Is(WIGroupLoadState.Loaded))
            {
                //be patient
                yield return(null);
            }

            if (WorldItemsGroup == null)
            {
                WorldItemsGroup = WIGroups.GetOrAdd(Transforms.WorldItems.gameObject, Transforms.WorldItems.name, ChunkGroup, null);
            }

            WorldItemsGroup.Load();

            while (!WorldItemsGroup.Is(WIGroupLoadState.Loaded))
            {
                //be patient
                yield return(null);
            }

            if (AboveGroundGroup == null)
            {
                AboveGroundGroup = WIGroups.GetOrAdd(Transforms.AboveGroundWorldItems.gameObject, Transforms.AboveGroundWorldItems.name, WorldItemsGroup, null);
                AboveGroundGroup.Props.IgnoreOnSave = true;
                AboveGroundGroup.Props.TerrainType  = LocationTerrainType.AboveGround;
            }

            if (BelowGroundGroup == null)
            {
                BelowGroundGroup = WIGroups.GetOrAdd(Transforms.BelowGroundWorldItems.gameObject, Transforms.BelowGroundWorldItems.name, WorldItemsGroup, null);
                BelowGroundGroup.Props.IgnoreOnSave = true;
                BelowGroundGroup.Props.TerrainType  = LocationTerrainType.BelowGround;
            }

            AboveGroundGroup.Load();
            BelowGroundGroup.Load();
            yield break;
        }
Ejemplo n.º 5
0
 public void Refresh()
 {
     ModuleGroup.transform.position = transform.position;
     ModuleGroup.transform.rotation = transform.rotation;
     ModuleGroup.Load();
 }
Ejemplo n.º 6
0
        public IEnumerator GetInventoryContainer(int currentIndex, bool forward, GetInventoryContainerResult result)
        {
            if (result == null)
            {
                yield break;
            }

            mOnAccessInventory.SafeInvoke();

            if (mContainerEnabler == null)
            {
                //if we don't have an enabler, we need one now
                if (CharacterInventoryGroup == null)
                {
                    //if we don't have a character group, we'll need to create it to store our stuff
                    CharacterInventoryGroup = WIGroups.GetOrAdd(worlditem.FileName, WIGroups.Get.World, worlditem);
                }
                //make sure the group is loaded
                CharacterInventoryGroup.Load();
                //create a new container enabler for our stuff
                mContainerEnabler = Stacks.Create.StackEnabler(CharacterInventoryGroup);
            }

            int       totalContainers = 1;
            ShopOwner shopOwner       = null;

            if (worlditem.Is <ShopOwner> (out shopOwner))
            {
                //are we alive? if so, this can mean any containers that are owned by us in the group
                //start in the group that
                int nextIndex = currentIndex;
                List <Container> containers = new List <Container> ();
                if (WIGroups.GetAllContainers(worlditem.Group, containers))
                {
                    if (forward)
                    {
                        nextIndex = containers.NextIndex <Container> (currentIndex);
                    }
                    else
                    {
                        nextIndex = containers.PrevIndex <Container> (currentIndex);
                    }
                    //tell the container that we're opening it, then wait a tick for it to fill
                    try {
                        containers [nextIndex].OnOpenContainer();
                    } catch (Exception e) {
                        Debug.LogException(e);
                        yield break;
                    }
                    yield return(null);

                    mContainerEnabler.EnablerStack.Items.Clear();
                    Stacks.Display.ItemInEnabler(containers [nextIndex].worlditem, mContainerEnabler);
                    result.ContainerEnabler = mContainerEnabler;
                    result.ContainerIndex   = nextIndex;
                    result.TotalContainers  = containers.Count;
                }
            }
            else
            {
                //if we're not a shop owner
                //then there's exactly one container, our inventory container
                //if we're holding a temporary item then there are two
                if (IsHoldingTemporaryItem)
                {
                    Debug.Log("We're holding item so we'll return 2 containers");
                    //index 0 is our container enabler
                    //index 1 is our temporary item
                    result.TotalContainers = 2;
                    if (currentIndex == 0)                      //toggle to our held item
                    //Stacks.Display.ItemInEnabler (worlditem, mTemporaryItemEnabler);
                    {
                        result.ContainerIndex   = 1;
                        result.ContainerEnabler = mTemporaryItemEnabler;
                    }
                    else                        //toggle to our container enabler
                    {
                        Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                        result.ContainerIndex   = 0;
                        result.ContainerEnabler = mContainerEnabler;
                    }
                }
                else
                {
                    Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                    result.ContainerIndex   = 0;
                    result.TotalContainers  = 1;
                    result.ContainerEnabler = mContainerEnabler;
                }
                //this is always the same
                result.InventoryBank = InventoryBank;
            }
            yield break;
        }