Exemple #1
0
        protected IEnumerator SleepingOverTime(Bed bed)
        {
            //first go to the bed sleep point
            //TODO make this a motile action
            worlditem.tr.position = bed.SleepingPosition;
            Motile motile = null;

            if (worlditem.Is <Motile> (out motile))
            {
                mSleepAction.Reset();
                mSleepAction.IdleAnimation = GameWorld.Get.FlagByName("IdleAnimation", "Sleeping");
                motile.PushMotileAction(mSleepAction, MotileActionPriority.ForceTop);
                //let them sleep zzzzz
                yield return(mSleepAction.WaitForActionToFinish(0.25f));

                //once we wake up, if the bed is not null
                //clear its occupant!
                if (bed != null)
                {
                    bed.Occupant = null;
                }
            }
            mIsSleeping = false;
            yield break;
        }
Exemple #2
0
 public void SleepInBed(Bed bed)
 {
     if (!mIsSleeping)
     {
         mIsSleeping = true;
         StartCoroutine(SleepingOverTime(bed));
     }
 }
Exemple #3
0
        public IEnumerator SendPlayerToHealingBed()
        {
            worlditem.ActiveState = WIActiveState.Active;
            Structure structure = worlditem.Get <Structure>();

            while (!structure.Is(StructureLoadState.ExteriorLoaded))
            {
                yield return(null);
            }
            Structures.AddInteriorToLoad(structure);
            while (!structure.Is(StructureLoadState.InteriorLoaded))
            {
                yield return(null);
            }
            Player.Local.Spawn();
            //find the first bed
            List <WorldItem> bedWorldItems = structure.StructureGroup.GetChildrenOfType(new List <string>()
            {
                "Bed"
            });

            while (bedWorldItems.Count == 0)
            {
                double waitUntil = Frontiers.WorldClock.AdjustedRealTime + 0.1f;
                while (Frontiers.WorldClock.AdjustedRealTime < waitUntil)
                {
                    yield return(null);
                }
                bedWorldItems = structure.StructureGroup.GetChildrenOfType(new List <string>()
                {
                    "Bed"
                });
            }
            WorldItem bedWorldItem = bedWorldItems[UnityEngine.Random.Range(0, bedWorldItems.Count)];
            Bed       bed          = bedWorldItem.Get <Bed>();

            Player.Local.transform.position = bed.BedsidePosition;
            bed.TryToSleep(WorldClock.Get.TimeOfDayAfter(WorldClock.TimeOfDayCurrent));
            yield break;
        }