示例#1
0
 internal void Remove(Scaler listener)
 {
     if (this.listeners.Contains(listener))
     {
         this.listeners.Remove(listener);
     }
 }
示例#2
0
        protected virtual void SetupPrefab(Part prefabPart)
        {
            Log.dbg("SetupPrefab {0}", this.InstanceID);
            ConfigNode PartNode   = GameDatabase.Instance.GetConfigs("PART").FirstOrDefault(c => c.name.Replace('_', '.') == part.name).config;
            ConfigNode ModuleNode = PartNode.GetNodes("MODULE").FirstOrDefault(n => n.GetValue("name") == moduleName);

            this.ScaleType = new ScaleType(ModuleNode);
            this.SetupFromConfig(ScaleType);
            this.scaler = PartDB.Scaler.Create(prefabPart, this.part, ScaleType);
            tweakScale  = currentScale = defaultScale;

            tfInterface = Type.GetType("TestFlightCore.TestFlightInterface, TestFlightCore", false);
        }
示例#3
0
        private void OnDestroy()
        {
            Log.dbg("OnDestroy {0}", this._InstanceID);             // Something bad is happening inside KSP guts before this being called,
            // so I had to cache the InstanceID because the part's data are inconsistent at this point.

            if (this.wasOnEditorAttachAdded)
            {
                this.part.OnEditorAttach -= this.OnEditorAttach;
            }
            if (this.wasOnEditorShipModifiedAdded)
            {
                GameEvents.onEditorShipModified.Remove(this.OnEditorShipModified);
            }
            if (null != this.scaler)
            {
                this.scaler = this.scaler.Destroy();
            }
        }
示例#4
0
        protected virtual void Setup(Part part)
        {
            Log.dbg("Setup {0}", this.InstanceID);

            {
                Part prefab = part.partInfo.partPrefab;
                ScaleType = (prefab.Modules["TweakScale"] as TweakScale).ScaleType;
                SetupFromConfig(ScaleType);
                this.scaler = PartDB.Scaler.Create(prefab, part, ScaleType, this);                     // This need to be reworked. I calling this twice. :(

                part.OnEditorAttach        += OnEditorAttach;
                this.wasOnEditorAttachAdded = true;
            }

            _updaters = TweakScaleUpdater.CreateUpdaters(part).ToArray();
            this.SetupCrewManifest();

            if (!isFreeScale && ScaleFactors.Length != 0)
            {
                tweakName  = Tools.ClosestIndex(tweakScale, ScaleFactors);
                tweakScale = ScaleFactors[tweakName];
            }
        }
示例#5
0
 internal void Add(Scaler listener)
 {
     this.listeners.Add(listener);
 }