示例#1
0
        protected IEnumerator SpawnInBedOverTime(MobileReference bedReference, Action <Bed> OnFinishAction)
        {
            if (mSpawningPlayer)
            {
                //whoops
                yield break;
            }
            mSpawningPlayer = true;

            CurrentStartupPosition = null;

            Bed loadedBed = null;

            mSpawnBedWorldItem = null;
            //super-load the item
            StartCoroutine(WIGroups.SuperLoadChildItem(bedReference.GroupPath, bedReference.FileName, SpawnBedLoaded, 0f));

            while (mSpawnBedWorldItem == null || !mSpawnBedWorldItem.Is(WILoadState.Initialized))
            {
                //waiting for bed
                yield return(null);
            }

            loadedBed = mSpawnBedWorldItem.Get <Bed> ();

            OnFinishAction(loadedBed);
            mSpawningPlayer = false;
            yield break;
        }
示例#2
0
        public void RefreshNoteProps( )
        {
            MissionStatus objectiveStatus = MissionStatus.Dormant;

            if (Missions.Get.ObjectiveStatusByName("Friends", "SpeakToKara", ref objectiveStatus))
            {
                if (Flags.Check((uint)MissionStatus.Completed, (uint)objectiveStatus, Flags.CheckType.MatchAny))
                {
                    worlditem.RemoveFromGame();
                    return;
                }
            }

            mExamineInfo.LocationsToReveal.Clear();

            if (Missions.Get.ObjectiveStatusByName("Legacy", "GiveFigurine", ref objectiveStatus) &&
                Flags.Check((uint)MissionStatus.Completed, (uint)objectiveStatus, Flags.CheckType.MatchAny))
            {
                State.ObservatoryNote = false;
            }

            if (State.ObservatoryNote)
            {
                mExamineInfo.StaticExamineMessage = ObservatoryNote;
                MobileReference observatoryLocation = new MobileReference(State.ObservatoryPath);
                mExamineInfo.LocationsToReveal.Add(observatoryLocation);
            }
            else
            {
                mExamineInfo.StaticExamineMessage = BalloonCampNote;
                MobileReference balloonCampLocation = new MobileReference(State.BalloonCampPath);
                mExamineInfo.LocationsToReveal.Add(balloonCampLocation);
            }
        }
示例#3
0
 public void AddCollateralToCurrentOffer(string locationPath)
 {
     if (!string.IsNullOrEmpty(locationPath))
     {
         MobileReference collateral = new MobileReference(locationPath);
         CurrentOfferCollateral.SafeAdd(collateral);
     }
 }
示例#4
0
        public static MotileAction GoTo(MobileReference target)
        {
            MotileAction newAction = new MotileAction();

            newAction.Type          = MotileActionType.GoToActionNode;
            newAction.Target        = target;
            newAction.Expiration    = MotileExpiration.Never;
            newAction.YieldBehavior = MotileYieldBehavior.YieldAndFinish;
            return(newAction);
        }
