private void CreateEntitySimulation(SimEntity e) { var nodes = e.Components.Where(c => c.Kind == NODE_KIND).Select(c => c.Attributes[0]); var conns = e.Components .Where(c => c.Kind == CONNECTION_KIND) .Select(c => new { N1 = c.CustomData[0], // node id: from N2 = c.CustomData[1], // node id: to L = c.Attributes[0], C = c.Attributes[1], P = c.Attributes[2], }); var s = new Simulation(); foreach (var friction in nodes) { //var pos = new System.Numerics.Vector2(0, 1); // var p = new Particle(pos); var p = new Particle(); p.Friction = friction; s.AddParticle(p); } foreach (var conn in conns) { var pl = new ParticleLink(s.Particles[conn.N1], s.Particles[conn.N2], conn.L, conn.P, conn.C); s.AddParticleLink(pl); } e.Simulation = s; }