static void OnCreateFracturePieceMessage(ref CreateFracturePieceMsg msg, MyNetworkClient sender) { Debug.Assert(!Sync.IsServer); var fracturedPiece = MyFracturedPiecesManager.Static.GetPieceFromPool(msg.FracturePiece.EntityId, true); Debug.Assert(msg.FracturePiece.EntityId != 0, "Fracture piece without ID"); try { fracturedPiece.Init(msg.FracturePiece); MyEntities.Add(fracturedPiece); } catch (Exception e) { MyLog.Default.WriteLine("Cannot add fracture piece: " + e.Message); if (fracturedPiece == null) { return; } MyFracturedPiecesManager.Static.RemoveFracturePiece(fracturedPiece, 0, true, false); StringBuilder sb = new StringBuilder(); foreach (var shape in msg.FracturePiece.Shapes) { sb.Append(shape.Name).Append(" "); } Debug.Fail("Recieved fracture piece not added"); MyLog.Default.WriteLine("Received fracture piece not added, no shape found. Shapes: " + sb.ToString()); } }
public static void CreateFracturePiece(MyObjectBuilder_FracturedPiece fracturePiece) { var msg = new CreateFracturePieceMsg(); msg.FracturePiece = fracturePiece; MySession.Static.SyncLayer.SendMessageToAll(ref msg); }
static void OnCreateFracturePieceMessage(ref CreateFracturePieceMsg msg, MyNetworkClient sender) { Debug.Assert(!Sync.IsServer); var fracturedPiece = MyFracturedPiecesManager.Static.GetPieceFromPool(msg.FracturePiece.EntityId, true); Debug.Assert(msg.FracturePiece.EntityId != 0, "Fracture piece without ID"); try { fracturedPiece.Init(msg.FracturePiece); MyEntities.Add(fracturedPiece); } catch (Exception e) { MyLog.Default.WriteLine("Cannot add fracture piece: " + e.Message); if (fracturedPiece == null) return; MyFracturedPiecesManager.Static.RemoveFracturePiece(fracturedPiece, 0, true, false); StringBuilder sb = new StringBuilder(); foreach(var shape in msg.FracturePiece.Shapes) { sb.Append(shape.Name).Append(" "); } Debug.Fail("Recieved fracture piece not added"); MyLog.Default.WriteLine("Received fracture piece not added, no shape found. Shapes: " + sb.ToString()); } }
public static void CreateFracturePiece(MyObjectBuilder_FracturedPiece fracturePiece) { Debug.Assert(Sync.IsServer); var msg = new CreateFracturePieceMsg(); msg.FracturePiece = fracturePiece; MySession.Static.SyncLayer.SendMessageToAll(ref msg); }