private void RefreshRooms()
    {
        int maxRoomSize = TuningData <Tuning> .Get().maxRoomSize;

        foreach (CavityInfo data in cavityInfos.GetDataList())
        {
            if (data.dirty)
            {
                Debug.Assert(data.room == null, "I expected info.room to always be null by this point");
                if (data.numCells > 0)
                {
                    if (data.numCells <= maxRoomSize)
                    {
                        CreateRoom(data);
                    }
                    foreach (KPrefabID building in data.buildings)
                    {
                        building.Trigger(144050788, data.room);
                    }
                    foreach (KPrefabID plant in data.plants)
                    {
                        plant.Trigger(144050788, data.room);
                    }
                }
                data.dirty = false;
            }
        }
        dirty = false;
    }
Esempio n. 2
0
    public override void Update(float dt)
    {
        List <Entry> dataList = entries.GetDataList();

        foreach (HandleVector <int> .Handle pendingRemoval in pendingRemovals)
        {
            entries.Free(pendingRemoval);
        }
        pendingRemovals.Clear();
        if (batch_update_delegate != null)
        {
            batch_update_delegate(dataList, dt);
        }
        else
        {
            int count = dataList.Count;
            for (int i = 0; i < count; i++)
            {
                Entry value = dataList[i];
                if (value.updater != null)
                {
                    value.updater.Update(value.data, dt - value.lastUpdateTime);
                    value.lastUpdateTime = 0f;
                    dataList[i]          = value;
                }
            }
        }
    }
 private void GatherPickupablesWhichCanBePickedUp(GameObject worker_go)
 {
     pickupsWhichCanBePickedUp.Clear();
     foreach (Fetchable data in fetchables.GetDataList())
     {
         Fetchable  current    = data;
         Pickupable pickupable = current.pickupable;
         if (pickupable.CouldBePickedUpByMinion(worker_go))
         {
             pickupsWhichCanBePickedUp.Add(new Pickup
             {
                 pickupable     = pickupable,
                 tagBitsHash    = current.tagBitsHash,
                 PathCost       = 65535,
                 masterPriority = current.masterPriority,
                 freshness      = current.freshness,
                 foodQuality    = current.foodQuality
             });
         }
     }
 }
 private static void CollectSortedClearables(Navigator navigator, KCompactedVector <MarkedClearable> clearables, List <SortedClearable> sorted_clearables)
 {
     sorted_clearables.Clear();
     foreach (MarkedClearable data in clearables.GetDataList())
     {
         MarkedClearable current        = data;
         int             navigationCost = current.pickupable.GetNavigationCost(navigator, current.pickupable.cachedCell);
         if (navigationCost != -1)
         {
             sorted_clearables.Add(new SortedClearable
             {
                 pickupable     = current.pickupable,
                 masterPriority = current.prioritizable.GetMasterPriority(),
                 cost           = navigationCost
             });
         }
     }
     sorted_clearables.Sort(SortedClearable.comparer);
 }