示例#5
0
        public void FollowPath(MobileReference start, MobileReference target, PathAvatar path, PathDirection direction)
        {
//						//we know the path contains the start destination
//						//now search for the end destination
//						if (path == null || !path.ContainsLocation(start.FileName, out StartLocationTarget)) {	////Debug.Log ("whoops didn't find path or start location");
//								return;
//						}
//
//						//load all this stuff into local vars
//						//we don't need to stop following current path, that'll fix itself
//						CurrentPath = path;
//						//set the first pilgrim stop to the start location and set to reached pilgrim stop
//						//that way we'll force find next neighbor on the first update
//						LastLocationReached = StartLocationTarget;
//						State.PathMode = FollowPathMode.ReachedPilgrimStop;
//						State.LastPathUsed = path.name;
//						State.CurrentStart = start;
//						State.CurrentTarget = target;
//						State.CurrentMeters = path.MetersFromPosition(StartLocationTarget.transform.position);
//						State.StartMeters = State.CurrentMeters;
//						State.Direction = direction;
//
//						if (!MobileReference.IsNullOrEmpty(target)) {
//								if (path.ContainsLocation(target.FileName, out EndLocationTarget)) {
//										State.TargetMeters = path.MetersFromPosition(EndLocationTarget.transform.position);
//								} else {
//										State.TargetMeters = path.LengthInMeters;
//								}
//						} else {
//								EndLocationTarget = null;
//						}
//
//						//send motile action telling character to follow the goal
//						if (mFollowPathAction == null) {
//								mFollowPathAction = new MotileAction();
//						}
//						mFollowPathAction.Reset();
//						mFollowPathAction.Type = MotileActionType.FollowGoal;
//						mFollowPathAction.Expiration = MotileExpiration.Never;
//						mFollowPathAction.YieldBehavior = MotileYieldBehavior.YieldAndWait;
//						//mFollowPathAction.LiveTarget = PathFollower; //TODO fix this
//						mFollowPathAction.Target.FileName = "[Pilgrim]";
//						PathFollower.transform.position = transform.position;
//
//						Motile motile = null;
//						if (worlditem.Is <Motile>(out motile)) {
//								motile.PushMotileAction(mFollowPathAction, MotileActionPriority.ForceTop);
//						}
//
//						if (!mFollowingPathOverTime) {
//								StartCoroutine(FollowPathOverTime());
//						}
        }
示例#6
0
 public override bool DoesContextAllowForUse(IItemOfInterest targetObject)
 {
     if (targetObject.IOIType == ItemOfInterestType.Player)
     {
         Usage.ListOptionDisplayName = "Resurrect";                                                //TODO can we clean this up?
         return(!MobileReference.IsNullOrEmpty(Extensions.ResurrectionMarker));
     }
     else
     {
         Usage.ListOptionDisplayName = "Set Resurrection Point";                                                //TODO can we clean this up?
         return(base.DoesContextAllowForUse(targetObject));
     }
 }
示例#7
0
        protected IEnumerator SendPlayerToStructure(int chunkID, MobileReference locationReference, string structureName, bool interior, STransform chunkPosition, Vector3 chunkOffset)
        {
            mStartupStructure = null;
            StartCoroutine(WIGroups.SuperLoadChildItem(
                               locationReference.GroupPath,
                               locationReference.FileName,
                               StartupStructureLoaded,
                               0f));

            while (mStartupStructure == null)
            {
                yield return(null);
            }

            double startBuildTime = WorldClock.RealTime;

            mStartupStructure.LoadPriority = StructureLoadPriority.SpawnPoint;
            Structures.AddExteriorToLoad(mStartupStructure);

            while (!mStartupStructure.Is(StructureLoadState.ExteriorLoaded | StructureLoadState.InteriorLoading | StructureLoadState.InteriorLoaded))
            {
                mLoadingInfo = "Waiting for exterior to build";
                if ((WorldClock.RealTime - startBuildTime) > 60f)
                {
                    mLoadingInfo = "Exterior build timeout!";
                    yield break;
                }
                yield return(null);
            }
            Structures.AddInteriorToLoad(mStartupStructure);
            startBuildTime = WorldClock.RealTime;

            while (!mStartupStructure.Is(StructureLoadState.InteriorLoaded))
            {
                mLoadingInfo = "Waiting for interior to build";
                if ((WorldClock.RealTime - startBuildTime) > 60f)
                {
                    mLoadingInfo = "Interior build timeout!";
                    yield break;
                }
                yield return(null);
            }
            mLoadingInfo = "Interior structure is built";
            Player.Local.Surroundings.StartupStructure = mStartupStructure;

            yield return(null);

            yield break;
        }
