Example #1
0
        public void RemoveType(ref MyDefinitionId resourceType)
        {
            if (!m_resourceIds.Contains(resourceType))
            {
                return;
            }

            if (OnRemoveType != null)
            {
                OnRemoveType(this, resourceType);
            }

            var newDataPerType   = new PerTypeData[m_resourceIds.Count - 1];
            int typeIndex        = GetTypeIndex(resourceType);
            int destinationIndex = 0;

            for (int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex, ++destinationIndex)
            {
                if (dataIndex == typeIndex)
                {
                    continue;
                }

                newDataPerType[destinationIndex] = m_dataPerType[dataIndex];
            }
            m_dataPerType = newDataPerType;
            m_resourceIds.Remove(resourceType);
            m_resourceTypeToIndex.Remove(resourceType);
        }
Example #2
0
        public void AddType(ref MyResourceSinkInfo sinkData)
        {
            if (m_resourceIds.Contains(sinkData.ResourceTypeId) || m_resourceTypeToIndex.ContainsKey(sinkData.ResourceTypeId))
            {
                return;
            }

            var newDataPerType = new PerTypeData[m_resourceIds.Count + 1];

            for (int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex)
            {
                newDataPerType[dataIndex] = m_dataPerType[dataIndex];
            }
            m_dataPerType = newDataPerType;
            m_dataPerType[m_dataPerType.Length - 1] = new PerTypeData
            {
                MaxRequiredInput  = sinkData.MaxRequiredInput,
                RequiredInputFunc = sinkData.RequiredInputFunc
            };
            m_resourceIds.Add(sinkData.ResourceTypeId);
            m_resourceTypeToIndex.Add(sinkData.ResourceTypeId, m_dataPerType.Length - 1);
            if (OnAddType != null)
            {
                OnAddType(this, sinkData.ResourceTypeId);
            }
        }
        public void AddType(ref MyResourceSinkInfo sinkData)
        {
            var newDataPerType = new PerTypeData[m_dataPerType.Length + 1];

            for (int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex)
            {
                newDataPerType[dataIndex] = m_dataPerType[dataIndex];
            }
            m_dataPerType = newDataPerType;
            m_dataPerType[m_dataPerType.Length - 1] = new PerTypeData
            {
                MaxRequiredInput  = sinkData.MaxRequiredInput,
                RequiredInputFunc = sinkData.RequiredInputFunc
            };
            m_resourceIds.Add(sinkData.ResourceTypeId);
            m_resourceTypeToIndex.Add(sinkData.ResourceTypeId, m_dataPerType.Length - 1);
            OnAddType(this);
        }
Example #4
0
        private void FillMarkedActions(HashSet <FinalizeAction> actions, IEnumerable <TileData> subDatas = null)
        {
            foreach (var kvp in dict)
            {
                FinalizeAction action      = kvp.Key;
                PerTypeData    perTypeData = kvp.Value;

                if (perTypeData.markRe && !actions.Contains(action))
                {
                    actions.Add(action);
                }
            }

            if (subDatas != null)
            {
                foreach (TileData subData in subDatas)
                {
                    subData.finalize.FillMarkedActions(actions, subDatas: subData.subDatas);
                }
            }
        }
Example #5
0
        private PerTypeData Type(MyDefinitionId id)
        {
            PerTypeData res;

            if (!_sinks.TryGetValue(id, out res))
            {
                _sinks.Add(id, res = new PerTypeData());
                var root = _resourceSink.Value;
                if (root != null)
                {
                    var info = new MyResourceSinkInfo()
                    {
                        MaxRequiredInput  = res.CalculateMaxInput(),
                        RequiredInputFunc = res.DelCalculateRequiredInput,
                        ResourceTypeId    = id
                    };
                    root.AddType(ref info);
                }
            }

            return(res);
        }
Example #6
0
        public void Add(FinalizeAction action, IOutput output, object product, MatrixWorld biomeMask)
        /// Adding new finalize data and marking finalize type to re-generate
        {
            PerTypeData perTypeData;

            if (!dict.TryGetValue(action, out perTypeData))
            {
                perTypeData = new PerTypeData();
                dict.Add(action, perTypeData);
            }

            if (!perTypeData.perOutputProducts.ContainsKey(output))
            {
                perTypeData.perOutputProducts.Add(output, (product, biomeMask));
            }
            else
            {
                perTypeData.perOutputProducts[output] = (product, biomeMask);
            }

            perTypeData.markRe = true;
        }
        public void RemoveType(ref MyDefinitionId resourceType)
        {
            if(!m_resourceIds.Contains(resourceType))
                return;

            if (OnRemoveType != null)
                OnRemoveType(this, resourceType);

            var newDataPerType = new PerTypeData[m_resourceIds.Count - 1];
            int typeIndex = GetTypeIndex(resourceType);
            int destinationIndex = 0;
            for(int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex, ++destinationIndex)
            {
                if (dataIndex == typeIndex)
                    continue;

                newDataPerType[destinationIndex] = m_dataPerType[dataIndex];
            }
            m_dataPerType = newDataPerType;
            m_resourceIds.Remove(resourceType);
            m_resourceTypeToIndex.Remove(resourceType);
        }
	    public void AddType(ref MyResourceSinkInfo sinkData)
	    {
            if (m_resourceIds.Contains(sinkData.ResourceTypeId) || m_resourceTypeToIndex.ContainsKey(sinkData.ResourceTypeId))
                return;

            var newDataPerType = new PerTypeData[m_resourceIds.Count + 1];
	        for (int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex)
	        {
	            newDataPerType[dataIndex] = m_dataPerType[dataIndex];
	        }
	        m_dataPerType = newDataPerType;
	        m_dataPerType[m_dataPerType.Length - 1] = new PerTypeData
	        {
	            MaxRequiredInput = sinkData.MaxRequiredInput,
	            RequiredInputFunc = sinkData.RequiredInputFunc
	        };
            m_resourceIds.Add(sinkData.ResourceTypeId);
            m_resourceTypeToIndex.Add(sinkData.ResourceTypeId, m_dataPerType.Length - 1);
            if(OnAddType != null)
	            OnAddType(this, sinkData.ResourceTypeId);
	    }
	    public void AddType(ref MyResourceSinkInfo sinkData)
	    {
	        var newDataPerType = new PerTypeData[m_dataPerType.Length + 1];
	        for (int dataIndex = 0; dataIndex < m_dataPerType.Length; ++dataIndex)
	        {
	            newDataPerType[dataIndex] = m_dataPerType[dataIndex];
	        }
	        m_dataPerType = newDataPerType;
	        m_dataPerType[m_dataPerType.Length - 1] = new PerTypeData
	        {
	            MaxRequiredInput = sinkData.MaxRequiredInput,
	            RequiredInputFunc = sinkData.RequiredInputFunc
	        };
            m_resourceIds.Add(sinkData.ResourceTypeId);
            m_resourceTypeToIndex.Add(sinkData.ResourceTypeId, m_dataPerType.Length - 1);
	        OnAddType(this);
	    }