/// <summary>
        /// Create a new instanced area, or return one from the free list if
        /// there was a free instance.
        /// </summary>
        /// <param name="TemplateArea">Supplies the template area object id.
        /// </param>
        /// <returns>The instanced area, else OBJECT_INVALID.</returns>
        private uint CreateAreaInstance(uint TemplateArea)
        {
            Stack <uint> FreeList;

            if (InstancedAreaFreeList.TryGetValue(TemplateArea, out FreeList))
            {
                if (FreeList.Count != 0)
                {
                    return(FreeList.Pop());
                }
            }

            uint AreaObject = CreateInstancedAreaFromSource(TemplateArea);

            if (AreaObject == OBJECT_INVALID)
            {
                return(OBJECT_INVALID);
            }

            //
            // We've created a new area, so inform the AI subsystem that there
            // is a new area to add to its representation.
            //

            ClearScriptParams();
            AddScriptParameterInt(200); // AREA_ON_INSTANCE_CREATE
            ExecuteScriptEnhanced("ACR_CreatureBehavior", AreaObject, TRUE);

            return(AreaObject);
        }
Esempio n. 2
0
    AudioSource GetFreeSource(AudioClip clip)
    {
        AudioSource source = null;

        if (FreeList.Count > 0)
        {
            source         = FreeList.Pop();
            source.enabled = true;
        }
        else
        {
            source = NewSource();
        }

        source.gameObject.SetActive(true);
        source.volume = volume;
        source.clip   = clip;
        source.name   = clip.name;

        PlayingList.Add(source);
        PlayingList.Sort(SortByEndTime);
        m_NeedToNormalize = true;
        return(source);
    }
Esempio n. 3
0
 internal static StackFrame Alloc(ScriptMethodBase scriptMethod, params object[] param)
 {
     return(FreeList.Count == 0 ? new StackFrame().Init(scriptMethod, param) : FreeList.Pop().Init(scriptMethod, param));
 }