示例#8
0
 public void OnFullyRead()
 {
     foreach (string skillToLearn in SkillsToLearn)
     {
         Skills.LearnSkill(skillToLearn);
         Skills.MarkSkill(skillToLearn);
     }
     foreach (string locationToReveal in LocationsToReveal)
     {
         MobileReference mr = new MobileReference(locationToReveal);
         Player.Local.Surroundings.Reveal(mr);
         Profile.Get.CurrentGame.MarkedLocations.SafeAdd(mr);                                                //mark the locatino even if we already know about it
     }
     Status |= BookStatus.FullyRead;
 }
        public override bool OnPlayerEnter()
        {
            if (mDimmingLanterns)
            {
                return(false);
            }

            if (LanternsToDim.Count == 0)
            {
                WorldItem lanternWorldItem = null;
                for (int i = 0; i < State.LanternsToDim.Count; i++)
                {
                    MobileReference mr = State.LanternsToDim[i];
                    if (WIGroups.FindChildItem(mr.GroupPath, mr.FileName, out lanternWorldItem))
                    {
                        LanternsToDim.Add(lanternWorldItem);
                    }
                }
                if (State.LanternsToDim.Count == 0)
                {
                    return(false);
                }
            }

            if (GuardInterventionTrigger == null)
            {
                WorldTriggerState wts = null;
                if (ParentChunk.GetTriggerState(State.GuardInterventionTriggerName, out wts))
                {
                    GuardInterventionTrigger = wts.trigger as TriggerGuardIntervention;
                }
                else
                {
                    return(false);
                }
            }

            mDimmingLanterns = true;
            mStartTime       = WorldClock.AdjustedRealTime;
            StartCoroutine(DimLanternsOverTime());

            return(true);
        }
