private void PartInitializeSuffixes() { AddSuffix("CONTROLFROM", new NoArgsSuffix(ControlFrom)); AddSuffix("NAME", new Suffix <string>(() => Part.name)); AddSuffix("TITLE", new Suffix <string>(() => Part.partInfo.title)); AddSuffix("STAGE", new Suffix <int>(() => Part.inverseStage)); AddSuffix("UID", new Suffix <string>(() => Part.uid().ToString())); AddSuffix("ROTATION", new Suffix <Direction>(() => new Direction(Part.transform.rotation))); AddSuffix("POSITION", new Suffix <Vector>(() => new Vector(Part.transform.position - shared.Vessel.findWorldCenterOfMass()))); AddSuffix("TAG", new NoArgsSuffix <string>(GetTagName)); AddSuffix("FACING", new Suffix <Direction>(() => GetFacing(Part))); AddSuffix("RESOURCES", new Suffix <ListValue>(() => GatherResources(Part))); AddSuffix("TARGETABLE", new Suffix <bool>(() => Part.Modules.OfType <ITargetable>().Any())); AddSuffix("SHIP", new Suffix <VesselTarget>(() => new VesselTarget(Part.vessel, shared))); AddSuffix("GETMODULE", new OneArgsSuffix <PartModuleFields, string>(GetModule)); AddSuffix("GETMODULEBYINDEX", new OneArgsSuffix <PartModuleFields, int>(GetModuleIndex)); AddSuffix(new[] { "MODULES", "ALLMODULES" }, new Suffix <ListValue>(GetAllModules, "A List of all the modules' names on this part")); AddSuffix("PARENT", new Suffix <PartValue>(() => PartValueFactory.Construct(Part.parent, shared), "The parent part of this part")); AddSuffix("HASPARENT", new Suffix <bool>(() => Part.parent != null, "Tells you if this part has a parent, is used to avoid null exception from PARENT")); AddSuffix("CHILDREN", new Suffix <ListValue <PartValue> >(() => PartValueFactory.ConstructGeneric(Part.children, shared), "A LIST() of the children parts of this part")); AddSuffix("DRYMASS", new Suffix <float>(Part.GetDryMass, "The Part's mass when empty")); AddSuffix("MASS", new Suffix <float>(Part.CalculateCurrentMass, "The Part's current mass")); AddSuffix("WETMASS", new Suffix <float>(Part.GetWetMass, "The Part's mass when full")); AddSuffix("HASPHYSICS", new Suffix <bool>(Part.HasPhysics, "Is this a strange 'massless' part")); }
public override string ToString() { string tagName = GetTagName(); if (string.IsNullOrEmpty(tagName)) { return(string.Format("PART({0},uid={1})", Part.name, Part.uid())); } return(string.Format("PART({0},tag={1})", Part.name, tagName)); }