public void SpawnDebris(GameObjectKind kind, string archetype, string part, Matrix4x4 transform, float mass, Vector3 initialForce)
 {
     actions.Enqueue(() =>
     {
         RigidModel mdl;
         if (kind == GameObjectKind.Ship)
         {
             var ship = Server.GameData.GetShip(archetype);
             mdl      = ((IRigidModelFile)ship.ModelFile.LoadFile(Server.Resources)).CreateRigidModel(false);
         }
         else
         {
             var arch = Server.GameData.GetSolarArchetype(archetype);
             mdl      = ((IRigidModelFile)arch.ModelFile.LoadFile(Server.Resources)).CreateRigidModel(false);
         }
         var newpart  = mdl.Parts[part].Clone();
         var newmodel = new RigidModel()
         {
             Root          = newpart,
             AllParts      = new[] { newpart },
             MaterialAnims = mdl.MaterialAnims,
             Path          = mdl.Path,
         };
         var id   = GenerateID();
         var go   = new GameObject($"debris{id}", newmodel, Server.Resources, part, mass, false);
         go.NetID = id;
         go.SetLocalTransform(transform);
         GameWorld.AddObject(go);
         updatingObjects.Add(go);
         go.Register(GameWorld.Physics);
         go.PhysicsComponent.Body.Impulse(initialForce);
         //Spawn debris
         foreach (Player p in Players.Keys)
         {
             p.SpawnDebris(go.NetID, kind, archetype, part, transform, mass);
         }
     });
 }
Exemple #2
0
 public void SpawnDebris(int id, GameObjectKind kind, string archetype, string part, Matrix4x4 tr, float mass)
 {
     rpcClient.SpawnDebris(id, kind, archetype, part, Vector3.Transform(Vector3.Zero, tr), tr.ExtractRotation(), mass);
 }