示例#10
0
        //searches chunks and loads location data into the locationData list
        //only searches for locations added using the SetMapData function
        public IEnumerator LocationsForChunks(string chunkName, int chunkID, Queue <WorldMapLocation> locationData, List <MapMarker> activeMapMarkers)
        {               //Debug.Log ("WorldMap: LocationsForChunks");
            List <MobileReference> locationList = null;

            if (!mRevealableToShow.TryGetValue(chunkName, out locationList))
            {
                //Debug.Log ("WorldMap: We have no locations for this chunk from SetMapData, returning immediately");
                yield break;
            }
            Vector3 chunkPosition;

            //add markers
            for (int i = 0; i < activeMapMarkers.Count; i++)
            {
                if (activeMapMarkers [i].ChunkID == chunkID)
                {
                    chunkPosition = activeMapMarkers [i].ChunkPosition;
                    WorldMapLocation wml = new WorldMapLocation(
                        null,
                        1,
                        "Marker",
                        string.Empty,
                        string.Empty,
                        true,
                        false,
                        "MapIconMapMarker",
                        Color.white,
                        MapIconStyle.Medium,
                        MapLabelStyle.None,
                        Vector3.zero,
                        chunkPosition,
                        false,
                        false,
                        LocationTypesToDisplay);
                    locationData.Enqueue(wml);
                }
            }

            MobileReference currentLocation = null;

            for (int i = 0; i < locationList.Count; i++)
            {
                if (!LoadData)
                {
                    //Debug.Log ("WorldMap: Load data is false, returning");
                    yield break;
                }
                currentLocation = locationList [i];
                StackItem stackItem = null;
                if (WIGroups.LoadStackItem(currentLocation, out stackItem))
                {
                    chunkPosition = stackItem.ChunkPosition;
                    //Debug.Log ("WorldMap: found stack item " + stackItem.DisplayName);
                    //next we need to get the location state from the stack item
                    LocationState   ls            = null;
                    RevealableState rs            = null;
                    VisitableState  vs            = null;
                    bool            isNewLocation = false;
                    bool            isMarked      = false;
                    if (NewLocations.Count > 0)
                    {
                        for (int j = NewLocations.LastIndex(); j >= 0; j--)
                        {
                            if (NewLocations [j] == currentLocation)
                            {
                                NewLocations.RemoveAt(j);
                                isNewLocation = true;
                                break;
                            }
                        }
                    }
                    //Debug.Log ("current location " + currentLocation.FullPath + " is marked? " + isMarked.ToString ( ));
                    isMarked = MarkedLocations.Contains(currentLocation);

                    if (stackItem.GetStateData <RevealableState> (out rs))
                    {
                        stackItem.GetStateData <LocationState> (out ls);
                        stackItem.GetStateData <VisitableState> (out vs);
                        //now convert it into a world map location
                        WorldMapLocation wml = null;
                        if (rs.CustomMapSettings || ls == null)
                        {
                            //non-custom settings come from the location
                            //so we can only use custom settings if ls is not null
                            //Debug.Log ("Custom settings for revealable with " + rs.IconName + " icon name");
                            wml = new WorldMapLocation(
                                currentLocation,
                                stackItem.Props.Local.ActiveRadius,
                                ls != null ? ls.Name.CommonName : string.Empty,
                                ls != null ? ls.Name.ProperName : string.Empty,
                                ls != null ? ls.Name.NickName : string.Empty,
                                vs != null ? vs.HasBeenVisited : true,
                                rs.MarkedForTriangulation,
                                rs.IconName,
                                rs.IconColor,
                                rs.IconStyle,
                                rs.LabelStyle,
                                rs.IconOffset,
                                chunkPosition,
                                isNewLocation,
                                isMarked,
                                LocationTypesToDisplay);
                            locationData.Enqueue(wml);
                        }
                        else
                        {
                            string        iconName   = "Outpost";
                            MapIconStyle  iconStyle  = MapIconStyle.None;
                            MapLabelStyle labelStyle = MapLabelStyle.None;
                            Color32       iconColor  = Color.gray;
                            Vector3       iconOffset = Vector3.zero;

                            GetIconProperties(stackItem, ls, rs, vs, ref iconName, ref iconStyle, ref labelStyle, ref iconColor, ref iconOffset);

                            wml = new WorldMapLocation(
                                currentLocation,
                                stackItem.Props.Local.ActiveRadius,
                                ls != null ? ls.Name.CommonName : string.Empty,
                                ls != null ? ls.Name.ProperName : string.Empty,
                                ls != null ? ls.Name.NickName : string.Empty,
                                vs != null ? vs.HasBeenVisited : true,
                                rs.MarkedForTriangulation,
                                iconName,
                                iconColor,
                                iconStyle,
                                labelStyle,
                                iconOffset,
                                chunkPosition,
                                isNewLocation,
                                isMarked,
                                LocationTypesToDisplay);
                            locationData.Enqueue(wml);
                        }
                    }
                    else
                    {
                        //Debug.Log ("Didn't get revealable state data in " + currentLocation.FileName);
                    }
                }
                else
                {
                    //Debug.Log ("Didin't get stack item for location " + currentLocation.FullPath);
                }
                //clear the stack item, we don't need it any more
                if (stackItem != null)
                {
                    stackItem.Clear();
                }
                yield return(null);
            }
            locationList.Clear();
            yield break;
        }
