private void refreshLoadedVesselRosterCLS(Dictionary <string, KeepFitCrewMember> roster,
                                                  KeepFitVesselRecord vesselRecord,
                                                  Vessel vessel)
        {
            ActivityLevel vesselDefaultActivityLevel = getDefaultActivityLevel(vessel);

            ConnectedLivingSpace.ICLSAddon cls = module.GetCLS();
            foreach (ConnectedLivingSpace.ICLSSpace space in cls.Vessel.Spaces)
            {
                ActivityLevel spaceBestActivityLevel = vesselDefaultActivityLevel;

                foreach (ConnectedLivingSpace.ICLSPart part in space.Parts)
                {
                    if (part.Part.CrewCapacity == 0)
                    {
                        continue;
                    }

                    // check all modules on the part in case we have multiple KeepFit modules for some reason
                    foreach (KeepFitPartModule kfModule in part.Part.FindModulesImplementing <KeepFitPartModule>())
                    {
                        ActivityLevel partActivityLevel = kfModule.activityLevel;
                        if (partActivityLevel > spaceBestActivityLevel)
                        {
                            spaceBestActivityLevel = partActivityLevel;
                        }
                    }

                    foreach (ConnectedLivingSpace.ICLSKerbal partCrewMember in space.Crew)
                    {
                        updateRosters(roster, vesselRecord, partCrewMember.Kerbal.name, spaceBestActivityLevel, true);
                    }
                }
            }
        }
 public static ConnectedLivingSpace.ICLSAddon GetCLS()
 {
     Type CLSAddonType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()).SingleOrDefault(t => t.FullName == "ConnectedLivingSpace.CLSAddon");
     if (CLSAddonType != null)
     {
         object realCLSAddon = CLSAddonType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
         _CLS =   (ConnectedLivingSpace.ICLSAddon)realCLSAddon;
     }
     return _CLS;
 }
Ejemplo n.º 3
0
 public static ConnectedLivingSpace.ICLSAddon GetCLS()
 {
   Type CLSAddonType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()).SingleOrDefault(t => t.FullName == "ConnectedLivingSpace.CLSAddon");
   if (CLSAddonType != null)
   {
     object realCLSAddon = CLSAddonType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
     _CLS =   (ConnectedLivingSpace.ICLSAddon)realCLSAddon;
   }
   return _CLS;
 }
Ejemplo n.º 4
0
        public static ConnectedLivingSpace.ICLSAddon GetCLS()
        {
            Type CLSAddonType = getType("ConnectedLivingSpace.CLSAddon");

            if (CLSAddonType != null)
            {
                object realCLSAddon = CLSAddonType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
                _CLS = (ConnectedLivingSpace.ICLSAddon)realCLSAddon;
            }
            return(_CLS);
        }
Ejemplo n.º 5
0
        public static ConnectedLivingSpace.ICLSAddon GetCLS()
        {
            // Just get the CLS Addon object everytime - it somehow seems to have gone stale. Does this fix the problem?
            Type CLSAddonType = AssemblyLoader.loadedAssemblies.SelectMany(a => a.assembly.GetExportedTypes()).SingleOrDefault(t => t.FullName == "ConnectedLivingSpace.CLSAddon");

            if (CLSAddonType != null)
            {
                object realCLSAddon = CLSAddonType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
                _CLS = (ConnectedLivingSpace.ICLSAddon)realCLSAddon;
            }

            return(_CLS);
        }
