예제 #1
0
 public void SaveConfigXml(XmlNode busNode)
 {
     //LogAgent.Debug("time begin BusManager.SaveConfig");
     if (!string.IsNullOrEmpty(Name))
     {
         var el = (XmlElement)busNode;
         el.SetAttribute("name", Name);
     }
     if (ModelId != ModelId.None)
     {
         var el = (XmlElement)busNode;
         el.SetAttribute("modelId", ModelId.ToString());
     }
     foreach (var device in m_deviceList)
     {
         try
         {
             var type         = device.GetType();
             var fullTypeName = GetNameByType(type);
             var xe           = busNode.OwnerDocument.CreateElement("Device");
             xe.SetAttribute("type", fullTypeName);
             if (!CheckIsLocalAssembly(type.Assembly))
             {
                 // non local assembly
                 xe.SetAttribute("assembly", type.Assembly.Location);
             }
             var node = busNode.AppendChild(xe);
             device.SaveConfigXml(node);
         }
         catch (Exception ex)
         {
             Logger.Error(ex);
         }
     }
     //LogAgent.Debug("time end BusManager.SaveConfig");
 }
        public bool DisableInstance(int sectorInstanceId, ModelId modelId)
        {
            MyModelInstanceData instanceData = null;
            m_instanceParts.TryGetValue(modelId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
            if (instanceData == null) return false;

            Debug.Assert(instanceData.InstanceData.Count > sectorInstanceId, "Disabling invalid instance in environment item sector!");
            if (instanceData.InstanceData.Count <= sectorInstanceId) return false;

            var data = instanceData.InstanceData[sectorInstanceId];
            data.InstanceData.LocalMatrix = Matrix.Zero;
            instanceData.InstanceData[sectorInstanceId] = data;

            instanceData.FreeInstances.Enqueue(sectorInstanceId);
            m_sectorItemCount--;
            m_invalidateAABB = true;

            return true;
        }
        public void UpdateRenderInstanceData(ModelId modelId)
        {
            using (m_instancePartsLock.AcquireSharedUsing())
            {
                MyModelInstanceData instanceData = null;
                m_instanceParts.TryGetValue(modelId, out instanceData);
                Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
                if (instanceData == null) return;

                instanceData.UpdateRenderInstanceData();
            }
        }
        public bool DisableInstance(int sectorInstanceId, ModelId modelId)
        {
            MyModelInstanceData instanceData = null;
            m_instanceParts.TryGetValue(modelId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
            if (instanceData == null)
            {
                return false;
            }

            if (instanceData.DisableInstance(sectorInstanceId))
            {
                m_sectorItemCount--;
                m_invalidateAABB = true;

                return true;
            }
            return false;
        }
        public void UpdateRenderInstanceData(ModelId modelId)
        {
            using (m_instancePartsLock.AcquireSharedUsing())
            {
                MyModelInstanceData instanceData = null;
                m_instanceParts.TryGetValue(modelId, out instanceData);
                Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
                if (instanceData == null)
                {
                    return;
                }

                instanceData.UpdateRenderInstanceData();
            }
        }
        public bool DisableInstance(int sectorInstanceId, ModelId modelId)
        {
            MyModelInstanceData instanceData = null;

            m_instanceParts.TryGetValue(modelId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
            if (instanceData == null)
            {
                return(false);
            }

            if (instanceData.DisableInstance(sectorInstanceId))
            {
                m_sectorItemCount--;
                m_invalidateAABB = true;

                return(true);
            }
            return(false);
        }
예제 #7
0
        public bool DisableInstance(int sectorInstanceId, ModelId modelId)
        {
            MyModelInstanceData instanceData = null;

            m_instanceParts.TryGetValue(modelId, out instanceData);
            Debug.Assert(instanceData != null, "Could not find instance data in a sector for model " + modelId.ToString());
            if (instanceData == null)
            {
                return(false);
            }

            Debug.Assert(instanceData.InstanceData.Count > sectorInstanceId, "Disabling invalid instance in environment item sector!");
            if (instanceData.InstanceData.Count <= sectorInstanceId)
            {
                return(false);
            }

            var data = instanceData.InstanceData[sectorInstanceId];

            data.InstanceData.LocalMatrix = Matrix.Zero;
            instanceData.InstanceData[sectorInstanceId] = data;

            instanceData.FreeInstances.Enqueue(sectorInstanceId);
            m_sectorItemCount--;
            m_invalidateAABB = true;

            return(true);
        }
예제 #8
0
파일: Model.cs 프로젝트: Tsuguri/CadCat
 public virtual string GetName()
 {
     return(ModelId.ToString());
 }