示例#11
0
        public WorldMapLocation(
            MobileReference reference,
            float radius,
            string name,
            string properName,
            string alternateName,
            bool visited,
            bool markedForTriangulation,
            string iconName,
            Color32 iconColor,
            MapIconStyle iconStyle,
            MapLabelStyle labelStyle,
            Vector3 iconOffset,
            Vector3 chunkPosition,
            bool isNew,
            bool isMarked,
            List <string> typesToDisplay)
        {
            Reference              = reference;
            Radius                 = radius;
            Name                   = name;
            mLowerName             = Name.ToLower();
            ProperName             = properName;
            AlternateName          = alternateName;
            Visited                = visited;
            MarkedForTriangulation = markedForTriangulation;
            IconName               = iconName;
            IconColor              = iconColor;
            IconStyle              = iconStyle;
            LabelStyle             = labelStyle;
            ChunkPosition          = chunkPosition;
            if (LabelStyle == MapLabelStyle.Descriptive)
            {
                LabelColor = Colors.Get.WorldMapLabelDescriptiveColor;
            }
            else
            {
                LabelColor = Colors.Get.WorldMapLabelColor;
            }

            //Debug.Log ("Icon name: " + IconName);

            Label          = null;
            Icon           = null;
            LabelTransform = null;
            IconTransform  = null;
            LabelPosition  = Vector3.zero;
            IconPosition   = Vector3.zero;
            IconOffset     = iconOffset;
            LabelScale     = 1f;
            IconScale      = 1f;
            IconAlpha      = 1f;
            IsNew          = isNew;
            IsMarked       = isMarked;
            Display        = typesToDisplay.Contains(IconName) || (reference == null);

            switch (IconStyle)
            {
            case MapIconStyle.AlwaysVisible:
                IconScale  = 250f;
                LabelScale = 1.1f;
                break;

            case MapIconStyle.Large:
            case MapIconStyle.Medium:
            case MapIconStyle.Small:
            case MapIconStyle.None:
            default:
                IconScale  = 75f;
                LabelScale = 1f;
                break;
            }
            //LabelPosition = Vector3.up * IconScale;
        }
示例#12
0
 public static bool MarkLocation(MobileReference mr)
 {
     //Debug.Log ("marking location " + mr.FullPath);
     return(MarkedLocations.SafeAdd(mr));
 }
示例#13
0
 public void SpawnInBed(MobileReference bedReference, Action <Bed> OnFinishAction)
 {
     StartCoroutine(SpawnInBedOverTime(bedReference, OnFinishAction));
 }