Ejemplo n.º 6
0
        public static ConnectedLivingSpace.ICLSAddon GetCLS()
        {
			Type CLSAddonType = null;
			AssemblyLoader.loadedAssemblies.TypeOperation(t =>
			{
				if (t.FullName == "ConnectedLivingSpace.CLSAddon")
				{
					CLSAddonType = t;
				}
			});
            if (CLSAddonType != null)
            {
                object realCLSAddon = CLSAddonType.GetProperty("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null, null);
                _CLS =   (ConnectedLivingSpace.ICLSAddon)realCLSAddon;
            }
            return _CLS;
        }
 private void refreshLoadedVesselRoster(Dictionary <string, KeepFitCrewMember> roster,
                                        KeepFitVesselRecord vesselRecord,
                                        Vessel vessel)
 {
     ConnectedLivingSpace.ICLSAddon cls = module.GetCLS();
     if (cls != null && gameConfig.applyCLSLimitsIfAvailable && vessel == FlightGlobals.ActiveVessel && cls.Vessel != null)
     {
         refreshLoadedVesselRosterCLS(roster, vesselRecord, vessel);
     }
     else if (gameConfig.useBestPartOnVessel)
     {
         refreshLoadedVesselRosterWholeVessel(roster, vesselRecord, vessel);
     }
     else
     {
         refreshLoadedVesselRosterPartOnly(roster, vesselRecord, vessel);
     }
 }
Ejemplo n.º 8
0
        public override void OnAwake()
        {
            this.Log_DebugOnly("OnAwake", "Scene[{0}]", HighLogic.LoadedScene);
            base.OnAwake();

            if (cls == null)
            {
                cls = CLSClient.GetCLS();
            }

            if (mainWindow == null)
            {
                mainWindow = gameObject.AddComponent <MainWindow>();
                mainWindow.Init(this);
            }

            if (logWindow == null)
            {
                logWindow = gameObject.AddComponent <LogWindow>();
                logWindow.Init(this);
            }

            if (configWindow == null)
            {
                configWindow = gameObject.AddComponent <ConfigWindow>();
                configWindow.Init(this);
            }

            if (rosterWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing rosterWindow");
                rosterWindow = gameObject.AddComponent <RosterWindow>();
                rosterWindow.Init(this);
            }

            if (allVesselsWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing allVesselsWindow");
                allVesselsWindow = gameObject.AddComponent <AllVesselsWindow>();
                allVesselsWindow.Init(this);
            }



            if (appLauncherButton != null)
            {
                this.Log_DebugOnly("OnAwake", "AppLauncher button already here");
            }
            else
            {
                this.Log_DebugOnly("OnAwake", "Adding AppLauncher button");

                Texture toolbarButtonTexture         = (Texture)GameDatabase.Instance.GetTexture("KeepFit/KeepFit", false);
                ApplicationLauncher.AppScenes scenes = ApplicationLauncher.AppScenes.FLIGHT |
                                                       //ApplicationLauncher.AppScenes.MAPVIEW |
                                                       ApplicationLauncher.AppScenes.SPACECENTER |
                                                       //ApplicationLauncher.AppScenes.SPH |
                                                       //ApplicationLauncher.AppScenes.VAB |
                                                       ApplicationLauncher.AppScenes.TRACKSTATION;

                appLauncherButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn,
                                                                                   onAppLaunchToggleOff,
                                                                                   onAppLaunchHoverOn,
                                                                                   onAppLaunchHoverOff,
                                                                                   onAppLaunchEnable,
                                                                                   onAppLaunchDisable,
                                                                                   scenes,
                                                                                   toolbarButtonTexture);
                ApplicationLauncher.Instance.AddOnRepositionCallback(onAppLauncherReposition);

                if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null)
                {
                    this.Log_DebugOnly("OnAwake", "Adding Toolbar Button");
                    this.toolmodLauncherButton = ToolbarManager.Instance.add("KeepFit", "MainButton");
                    if (this.toolmodLauncherButton != null)
                    {
                        appLauncherButton.VisibleInScenes      = scenes; // TODO
                        this.toolmodLauncherButton.Visibility  = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.TRACKSTATION });
                        this.toolmodLauncherButton.TexturePath = "KeepFit/UIResources/KeepFit";
                        this.toolmodLauncherButton.ToolTip     = "KeepFit Toolbar";
                        this.toolmodLauncherButton.OnClick    += ((e) => this.toolmodButtonToggle());
                    }
                }
            }


            this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewRosterController");
            crewRosterController = gameObject.AddComponent <KeepFitCrewRosterController>();
            crewRosterController.Init(this);

            if (HighLogic.LoadedScene == GameScenes.FLIGHT ||
                HighLogic.LoadedScene == GameScenes.TRACKSTATION ||
                HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewFitnessController");
                crewFitnessController = gameObject.AddComponent <KeepFitCrewFitnessController>();
                crewFitnessController.Init(this);
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitGeeEffectsController");
                this.geeEffectsController = gameObject.AddComponent <KeepFitGeeEffectsController>();
                this.geeEffectsController.Init(this);
            }
        }
