internal string Invoke(PartModule m, List <KeyValuePair <string, double> > resourcesList, CelestialBody body, Dictionary <string, double> environment) { IKerbalismModule km = m as IKerbalismModule; if (km != null) { return(km.PlannerUpdate(resourcesList, body, environment)); } var result = methodInfo.Invoke(m, new object[] { resourcesList, body, environment }); if (result != null) { return(result.ToString()); } return("unknown"); }
public string invoke(Dictionary <string, double> availableRresources, List <KeyValuePair <string, double> > resourceChangeRequest) { IKerbalismModule km = module as IKerbalismModule; if (km != null) { return(km.ResourceUpdate(availableRresources, resourceChangeRequest)); } var title = methodInfo.Invoke(module, new object[] { availableRresources, resourceChangeRequest }); if (title == null) { return(module.moduleName); } return(title.ToString()); }
private void Process_apiModule(PartModule m, EnvironmentAnalyzer env, VesselAnalyzer va) { List <KeyValuePair <string, double> > resourcesList = new List <KeyValuePair <string, double> >(); Dictionary <string, double> environment = new Dictionary <string, double>(); environment["altitude"] = env.altitude; environment["orbital_period"] = env.orbital_period; environment["shadow_period"] = env.shadow_period; environment["shadow_time"] = env.shadow_time; environment["albedo_flux"] = env.albedo_flux; environment["solar_flux"] = env.solar_flux; environment["sun_dist"] = env.sun_dist; environment["temperature"] = env.temperature; environment["total_flux"] = env.total_flux; environment["temperature"] = env.temperature; environment["sunlight"] = Planner.Sunlight == Planner.SunlightState.Shadow ? 0 : 1; Lib.Log("resource count before call " + resourcesList.Count); string title; IKerbalismModule km = m as IKerbalismModule; if (km != null) { title = km.PlannerUpdate(resourcesList, env.body, environment); } else { title = apiDelegates[m.moduleName].Invoke(m, resourcesList, env.body, environment); } Lib.Log("resource count after call " + resourcesList.Count); foreach (var p in resourcesList) { var res = Resource(p.Key); if (p.Value >= 0) { res.Produce(p.Value, title); } else { res.Consume(-p.Value, title); } } }
public PlannerDelegate(IKerbalismModule module) { this.module = module; }