示例#14
0
        //this function is meant to be used with the HouseOfHealing skill
        //i've only been able to get this process to work a few times
        //the idea is to super-load the last visited HOH
        //then load its interior and put the player in one of its beds
        //great in theory but in practice something always f***s up
        protected IEnumerator SpawnInClosestStructureOverTime(Vector3 despawnPosition, List <MobileReference> structureReferences, Action <Bed> OnFinishAction)
        {
            if (mSpawningPlayer)
            {
                //whoops
                yield break;
            }
            mSpawningPlayer = true;

            CurrentStartupPosition = null;

            float           closestDistanceSoFar           = Mathf.Infinity;
            StackItem       closestStructureStateSoFar     = null;
            StackItem       currentStructureState          = null;
            MobileReference currentStructureReference      = null;
            MobileReference closestStructureReferenceSoFar = null;
            Vector3         closestStructurePositionSoFar  = despawnPosition;
            WorldChunk      currentChunk = null;

            //find out which structure is the closest
            for (int i = 0; i < structureReferences.Count; i++)
            {
                currentStructureReference = structureReferences [i];
                //Debug.Log ("SPAWNMANAGER: Checking structure reference " + currentStructureReference.FullPath.ToString ());
                if (WIGroups.LoadStackItem(currentStructureReference, out currentStructureState))
                {
                    if (currentStructureState.Is <Structure> ())
                    {
                        //get the chunk for this item
                        if (GameWorld.Get.ChunkByID(currentStructureReference.ChunkID, out currentChunk))
                        {
                            Vector3 structureWorldPosition = WorldChunk.ChunkPositionToWorldPosition(currentChunk.ChunkBounds, currentStructureState.ChunkPosition);
                            structureWorldPosition += currentChunk.ChunkOffset;
                            float currentDistance = Vector3.Distance(despawnPosition, structureWorldPosition);
                            if (currentDistance < closestDistanceSoFar)
                            {
                                closestDistanceSoFar           = currentDistance;
                                closestStructureStateSoFar     = currentStructureState;
                                closestStructureReferenceSoFar = currentStructureReference;
                                closestStructurePositionSoFar  = structureWorldPosition;
                            }
                        }
                    }
                }
            }

            if (closestStructureStateSoFar == null)
            {
                yield break;
            }

            //move the player to the position of the new item
            //this will help us to super-load the structure
            Player.Local.Position = closestStructurePositionSoFar;

            //reset the current loading structure
            mSpawnStructureWorldItem = null;
            Structure spawnStructure = null;
            Bed       loadedBed      = null;

            //super-load the item
            //yield return null;
            //WorldItems.Get.SuspendActiveStateChecking = true;
            StartCoroutine(WIGroups.SuperLoadChildItem(closestStructureReferenceSoFar.GroupPath, closestStructureReferenceSoFar.FileName, SpawnStructureLoaded, 0f));
            WIGroup lastGroupLoaded = null;

            while (mSpawnStructureWorldItem == null)
            {
                yield return(null);
            }

            //WorldItems.Get.SuspendActiveStateChecking = false;
            //okay next we have to load the structure interior
            mSpawnStructureWorldItem.ActiveStateLocked = false;
            mSpawnStructureWorldItem.ActiveState       = WIActiveState.Active;
            mSpawnStructureWorldItem.ActiveStateLocked = true;
            yield return(null);

            //now that the player is where they're supposed to be we can resume active state checking
            //but keep the structure itself locked
            //Player.Local.Position = mSpawnStructureWorldItem.Position;
            //ColoredDebug.Log ("Sending player to spawn structure position " + mSpawnStructureWorldItem.Position.ToString (), "Yellow");

            spawnStructure = mSpawnStructureWorldItem.Get <Structure> ();
            spawnStructure.LoadPriority = StructureLoadPriority.SpawnPoint;
            if (spawnStructure.Is(StructureLoadState.ExteriorUnloaded))
            {
                yield return(StartCoroutine(spawnStructure.CreateStructureGroups(StructureLoadState.ExteriorLoaded)));

                Structures.AddExteriorToLoad(spawnStructure);
                while (spawnStructure.Is(StructureLoadState.ExteriorLoading | StructureLoadState.ExteriorWaitingToLoad))
                {
                    yield return(null);
                }
            }
            if (spawnStructure.Is(StructureLoadState.ExteriorLoaded))
            {
                Structures.AddInteriorToLoad(spawnStructure);
                while (spawnStructure.Is(StructureLoadState.InteriorWaitingToLoad | StructureLoadState.InteriorLoading))
                {
                    yield return(null);
                }
                spawnStructure.RefreshColliders(true);
                spawnStructure.RefreshRenderers(true);
                //finally we search for a bed
            }
            spawnStructure.StructureGroup.Load();
            while (!spawnStructure.StructureGroup.Is(WIGroupLoadState.Loaded))
            {
                yield return(null);
            }

            yield return(null);

            //wait a tick to let the group catch up
            //wait a tick to let the group catch up
            yield return(null);

            List <WorldItem> bedWorldItems = new List <WorldItem> ();

            while (bedWorldItems.Count == 0)
            {
                yield return(StartCoroutine(WIGroups.GetAllChildrenByType(spawnStructure.StructureGroup.Props.PathName, new List <string> ()
                {
                    "Bed"
                }, bedWorldItems, spawnStructure.worlditem.Position, Mathf.Infinity, 1)));

                //can't use WaitForSeconds because timescale will be zero
                double waitUntil = WorldClock.RealTime + 0.1f;
                while (WorldClock.RealTime < waitUntil)
                {
                    yield return(null);
                }
            }

            WorldItem bedWorldItem = bedWorldItems [0];

            while (!bedWorldItem.Is(WILoadState.Initialized))
            {
                yield return(null);
            }
            loadedBed = bedWorldItem.Get <Bed> ();
            //Player.Local.Position = loadedBed.BedsidePosition;
            mSpawningPlayer = false;
            mSpawnStructureWorldItem.ActiveStateLocked = false;
            OnFinishAction(loadedBed);
            Player.Local.Surroundings.StructureEnter(spawnStructure);
            yield break;
        }
