コード例 #1
0
 public GameObject GetUiPerson(Person person)
 {
     if (mUiPeopleMap.ContainsKey(person))
     {
         return(mUiPeopleMap.GetValue(person));
     }
     return(null);
 }
コード例 #2
0
 public GameObject GetUiDemand(GodDemand demand)
 {
     if (mUiDemandMap.ContainsKey(demand))
     {
         return(mUiDemandMap.GetValue(demand));
     }
     return(null);
 }
コード例 #3
0
        private static Optional <CodeStyleOption <ParenthesesPreference> > ParseParenthesesPreference(
            string optionString, Optional <CodeStyleOption <ParenthesesPreference> > defaultValue)
        {
            if (TryGetCodeStyleValueAndOptionalNotification(optionString,
                                                            out var value, out var notificationOpt))
            {
                Debug.Assert(s_parenthesesPreferenceMap.ContainsKey(value));
                return(new CodeStyleOption <ParenthesesPreference>(s_parenthesesPreferenceMap.GetValueOrDefault(value),
                                                                   notificationOpt ?? NotificationOption.Silent));
            }

            return(defaultValue);
        }
コード例 #4
0
    void UpdateRenderables <T>(
        List <T> renderables,
        GameObject newObject,
        List <GameObject> objectPool,
        BidirectionalMap <T, GameObject> renderableObjectMap,
        Transform uiContainer,
        System.Action <GameObject> onCreateCallback = null)
        where T : IRenderable
    {
        // Put all GameObjects in a set, and remove the objects that are still in used
        HashSet <GameObject> unusedObjects = new HashSet <GameObject>(renderableObjectMap.Values);

        foreach (T renderable in renderables)
        {
            GameObject uiObject;
            // Spawn new UI person
            if (!renderableObjectMap.ContainsKey(renderable))
            {
                if (objectPool.Count > 0)
                {
                    uiObject = objectPool[objectPool.Count - 1];
                    objectPool.RemoveAt(objectPool.Count - 1);
                    uiObject.SetActive(true);
                }
                else
                {
                    uiObject = Instantiate(newObject);
                }
                uiObject.transform.SetParent(uiContainer, false);
                renderableObjectMap.Add(renderable, uiObject);
                if (onCreateCallback != null)
                {
                    onCreateCallback(uiObject);
                }
            }
            else
            {
                uiObject = renderableObjectMap.GetValue(renderable);
                unusedObjects.Remove(uiObject);
            }
            renderable.RenderTo(uiObject);
        }
        foreach (GameObject uiObject in unusedObjects)
        {
            renderableObjectMap.RemoveValue(uiObject);
            objectPool.Add(uiObject);
            uiObject.SetActive(false);
            uiObject.transform.SetParent(null, false);
        }
    }
コード例 #5
0
        private static CodeStyleOption <AccessibilityModifiersRequired> ParseAccessibilityModifiersRequired(string optionString)
        {
            if (TryGetCodeStyleValueAndOptionalNotification(optionString,
                                                            out var value, out var notificationOpt))
            {
                if (value == "never")
                {
                    // If they provide 'never', they don't need a notification level.
                    notificationOpt = notificationOpt ?? NotificationOption.Silent;
                }

                if (notificationOpt != null)
                {
                    Debug.Assert(s_accessibilityModifiersRequiredMap.ContainsKey(value));
                    return(new CodeStyleOption <AccessibilityModifiersRequired>(s_accessibilityModifiersRequiredMap.GetValueOrDefault(value), notificationOpt));
                }
            }

            return(s_requireAccessibilityModifiersDefault);
        }