public override void CopyFrom(CAsset source) { base.CopyFrom(source); CEntityAsset <T> sourceAsset = (CEntityAsset <T>)source; m_entityJson = sourceAsset.m_entityJson; }
public override void CopyFrom(CAsset source) { base.CopyFrom(source); CKlaxScriptInterfaceAsset interfaceAsset = (CKlaxScriptInterfaceAsset)source; Interface = interfaceAsset.Interface; }
internal override void InitFromAsset(Device device, CAsset asset) { CMeshAsset meshAsset = (CMeshAsset)asset; System.Diagnostics.Debug.Assert(meshAsset != null && meshAsset.IsLoaded); int sizePerVertex = Utilities.SizeOf <SVertexInfo>(); m_sizePerVertex = sizePerVertex; m_primitiveTopology = meshAsset.PrimitiveTopology; m_vertexBuffer = Buffer.Create(device, BindFlags.VertexBuffer, meshAsset.VertexData, sizePerVertex * meshAsset.VertexData.Length); m_vertexCount = meshAsset.VertexData.Length; m_primitiveCount = meshAsset.FaceCount; m_indexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, meshAsset.IndexData); m_indexCount = meshAsset.IndexData.Length; BoundingBox = new BoundingBox(meshAsset.AABBMin, meshAsset.AABBMax); BoundingSphere = SharpDX.BoundingSphere.FromBox(BoundingBox); if (meshAsset.MaterialAsset != null) { Material = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CMaterial>(meshAsset.MaterialAsset); } else { Material = CRenderer.Instance.ResourceManager.DefaultMaterial; } }
/// <summary> /// Gets a resource of a given type created from the given asset. If the resource is not registered yet it will be created async returning a not loaded resource /// </summary> /// <param name="asset"></param> /// <returns></returns> public T RequestResourceFromAsset <T>(CAsset asset) where T : CResource, new() { System.Diagnostics.Debug.Assert(asset != null, "Tried to get a resource from a invalid asset"); T newResource; lock (m_resourceMutex) { m_registeredResources.TryGetValue(asset.Guid, out CResource rawResource); T resource = rawResource as T; if (resource != null) { return(resource); } newResource = new T(); newResource.Guid = asset.Guid; System.Diagnostics.Debug.Assert(newResource.IsAssetCorrectType(asset)); m_registeredResources.Add(asset.Guid, newResource); } if (asset.IsLoaded) { Task.Run(() => CreateResource(newResource, asset)); } else { m_waitingAssets.Add(asset); } return(newResource); }
public void LoadAsset() { CAsset asset = null; if (mType == EAssetType.AT_BRUSH) { asset = new CBrushAsset(); } else if (mType == EAssetType.AT_MODEL) { asset = new CModelAsset(); } else if (mType == EAssetType.AT_LEVEL) { asset = new CLevelAsset(); } else if (mType == EAssetType.AT_ITEM) { asset = new CItemAsset(); } if (asset != null) { asset.mName = mName; asset.mFileName = mFileName; asset.mType = mType; asset.Load(); mAsset = asset; } else { Debug.LogError("Could not load asset: " + mName); } }
public void UpdateResources(DeviceContext deviceContext) { for (int i = m_waitingAssets.Count - 1; i >= 0; --i) { CAsset asset = m_waitingAssets[i]; if (asset.IsLoaded) { CResource resource = m_registeredResources[asset.Guid]; System.Diagnostics.Debug.Assert(resource != null); Task.Run(() => CreateResource(resource, asset)); ContainerUtilities.RemoveSwapAt(m_waitingAssets, i); break; } } lock (m_resourceMutex) { for (int i = 0; i < m_waitingResources.Count; ++i) { m_waitingResources[i].InitWithContext(m_graphicsDevice, deviceContext); } m_waitingResources.Clear(); } }
internal override void InitFromAsset(Device device, CAsset asset) { CShaderAsset shaderAsset = new CShaderAsset(); System.Diagnostics.Debug.Assert(shaderAsset != null && shaderAsset.IsLoaded); Shader = CRenderer.Instance.ResourceManager.RequestShader(shaderAsset.ShaderName); }
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!m_bIsLocked) { if (AssetSelector.SelectedIndex >= 0) { CAsset selectedAsset = (CAsset)AssetSelector.SelectedItem; object newValue = Activator.CreateInstance(PropertyInfo.ValueType, selectedAsset); SetInspectorValue(PropertyInfo, PropertyInfo.Value, newValue); } } }
public override void InitItem(CAsset Asset) { base.InitItem(Asset); mMaxCompletedPapers = 5; mMaxPaperStackSlots = 5; mStressRate = 1.0f; mEfficiency = 1.0f; mUserID = -1; mCompletedStacks.Clear(); }
public CAssetEntryViewModel(CAsset asset, CAssetBrowserViewModel viewModel) { Asset = asset; m_viewModel = viewModel; TypeName = asset.GetTypeName(); Color = EditorConversionUtility.ConvertEngineColorToSystem(asset.GetTypeColor()); BorderColor = new SolidColorBrush(Color); Name = Asset.Name; EditName = Name; DeleteAssetCommand = new CRelayCommand(OnDeleteAsset); MouseLeftDownCommand = new CRelayCommand(OnMouseLeftDown); }
private void _OnClickCreateNewAssetWindow(GameObject Window, EAssetType Type, string AssetName) { string errorStr; if (CGame.AssetManager.IsAssetNameValid(AssetName, out errorStr)) { GameObject.Destroy(Window); CTUITreeViewItem treeItem = null; CAsset asset = null; if (Type == EAssetType.AT_MODEL) { treeItem = _tviModels; asset = new CModelAsset(); } else if (Type == EAssetType.AT_BRUSH) { treeItem = _tviBrushes; asset = new CBrushAsset(); } else if (Type == EAssetType.AT_LEVEL) { treeItem = _tviLevels; asset = new CLevelAsset(); } else if (Type == EAssetType.AT_ITEM) { treeItem = _tviItems; asset = new CItemAsset(); } asset.mName = AssetName; asset.mFileName = CGame.DataDirectory + asset.mName + "." + CAssetManager.ASSET_FILE_EXTENSION; Debug.Log("New Asset Path: " + asset.mFileName); asset.Save(); CAssetDeclaration decl = CGame.AssetManager.CreateAssetDeclaration(asset); treeItem.AddItem(decl.mName, () => OnClickAsset(decl.mName), () => mToolkit.EditAsset(decl.mName)); treeItem.RebuildEntireTree(); mToolkit.EditAsset(AssetName); } else { Debug.Log("Asset creation failed: " + errorStr); } }
private void CreateResource(CResource target, CAsset source) { System.Diagnostics.Debug.Assert(source.IsLoaded); target.InitFromAsset(m_graphicsDevice, source); if (target.NeedsContext()) { lock (m_resourceMutex) { m_waitingResources.Add(target); } } else { target.FinishLoading(); } }
internal override void InitFromAsset(Device device, CAsset asset) { CMaterialAsset materialAsset = (CMaterialAsset)asset; System.Diagnostics.Debug.Assert(materialAsset != null && materialAsset.IsLoaded); if (materialAsset.Shader != null) { ShaderResource = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CShaderResource>(materialAsset.Shader); } else { ShaderResource = CRenderer.Instance.ResourceManager.DefaultShader; } SetColorParameter(new SHashedName("tintColor"), Vector4.One); SetColorParameter(new SHashedName("specularColor"), Vector4.One); SetScalarParameter(new SHashedName("specularPower"), 10); for (int i = 0; i < materialAsset.MaterialParameters.Count; i++) { var parameterDesc = materialAsset.MaterialParameters[i]; if (parameterDesc.parameter.parameterData == null) { continue; } if (parameterDesc.parameter.parameterType == EShaderParameterType.Texture) { CAssetReference <CTextureAsset> textureReference = (CAssetReference <CTextureAsset>)parameterDesc.parameter.parameterData; if (textureReference.GetAsset() != null) { CTextureSampler sampler = CRenderer.Instance.ResourceManager.RequestResourceFromAsset <CTextureSampler>(textureReference.GetAsset()); SShaderParameter activeParameter = new SShaderParameter() { parameterData = sampler, parameterType = EShaderParameterType.Texture }; m_activeParameters[parameterDesc.name] = activeParameter; } } else { m_activeParameters[parameterDesc.name] = parameterDesc.parameter; } } }
public CAssetDeclaration CreateAssetDeclaration(CAsset Asset) { string errorStr; if (!IsAssetNameValid(Asset.mName, out errorStr)) { return(null); } CAssetDeclaration decl = new CAssetDeclaration(); decl.mName = Asset.mName; decl.mFileName = Asset.mFileName; decl.mType = Asset.mType; decl.mAsset = Asset; mAssetDeclarations[Asset.mName] = decl; return(decl); }
//Check for memory leaks here private void ScriptsTree_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { //Find the asset in the package PackageViewerOld.Package Package = Program.PV.PackageList.Find(x => x.Path == e.Node.Parent.Name); //Save whatever data is in the text editor now if (CurrentAsset != null) { CurrentAsset.Data = CodeView.Text.ToCharArray(); } CurrentAsset = Package.Assets.Find(x => x.Path == e.Node.Name); if (!e.Node.Text.Contains("*")) { CurrentAsset.Data = EoverseEngine.AssetGetData(CurrentAsset.Ptr, Package.Ptr).ToCharArray(); //Mark the asset, indicating that its loaded e.Node.Text = e.Node.Text.Insert(0, "*"); } CodeView.Text = new String(CurrentAsset.Data); }
public virtual void InitItem(CAsset Asset) { mAsset = (CItemAsset)Asset; mWidth = mAsset.mWidth; mLength = mAsset.mLength; mOffsetX = 0; mOffsetY = 0; mDurability = mAsset.mDurability; mMaxDurability = mDurability; mCost = mAsset.mCost; /* * _usageSlotDefinition = new CEntryPoint[mDefinition.mSlots]; * for (int i = 0; i < mDefinition.mSlots; ++i) * { * _usageSlotDefinition[i] = new CEntryPoint(); * _usageSlotDefinition[i].mPosition = new Vector2(mDefinition.mSlotTransform[i].x, mDefinition.mSlotTransform[i].y); * _usageSlotDefinition[i].mRotation = (int)mDefinition.mSlotTransform[i].z; * } */ }
internal abstract void InitFromAsset(Device device, CAsset asset);
internal override bool IsAssetCorrectType(CAsset asset) { return(asset is CMeshAsset); }
public string GetAsset(string InputValue) { CAsset customer = service.GetAsset(InputValue); return(CJson.SerializeObject(customer)); }
internal abstract bool IsAssetCorrectType(CAsset asset);