Пример #1
0
 //We don't need to check index as that's already done further up the chain
 void DespawnCallback(bool initial, int index, BeatmapObject objectData)
 {
     try //"Index was out of range. Must be non-negative and less than the size of the collection." Huh?
     {
         BeatmapObjectContainer e = LoadedContainers[index];
         e.SafeSetActive(false);
     }
     catch { }
 }
Пример #2
0
 void SpawnCallback(bool initial, int index, BeatmapObject objectData)
 {
     try
     {
         BeatmapObjectContainer e = LoadedContainers[index];
         e.SafeSetActive(true);
     }
     catch { }
 }
Пример #3
0
    //We don't need to check index as that's already done further up the chain
    void SpawnCallback(bool initial, int index, BeatmapObject objectData)
    {
        BeatmapObjectContainer e = LoadedContainers[index];

        if (e.PreviousActiveState != true)
        {
            e.gameObject.SetActive(true);
            e.SafeSetActive(true);
        }
    }
    /// <summary>
    /// Recycles the container belonging to a provided <see cref="BeatmapObject"/>, putting it back into the container pool for future use.
    /// </summary>
    /// <param name="obj">Object whose container will be recycled.</param>
    protected void RecycleContainer(BeatmapObject obj)
    {
        if (!obj.HasAttachedContainer)
        {
            return;
        }
        //Debug.Log($"Recycling container with hash code {obj.GetHashCode()}");
        BeatmapObjectContainer container = LoadedContainers[obj];

        container.objectData = null;
        container.SafeSetActive(false);
        //container.transform.SetParent(PoolTransform);
        LoadedContainers.Remove(obj);
        PooledContainers.Enqueue(container);
        OnContainerDespawn(container, obj);
        obj.HasAttachedContainer = false;
    }
    /// <summary>
    /// Dequeues a container from the pool and attaches it to a provided <see cref="BeatmapObject"/>
    /// </summary>
    /// <param name="obj">Object to store within the container.</param>
    protected void CreateContainerFromPool(BeatmapObject obj)
    {
        if (obj.HasAttachedContainer)
        {
            return;
        }
        //Debug.Log($"Creating container with hash code {obj.GetHashCode()}");
        if (!PooledContainers.Any())
        {
            CreateNewObject();
        }
        BeatmapObjectContainer dequeued = PooledContainers.Dequeue();

        dequeued.objectData = obj;
        dequeued.transform.localEulerAngles = Vector3.zero;
        dequeued.UpdateGridPosition();
        dequeued.SafeSetActive(true);
        UpdateContainerData(dequeued, obj);
        dequeued.OutlineVisible = SelectionController.IsObjectSelected(obj);
        PluginLoader.BroadcastEvent <ObjectLoadedAttribute, BeatmapObjectContainer>(dequeued);
        LoadedContainers.Add(obj, dequeued);
        obj.HasAttachedContainer = true;
        OnContainerSpawn(dequeued, obj);
    }
Пример #6
0
    //We don't need to check index as that's already done further up the chain
    void DespawnCallback(bool initial, int index, BeatmapObject objectData)
    {
        BeatmapObjectContainer e = LoadedContainers[index];

        e.SafeSetActive(false);
    }