示例#15
0
        public bool ReadChapter(int chapterNumber, out Chapter chapter)
        {
            if (!mHasGeneratedChapters)
            {
                BuildBookChapters();
            }

            if (chapterNumber < 0 || chapterNumber >= BookChapters.Count)
            {
                chapter = null;
                return(false);
            }

            if (chapterNumber > LastChapterRead)
            {
                LastChapterRead = chapterNumber;
            }

            chapter = BookChapters[chapterNumber];

            if (chapter.MissionsToActivate.Count > 0)
            {
                if (chapter.MissionsToActivate.Count > 1)
                {
                    //if we have more than one mission to activate
                    //we ignore any objectives and just activate the missions
                    //(i don't like this but the format is locked so whatever)
                    foreach (string missionToActivate in chapter.MissionsToActivate)
                    {
                        Missions.Get.ActivateMission(missionToActivate, MissionOriginType.Book, Name);
                    }
                }
                else
                {
                    string missionToActivate = chapter.MissionsToActivate[0];
                    if (chapter.MissionObjectivesToActivate.Count > 0)
                    {
                        //activate the objectives instead of the mission
                        foreach (string objectiveToActivate in chapter.MissionObjectivesToActivate)
                        {
                            Missions.Get.ActivateObjective(missionToActivate, objectiveToActivate, MissionOriginType.Book, Name);
                        }
                    }
                    else
                    {
                        //otherwise just activate the mission
                        Missions.Get.ActivateMission(missionToActivate, MissionOriginType.Book, Name);
                    }
                }
            }

            foreach (string blueprintToReveal in chapter.BlueprintsToReveal)
            {
                Blueprints.Get.Reveal(blueprintToReveal, BlueprintRevealMethod.Book, CleanTitle);
            }
            foreach (string skillToLearn in chapter.SkillsToLearn)
            {
                Skills.LearnSkill(skillToLearn);
            }
            foreach (string skillToReveal in chapter.SkillsToReveal)
            {
                Skills.RevealSkill(skillToReveal);
            }
            foreach (string locationToReveal in chapter.LocationsToReveal)
            {
                MobileReference mr = new MobileReference(locationToReveal);
                Player.Local.Surroundings.Reveal(mr);
                Profile.Get.CurrentGame.MarkedLocations.SafeAdd(mr);
            }
            foreach (string structureToAquire in chapter.StructuresToAquire)
            {
                MobileReference mr = new MobileReference(structureToAquire);
                Player.Local.Inventory.AcquireStructure(mr, true);
            }

            //this is now done in the chapter on the fly
            //chapter.Contents = Frontiers.Data.GameData.InterpretScripts (chapter.Contents, Profile.Get.CurrentGame.Character.Gender, null);

            //if (chapterNumber == mBookChapters.LastIndex()) {
            //TODO temp - book reading will go back to chapter-based eventually
            OnFullyRead();
            //}

            return(true);
        }
