public void GetEntityReflectionInfo(Int64 EntityID, out List <TypeReflectionInfo> output) { output = new List <TypeReflectionInfo>(); BaseEntity entity; if (entities.TryGetValue(EntityID, out entity)) { // First we'll get the Entity info TypeReflectionInfo entityInfo = QSUtils.GetReflectionInfo(entity, entity.GetType()); output.Add(entityInfo); // Now we'll get the Components' info foreach (KeyValuePair <ComponentType, BaseComponent> entry in entity.Components) { TypeReflectionInfo compInfo = QSUtils.GetReflectionInfo(entry.Value, entry.Value.GetType()); output.Add(compInfo); } } }
public void RayCastForEntityReport() { // First we determine the line segment between the camera's position and the cursor // as if it were at the far plane. var msgGetSegment = ObjectPool.Aquire <MsgGetLineSegmentToCursor>(); this.game.SendInterfaceMessage(msgGetSegment, InterfaceType.Camera); // Now we use that line segment to check for physics collisions PhysicsInterface physics = this.game.SceneManager.GetInterface(InterfaceType.Physics) as PhysicsInterface; if (null == physics) { throw new Exception("Cannot perform a physics ray cast without a registered PhysicsInterface"); } SegmentIntersectInfo info = physics.PerformSegmentIntersectQuery(msgGetSegment.lineSegment); // Check if the ray hit anything if (QSGame.UniqueIDEmpty == info.entityID) { return; } List <TypeReflectionInfo> entityInfo; this.game.SceneManager.GetEntityReflectionInfo(info.entityID, out entityInfo); if (null == this.infoWindows) { this.infoWindows = new Dictionary <Int64, EntityInfoWindow>(); } EntityInfoWindow window; if (!this.infoWindows.TryGetValue(info.entityID, out window)) { // If a window doesn't yet exist for this entity, then we create one window = new EntityInfoWindow(100, 100, info.entityID, this.game); this.infoWindows.Add(info.entityID, window); this.game.Gui.Screen.Desktop.Children.Add(window); } else { if (!window.IsOpen) { this.game.Gui.Screen.Desktop.Children.Add(window); } window.Label.Items.Clear(); } for (int i = 0; i < entityInfo.Count; ++i) { TypeReflectionInfo rInfo = entityInfo[i]; window.Label.Items.Add(rInfo.typeName); List <string> details = QSUtils.ConvertTypeReflectionInfoToString(rInfo.properties); for (int j = 0; j < details.Count; ++j) { window.Label.Items.Add(details[j]); } } }