Пример #1
0
    public List <KeyValuePair <DecorationDefinition, int> > GetAvailableDecorations()
    {
        HashSet <string> hashSet = new HashSet <string>();

        if (cachedCalculatedDecorationInventory == null)
        {
            if (decorationInventory == null)
            {
                Log.LogError(this, "Attempting to access the Decoration inventory before it is loaded");
                return(new List <KeyValuePair <DecorationDefinition, int> >());
            }
            if (sceneLayout == null)
            {
                Log.LogError(this, "Attempting to access the Decoration inventory before scene is loaded");
                return(new List <KeyValuePair <DecorationDefinition, int> >());
            }
            cachedAvailableDecorationCounts = new Dictionary <int, int>(decorationInventory.Decorations);
            foreach (DecorationLayoutData item in sceneLayout.GetLayoutEnumerator())
            {
                DecorationLayoutData current = item;
                bool flag = true;
                if (current.Type == DecorationLayoutData.DefinitionType.Decoration && cachedAvailableDecorationCounts.ContainsKey(current.DefinitionId))
                {
                    if (current.CustomProperties.ContainsKey("partner") && current.CustomProperties.ContainsKey("guid"))
                    {
                        flag = !hashSet.Contains(current.CustomProperties["partner"]);
                        hashSet.Add(current.CustomProperties["guid"]);
                    }
                    if (flag)
                    {
                        Dictionary <int, int> dictionary;
                        int definitionId;
                        (dictionary = cachedAvailableDecorationCounts)[definitionId = current.DefinitionId] = dictionary[definitionId] - 1;
                    }
                }
            }
            cachedCalculatedDecorationInventory = new List <KeyValuePair <DecorationDefinition, int> >();
            foreach (KeyValuePair <int, int> cachedAvailableDecorationCount in cachedAvailableDecorationCounts)
            {
                if (decorationDefinitions.ContainsKey(cachedAvailableDecorationCount.Key))
                {
                    cachedCalculatedDecorationInventory.Add(new KeyValuePair <DecorationDefinition, int>(decorationDefinitions[cachedAvailableDecorationCount.Key], cachedAvailableDecorationCount.Value));
                }
            }
        }
        return(cachedCalculatedDecorationInventory);
    }
 private void modifyObjectManipulators(Action <GameObject, DecorationLayoutData> modify)
 {
     foreach (DecorationLayoutData item in SceneLayoutData.GetLayoutEnumerator())
     {
         Transform obj = sceneLayoutContainer;
         DecorationLayoutData.ID id = item.Id;
         Transform transform        = obj.Find(id.GetFullPath());
         if (!(transform == null))
         {
             modify(transform.gameObject, item);
         }
     }
 }
 public static void ConvertToMutableSceneLayout(MutableSceneLayout mutableSceneLayout, SceneLayoutData sceneLayoutData)
 {
     mutableSceneLayout.zoneId            = sceneLayoutData.LotZoneName;
     mutableSceneLayout.lightingId        = sceneLayoutData.LightingId;
     mutableSceneLayout.musicId           = sceneLayoutData.MusicTrackId;
     mutableSceneLayout.extraInfo         = sceneLayoutData.ExtraInfo;
     mutableSceneLayout.decorationsLayout = new List <DecorationLayout>();
     foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator())
     {
         DecorationLayout        item = default(DecorationLayout);
         ref DecorationLayout.Id id   = ref item.id;
         DecorationLayoutData.ID id2  = item2.Id;
         id.name = id2.Name;
         ref DecorationLayout.Id id3 = ref item.id;
    internal override List <KeyValuePair <DecorationDefinition, int> > GetDefinitionsToDisplay()
    {
        List <KeyValuePair <DecorationDefinition, int> > list = new List <KeyValuePair <DecorationDefinition, int> >();

        if (sceneLayoutData != null)
        {
            foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator())
            {
                DecorationLayoutData current = item2;
                if (current.Type == DecorationLayoutData.DefinitionType.Decoration && dictionaryOfDecorationDefinitions.ContainsKey(current.DefinitionId))
                {
                    DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[current.DefinitionId];
                    int availableDecorationCount = SceneRefs.Get <SceneManipulationService>().GetAvailableDecorationCount(decorationDefinition.Id);
                    KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        if (SceneRefs.IsSet <SceneManipulationService>())
        {
            SceneManipulationService sceneManipulationService = SceneRefs.Get <SceneManipulationService>();
            if (sceneManipulationService.IsObjectSelectedForAdd)
            {
                ObjectManipulator currentObjectManipulator = sceneManipulationService.ObjectManipulationInputController.CurrentObjectManipulator;
                if (currentObjectManipulator != null)
                {
                    int definitionId = currentObjectManipulator.GetComponent <ManipulatableObject>().DefinitionId;
                    DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[definitionId];
                    int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(decorationDefinition.Id);
                    KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount);
                    if (!list.Contains(item))
                    {
                        list.Add(item);
                    }
                }
            }
        }
        return(list);
    }