コード例 #1
0
        void GetAvailableMedicalRooms(long playerId, out List <MyMedicalRoom> medicalRooms)
        {
            List <MyCubeGrid> cubeGrids = MyEntities.GetEntities().OfType <MyCubeGrid>().ToList();

            medicalRooms = new List <MyMedicalRoom>();

            foreach (var grid in cubeGrids)
            {
                grid.GridSystems.UpdatePower();

                foreach (var slimBlock in grid.GetBlocks())
                {
                    MyMedicalRoom medicalRoom = slimBlock.FatBlock as MyMedicalRoom;
                    if (medicalRoom != null)
                    {
                        medicalRoom.UpdateIsWorking();

                        if (medicalRoom.IsWorking)
                        {
                            if (medicalRoom.HasPlayerAccess(playerId) || medicalRoom.SetFactionToSpawnee)
                            {
                                medicalRooms.Add(medicalRoom);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        static void GetAvailableMedicalRooms(long playerId, List <MyMedicalRoomInfo> medicalRooms)
        {
            List <MyCubeGrid> cubeGrids = MyEntities.GetEntities().OfType <MyCubeGrid>().ToList();

            foreach (var grid in cubeGrids)
            {
                grid.GridSystems.UpdatePower();

                foreach (var slimBlock in grid.GetBlocks())
                {
                    MyMedicalRoom medicalRoom = slimBlock.FatBlock as MyMedicalRoom;
                    if (medicalRoom != null)
                    {
                        medicalRoom.UpdateIsWorking();

                        if (medicalRoom.IsWorking)
                        {
                            if (medicalRoom.HasPlayerAccess(playerId) || medicalRoom.SetFactionToSpawnee)
                            {
                                MyMedicalRoomInfo info = new MyMedicalRoomInfo();
                                info.MedicalRoomId   = medicalRoom.EntityId;
                                info.MedicalRoomName = medicalRoom.CustomName != null?medicalRoom.CustomName.ToString() : (medicalRoom.Name != null ? medicalRoom.Name : medicalRoom.ToString());

                                info.OxygenLevel = medicalRoom.GetOxygenLevel();
                                info.OwnerId     = medicalRoom.IDModule.Owner;

                                Vector3D medRoomPosition         = medicalRoom.PositionComp.GetPosition();
                                Vector3D preferredCameraPosition = medRoomPosition + medicalRoom.WorldMatrix.Up * 20 + medicalRoom.WorldMatrix.Right * 20 + medicalRoom.WorldMatrix.Forward * 20;
                                Vector3D?cameraPosition          = MyEntities.FindFreePlace(preferredCameraPosition, 1);

                                if (!cameraPosition.HasValue)
                                {
                                    cameraPosition = preferredCameraPosition;
                                }

                                info.PrefferedCameraPosition = cameraPosition.Value;
                                info.MedicalRoomPosition     = medRoomPosition;
                                info.MedicalRoomUp           = medicalRoom.PositionComp.WorldMatrix.Up;
                                if (medicalRoom.CubeGrid.Physics != null)
                                {
                                    info.MedicalRoomVelocity = medicalRoom.CubeGrid.Physics.LinearVelocity;
                                }

                                medicalRooms.Add(info);
                            }
                        }
                    }
                }
            }
        }