4 using SiliconStudio.Paradox;
5 using SiliconStudio.Paradox.DataModel;
6 using SiliconStudio.Paradox.Effects;
7 using SiliconStudio.Paradox.Engine;
8 using SiliconStudio.Paradox.EntityModel;
9 using SiliconStudio.Paradox.Extensions;
10 using SiliconStudio.Paradox.Games;
11 using SiliconStudio.Paradox.Games.Collections;
12 using SiliconStudio.Paradox.Games.Serialization.Contents;
13 using Paradox.Framework.Shaders;
22 [ContentSerializer(typeof(EntityComponentContentSerializer<BulletParticleEmitterComponent>))]
27 internal RenderContextBase renderContext;
29 private TimeSpan lastTime;
31 private Entity dragonHead = null;
35 Type = ParticleEmitterType.GpuStatic;
36 Shader =
new ShaderClassSource(
"ParticleUpdaterBullet");
48 base.OnAddToSystem(EntitySystem, renderContext);
49 this.EntitySystem = EntitySystem;
50 this.renderContext = renderContext;
55 if (dragonHead == null)
56 dragonHead = EntitySystem.Entities.FirstOrDefault(x => x.Name ==
"English DragonPelvis");
60 if (dragonHead != null)
62 var dragonTransform = dragonHead.Transformation;
63 if (dragonTransform != null)
65 desc.TargetOld = desc.Target;
66 desc.Target = (
Vector3)dragonTransform.WorldMatrix.Row4;
70 var animationComponent = RootAnimation.GetOrCreate(AnimationComponent.Key);
71 if (animationComponent != null)
73 desc.AnimationTime = (float)animationComponent.CurrentTime.TotalSeconds;
75 if ((animationComponent.CurrentTime.Ticks - lastTime.Ticks) < 0)
78 lastTime = animationComponent.CurrentTime;
86 if (entity.
Name.StartsWith(
"maguma_"))
88 var meshComponent = entity.Get(ModelComponent.Key);
89 if (meshComponent == null)
92 foreach (var effectMesh
in meshComponent.SubMeshes)
94 var subMeshData = effectMesh.MeshData.Value.SubMeshDatas[MeshData.StandardSubMeshData];
95 var buffer = subMeshData.GetVertexBufferData<
Vector3>(
"POSITION");
96 var gpuBuffer = Buffer.Structured.New(renderContext.GraphicsDevice, buffer);
97 Parameters.Set(ScriptParticleSmoke.VerticesEmitterKey, gpuBuffer);
105 bool isUptoDate =
true;
116 var random =
new Random(0);
117 var particlesBuffer = (ScriptParticleSmoke.ParticleData[])
ParticleData;
119 for (
int i = 0; i < particlesBuffer.Length; i++)
121 var timeProb = (float)random.NextDouble();
122 var timeStepFactor = 50 * Math.Pow(1 - timeProb, 3.0) + 1.0;
123 var time = (((int)(random.NextDouble() * description.MaxTimeTarget / timeStepFactor) + 1) * timeStepFactor) % description.MaxTimeTarget;
124 particlesBuffer[i] =
new ScriptParticleSmoke.ParticleData
127 Opacity = (
Half)0.0f,
129 TimeStep = (
Half)timeStepFactor,
140 return Parameters.TryGet(ScriptParticleSmoke.BulletEmitterKey);
144 Parameters.Set(ScriptParticleSmoke.BulletEmitterKey, value);
SiliconStudio.Paradox.Graphics.Buffer Buffer
bool UpdateNextBuffer
Gets or sets a value indicating whether [update next buffer].
BulletEmitterDescription Description
Game entity. It usually aggregates multiple EntityComponent
int Count
Gets or sets the particle count.
SiliconStudio.Paradox.Games.Mathematics.Half4 Half4
SiliconStudio.Paradox.Games.Mathematics.Vector3 Vector3
Action< ParticleEmitterComponent, Entity, TrackingCollectionChangedEventArgs > MeshUpdate
A callback called whenever the component is updated by the ParticleSystem.
SiliconStudio.Paradox.Games.Utilities Utilities
override void OnAddToSystem(EntitySystem EntitySystem, RenderContextBase renderContext)
SiliconStudio.Paradox.Graphics.Buffer Buffer
int ParticleElementSize
Gets or sets the size of the particle element.
ShaderClassSource Shader
Gets or sets the shader.
SiliconStudio.Core.Utilities Utilities
Manage a collection of entities.
SiliconStudio.Paradox.Games.Mathematics.Half Half
string Name
Gets or sets the name of this component.
Action< ParticleEmitterComponent > UpdateSystem
ParticleEmitterType Type
Gets or sets the type of this emitter..
Array ParticleData
Gets or sets the particle data.
SiliconStudio.Core.Mathematics.Vector3 Vector3
Action< ParticleEmitterComponent > UpdateData
BulletParticleEmitterComponent()