示例#16
0
    protected void DrawMobileReference(MobileReference mr)
    {                           //TODO move this to Frontiers.Data, this is actually useful
        bool stretchWidthBeforeEntry = miniButtonStyle.stretchWidth;

        miniButtonStyle.stretchWidth = false;
        GUI.color = Color.yellow;

        string         finalPath           = string.Empty;
        Stack <string> newGroupStack       = new Stack <string>();
        Stack <string> groupMinusLast      = new Stack <string>();
        bool           doLastGroupDropDown = false;
        bool           doChildItemDropDown = false;

        if (string.IsNullOrEmpty(mr.GroupPath))
        {
            mr.GroupPath = "Root";
        }
        Stack <string> splitGroup = WIGroup.SplitPath(mr.GroupPath);
        //it's always root
        string lastGroupInPath = string.Empty;

        if (splitGroup.Count == 1)
        {
            lastGroupInPath = splitGroup.Pop();
            groupMinusLast.Push(lastGroupInPath);
            newGroupStack.Push(lastGroupInPath);
            GUILayout.Button(lastGroupInPath, miniButtonStyle);
        }
        else
        {
            while (splitGroup.Count > 0)
            {
                lastGroupInPath = splitGroup.Pop();
                if (splitGroup.Count > 0)                                                       //if there's still at least one more to go...
                //add it to both stacks
                {
                    groupMinusLast.Push(lastGroupInPath);
                    newGroupStack.Push(lastGroupInPath);
                    doLastGroupDropDown = true;
                    GUILayout.Button(lastGroupInPath, miniButtonStyle);
                }
            }
        }

        bool   madeGroupSelection = false;
        string newGroupSelection  = string.Empty;
        string groupPathMinusLast = WIGroup.CombinePath(groupMinusLast);

        if (doLastGroupDropDown)
        {
            //get the path of the group, minus the last group
            List <string> currentGroups = Mods.Get.Editor.GroupChildGroupNames(groupPathMinusLast);
            if (currentGroups.Count > 0)
            {
                GUI.color = Color.Lerp(Color.yellow, Color.gray, 0.5f);
                int indexOfLastGroup = currentGroups.IndexOf(lastGroupInPath);
                if (indexOfLastGroup < 0)
                {
                    indexOfLastGroup = 0;
                }
                int indexOfGroupSelection = EditorGUILayout.Popup(indexOfLastGroup, currentGroups.ToArray());
                if (indexOfGroupSelection >= 0 && indexOfGroupSelection < currentGroups.Count)
                {
                    newGroupSelection  = currentGroups[indexOfGroupSelection];
                    madeGroupSelection = true;
                }
            }
        }

        //if we picked a new group add the selected group
        //otherwise just add the old group
        if (madeGroupSelection)
        {
            newGroupStack.Push(newGroupSelection);
        }
        else
        {
            newGroupStack.Push(lastGroupInPath);
        }

        List <string> nextGroups = Mods.Get.Editor.GroupChildGroupNames(mr.GroupPath);

        if (nextGroups.Count > 0)
        {
            GUI.color = Color.green;
            if (GUILayout.Button("+", miniButtonStyle))                                         //if we click the add button, change the group
            {
                newGroupStack.Push(nextGroups[0]);
            }
        }

        finalPath = WIGroup.CombinePath(newGroupStack);

        GUI.color = Color.red;
        if (GUILayout.Button("-", miniButtonStyle))
        {
            //set the last group path to the one BEFORE the current last
            finalPath = groupPathMinusLast;
        }

        mr.GroupPath = finalPath;

        miniButtonStyle.stretchWidth = true;
        GUI.color = Color.white;
        //now get all child items
        List <string> childItemsInGroup = Mods.Get.Editor.GroupChildItemNames(mr.GroupPath);

        if (childItemsInGroup.Count == 0)
        {
            GUILayout.Label("(No child items)");
        }
        else
        {
            string newChildItemSelection = string.Empty;
            int    indexChildSelection   = childItemsInGroup.IndexOf(mr.FileName);
            if (indexChildSelection < 0)
            {
                indexChildSelection = 0;
            }
            int indexOfChildItemSelection = EditorGUILayout.Popup(indexChildSelection, childItemsInGroup.ToArray());
            if (indexOfChildItemSelection >= 0 && indexOfChildItemSelection < childItemsInGroup.Count)
            {
                newChildItemSelection = childItemsInGroup[indexOfChildItemSelection];
                mr.FileName           = newChildItemSelection;
            }
        }

        //mr.GroupPath = newGroupPath;
        //mr.FileName = newChildItemSelection;

        miniButtonStyle.stretchWidth = stretchWidthBeforeEntry;
    }