public void NewEntity(MyMwcObjectBuilder_Base objectBuilder, Matrix matrix) { Debug.Assert(objectBuilder.EntityId.HasValue, "EntityId must be set"); var msg = new MyEventNewEntity(); msg.ObjectBuilder = objectBuilder; msg.Position = new MyMwcPositionAndOrientation(matrix); Peers.SendToAll(ref msg, NetDeliveryMethod.ReliableOrdered, 0, DEFAULT_LARGE_MESSAGE_SIZE); }
void OnNewEntity(ref MyEventNewEntity msg) { var entityId = msg.ObjectBuilder.EntityId.ToEntityId(); if (entityId.HasValue && MyEntities.GetEntityByIdOrNull(entityId.Value) != null) { return; } var entity = MyEntities.CreateFromObjectBuilderAndAdd(null, msg.ObjectBuilder, msg.Position.GetMatrix()); HookEntity(entity); }