Ejemplo n.º 9
0
        public override void OnAwake()
        {
            this.Log_DebugOnly("OnAwake", "Scene[{0}]", HighLogic.LoadedScene);
            base.OnAwake();

            if (cls == null)
            {
                cls = CLSClient.GetCLS();
            }

            if (mainWindow == null)
            {
                mainWindow = gameObject.AddComponent<MainWindow>();
                mainWindow.Init(this);
            }

            if (logWindow == null)
            {
                logWindow = gameObject.AddComponent<LogWindow>();
                logWindow.Init(this);
            }

            if (configWindow == null)
            {
                configWindow = gameObject.AddComponent<ConfigWindow>();
                configWindow.Init(this);
            }

            if (rosterWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing rosterWindow");
                rosterWindow = gameObject.AddComponent<RosterWindow>();
                rosterWindow.Init(this);
            }

            if (allVesselsWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing allVesselsWindow");
                allVesselsWindow = gameObject.AddComponent<AllVesselsWindow>();
                allVesselsWindow.Init(this);
            }

            if (appLauncherButton != null)
            {
                this.Log_DebugOnly("OnAwake", "AppLauncher button already here");
            }
            else
            {
                this.Log_DebugOnly("OnAwake", "Adding AppLauncher button");

                Texture toolbarButtonTexture = (Texture)GameDatabase.Instance.GetTexture("KeepFit/KeepFit", false);
                ApplicationLauncher.AppScenes scenes = ApplicationLauncher.AppScenes.FLIGHT |
                                                       ApplicationLauncher.AppScenes.MAPVIEW |
                                                       ApplicationLauncher.AppScenes.SPACECENTER |
                                                       ApplicationLauncher.AppScenes.SPH |
                                                       ApplicationLauncher.AppScenes.VAB |
                                                       ApplicationLauncher.AppScenes.TRACKSTATION;

                appLauncherButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn,
                                                               onAppLaunchToggleOff,
                                                               onAppLaunchHoverOn,
                                                               onAppLaunchHoverOff,
                                                               onAppLaunchEnable,
                                                               onAppLaunchDisable,
                                                               scenes,
                                                               toolbarButtonTexture);
                ApplicationLauncher.Instance.AddOnRepositionCallback(onAppLauncherReposition);
            }

            this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewRosterController");
            crewRosterController = gameObject.AddComponent<KeepFitCrewRosterController>();
            crewRosterController.Init(this);

            if (HighLogic.LoadedScene == GameScenes.FLIGHT ||
                HighLogic.LoadedScene == GameScenes.TRACKSTATION ||
                HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewFitnessController");
                crewFitnessController = gameObject.AddComponent<KeepFitCrewFitnessController>();
                crewFitnessController.Init(this);
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitGeeEffectsController");
                this.geeEffectsController = gameObject.AddComponent<KeepFitGeeEffectsController>();
                this.geeEffectsController.Init(this);
            }
        }
Ejemplo n.º 10
0
        public override void OnAwake()
        {
            this.Log_DebugOnly("OnAwake", "Scene[{0}]", HighLogic.LoadedScene);
            base.OnAwake();

            if (cls == null)
            {
                cls = CLSClient.GetCLS();
            }

            if (mainWindow == null)
            {
                mainWindow = gameObject.AddComponent <MainWindow>();
                mainWindow.Init(this);
            }

            if (logWindow == null)
            {
                logWindow = gameObject.AddComponent <LogWindow>();
                logWindow.Init(this);
            }

            if (configWindow == null)
            {
                configWindow = gameObject.AddComponent <ConfigWindow>();
                configWindow.Init(this);
            }

            if (rosterWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing rosterWindow");
                rosterWindow = gameObject.AddComponent <RosterWindow>();
                rosterWindow.Init(this);
            }

            if (allVesselsWindow == null)
            {
                this.Log_DebugOnly("OnAwake", "Constructing allVesselsWindow");
                allVesselsWindow = gameObject.AddComponent <AllVesselsWindow>();
                allVesselsWindow.Init(this);
            }



            if (appLauncherButton != null)
            {
                this.Log_DebugOnly("OnAwake", "AppLauncher button already here");
            }
            else
            {
                this.Log_DebugOnly("OnAwake", "Adding AppLauncher button");

                Texture toolbarButtonTexture         = (Texture)GameDatabase.Instance.GetTexture("KeepFit/KeepFit", false);
                ApplicationLauncher.AppScenes scenes = ApplicationLauncher.AppScenes.FLIGHT |
                                                       ApplicationLauncher.AppScenes.MAPVIEW |
                                                       ApplicationLauncher.AppScenes.SPACECENTER |
                                                       ApplicationLauncher.AppScenes.SPH |
                                                       ApplicationLauncher.AppScenes.VAB |
                                                       ApplicationLauncher.AppScenes.TRACKSTATION;

                appLauncherButton = ApplicationLauncher.Instance.AddModApplication(onAppLaunchToggleOn,
                                                                                   onAppLaunchToggleOff,
                                                                                   onAppLaunchHoverOn,
                                                                                   onAppLaunchHoverOff,
                                                                                   onAppLaunchEnable,
                                                                                   onAppLaunchDisable,
                                                                                   scenes,
                                                                                   toolbarButtonTexture);
                ApplicationLauncher.Instance.AddOnRepositionCallback(onAppLauncherReposition);
            }


            this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewRosterController");
            crewRosterController = gameObject.AddComponent <KeepFitCrewRosterController>();
            crewRosterController.Init(this);

            if (HighLogic.LoadedScene == GameScenes.FLIGHT ||
                HighLogic.LoadedScene == GameScenes.TRACKSTATION ||
                HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitCrewFitnessController");
                crewFitnessController = gameObject.AddComponent <KeepFitCrewFitnessController>();
                crewFitnessController.Init(this);
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                this.Log_DebugOnly("OnAwake", "Adding KeepFitGeeEffectsController");
                this.geeEffectsController = gameObject.AddComponent <KeepFitGeeEffectsController>();
                this.geeEffectsController.Init(this);
            }
        }