/// <summary> /// Adds effects to the store. /// </summary> /// <returns>Store that inludes passed effects</returns> /// <param name="effects">Effects collection</param> public Store WithEffects(IEnumerable <Effect> effects) { var storeEffects = new Dictionary <string, IList <IEffectMethodWrapper> >(this._effects); var store = new Store { _items = this._items.ToList(), _subscriptions = new ConcurrentDictionary <string, ISubscription>(this._subscriptions), _effects = storeEffects }; foreach (var effect in effects) { var wrapper = EffectWrapper.FromObject(store, effect); if (storeEffects.ContainsKey(wrapper.ActionTypeName)) { storeEffects[wrapper.ActionTypeName].Add(wrapper); } else { storeEffects.Add(wrapper.ActionTypeName, new List <IEffectMethodWrapper> { wrapper }); } } return(store); }
public GrassRendrer(Form1 F) : base(F.Device) { this.P = F; this.CallFrequency = STDCallFrequencys.Always; E3 = new EffectWrapper("Grass_Mesh.fx", D); BlendStateDescription bsd = new BlendStateDescription() { AlphaToCoverageEnable = true, IndependentBlendEnable = false, }; RenderTargetBlendDescription rtbd = new RenderTargetBlendDescription() { BlendEnable = true, BlendOperation = BlendOperation.Add, BlendOperationAlpha = BlendOperation.Add, RenderTargetWriteMask = ColorWriteMaskFlags.All, DestinationBlend = BlendOption.InverseSourceAlpha, SourceBlend = BlendOption.SourceAlpha, SourceBlendAlpha = BlendOption.Zero, DestinationBlendAlpha = BlendOption.One }; bsd.RenderTargets[0] = rtbd; bsd0 = BlendState.FromDescription(D.HadrwareDevice(), bsd); StaticVertex[] vs = new StaticVertex[100]; mBuffer = new DynamicMeshBuffer<StaticVertex>(D, PrimitiveTopology.PointList); mBuffer.Write(vs); }
public override void Start() { base.Start(); var basicEffect = new BasicEffect(Engine.Renderer.Device); basicEffect.LightingEnabled = false; basicEffect.VertexColorEnabled = true; basicEffect.FogEnabled = false; m_effect = new EffectWrapper(basicEffect); int capacity = 512 * 512 * 4; m_lineMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.LineList, capacity); m_triangleMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.TriangleList, capacity); Engine.Renderer.RenderLayers["ArenaOverlay7"].Renderables.Add(this); m_player = Owner.FindComponent <Player>(); m_chargeTimerMS = new Timer(Engine.GameTime.Source, m_player.Parameters.ChargedPass.ChargeTimeMS); m_chargeTimerMS.Start(); m_chargeTimerMS.OnTime += m_chargeTimerMS_OnTime; m_chargedMax = false; }
public override void Start() { base.Start(); m_audioCmpBallLaunch = new AudioComponent("Audio/Sounds.lua::BallShot"); Owner.Attach(m_audioCmpBallLaunch); Sprite sprite1 = Sprite.Create("Graphics/LauncherCentralShield.lua::Sprite"); sprite1.SetAnimation("Normal"); sprite1.Alpha = 0; m_spriteCmp1 = new SpriteComponent(sprite1, "ArenaOverlay5"); m_spriteCmp1.Visible = false; sprite1.Playing = true; m_spriteCmp1.Sprite.Scale = new Vector2(m_scale, m_scale); Owner.Attach(m_spriteCmp1); Sprite sprite2 = Sprite.Create("Graphics/LauncherCentralShield.lua::Sprite2"); sprite2.SetAnimation("Normal"); sprite2.Alpha = 0; m_spriteCmp2 = new SpriteComponent(sprite2, "ArenaOverlay5"); m_spriteCmp2.Visible = false; sprite2.Playing = true; Owner.Attach(m_spriteCmp2); var basicEffect = new BasicEffect(Engine.Renderer.Device); basicEffect.LightingEnabled = false; basicEffect.VertexColorEnabled = true; basicEffect.FogEnabled = false; m_effect = new EffectWrapper(basicEffect); int capacity = 512 * 512 * 4; m_lineMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.LineList, capacity); m_triangleMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.TriangleList, capacity); Engine.Renderer.RenderLayers["ArenaOverlay7"].Renderables.Add(this); m_chargeTimerMS = new Timer(Engine.GameTime.Source, 2000); m_chargeTimerMS.OnTime += m_chargeTimerMS_OnTime; m_maxChargeTimerMS = new Timer(Engine.GameTime.Source, 300); m_maxChargeTimerMS.OnTime += m_maxChargeTimerMS_OnTime; m_chargedMax = false; m_launcherTeam = new List <Player>(); m_shield = new LauncherShield(this); Owner.Attach(m_shield); }
public GizmoComponent(Form1 Parent) { tRenderer = new AdvTextRenderer(new Font("Arial", 23), Parent.Device, Color.White); Parent.BackBufferControl.MouseMove += new System.Windows.Forms.MouseEventHandler(BackBufferControl_MouseMove); P = Parent; API_Device D = Parent.Device; E = new EffectWrapper("gizmo.fx", D); float f = scale; float q = scale * s; Vector4[] V = new Vector4[] { new Vector4(0, 0, 0, 1), new Vector4(f, 0, 0, 1), // 1 new Vector4(0, f, 0, 1), new Vector4(0, 0, f, 1), new Vector4(q, 0, 0, 1), // 4 new Vector4(0, q, 0, 1), new Vector4(0, 0, q, 1), new Vector4(q, q, 0, 1), // 7 new Vector4(0, q, q, 1), new Vector4(q, 0, q, 1), }; int[] I = new int[] { 0, 1, 0, 2, 0, 3, 4, 7, 5, 7, 5, 8, 6, 8, 6, 9, 4, 9, }; int[] I2 = new int[] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, }; colorVertex[] Dy = new colorVertex[I.Length]; for (int i = 0; i < Dy.Length; i++) Dy[i] = new colorVertex(I[i], I2[i]); meshBuffer = new MeshBuffer(Dy, Dy[0], D, PrimitiveTopology.LineList); E.Variables["PointA"].SetVariable(V); ColorA = new Vector4[10]; Vector4 x = new Vector4(1, 0, 0, 1); Vector4 y = new Vector4(0, 0, 1, 1); Vector4 z = new Vector4(0, 1, 0, 1); ColorA[0] = x; ColorA[1] = y; ColorA[2] = z; ColorA[3] = x; ColorA[4] = y; ColorA[5] = y; ColorA[6] = z; ColorA[7] = z; ColorA[8] = x; }
private void PlayTouchEffect(Vector2 vecMousePos) { Vector3 vecPos = _pCamera.ScreenToWorldPoint(vecMousePos); vecPos.z += _pCamera.nearClipPlane + 1f; EffectWrapper pEffect_Origin = _arrTouchEffect.GetRandomItem(); try { EffectManager.DoPlayEffect(pEffect_Origin, vecPos); } catch (System.Exception e) { OnException?.Invoke(pEffect_Origin, e); } }
public override void Start() { var basicEffect = new BasicEffect(Engine.Renderer.Device); basicEffect.LightingEnabled = false; basicEffect.VertexColorEnabled = true; basicEffect.FogEnabled = false; m_fadeOutTimer = new Timer(Engine.GameTime.Source, 300, TimerBehaviour.Stop); m_fadeOutTimerEvent = new TimerEvent(m_fadeOutTimer_OnTime); m_fadeOutTimer.OnTime += m_fadeOutTimerEvent; m_effect = new EffectWrapper(basicEffect); m_mesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, Microsoft.Xna.Framework.Graphics.PrimitiveType.TriangleList, 2048); Engine.Renderer.RenderLayers["ArenaOverlay7"].Renderables.Add(this); }
private void ManageEffects() { Transform expectedParent = self.GetVehicle()?.transform; #region Scan EffectWrapper scanEffect = scanLineEffect; Vector3 scanScale = new Vector3(0.5f, 0.5f, GetScanDistance()); if (scanLevel > 0) { scanEffect = scanSphereEffect; scanScale = Vector3.one * GetScanDistance(); scanLineEffect?.SetShown(false); } else { scanSphereEffect?.SetShown(false); } if (scanEffect != null) { if (scanEffect.transform.parent != expectedParent) { scanEffect.transform.SetParent(expectedParent, false); } scanEffect.shownScale = scanScale; scanEffect.SetShown(scan); scanEffect.SetColor(CanScan ? Color.green : Color.red); } #endregion #region Capture if (captureEffect != null) { if (captureEffect.transform.parent != expectedParent) { captureEffect.transform.SetParent(expectedParent, false); } captureEffect.shownScale = Vector3.one * GetCaptureDistance(); captureEffect.SetShown(capture); captureEffect.SetColor(IsCapturing ? Color.green : Color.red); } #endregion }
public DebugScreen() { int capacity = 1024 * 1024 * 4; m_lineMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.LineList, capacity); m_triangleMesh = new DynamicMesh <VertexPositionColor>(Engine.Renderer.Device, VertexPositionColor.VertexDeclaration, PrimitiveType.TriangleList, capacity); m_texts = new List <TextEntry>(); ResetBrush(); var basicEffect = new BasicEffect(Engine.Renderer.Device); basicEffect.LightingEnabled = false; basicEffect.VertexColorEnabled = true; basicEffect.FogEnabled = false; m_effect = new EffectWrapper(basicEffect); }
//--------------------------------------------------------------------------- public void Init(GraphicsDevice device, int width, int height, Texture2D backgroundTexture = null, Effect lightingEffect = null) { Device = device; m_EffectWrapper = new EffectWrapper(device, width, height); m_ComponentsTarget = new RenderTarget2D(device, width, height); m_LightingTarget = new RenderTarget2D(device, width, height); m_ShadowTarget = new RenderTarget2D(device, width, height); m_MainTarget = new RenderTarget2D(device, width, height); BackgroundTexture = backgroundTexture; LightingEffect = lightingEffect; if (lightingEffect != null) { AddEffect(lightingEffect); } Viewport = new Rectangle(0, 0, width, height); }
public TSTRENDERER(ModelViewer MV) : base(MV.Device) { this.CallFrequency = STDCallFrequencys.Always; this.MV = MV; D = MV.Device; E = new EffectWrapper("ambient.fx", MV.Device); }
void Start() { effectManager = GameObject.Find("Player").GetComponent <EffectWrapper>(); dashDistance = effectManager.dashDistance; }
public NodeDisplayerPostProc(Form1 P) { LineDrawer = new EffectWrapper("Line.fx", P.Device); this.P = P; short[] indices = new short[] { 0, 1, 0, 2, 0, 3, 1, 4, 1, 6, 2, 4, 2, 5, 3, 5, 3, 6, 4, 7, 5, 7, 6, 7 }; BoundingBox boundingBox = new BoundingBox(new Vector3(-1.0f), new Vector3(+1.0f)); StaticVertex[] vertices = new StaticVertex[8]; vertices[0].Position = new Vector4(boundingBox.Minimum.X, boundingBox.Minimum.Y, boundingBox.Minimum.Z, 1f); vertices[1].Position = new Vector4(boundingBox.Minimum.X, boundingBox.Minimum.Y, boundingBox.Maximum.Z, 1f); vertices[2].Position = new Vector4(boundingBox.Minimum.X, boundingBox.Maximum.Y, boundingBox.Minimum.Z, 1f); vertices[3].Position = new Vector4(boundingBox.Maximum.X, boundingBox.Minimum.Y, boundingBox.Minimum.Z, 1f); vertices[4].Position = new Vector4(boundingBox.Minimum.X, boundingBox.Maximum.Y, boundingBox.Maximum.Z, 1f); vertices[5].Position = new Vector4(boundingBox.Maximum.X, boundingBox.Maximum.Y, boundingBox.Minimum.Z, 1f); vertices[6].Position = new Vector4(boundingBox.Maximum.X, boundingBox.Minimum.Y, boundingBox.Maximum.Z, 1f); vertices[7].Position = new Vector4(boundingBox.Maximum.X, boundingBox.Maximum.Y, boundingBox.Maximum.Z, 1f); mBuffer = new MeshBuffer(vertices, indices, SlimDX.DXGI.Format.R16_UInt, vertices[0], P.Device, SlimDX.Direct3D11.PrimitiveTopology.LineList, SlimDX.Direct3D11.CpuAccessFlags.Write); }
public IconDrawer(Form1 F) { P = F; E = new EffectWrapper("IconDrawer.fx", F.Device); DynamicIndexVertex[] D = new DynamicIndexVertex[] { new DynamicIndexVertex(0), new DynamicIndexVertex(1), new DynamicIndexVertex(2), new DynamicIndexVertex(2), new DynamicIndexVertex(3), new DynamicIndexVertex(0)}; M = new MeshBuffer(D, D[0], Device, SlimDX.Direct3D11.PrimitiveTopology.TriangleList); }
public NavRenderer(Form1 F) : base(F.Device) { P = F; P.ObjectSelected += new EventHandler(P_ObjectSelected); RisenWorld.WorldCleared += new WorldCleared(RisenWorld_OnClear); RisenWorld.LrentFileAdded += new FilesAdded(RisenWorld_OnFileAdded); RisenWorld.LoadingFinished += new LoadingFinished(RisenWorld_LoadingFinished); RisenWorld.EntityAdded += new EntityAdded(RisenWorld_EntityAdded); tSorter = new ThreadedLibraryRenderer(); tSorter.Predicate = ComparePredicate; E = new EffectWrapper("gizmo.fx", D); GizmoComponent.colorVertex[] V = new GizmoComponent.colorVertex[100]; for(int i = 0; i < V.Length; i++) V[i] = new GizmoComponent.colorVertex(i,0); mBuffer = new MeshBuffer(V, V[0], F.Device, PrimitiveTopology.TriangleList); }
public static void InitFileManager(D3DApplication a_App, string a_Basepath = null) { NotifyOnPhysicalWatch = true; g_pApp = a_App; API_Device D = a_App.Device; e_MatEffect = new EffectWrapper("matCombiner.fx", D); r_MatTarget = new RenderTarget(2048, 2048, 1, SlimDX.Direct3D11.BindFlags.RenderTarget, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D); D.Content.FileHandleCreator = getHandle; D.Content.RegisterMaterialLoader(new XmatLoader()); D.Content.RegisterModelLoader(new XMACLoader()); D.Content.RegisterModelLoader(new XMSHLoader()); D.Content.RegisterTextureLoader(new XIMGLoader()); string basePath2 = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Deep Silver\Risen\", "INSTALL_DIR", string.Empty) as string; if (basePath2 != null && Directory.Exists(basePath2)) {//registry based g_pGamepath = basePath2.Replace(@"\bin", @"\"); } else if(!string.IsNullOrEmpty(a_Basepath)) {//ini file based g_pGamepath = a_Basepath + @"\"; } else { var msg = "Couldn't find risen directory. Terminating"; SystemLog.Append(LogImportance.System, msg); SystemLog.Flush(); MessageBox.Show(msg); throw new Exception(); } m_Paks = new Dictionary<string, RisenPak>(); DirectoryInfo[] Ds = new DirectoryInfo[] { new DirectoryInfo(g_pGamepath + "/data/common"), new DirectoryInfo(g_pGamepath + "/data/compiled") }; for (int i = 0; i < Ds.Length; i++) { if (!Ds[i].Exists) continue; int n = -1; while (true) { string a = n.ToString().PadLeft(2, '0'); FileInfo[] Fs = Ds[i].GetFiles(n < 0 ? ("*.pak") : ("*.p" + a)); foreach (FileInfo f in Fs) { string key = Ds[i].Name + @"\" + f.Name.Replace(f.Extension, "") + (n < 0 ? "" : a); RisenPak val = new RisenPak(FileManager.GetFile(f.FullName), _Files, n >= 0); m_Paks.Add(key, val); } n++; if (Fs.Length == 0) break; } } m_Watcher.Path = g_pGamepath; m_Watcher.IncludeSubdirectories = true; m_Watcher.NotifyFilter = NotifyFilters.FileName; m_Watcher.Created += W_Created; m_Watcher.Deleted += W_Created; m_Watcher.Renamed += W_Created; m_Watcher.EnableRaisingEvents = true; initFinished = true; StdFileReader S = new StdFileReader(); Dictionary<string, EFile> _PhyFiles = new Dictionary<string, EFile>(); List<EFile> newFiles = new List<EFile>(); Stack<DirectoryInfo> Dirs = new Stack<DirectoryInfo>(); Dirs.Push(new DirectoryInfo(g_pGamepath + "/Data")); while (Dirs.Count != 0) { DirectoryInfo d = Dirs.Pop(); DirectoryInfo[] _d = d.GetDirectories(); FileInfo[] _f = d.GetFiles(); foreach (DirectoryInfo q0 in _d) Dirs.Push(q0); foreach (FileInfo q1 in _f) { string k = q1.Name.ToUpper(); if (!isArchiveExtension(q1)) { EFile e = new EFile(q1.FullName, S); if (_PhyFiles.ContainsKey(k)) { SystemLog.Append(LogImportance.System, "Two identical physical files found!"); throw new Exception("Two identical physical files found!"); } _PhyFiles.Add(k, e); if (!FileManager._PhyFiles.ContainsKey(k)) newFiles.Add(e); } } } FileManager._PhyFiles = _PhyFiles; List<EFile> tabfiles = new List<EFile>(); System.IO.StreamReader tr = new System.IO.StreamReader(g_pGamepath + "data\\ini\\loc.ini"); while (!tr.EndOfStream) { string l = tr.ReadLine(); while (!tr.EndOfStream && string.IsNullOrEmpty(l)) l = tr.ReadLine(); if (tr.EndOfStream) break; string prefix = tr.ReadLine().Replace("prefix=", ""), csv = tr.ReadLine().Replace("csv=", ""), bin = tr.ReadLine().Replace("bin=", ""); EFile a = GetFile(bin.Replace(@"#G3:/", "")); if (!a.IsOpenable) SystemLog.Append(LogImportance.Warning, "Tab file not found : " + a.Name); tabFile b = new tabFile(a); tab_files.Add(a.Name, b); tab_FilesPrefix.Add(prefix.ToLower(), b); } tr.Close(); }