internal static Scaler Create(Part prefab, Part part, ScaleType scaleType, TweakScale ts = null) { bool hasVariants = prefab.Modules.Contains("ModulePartVariants"); return(null == ts ? new Scaler(prefab, part, scaleType, ts) : hasVariants ? FindAndCreate("VariantPartScaler", prefab, part, scaleType, ts) : FindAndCreate("StandardPartScaler", prefab, part, scaleType, ts) ); }
/// <summary> /// Initialises the PartDB thingy. /// </summary> /// <param name="prefab"></param> the prefab data fetch from the KSP's OnLoad(null) call /// <param name="part"></param> the part /// <param name="scaleType"></param> the default scaleType /// <param name="ts"></param> the TweakScale object that own us. **MUST BE NULL** when starting up KSP (Loading Scene). protected Scaler(Part prefab, Part part, ScaleType scaleType, TweakScale ts) { this.prefab = prefab; this.part = part; this.ScaleNodes = scaleType.ScaleNodes; this.ts = ts; this.defaultScale = this.currentScale = this.previousScale = scaleType.DefaultScale; if (null != this.ts) { this.currentScale = this.previousScale = this.ts.currentScale; } if (HighLogic.LoadedSceneIsEditor) { this.OnEditorIn(); } GameEventGameSceneSwitchListener.Instance.Add(this); }
public VariantPartScaler(Part prefab, Part part, ScaleType scaleType, TweakScale ts) : base(prefab, part, scaleType, ts) { this.previousVariant = this.currentVariant = part.variants.SelectedVariant; }
private static Scaler FindAndCreate(string name, Part prefab, Part part, ScaleType scaleType, TweakScale ts) { string qualifiedName = "TweakScale.PartDB." + name; Type type = KSPe.Util.SystemTools.TypeFinder.FindByQualifiedName(qualifiedName); return((Scaler)Activator.CreateInstance(type, prefab, part, scaleType, ts)); }
public StandardPartScaler(Part prefab, Part part, ScaleType scaleType, TweakScale ts) : base(prefab, part, scaleType, ts) { }