Esempio n. 5
0
    public void RenderEveryTick(float dt)
    {
        ListPool <Sound, LoopingSoundManager> .PooledList pooledList = ListPool <Sound, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList2 = ListPool <int, LoopingSoundManager> .Allocate();

        ListPool <int, LoopingSoundManager> .PooledList pooledList3 = ListPool <int, LoopingSoundManager> .Allocate();

        List <Sound> dataList    = sounds.GetDataList();
        bool         flag        = Time.timeScale == 0f;
        SoundCuller  soundCuller = CameraController.Instance.soundCuller;

        for (int i = 0; i < dataList.Count; i++)
        {
            Sound sound = dataList[i];
            if ((UnityEngine.Object)sound.transform != (UnityEngine.Object)null)
            {
                sound.pos = sound.transform.GetPosition();
                if ((UnityEngine.Object)sound.animController != (UnityEngine.Object)null)
                {
                    Vector3 offset = sound.animController.Offset;
                    sound.pos.x += offset.x;
                    sound.pos.y += offset.y;
                }
            }
            bool flag2     = !sound.IsCullingEnabled || (sound.ShouldCameraScalePosition && soundCuller.IsAudible(sound.pos, sound.falloffDistanceSq)) || soundCuller.IsAudibleNoCameraScaling(sound.pos, sound.falloffDistanceSq);
            bool isPlaying = sound.IsPlaying;
            if (flag2)
            {
                pooledList.Add(sound);
                if (!isPlaying)
                {
                    SoundDescription soundDescription = GetSoundDescription(sound.path);
                    sound.ev    = KFMOD.CreateInstance(soundDescription.path);
                    dataList[i] = sound;
                    pooledList2.Add(i);
                }
            }
            else if (isPlaying)
            {
                pooledList3.Add(i);
            }
        }
        LoopingSoundParameterUpdater.Sound sound2;
        foreach (int item in pooledList2)
        {
            Sound            value             = dataList[item];
            SoundDescription soundDescription2 = GetSoundDescription(value.path);
            value.ev.setPaused(flag && value.ShouldPauseOnGamePaused);
            Vector2 v = value.pos;
            if (value.ShouldCameraScalePosition)
            {
                v = SoundEvent.GetCameraScaledPosition(v);
            }
            value.ev.set3DAttributes(RuntimeUtils.To3DAttributes(v));
            value.ev.start();
            value.flags |= Sound.Flags.PLAYING;
            if (value.firstParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.firstParameter), value.firstParameterValue);
            }
            if (value.secondParameter != HashedString.Invalid)
            {
                value.ev.setParameterValueByIndex(soundDescription2.GetParameterIdx(value.secondParameter), value.secondParameterValue);
            }
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value.ev;
            sound2.path        = value.path;
            sound2.description = soundDescription2;
            sound2.transform   = value.transform;
            LoopingSoundParameterUpdater.Sound sound3     = sound2;
            SoundDescription.Parameter[]       parameters = soundDescription2.parameters;
            for (int j = 0; j < parameters.Length; j++)
            {
                SoundDescription.Parameter   parameter = parameters[j];
                LoopingSoundParameterUpdater value2    = null;
                if (parameterUpdaters.TryGetValue(parameter.name, out value2))
                {
                    value2.Add(sound3);
                }
            }
            dataList[item] = value;
        }
        pooledList2.Recycle();
        foreach (int item2 in pooledList3)
        {
            Sound            value3            = dataList[item2];
            SoundDescription soundDescription3 = GetSoundDescription(value3.path);
            sound2             = default(LoopingSoundParameterUpdater.Sound);
            sound2.ev          = value3.ev;
            sound2.path        = value3.path;
            sound2.description = soundDescription3;
            sound2.transform   = value3.transform;
            LoopingSoundParameterUpdater.Sound sound4      = sound2;
            SoundDescription.Parameter[]       parameters2 = soundDescription3.parameters;
            for (int k = 0; k < parameters2.Length; k++)
            {
                SoundDescription.Parameter   parameter2 = parameters2[k];
                LoopingSoundParameterUpdater value4     = null;
                if (parameterUpdaters.TryGetValue(parameter2.name, out value4))
                {
                    value4.Remove(sound4);
                }
            }
            if (value3.ShouldCameraScalePosition)
            {
                value3.ev.stop(STOP_MODE.IMMEDIATE);
            }
            else
            {
                value3.ev.stop(STOP_MODE.ALLOWFADEOUT);
            }
            value3.flags &= ~Sound.Flags.PLAYING;
            value3.ev.release();
            dataList[item2] = value3;
        }
        pooledList3.Recycle();
        float velocityScale = TuningData <Tuning> .Get().velocityScale;

        foreach (Sound item3 in pooledList)
        {
            Sound         current3   = item3;
            ATTRIBUTES_3D attributes = SoundEvent.GetCameraScaledPosition(current3.pos).To3DAttributes();
            attributes.velocity = (current3.velocity * velocityScale).ToFMODVector();
            current3.ev.set3DAttributes(attributes);
        }
        foreach (KeyValuePair <HashedString, LoopingSoundParameterUpdater> parameterUpdater in parameterUpdaters)
        {
            parameterUpdater.Value.Update(dt);
        }
        pooledList.Recycle();
    }