public static bool AntennaHasConnection(Part part)
        {
            if (RTCore.Instance == null) return false;
            var antennaModules = part.Modules.OfType<IAntenna>();

            return antennaModules.Any(m => m.Connected);
        }
Example #2
0
        public static double GetThrustTorque(Part p, Vessel vessel)
        {
            var CoM = vessel.CoM;

            if (p.State == PartStates.ACTIVE)
            {
                if (p is LiquidEngine)
                {
                    if (((LiquidEngine)p).thrustVectoringCapable)
                    {
                        return Math.Sin(Math.Abs(((LiquidEngine)p).gimbalRange) * Math.PI / 180) * ((LiquidEngine)p).maxThrust * (p.Rigidbody.worldCenterOfMass - CoM).magnitude;
                    }
                }
                else if (p is LiquidFuelEngine)
                {
                    if (((LiquidFuelEngine)p).thrustVectoringCapable)
                    {
                        return Math.Sin(Math.Abs(((LiquidFuelEngine)p).gimbalRange) * Math.PI / 180) * ((LiquidFuelEngine)p).maxThrust * (p.Rigidbody.worldCenterOfMass - CoM).magnitude;
                    }
                }
                else if (p is AtmosphericEngine)
                {
                    if (((AtmosphericEngine)p).thrustVectoringCapable)
                    {
                        return Math.Sin(Math.Abs(((AtmosphericEngine)p).gimbalRange) * Math.PI / 180) * ((AtmosphericEngine)p).maximumEnginePower * ((AtmosphericEngine)p).totalEfficiency * (p.Rigidbody.worldCenterOfMass - CoM).magnitude;
                    }
                }
            }

            return 0;
        }
        public BaseToken(string token,
                         string par1,
                         string par2,
                         string par3,
                         string par4,
                         string par5,
                         string par6,
                         string par7,
                         string par8,
                         string par9,
                         int rowIndex,
                         int columnIndex,
                         Part p)
        {
            if (token.IndexOf("[") > -1)
            {
                //提取指令名中的说明部分
                Reference = token.Substring(token.LastIndexOf("[") + 1).Replace("]", "");
            }

            this.Token = token;
            this.Par1 = par1;
            this.Par2 = par2;
            this.Par3 = par3;
            this.Par4 = par4;
            this.Par5 = par5;
            this.Par6 = par6;
            this.Par7 = par7;
            this.Par8 = par8;
            this.Par9 = par9;
            this.Part = p;

            this.RowIndex = rowIndex;
            this.ColumnIndex = columnIndex;
        }
Example #4
0
    void buyPart(Part part)
    {
        if (mobo != null)
        {
            if (part.price < funds)
            {
                if (mobo.plugIn(part))
                {
                    funds -= part.price;
                    print("Part purchased! Remaining Funds: " + funds);
                    storeFront.Remove(part);
                }
                else
                {
                    print("Your motherboard's interface is not compatible with this!");
                }

            }
            else
            {
                print("You must construct additional cash piles!");
            }
        }
        else
        {
            print("You have no motherboard on which to plug things in to test if they work!");
        }
    }
 public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
 {
     ourVessel = thatPart.vessel;
     ourPart = thatPart;
     screenTexture = screen;
     cameraAspect = aspect;
 }
        private void Savebtn_Click(object sender, EventArgs e)
        {
            //save settings to resource file then test settings to connect

            Properties.Settings.Default.uname = Uname.Text;

            Properties.Settings.Default.passw = Passw.Text;

            Properties.Settings.Default.Save();

            string server = Properties.Settings.Default .svrname + ":" + Properties.Settings.Default.svrport;

            try
            {

                DataList.EpicConn = new BLConnectionPool(Uname.Text, Passw.Text, "AppServerDC://" + server);

                Part EpicPart = new Part(DataList.EpicConn);

                bool ValidLogin = EpicPart.PartExists(null);

                Properties.Settings.Default.validated = true;

                Properties.Settings.Default.Save();

                DataList.EpicClose();

                this.Close();

            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message,"Try Again");
            }
        }
Example #7
0
 public AnimatedNode(AttachNode node, Transform node_transform, Part part)
 {
     this.node = node;
     this.part = part;
     nT        = node_transform;
     pT        = part.partTransform;
 }
		void Awake()
		{
			part = GetComponentInParent<Part>();
			vessel = part.vessel;

			CamTools.OnResetCTools += OnResetCTools;
		}
        //detect if a part is above a deactivated engine or fuel tank
        public static bool HasDeactivatedEngineOrTankDescendant(Part p)
        {
            if ((p.State == PartStates.DEACTIVATED) && (p is FuelTank || p.IsEngine()) && !p.IsSepratron())
            {
                return true; // TODO: yet more ModuleEngine lazy checks
            }

            //check if this is a new-style fuel tank that's run out of resources:
            bool hadResources = false;
            bool hasResources = false;
            foreach (PartResource r in p.Resources)
            {
                if (r.name == "ElectricCharge") continue;
                if (r.maxAmount > 0) hadResources = true;
                if (r.amount > 0) hasResources = true;
            }
            if (hadResources && !hasResources) return true;

            if (p.IsEngine() && !p.EngineHasFuel()) return true;

            foreach (Part child in p.children)
            {
                if (HasDeactivatedEngineOrTankDescendant(child)) return true;
            }
            return false;
        }
Example #10
0
        public static void AssignAttachIcon(Part part, AttachNode node, Color iconColor, string name = null)
        {
            // Create NodeTransform if needed
            if (node.nodeTransform == null)
            {
                node.nodeTransform = new GameObject("KISNodeTransf").transform;
                node.nodeTransform.parent = part.transform;
                node.nodeTransform.localPosition = node.position;
                node.nodeTransform.localRotation = KIS_Shared.GetNodeRotation(node);
            }

            if (!node.icon)
            {
                node.icon = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                if (node.icon.collider) UnityEngine.Object.DestroyImmediate(node.icon.collider);
                if (node.icon.renderer)
                {
                    node.icon.renderer.material = new Material(Shader.Find("Transparent/Diffuse"));
                    iconColor.a = 0.5f;
                    node.icon.renderer.material.color = iconColor;
                }
                node.icon.transform.parent = part.transform;
                if (name != null) node.icon.name = name;
                double num;
                if (node.size == 0)
                {
                    num = (double)node.size + 0.5;
                }
                else num = (double)node.size;
                node.icon.transform.localScale = Vector3.one * node.radius * (float)num;
                node.icon.transform.parent = node.nodeTransform;
                node.icon.transform.localPosition = Vector3.zero;
                node.icon.transform.localRotation = Quaternion.identity;
            }
        }
Example #11
0
    public EngineModuleWrapper(Part part, string engineID)
    {
        ModuleEngines _engine = null;
        foreach (PartModule pm in part.Modules)
        {
            _engine = pm as ModuleEngines;
            if (_engine != null && _engine.engineID.ToLowerInvariant() == engineID.ToLowerInvariant())
                break;
        }
        if (_engine != null)
        {
            engine = _engine;
            if (part.Modules.Contains("ModuleEnginesRF"))
                engineType = EngineModuleType.REALENGINE;
            else if (part.Modules.Contains("ModuleEngines"))
                engineType = EngineModuleType.ENGINE;
            else if (part.Modules.Contains("ModuleEnginesFX"))
                engineType = EngineModuleType.ENGINEFX;
            else
                engineType = EngineModuleType.UNKNOWN;

            _minFuelFlow = engine.minFuelFlow;
            _maxFuelFlow = engine.maxFuelFlow;
        }
        else
        {
            engineType = EngineModuleType.UNKNOWN;
        }
    }
Example #12
0
 /// <param name="from">Object of comparison</param>
 public TargetHelper(Part from)
 {
     selfPart = from;
     self = selfPart.gameObject;
     for (int i = 0; i < 100; i++)
         moveToTargetSteps.Add(false);
 }
 private void OnPartDie(Part part)
 {
     if (autoAbort && part.vessel == vessel) {
         Debug.Log ("LEST: Part Failure - " + part.partInfo.title);
         vessel.ActionGroups.SetGroup (KSPActionGroup.Abort, true);
     }
 }
        /// <summary>
        /// If a part dies, rebuild the sphere
        /// </summary>
        void onPartDie(Part part)
        {
            // If there's no part or vessel, abort
            if (part == null || part.vessel == null)
                return;

            // Get the CelestialBody
            CelestialBody body = part.vessel.mainBody;

            // Get the Vessel
            Vessel vessel = part.vessel;

            // Create the Deformation
            Deformation deformation = new Deformation
            {
                position = Utility.LLAtoECEF(vessel.latitude, vessel.longitude, vessel.terrainAltitude, body.Radius),
                vPos = vessel.vesselTransform.position,
                altitude = vessel.terrainAltitude + body.Radius,
                body = body,
                surfaceSpeed = vessel.srfSpeed,
                mass = part.mass + part.GetResourceMass(),
                srfAngle = Vector3d.Angle(Vector3d.up, vessel.vesselTransform.forward)
            };
            deformations.Enqueue(deformation);
        }
Example #15
0
 /// <summary>
 /// Catch the event of the part disappearing, from crashing or
 /// from unloading from distance or scene change, and ensure
 /// the window closes if it was open when that happens:
 /// </summary>
 /// <param name="whichPartWentAway">The callback is called for EVERY part
 /// that ever goes away, so we have to check if it's the right one</param>
 public void GoAwayEventCallback(Part whichPartWentAway)
 {
     if (whichPartWentAway != attachedModule.part)
         return;
     
     Close();
 }
Example #16
0
 public FSengineWrapper(Part part)
 {
     engine = part.Modules.OfType<ModuleEngines>().FirstOrDefault();
     if (engine != null)
     {
         type = EngineType.ModuleEngine;
     }
     else
     {
         engineFX = part.Modules.OfType<ModuleEnginesFX>().FirstOrDefault();
         if (engineFX != null)
         {
             type = EngineType.ModuleEngineFX;
         }
         else
         {
             fsengine = part.Modules.OfType<FSengine>().FirstOrDefault();
             if (fsengine != null)
             {
                 type = EngineType.FSengine;
             }
         }
     }
     //Debug.Log("FSengineWrapper: engine type is " + type.ToString());
 }
Example #17
0
        protected virtual void Set(Part p, ReentrySimulation.SimCurves _simCurves)
        {
            Rigidbody rigidbody = p.rb;

            totalMass = rigidbody == null ? 0 : rigidbody.mass; // TODO : check if we need to use this or the one without the childMass
            shieldedFromAirstream = p.ShieldedFromAirstream;

            noDrag = rigidbody == null && !PhysicsGlobals.ApplyDragToNonPhysicsParts;
            hasLiftModule = p.hasLiftModule;
            bodyLiftMultiplier = p.bodyLiftMultiplier * PhysicsGlobals.BodyLiftMultiplier;

            simCurves = _simCurves;

            cubes = new DragCubeList();
            CopyDragCubesList(p.DragCubes, cubes);

            // Rotation to convert the vessel space vesselVelocity to the part space vesselVelocity
            vesselToPart = Quaternion.LookRotation(p.vessel.GetTransform().InverseTransformDirection(p.transform.forward), p.vessel.GetTransform().InverseTransformDirection(p.transform.up)).Inverse();

            //DragCubeMultiplier = PhysicsGlobals.DragCubeMultiplier;
            //DragMultiplier = PhysicsGlobals.DragMultiplier;


            //if (p.dragModel != Part.DragModel.CUBE)
            //    MechJebCore.print(p.name + " " + p.dragModel);

            //oPart = p;

        }
Example #18
0
        public BaseKspCamera(Part part, int windowSize, string windowLabel = "Camera")
        {
            this.windowSize = windowSize/2;
            this.part = part;
            subWindowLabel = windowLabel;
            this.windowLabel = windowLabel;
            partGameObject = part.gameObject;

            InitWindow();
            InitTextures();

            GameEvents.OnFlightUIModeChanged.Add(FlightUIModeChanged);

            GameObject updateGUIHolder = new GameObject();
            updateGUIObject = updateGUIHolder.AddComponent<UpdateGUIObject>();
            //updateGUIHolder.transform.parent = part.transform;

            guiStyleLabelBold = new GUIStyle("label") { fontSize = 13, fontStyle = FontStyle.Bold };
            guiStyleGreenLabelSmall = new GUIStyle("label") { fontSize = 11 };
            guiStyleGreenLabelSmall.normal.textColor = Color.green;
            guiStyleGreenLabelStandart = new GUIStyle(guiStyleGreenLabelSmall) { fontSize = 13 };
            guiStyleGreenLabelBold = new GUIStyle(guiStyleGreenLabelSmall) { fontSize = 15, fontStyle = FontStyle.Bold };
            guiStyleGreenLabelBold.alignment = TextAnchor.MiddleCenter;
            guiStyleRedLabelBoldLarge = new GUIStyle("label") { fontSize = 25, fontStyle = FontStyle.Bold };
            guiStyleRedLabelBoldLarge.normal.textColor = Color.red;
            guiStyleRedLabelBoldLarge.alignment = TextAnchor.MiddleCenter;
        }
Example #19
0
        /// <summary>
        /// Save or update current part
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_save_part_Click(object sender, EventArgs e)
        {
            Part part;
            if (treeView.SelectedNode.Tag != null && tb_debug_id.Text != "") {
                part = (Part)treeView.SelectedNode.Tag;
            } else {
                part = new Part(-1, tb_partnr.Text.ToString());
            }

            this.readForm(part);

            /*
            part.Mass = PartController.convertStringToFloat(tb_mass.Text.ToString());
            part.Weight = PartController.convertStringToFloat(tb_weight.Text.ToString());
            part.Length = PartController.convertStringToFloat(tb_length.Text.ToString());
            part.Width = PartController.convertStringToFloat(tb_width.Text.ToString());
            part.Height = PartController.convertStringToFloat(tb_height.Text.ToString());
            part.Description = tb_description.Text.ToString();
            */
            if (PartController.savePart(part)) {
                PartController.showMessageInfo("Part wurde erfolgreich gespeichert.", "Info");
            }
            else {
                PartController.showMessageWarning("Part konnte nicht gespeichert werden.", "Warnung");
            }

            //reload parts
            parts = PartController.loadParts();
            this.loadTree(parts);

            this.clearForm();
        }
Example #20
0
        public static bool createGroup(Part part, FXGroup group, string name, float distance, float spread, bool isloop, bool isLinearRolloff, bool bypassEffects)
        {
            if (name != string.Empty) {
                if (!GameDatabase.Instance.ExistsAudioClip (name)) {
                    Debug.LogError ("[DynamicSFX] AudioFile " + name + " not found");
                    return false;
                }
                if(part == null)
                {
                    group.audio = Camera.main.gameObject.AddComponent<AudioSource>();
                }else{
                    group.audio = part.gameObject.AddComponent<AudioSource> ();
                }

                group.audio.dopplerLevel = 0f;
                group.audio.panLevel = 1f;
                group.audio.clip = GameDatabase.Instance.GetAudioClip (name);
                group.audio.loop = isloop;
                group.audio.maxDistance = distance;
                group.audio.spread = spread;
                group.audio.playOnAwake = false;
                group.audio.bypassEffects = bypassEffects;

                if (isLinearRolloff == true) {
                    group.audio.rolloffMode = AudioRolloffMode.Linear;
                } else {
                    group.audio.rolloffMode = AudioRolloffMode.Logarithmic;
                }

                Debug.Log("[DynamicSFX] Added " + name + ".* in FXGroup " + group.name + " for Part = " + part.name);
                return true;
            }
            return false;
        }
        public IntakeCrossSectionAdjuster(PartModule intake, Matrix4x4 worldToVesselMatrix)
        {
            this.part = intake.part;
            intakeModule = intake as ModuleResourceIntake;
            intakeTrans = intakeModule.intakeTransform;

            if (!string.IsNullOrEmpty(intakeModule.occludeNode))
                node = intakeModule.node; 
            
            foreach (AttachNode candidateNode in part.attachNodes)
                if (candidateNode.nodeType == AttachNode.NodeType.Stack && Vector3.Dot(candidateNode.position, (part.transform.worldToLocalMatrix * intakeTrans.localToWorldMatrix).MultiplyVector(Vector3.forward)) > 0)
                {
                    if (candidateNode == node)
                        continue;

                    nodeOffsetArea = candidateNode.size;
                    if (nodeOffsetArea == 0)
                        nodeOffsetArea = 0.5;

                    nodeOffsetArea *= 0.625;     //scale it up as needed
                    nodeOffsetArea *= nodeOffsetArea;
                    nodeOffsetArea *= Math.PI;  //calc area;

                    nodeOffsetArea *= -1;        //and the adjustment area
                    break;
                }

            thisToVesselMatrix = worldToVesselMatrix * intakeTrans.localToWorldMatrix;

            vehicleBasisForwardVector = Vector3.forward;
            vehicleBasisForwardVector = thisToVesselMatrix.MultiplyVector(vehicleBasisForwardVector);

            Type intakeType = intake.GetType();
            intakeArea = (float)intakeType.GetField("Area").GetValue(intake);
        }
        public static bool IsConnectedToModule(this Part currentPart, String partmodule, int maxChildDepth, Part previousPart = null)
        {
            bool found = currentPart.Modules.Contains(partmodule);
            if (found)
                return true;

            if (currentPart.parent != null && currentPart.parent != previousPart)
            {
                bool foundPart = IsConnectedToModule(currentPart.parent, partmodule, maxChildDepth, currentPart);
                if (foundPart)
                    return true;
            }

            if (maxChildDepth > 0)
            {
                foreach (var child in currentPart.children.Where(c => c != null && c != previousPart))
                {
                    bool foundPart = IsConnectedToModule(child, partmodule, (maxChildDepth - 1), currentPart);
                    if (foundPart)
                        return true;
                }
            }

            return false;
        }
Example #23
0
    public static void GetRandomPart()
    {
        int numberOfAvailableParts = 7;
        System.Random r = new System.Random();
        switch (r.Next(numberOfAvailableParts))
        {
            case 0:
                CurrPart = new I_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 1:
                CurrPart = new J_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 2:
                CurrPart = new L_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 3:
                CurrPart = new O_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 4:
                CurrPart = new S_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 5:
                CurrPart = new T_Detail((int)Spawn.x, (int)Spawn.z);
                break;
            case 6:
                CurrPart = new Z_Detail((int)Spawn.x, (int)Spawn.z);
                break;

            default:
                break;
        }
    }
        private int GetScienceCount(Part part, bool IsCapacity)
        {
            try
            {
                int scienceCount = 0;
                int capacity = 0;
                foreach (PartModule pm in part.Modules)
                {
                    // Containers.
                    if (pm is ModuleScienceContainer)
                    {
                        scienceCount += ((ModuleScienceContainer)pm).GetScienceCount();
                        capacity += ((ModuleScienceContainer)pm).capacity;
                    }
                    else if (pm is ModuleScienceExperiment)
                    {
                        scienceCount += ((ModuleScienceExperiment)pm).GetScienceCount();
                        capacity += 1;
                    }
                }

                if (IsCapacity)
                    return capacity;
                else
                    return scienceCount;
            }
            catch (Exception ex)
            {
                ManifestUtilities.LogMessage(string.Format(" in GetScienceCount.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
                return 0;
            }
        }
Example #25
0
		void OnPartDie(Part p)
		{
			if(gameObject.activeInHierarchy)
			{
				StartCoroutine(DelayedCleanJammerListRoutine());
			}
		}
        public static bool CanBeXferred(Part SelectedPart)
        {
            bool results = false;
            try
            {
                if (SelectedPart == ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource)
                {
                    // Source to target
                    // Are the parts capable of holding kerbals and are there kerbals to move?
                    if ((ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget) && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource.protoModuleCrew.Count > 0)
                    {
                        // now, are the parts connected to each other in the same living space?
                        results = IsCLS();
                    }
                }
                else  //SelectedPart must be SeletedPartTarget
                {
                    // Target to Source
                    if ((ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != null && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartSource != ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget) && ManifestController.GetInstance(FlightGlobals.ActiveVessel).SelectedPartTarget.protoModuleCrew.Count > 0)
                    {
                        // now, are the parts connected to each other in the same living space?
                        results = IsCLS();
                    }
                }
            }
            catch (Exception ex)
            {
                ManifestUtilities.LogMessage(string.Format(" in CanBeXferred.  Error:  {0} \r\n\r\n{1}", ex.Message, ex.StackTrace), "Error", true);
            }

            return results;
        }
Example #27
0
        protected override void calculateCoM(Part part)
        {
            if (part.GroundParts ()) {
                return;
            }

            Vector3 com;
            if (!part.GetCoM (out com)) {
                return;
            }

            /* add resource mass */
            for (int i = 0; i < part.Resources.Count; i++) {
                PartResource res = part.Resources [i];
                if (!Resource.ContainsKey (res.info.name)) {
                    Resource [res.info.name] = new DCoMResource (res);
                } else {
                    Resource [res.info.name].amount += res.amount;
                }
            }

            /* calculate DCoM */
            float m = part.GetSelectedMass();

            vectorSum += com * m;
            totalMass += m;
        }
Example #28
0
 public static void TranslatePart(GameObject[] partUnity, Part<SimpleCube> part)
 {
     for (int i = 0; i < partUnity.Length; i++)
     {
         Translate(partUnity[i], part.GetCubes[i]);
     }
 }
        private static void HackStrutCData(ShipConstruct ship, Part p,
											int part_base)
        {
            //Debug.Log (String.Format ("[EL] before {0}", p.customPartData));
            string[] Params = p.customPartData.Split (';');
            for (int i = 0; i < Params.Length; i++) {
                string[] keyval = Params[i].Split (':');
                string Key = keyval[0].Trim ();
                string Value = keyval[1].Trim ();
                if (Key == "tgt") {
                    string[] pnameval = Value.Split ('_');
                    string pname = pnameval[0];
                    int val = int.Parse (pnameval[1]);
                    if (val == -1) {
                        Strut strut = new Strut (p, Params);
                        if (strut.target != null) {
                            val = ship.parts.IndexOf (strut.target);
                        }
                    }
                    if (val != -1) {
                        val += part_base;
                    }
                    Params[i] = "tgt: " + pname + "_" + val.ToString ();
                    break;
                }
            }
            p.customPartData = String.Join ("; ", Params);
            //Debug.Log (String.Format ("[EL] after {0}", p.customPartData));
        }
Example #30
0
        public static double GetThrustTorque(Part p, Vessel vessel)
        {
            if (p.State == PartStates.ACTIVE)
            {
                var gimbal = p.Modules.OfType<ModuleGimbal>().FirstOrDefault();

                if (gimbal != null && !gimbal.gimbalLock)
                {
                    var engine = p.Modules.OfType<ModuleEngines>().FirstOrDefault();
                    var fxengine = p.Modules.OfType<ModuleEnginesFX>().FirstOrDefault();

                    var magnitude = (p.Rigidbody.worldCenterOfMass - vessel.CoM).magnitude;
                    var gimbalRange = Math.Sin(Math.Abs(gimbal.gimbalRange));

                    var engineActive = engine != null && engine.isOperational;
                    var enginefxActive = fxengine != null && fxengine.isOperational;

                    if (engineActive)
                    {
                        return gimbalRange * engine.finalThrust * magnitude;
                    }
                    if (enginefxActive)
                    {
                        return gimbalRange * fxengine.finalThrust * magnitude;
                    }
                }
            }
            return 0;
        }
Example #31
0
        //Bill of Material
        public override void Build()
        {
            Part   part;
            string partleader = this.Parent.UnitID + "." + this.CreateID.ToString();

            decimal pweight = FrameWorks.Functions.PanelWieghtS2000(m_subAssemblyWidth, m_subAssemblyHieght);

            string labelStileR  = string.Empty;
            string labelStileL  = string.Empty;
            string labelTopRail = string.Empty;
            string labelBotRail = string.Empty;

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            #region Frame

            ////////////////////////////////////////////////////////////////////////////////////

            // JmbAlumR -->>
            part = new Part(4347, "JmbAlumR", this, 1, m_subAssemblyHieght);
            part.PartGroupType = "Frame";
            part.PartLabel     = "1)MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // JmbAlumL <<--
            part = new Part(4347, "JmbAlumL", this, 1, m_subAssemblyHieght);
            part.PartGroupType = "Frame";
            part.PartLabel     = "1)MiterEnds" + "\r\n" +
                                 "2)" + FrameWorks.Functions.TieBarLockCenter(this.SubAssemblyHieght);
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // HeadAlum ^^
            part = new Part(4347, "HeadAlum", this, 1, m_subAssemblyWidth);
            part.PartGroupType = "Frame";
            part.PartLabel     = "1)MiterEnds" + "\r\n" +
                                 "2)Machine Right PN:1741";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // SillAlum ||
            part = new Part(4347, "SillAlum", this, 1, m_subAssemblyWidth);
            part.PartGroupType = "Frame";
            part.PartLabel     = "1)MiterEnds" + "\r\n" +
                                 "2)Machine Right PN:1741";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Screen

            ////////////////////////////////////////////////////////////////////////////////////

            // ScrnFrmLeft
            part = new Part(4430, "ScrnFrmLeft", this, 1, m_subAssemblyHieght - screenReduce2X);
            part.PartGroupType = "Screen";
            part.PartLabel     = "1)MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // ScrnFrmRight
            part = new Part(4430, "ScrnFrmRight", this, 1, m_subAssemblyHieght - screenReduce2X);
            part.PartGroupType = "Screen";
            part.PartLabel     = "1)MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // ScrnFrmTop
            part = new Part(4430, "ScrnFrmTop", this, 1, m_subAssemblyWidth - screenReduce2X);
            part.PartGroupType = "Screen";
            part.PartLabel     = "1)MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // ScrnFrmBot
            part = new Part(4430, "ScrnFrmBot", this, 1, m_subAssemblyWidth - screenReduce2X);
            part.PartGroupType = "Screen";
            part.PartLabel     = "1)MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Hardware

            ////////////////////////////////////////////////////////////////////////////////////

            // AglBrktAlum
            part = new Part(3206, "AglBrktAlum", this, 8, AlumCrnBrk);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "WndFrame";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // ScreenAssyBrace
            part = new Part(1118, "ScreenAssyBrace", this, 4, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // CupPoint#8-32x3/16
            part = new Part(1537, "CupPoint#8-32x3/16", this, 8, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // OperatorEncoreRH
            part = new Part(5095, "OperatorEncoreRH", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // RH_Encore®CoverHandle
            part = new Part(4938, "RH_Encore®CoverHandle", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // OperatorBacker
            part = new Part(5253, "OperatorBacker", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            int hardwarecount = 1;
            if (m_subAssemblyHieght < 51.9999m)
            {
                hardwarecount = 1;
            }
            else
            {
                hardwarecount = 2;
            }

            ////////////////////////////////////////////////////////////////////////////////////

            // TruthMaxim24Lock
            part = new Part(4911, "TruthMaxim24Lock", this, hardwarecount, 0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // Keeper
            part = new Part(3516, "Keeper", this, hardwarecount, 0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            //Get the size of the tiebar partNo--
            decimal tieBarLength = FrameWorks.Functions.S2000TieBar(m_subAssemblyHieght);

            //check is sash even requires a tiebar
            if (tieBarLength != 0)
            {
                // Tie Bars
                part = new Part(3625, "Tie Bars", this, 1, tieBarLength);
                part.PartGroupType = "Hardware";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Seal/Weatherstripping

            ////////////////////////////////////////////////////////////////////////////////////

            decimal periFrame = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gaskFrmReduce, m_subAssemblyWidth - gaskFrmReduce);

            ////////////////////////////////////////////////////////////////////////////////////

            //FrameSeal
            for (int i = 0; i < 1; i++)
            {
                periFrame = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gaskFrmReduce, m_subAssemblyWidth - gaskFrmReduce);

                part = new Part(2274, "FrameSeal", this, 1, periFrame);
                part.PartGroupType = "Seal";
                part.PartLabel     = "";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            #region Sash

            ////////////////////////////////////////////////////////////////////////////////////

            // StileAlumL <<--
            part = new Part(4350, "StileAlumL", this, 1, m_subAssemblyHieght - frameReduce2X);
            part.PartGroupType = "Sash";
            part.PartLabel     = labelStileR = "1)MiterEnds" + "r\n" +
                                               "2)MachineKeeper";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // StileAlumR -->>
            part = new Part(4350, "StileAlumR", this, 1, m_subAssemblyHieght - frameReduce2X);
            part.PartGroupType = "Sash";
            part.PartLabel     = labelStileL = "MiterEnds";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // RailAlumT ^^
            part = new Part(4350, "RailAlumT", this, 1, m_subAssemblyWidth - frameReduce2X);
            part.PartGroupType = "Sash";
            part.PartLabel     = labelTopRail = "1)MiterEnds" + "\r\n" +
                                                "2)Machine1741Right";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // RailAlumB ||
            part = new Part(4350, "RailAlumB", this, 1, m_subAssemblyWidth - frameReduce2X);
            part.PartGroupType = "Sash";
            part.PartLabel     = labelBotRail = "1)MiterEnds" + "\r\n" +
                                                "2)Machine1741Right";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Muntins

            ////////////////////////////////////////////////////////////////////////////////////

            // ExtMuntHorz
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4588, "ExtMuntHorz", this, 1, (m_subAssemblyWidth - sidMuntGPExt2) / 2.0m);
                part.PartGroupType = "Muntins";
                part.PartLabel     = "WELD_BISHOP_Ends";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            // IntMuntHorz
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4587, "IntMuntHorz", this, 1, (m_subAssemblyWidth - sidMuntGPInt2) / 2.0m);
                part.PartGroupType = "Muntins";
                part.PartLabel     = "BEVEL_BISHOP_Ends";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            // ExtMuntVert
            for (int i = 0; i < 3; i++)
            {
                part = new Part(4588, "ExtMuntVert", this, 1, (m_subAssemblyHieght - sidMuntGPExt2) / 3.0m);
                part.PartGroupType = "Muntins";
                part.PartLabel     = "WELD_BISHOP_Ends";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            // IntMuntVert
            for (int i = 0; i < 3; i++)
            {
                part = new Part(4587, "IntMuntVert", this, 1, (m_subAssemblyHieght - sidMuntGPInt2) / 3.0m);
                part.PartGroupType = "Muntins";
                part.PartLabel     = "BEVEL_BISHOP_Ends";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region StopAlum

            ////////////////////////////////////////////////////////////////////////////////////

            // AlumGlsStpLeft
            part = new Part(4341, "AlumGlsStpLeft", this, 1, m_subAssemblyHieght - gstopReduce2X);
            part.PartGroupType = "StopAlum";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // AlumGlsStpRight
            part = new Part(4341, "AlumGlsStpRight", this, 1, m_subAssemblyHieght - gstopReduce2X);
            part.PartGroupType = "StopAlum";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // AlumGlsStpTop
            part = new Part(4341, "AlumGlsStpTop", this, 1, m_subAssemblyWidth - gstopReduce2X);
            part.PartGroupType = "StopAlum";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // AlumGlsStpBot
            part = new Part(4341, "AlumGlsStpBot", this, 1, m_subAssemblyWidth - gstopReduce2X);
            part.PartGroupType = "StopAlum";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region AsemblHrdwr

            ////////////////////////////////////////////////////////////////////////////////////

            // SS_0.4625_InsetCrnBrace
            part = new Part(4784, "SS_0.4625_InsetCrnBrace", this, 4, 0.0m);
            part.PartGroupType = "AsemblHrdwr";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // FlatHead_8-32x3/16_UndercutHead
            part = new Part(502, "FlatHead_8-32x3/16_UndercutHead", this, 16, 0.0m);
            part.PartGroupType = "AsemblHrdwr";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // AglBrktAlum
            part = new Part(3206, "AglBrktAlum", this, 4, AlumCrnBrk);
            part.PartGroupType = "AsemblHrdwr";
            part.PartLabel     = "SashWnd";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            //Cross_Bracket
            part = new Part(5267, "Cross_Bracket", this, 2, AlumCrnBrk);
            part.PartGroupType = "AsemblHrdwr";
            part.PartLabel     = "Cross_3.025";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            //SetScrew_10_32
            part = new Part(3518, "SetScrew_10_32", this, 16, PointSetScrew);
            part.PartGroupType = "AsemblHrdwr";
            part.PartLabel     = "1/4_20x.25";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Hardware

            ////////////////////////////////////////////////////////////////////////////////////

            // HingeCaseUR
            part = new Part(1741, "HingeCaseUR", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // HingeCaseLR
            part = new Part(1741, "HingeCaseLR", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // HingeShoeLR
            part = new Part(5279, "HingeShoeLR", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // HingeFiller
            part = new Part(5280, "HingeFiller", this, 2, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Glass

            ////////////////////////////////////////////////////////////////////////////////////

            // GlassPanel
            part = new Part(5503);
            part.FunctionalName    = "GlassPanel";
            part.PartGroupType     = "Glass";
            part.Qnty              = 1;
            part.ContainerAssembly = this;
            part.PartWidth         = (m_subAssemblyWidth - glassReduce2X);
            part.PartLength        = (m_subAssemblyHieght - glassReduce2X);
            part.PartThick         = 1.25m;
            part.PartLabel         = "SDL_2x3";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Seal/Weatherstripping

            ////////////////////////////////////////////////////////////////////////////////////

            //SashEdgeSeal
            for (int i = 0; i < 1; i++)
            {
                decimal periSash = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - edgeSealAdd, m_subAssemblyWidth - edgeSealAdd);

                part = new Part(2274, "SashEdgeSeal", this, 1, periSash);
                part.PartGroupType = "Seal";
                part.PartLabel     = "";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            //EPDM_PreSet
            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gaskSashReduce, m_subAssemblyWidth - gaskSashReduce);

                part = new Part(4314, "EPDM_PreSet", this, 1, peri);
                part.PartGroupType = "Seal";
                part.PartLabel     = "";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////

            //EPDM_Wedge
            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gaskSashReduce, m_subAssemblyWidth - gaskSashReduce);

                part = new Part(4284, "EPDM_Wedge", this, 1, peri);
                part.PartGroupType = "Seal";
                part.PartLabel     = "";
                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////////
            // EPDM_PreSet
            part = new Part(4314, "EPDM_PreSet", this, 2, m_subAssemblyHieght - sidMuntGPExt2);
            part.PartGroupType = "Seal";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // EPDM_Wedge
            part = new Part(4284, "EPDM_Wedge", this, 2, m_subAssemblyHieght - sidMuntGPInt2);
            part.PartGroupType = "Seal";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // EPDM_PreSet
            part = new Part(4314, "EPDM_PreSet", this, 4, m_subAssemblyWidth - sidMuntGPExt2);
            part.PartGroupType = "Seal";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            // EPDM_Wedge
            part = new Part(4284, "EPDM_Wedge", this, 4, m_subAssemblyWidth - sidMuntGPInt2);
            part.PartGroupType = "Seal";
            part.PartLabel     = "";
            m_parts.Add(part);

            ////////////////////////////////////////////////////////////////////////////////////

            #endregion

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        }
Example #32
0
        //Bill of Material
        public override void Build()
        {
            Part   part;
            string partleader = this.Parent.UnitID + "." + this.CreateID.ToString();



            #region Frame-Parts


            // JamBrzL -->>
            part = new Part(4306, "JamBrzL|>", this, 1, m_subAssemblyHieght - calkJoint);
            part.PartGroupType = "Frame-Parts";
            part.PartLabel     = "1)MiterTop";

            m_parts.Add(part);



            // JamBrzR -->>
            part = new Part(4306, "JamBrzR|>", this, 1, m_subAssemblyHieght - calkJoint);
            part.PartGroupType = "Frame-Parts";
            part.PartLabel     = "1)MiterTop";

            m_parts.Add(part);


            // HeadBrz ^^
            part = new Part(4306, "HeadBrz", this, 1, m_subAssemblyWidth);
            part.PartGroupType = "Frame-Parts";
            part.PartLabel     = "1)MiterEnds";

            m_parts.Add(part);


            #endregion

            #region AsemblHrdwr

            //////////////////////////////////////////////////////////////////////////////

            // BrzCnrBrkt
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4265, "BrzCnrBrkt", this, 1, bronzeCrnBrk);
                part.PartGroupType = "AsemblHrdwr-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // SetSocScrew_1/4-20x1/4
            for (int i = 0; i < 16; i++)
            {
                part = new Part(1545, "SetSocScrew_1/4-20x1/4", this, 1, 0.0m);
                part.PartGroupType = "AsemblHrdwr-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region HardWare



            // FIXED_STAND
            part = new Part(911, "FIXED_STAND", this, 1, 0.0m);
            part.PartGroupType = "Hardware-Parts";
            part.PartLabel     = "";

            m_parts.Add(part);



            // TABS

            part = new Part(3649, "TABS", this, Convert.ToInt32(this.Perimeter / 16.0m + 1.0m), NFtab);
            part.PartGroupType = "HardWare-Parts";
            part.PartLabel     = "CUT_LENGTH_3_INCHES";

            m_parts.Add(part);



            #endregion

            #region Seal/Weatherstripping



            decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght, m_subAssemblyWidth);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            for (int i = 0; i < 1; i++)
            {
                peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - calkJoint, m_subAssemblyWidth);

                //FrameSealKfolD
                part = new Part(2274, "FrameSealKfolD", this, 1, peri - m_subAssemblyWidth - 4.0m);
                part.PartGroupType = "Seal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////



            #endregion
        }
Example #33
0
        private void UpdateMonsterInfo(Monster Monster)
        {
            Visibility                = Visibility.Visible;
            MonsterName.Text          = Monster.Name;
            MonsterHealthBar.MaxSize  = Width * 0.7833333333333333;
            MonsterStaminaBar.MaxSize = Width - 72;

            // Update monster health and stamina
            UpdateHealthBar(MonsterHealthBar, Monster.Health, Monster.MaxHealth);
            UpdateHealthBar(MonsterStaminaBar, Monster.Stamina, Monster.MaxStamina);
            SetMonsterHealthBarText(Monster.Health, Monster.MaxHealth);
            SetMonsterStaminaText(Monster.Stamina, Monster.MaxStamina);
            DisplayCapturableIcon(Monster.Health, Monster.MaxHealth, Monster.CaptureThreshold);

            // Gets monster icon
            MonsterIcon.Source = GetMonsterIcon(Monster.Id);

            SwitchSizeBasedOnTarget();

            // Parts
            int index = 0;

            MonsterPartsContainer.Children.Clear();
            while (index < Monster.Parts.Count)
            {
                Part        mPart       = Monster.Parts[index];
                MonsterPart PartDisplay = new MonsterPart()
                {
                    Style = FindResource("OVERLAY_MONSTER_SUB_PART_STYLE") as Style
                };
                PartDisplay.SetContext(mPart, MonsterPartsContainer.ItemWidth);
                MonsterPartsContainer.Children.Add(PartDisplay);
                index++;
            }

            // Ailments
            index = 0;
            MonsterAilmentsContainer.Children.Clear();
            while (index < Monster.Ailments.Count)
            {
                Ailment        ailment        = Monster.Ailments[index];
                MonsterAilment AilmentDisplay = new MonsterAilment()
                {
                    Style = FindResource("OVERLAY_MONSTER_SUB_AILMENT_STYLE") as Style
                };
                AilmentDisplay.SetContext(ailment, MonsterAilmentsContainer.ItemWidth);
                MonsterAilmentsContainer.Children.Add(AilmentDisplay);
                index++;
            }

            // Enrage
            if (Monster.IsEnraged && !ConfigManager.Settings.Overlay.MonstersComponent.HideHealthInformation)
            {
                ANIM_ENRAGEDICON.Begin(MonsterHealthBar, true);
                ANIM_ENRAGEDICON.Begin(HealthBossIcon, true);
                EnrageTimerText.Visibility = Visibility.Visible;
                EnrageTimerText.Text       = $"{Monster.EnrageTimerStatic - Monster.EnrageTimer:0}s";
            }

            // Set monster crown
            MonsterCrown.Source     = Monster.Crown == null ? null : (ImageSource)FindResource(Monster.Crown);
            MonsterCrown.Visibility = Monster.Crown == null ? Visibility.Collapsed : Visibility.Visible;
            Weaknesses.Children.Clear(); // Removes every weakness icon
            if (Monster.Weaknesses == null)
            {
                return;
            }
            index = 0;
            while (index < Monster.Weaknesses.Keys.Count)
            {
                string      Weakness = Monster.Weaknesses.Keys.ElementAt(index);
                ImageSource img      = FindResource(Weakness) as ImageSource;
                img?.Freeze();
                WeaknessDisplay MonsterWeaknessDisplay = new WeaknessDisplay
                {
                    Icon   = img,
                    Width  = 20,
                    Height = 20
                };
                Weaknesses.Children.Add(MonsterWeaknessDisplay);
                index++;
            }
            // Sometimes Alatreon's state changes before OnMonsterSpawn is dispatched
            if (Monster.GameId == 87)
            {
                OnAlatreonElementShift(this, EventArgs.Empty);
            }
        }
 public static Expression <Func <MaterialConsumableItem, bool> > DefaultSearchExpression(Part part, Shopfloorline sfl)
 {
     return((i) => i.Part.Id == part.Id && i.Shopfloorline.Id == sfl.Id);
 }
 public static Action <MaterialConsumableItem> DefaultCreateMapping(Part part, Shopfloorline sfl, int qty)
 {
     return((i) => { i.Part = part;
                     i.Qty = qty;
                     i.Shopfloorline = sfl; });
 }
Example #36
0
 // repair a specified part
 public static void Repair(Part part)
 {
     part.FindModulesImplementing <Reliability>().FindAll(k => k.isEnabled && k.broken).ForEach(k => k.Repair());
 }
Example #37
0
 // return true if the part specified has a malfunction or critical failure
 public static bool Broken(Part part)
 {
     return(part.FindModulesImplementing <Reliability>().FindAll(k => k.isEnabled && k.broken) != null);
 }
Example #38
0
        private void ProcessElectricity(Part partObj, float time)
        {
            if (ProcessorMode == ProcessorModes.OFF)
            {
                return;
            }

            double volumePower = 0;

            if (shared.VolumeMgr.CheckCurrentVolumeRange())
            {
                // If the current volume is in range, check the capacity and calculate power
                var volume = shared.VolumeMgr.CurrentVolume;
                if (volume.Name == "Archive")
                {
                    volumePower = ARCHIVE_EFFECTIVE_BYTES * ECPerBytePerSecond;
                }
                else
                {
                    volumePower = volume.Capacity * ECPerBytePerSecond;
                }
            }
            else
            {
                // if the volume isn't in range, assume it doesn't consume any power
                volumePower = 0;
            }

            if (ProcessorMode == ProcessorModes.STARVED)
            {
                // If the processor is STARVED, check to see if there is enough EC to turn it back on.
                var request = averagePower.Mean;  // use the average power draw as a baseline of the power needed to restart.
                if (request > 0)
                {
                    var available = partObj.RequestResource("ElectricCharge", request);
                    if (available / request > 0.5)
                    {
                        SetMode(ProcessorModes.READY);
                    }
                    // Since we're just checking to see if there is enough power to restart, return
                    // the consumed EC.  The actual demand value will be drawn on the next update after
                    // the cpu boots.  This should give the ship a chance to collect a little more EC
                    // before the cpu actually boots.
                    partObj.RequestResource("ElectricCharge", -available);
                }
                else
                {
                    // If there is no historical power request, simply turn the processor back on.  This
                    // should not be possible, since it means that some how the processor got set to
                    // the STARVED mode, even though no power was requested.
                    SetMode(ProcessorModes.READY);
                }
                RequiredPower = (float)request; // Make sure RequiredPower matches the average.
            }
            else
            {
                // Because the processor is not STARVED, evaluate the power requirement based on actual operation.
                // For EC drain purposes, always pretend atleast 1 instruction happened, so idle drain isn't quite zero:
                int instructions = System.Math.Max(shared.Cpu.InstructionsThisUpdate, 1);
                var request      = volumePower * time + instructions * ECPerInstruction;
                if (request > 0)
                {
                    // only check the available EC if the request is greater than 0EC.  If the request value
                    // is zero, then available will always be zero and it appears that mono/.net treat
                    // "0 / 0" as equaling "0", which prevents us from checking the ratio.  Since getting
                    // "0" available of "0" requested is a valid state, the processor mode is only evaluated
                    // if request is greater than zero.
                    var available = partObj.RequestResource("ElectricCharge", request);
                    if (available / request < 0.5)
                    {
                        // 0.5 is an arbitrary ratio for triggering the STARVED mode.  It allows for some
                        // fluctuation away from the exact requested EC, ando adds some fuzzy math to how
                        // we deal with the descreet physics frames.  Essentially if there was enough power
                        // to run for half of a physics frame, the processor stays on.
                        SetMode(ProcessorModes.STARVED);
                    }
                }
                // Set RequiredPower to the average requested power.  This should help "de-bounce" the value
                // so that it doesn't fluctuate wildly (between 0.2 and 0.000001 in a single frame for example)
                RequiredPower = (float)averagePower.Update(request) / TimeWarp.fixedDeltaTime;
            }
        }
Example #39
0
        /*
        /// <summary>
        /// Adds the parent part of a <see cref="BaseAction"/> to be highlighted.
        /// </summary>
        /// <param name="action">The <see cref="BaseAction"/> of the part to be highlighted.</param>
        public void Add(BaseAction action)
        {
            this.Add(action.listParent.part);
        }
        */

        /// <summary>
        /// Gets a value indicating whether the highlighter contains a <see cref="Part"/>.
        /// </summary>
        /// <param name="p">The <see cref="Part"/> to search for.</param>
        /// <returns>True if the highlighter contains the <see cref="Part"/>.</returns>
        public bool Contains(Part p)
        {
            return this.internalHighlight.Contains(p);
        }
Example #40
0
        /// <summary>
        /// Load infos into this object and create a new BaseEvent
        /// </summary>
        /// <returns>true - loaded successfull</returns>
        public override bool Load(ConfigNode n, FlightComputer fc)
        {
            if (base.Load(n, fc))
            {
                // deprecated since 1.6.2, we need this for upgrading from 1.6.x => 1.6.2
                int PartId = 0;
                {
                    if (n.HasValue("PartId"))
                    {
                        PartId = int.Parse(n.GetValue("PartId"));
                    }
                }

                if (n.HasValue("flightID"))
                {
                    this.flightID = uint.Parse(n.GetValue("flightID"));
                }

                this.Module    = n.GetValue("Module");
                this.GUIName   = n.GetValue("GUIName");
                this.Name      = n.GetValue("Name");
                NewValueString = n.GetValue("NewValue");

                RTLog.Notify("Try to load an PartActionCommand from persistent with {0},{1},{2},{3},{4}",
                             PartId, this.flightID, this.Module, this.GUIName, this.Name);

                Part part     = null;
                var  partlist = FlightGlobals.ActiveVessel.parts;

                if (this.flightID == 0)
                {
                    // only look with the partid if we've enough parts
                    if (PartId < partlist.Count)
                    {
                        part = partlist.ElementAt(PartId);
                    }
                }
                else
                {
                    part = partlist.Where(p => p.flightID == this.flightID).FirstOrDefault();
                }

                if (part == null)
                {
                    return(false);
                }

                PartModule partmodule = part.Modules[Module];
                if (partmodule == null)
                {
                    return(false);
                }

                BaseFieldList fieldList = new BaseFieldList(partmodule);
                if (fieldList.Count <= 0)
                {
                    return(false);
                }

                this.BaseField = fieldList[this.Name];
                return(this.BaseField != null);
            }

            return(false);
        }
Example #41
0
 public override int GetHashCode()
 {
     return(Part != null ? Part.GetHashCode() : 0);
 }
 public virtual void Init(Part part)
 {
     this.part = part;
 }
        public void Directional(Part thisPart, int counter, bool Listening, float percentagePower, double recvSize, double recvEfficiency,
                                bool useSpotArea, bool useFacingVector, string state, out string status, out string VesselName, out double receivedpower, out int count)
        {
            frames += 1;
            if (frames == 40)
            {
                vesselFinder.SourceData(thisPart.vessel.GetDisplayName(), out VesselList, out excessList, out constantList, out targetList, out wavelengthList);
                frames = 0;
            }
            if (counter >= VesselList.Count)
            {
                counter = 0;
            }

            if (VesselList.Count > 0)
            {
                if (Listening & targetList[counter] == thisPart.vessel.GetDisplayName())
                {
                    Vector3d dest = thisPart.vessel.GetWorldPos3D();
                    double   excess2 = excessList[counter]; double constant2 = constantList[counter];
                    VesselName = VesselList[counter].GetDisplayName();
                    Vector3d source   = VesselList[counter].GetWorldPos3D();
                    double   distance = Vector3d.Distance(source, dest);
                    double   spotsize = (useSpotArea) ? Math.Pow((constant2 * distance / 2), 2) * 3.14 : constant2 * distance;

                    occlusion.IsOccluded(source, dest, wavelengthList[counter], out CelestialBody body, out bool occluded);

                    // adding EC that has been received
                    if (recvSize < spotsize)
                    {
                        receivedpower = Math.Round(((recvSize / spotsize) * recvEfficiency * excess2 * (percentagePower / 100)), 1);
                    }
                    else
                    {
                        receivedpower = Math.Round(((recvEfficiency * excess2) * (percentagePower / 100)), 1);
                    }
                    if (occluded)
                    {
                        receivedpower = 0;
                        state         = occludedby + body.GetDisplayName().TrimEnd('N', '^');
                    }
                    else
                    {
                        state = operational;
                    }

                    receivedpower *= relativistic.RedOrBlueShift(VesselList[counter], thisPart.vessel, state, out state);
                    if (useFacingVector)
                    {
                        receivedpower *= FractionalFlux(source, dest, thisPart);
                    }
                    if (relativistic.WarpDriveEngaged(thisPart))
                    {
                        receivedpower = 0;
                        state         = warpEngaged;
                    }
                }
                else
                {
                    receivedpower = 0;
                    VesselName    = vesselNone;
                }
            }
            else
            {
                receivedpower = 0;
                VesselName    = vesselNone;
            }
            status = state; count = counter;
        }
Example #44
0
 internal void thisPart(Part thisPart)
 {
     this.part = thisPart;
     this.part.AddModule("STCrewQuarters");
     //this.part.CreateInternalModel(PartLoader.GetInternalPart("mk1PodCockpit"));
 }
Example #45
0
        //Bill of Material
        public override void Build()
        {
            Part   part;
            string partleader = this.Parent.UnitID + "." + this.CreateID.ToString();



            #region Frame-Parts


            // JamBrzL -->>
            decimal doorPanel = decimal.Zero;

            doorPanel = this.Parent.SubAssemblies[0].SubAssemblyHieght;

            part = new Part(3948, "JamBrzL_|<", this, 1, m_subAssemblyHieght);
            part.PartGroupType = "Frame-Parts";
            decimal step = (doorPanel - 15.0m);
            step /= Convert.ToDecimal((FrameWorks.Functions.HingeCount(doorPanel) - 1));
            step  = Math.Round(step, 4);
            string msg = "";
            part.PartLabel = "1) MiterTop\r\n" +
                             "2) [911.m]Cope Jamb Bottom->\r\n" +
                             "3) Position 0rigin TOU @ ->" + (7.5m + 0.875m).ToString() + "\r\n" +
                             "4) Hinge Backer Prep->[1982.m] "
                             + FrameWorks.Functions.HingeCount(doorPanel).ToString() + "@<" + step.ToString() + ">O.C.";

            m_parts.Add(part);


            // JamBrzR -->>
            part = new Part(3948, "JamBrzR_|>", this, 1, m_subAssemblyHieght);
            part.PartGroupType = "Frame-Parts";
            part.PartLabel     = "1)MiterTop\r\n" +
                                 "2)[1962.m]Position 0rigin Strike Plate";

            m_parts.Add(part);


            // HeadBrz ^^
            part = new Part(3948, "HeadBrz", this, 1, m_subAssemblyWidth);
            part.PartGroupType = "Frame-Parts";
            part.PartLabel     = "1)MiterEnds\r\n" +
                                 "2)[1987.m]Position 0rigin Shoot Strike";

            m_parts.Add(part);


            #endregion

            #region HardWare



            // Strike Plate
            part = new Part(4153, "Strike Plate", this, 1, 0.0m);
            part.PartGroupType = "Hardware-Parts";
            part.PartLabel     = "";

            m_parts.Add(part);



            // Shoot Strike
            part = new Part(1988, "Shoot Strike", this, 2, 0.0m);
            part.PartGroupType = "Hardware-Parts";
            part.PartLabel     = "";

            m_parts.Add(part);



            #endregion

            #region Seal/Weatherstripping



            decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght, m_subAssemblyWidth);

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            for (int i = 0; i < 1; i++)
            {
                peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght, m_subAssemblyWidth);

                //FrameSeal
                part = new Part(1005, "FrameSeal", this, 1, peri - m_subAssemblyWidth - 4.0m * gasketReduce);
                part.PartGroupType = "Seal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////



            #endregion
        }
Example #46
0
 public void OnPartUndock(Part p)
 {
     OnVesselModified(p.vessel);
 }
Example #47
0
        public static double fixedRequestResource(Part part, string resourcename, double resource_amount, ResourceFlowMode flow)
        {
            if (flow == ResourceFlowMode.NULL)
            {
                flow = PartResourceLibrary.Instance.GetDefinition(resourcename).resourceFlowMode;
            }

            if (flow != ResourceFlowMode.ALL_VESSEL)
            {
                return(part.RequestResource(resourcename, resource_amount));
            }

            var partsWithResource = part.vessel.parts.Where(p => p.Resources.Contains(resourcename));

            Dictionary <Part, ORSPropellantControl> partLookup;

            if (orsPropellantDictionary.ContainsKey(part.vessel))
            {
                partLookup = orsPropellantDictionary[part.vessel];
            }
            else
            {
                partLookup = part.vessel.FindPartModulesImplementing <ORSPropellantControl>().ToDictionary(p => p.part);
                orsPropellantDictionary.Add(part.vessel, partLookup);
            }

            var partResources = partsWithResource.Where(p => !partLookup.ContainsKey(p) || partLookup[p].isPropellant).Select(p => p.Resources[resourcename]);
            IList <PartResource> relevant_part_resources = new List <PartResource>
                                                           (
                resource_amount > 0
                    ? partResources.Where(p => p.flowState && p.amount > 0)
                    : partResources.Where(p => p.flowState && p.maxAmount > p.amount)
                                                           );

            if (!relevant_part_resources.Any())
            {
                return(0);
            }

            double total_resource_change = 0;
            double res_ratio             = resource_amount > 0
                ? Math.Min(resource_amount / relevant_part_resources.Sum(p => p.amount), 1)
                : Math.Min(-resource_amount / relevant_part_resources.Sum(p => p.maxAmount - p.amount), 1);

            if (res_ratio == 0 || double.IsNaN(res_ratio) || double.IsInfinity(res_ratio))
            {
                return(0);
            }

            foreach (PartResource local_part_resource in relevant_part_resources)
            {
                if (resource_amount > 0)
                {
                    var part_resource_change = local_part_resource.amount * res_ratio;
                    local_part_resource.amount -= part_resource_change;
                    total_resource_change      += part_resource_change;
                }
                else
                {
                    var part_resource_change = (local_part_resource.maxAmount - local_part_resource.amount) * res_ratio;
                    local_part_resource.amount += part_resource_change;
                    total_resource_change      -= part_resource_change;
                }
            }
            return(total_resource_change);
        }
        public void Spherical(Part thisPart, bool Listening, float percentagePower, double recvSize,
                              double recvEfficiency, bool useSpotArea, bool useFacingVector, string state, out string status, out double received_power)
        {
            frames += 1;
            if (frames == 40)
            {
                vesselFinder.SourceData(thisPart.vessel.GetDisplayName(), out VesselList, out excessList, out constantList, out targetList, out wavelengthList);
                frames = 0;
            }

            received_power = 0;
            if (VesselList.Count > 0)
            {
                if (Listening)
                {
                    Vector3d dest = thisPart.vessel.GetWorldPos3D();
                    planetList.Clear();
                    // adds up all the received power values from all vessels in CorrectVesselList
                    for (int n = 0; n < VesselList.Count; n++)
                    {
                        if (targetList[n] == thisPart.vessel.GetDisplayName())
                        {
                            double   excess2 = excessList[n]; double constant2 = constantList[n];
                            Vector3d source   = VesselList[n].GetWorldPos3D();
                            double   distance = Vector3d.Distance(source, dest);
                            double   spotsize = (useSpotArea) ? Math.Pow(constant2 * distance / 2, 2) * 3.14 : constant2 * distance;
                            occlusion.IsOccluded(source, dest, wavelengthList[n], out CelestialBody celestial, out bool occluded);


                            // adding EC that has been received
                            if (recvSize < spotsize)
                            {
                                if (occluded == false)
                                {
                                    received_power += ((recvSize / spotsize) * recvEfficiency * excess2 * (percentagePower / 100))
                                                      * relativistic.RedOrBlueShift(VesselList[n], thisPart.vessel, state, out state)
                                                      * ((useFacingVector) ? FractionalFlux(source, dest, thisPart) : 1);
                                }
                            }
                            else
                            {
                                if (occluded == false)
                                {
                                    received_power += (recvEfficiency * excess2 * (percentagePower / 100))
                                                      * relativistic.RedOrBlueShift(VesselList[n], thisPart.vessel, state, out state)
                                                      * ((useFacingVector) ? FractionalFlux(source, dest, thisPart) : 1);
                                }
                            }
                            if (occluded)
                            {
                                planetList.Add(celestial);
                            }
                        }
                    }
                    if (planetList.Count > 0)
                    {
                        state = occludedby + planetList[planetList.Count - 1].GetDisplayName().TrimEnd('N', '^');
                    }
                    else
                    {
                        state = operational;
                    }
                    if (relativistic.WarpDriveEngaged(thisPart) & state != warpEngaged)
                    {
                        received_power = 0d;
                        state          = warpEngaged;
                    }
                }
            }
            status = state;
        }
Example #49
0
 public static double fixedRequestResourceSpareCapacity(Part part, string resourcename)
 {
     return(part.GetConnectedResources(resourcename).Sum(r => r.maxAmount - r.amount));
 }
Example #50
0
    //since it is a unity function, override isn't necessary
    private void OnCollisionEnter(Collision collision)
    {
        GameObject other = collision.gameObject;

        switch (other.tag)
        {
        case "ProjectileHero":
            Projectile p = other.GetComponent <Projectile>();
            //prevent damage off screen
            bounds.center = transform.position + boundsCenterOffset;
            if (bounds.extents == Vector3.zero || Utils.ScreenBoundsCheck(bounds, BoundsTest.offScreen) != Vector3.zero)
            {
                Destroy(other);
            }

            //Hurt this enemy
            GameObject goHit  = collision.contacts[0].thisCollider.gameObject;
            Part       prtHit = FindPart(goHit);
            if (prtHit == null)
            {
                goHit  = collision.contacts[0].otherCollider.gameObject;
                prtHit = FindPart(goHit);
            }
            if (prtHit.protectedBy != null)
            {
                foreach (string s in prtHit.protectedBy)
                {
                    if (!Destroyed(s))
                    {
                        //then don't damage the part
                        Destroy(other);    //other is projectile
                        return;
                    }
                }
            }
            //It's not protected, so damage
            prtHit.health -= Main.W_DEFS[p.type].damageOnHit;
            //Show damage on the part
            ShowLocalizedDamage(prtHit.mat);
            if (prtHit.health <= 0)
            {
                prtHit.go.SetActive(false);    //remove part
            }
            //check to see if whole ship is destroyed
            bool allDestroyed = true;     //assume it is
            foreach (Part prt in parts)
            {
                if (!Destroyed(prt))
                {
                    allDestroyed = false;
                    break;
                }
            }
            if (allDestroyed)
            {
                Main.S.ShipDestroyed(this);
                Destroy(this.gameObject);
            }
            Destroy(other);    //destroy projectile
            break;
        }
    }
Example #51
0
        //Bill of Material
        public override void Build()
        {
            Part part;

            string partleader = this.Parent.UnitID + "." + this.CreateID.ToString();

            decimal pweight = FrameWorks.Functions.PanelWieghtS2000(m_subAssemblyWidth, m_subAssemblyHieght);

            string labelStileR  = string.Empty;
            string labelStileL  = string.Empty;
            string labelTopRail = string.Empty;
            string labelBotRail = string.Empty;



            #region FrameBrz

            //////////////////////////////////////////////////////////////////////////////

            // Frame_4415_Vert
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4415, "Frame_4415_Vert", this, 1, m_subAssemblyHieght);
                part.PartGroupType = "FrameBrz-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // Frame_4415_Horz
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4415, "Frame_4415_Horz", this, 1, m_subAssemblyWidth);
                part.PartGroupType = "FrameBrz-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region FrameSeal

            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - K_FOLD_Q_Lon, m_subAssemblyWidth - K_FOLD_Q_Lon);

                //FrameSeal
                part = new Part(2274, "K_FOLD_Q_Lon", this, 1, peri);
                part.PartGroupType = "FrameSeal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }


            #endregion

            #region FrameHardware

            //////////////////////////////////////////////////////////////////////////////

            //CornerBrackets
            for (int i = 0; i < 8; i++)
            {
                part = new Part(4265, "CornerBrackets", this, 1, bronzeCrnBrk);
                part.PartGroupType = "FrameHardware-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // SupportBlockL
            part = new Part(2995, "SupportBlockL", this, 1, 0.0m);
            part.PartGroupType = "FrameHardware-Parts";
            part.PartLabel     = "";

            m_parts.Add(part);

            //////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Sash

            //////////////////////////////////////////////////////////////////////////////

            // Sash_4416_Vert
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4416, "Sash_4416_Vert", this, 1, m_subAssemblyHieght - sashReduceX2);
                part.PartGroupType = "Sash-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // Sash_4416_Horz
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4416, "Sash_4416_Horz", this, 1, m_subAssemblyWidth - sashReduceX2);
                part.PartGroupType = "Sash-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region MuntinBars

            //////////////////////////////////////////////////////////////////////////////

            //Muntin_Int
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4423, "Muntin_4423_Int", this, 1, m_subAssemblyWidth - stopReduceX2);
                part.PartGroupType = "MuntinBars-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            //Muntin_Ext
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4418, "Muntin_4418_Ext", this, 1, m_subAssemblyWidth - muntinReduceX2);
                part.PartGroupType = "MuntinBars-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            #endregion

            #region StopBrz1x5

            //////////////////////////////////////////////////////////////////////////////

            //GlsStpVt
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4413, "GlsStp_4413_Vt", this, 1, (m_subAssemblyHieght - (stopReduceX2 + muntinNibX4)) / 5.0m - 0.75m);
                part.PartGroupType = "StopBrz1x5-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "TopLite";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            //GlsStpVt
            for (int i = 0; i < 8; i++)
            {
                part = new Part(4413, "GlsStp_4413_Vt", this, 1, (m_subAssemblyHieght - (stopReduceX2 + muntinNibX4)) / 5.0m + 0.1875m);
                part.PartGroupType = "StopBrz1x5-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "4LowLite";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            //GlsStpHz
            for (int i = 0; i < 2; i++)
            {
                part = new Part(4413, "GlsStp_4413_Hz", this, 1, m_subAssemblyWidth - stopReduceX2);
                part.PartGroupType = "StopBrz1x5-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            ////////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Glass

            //Glass Panel

            part = new Part(4212);

            part.FunctionalName    = "Glass_0.53125Lami";
            part.PartGroupType     = "Glass-Parts";
            part.Qnty              = 1;
            part.ContainerAssembly = this;
            part.PartWidth         = m_subAssemblyWidth - (glassReduceX2);
            part.PartLength        = m_subAssemblyHieght - (glassReduceX2);
            part.PartThick         = 0.53125m;

            m_parts.Add(part);

            #endregion

            #region GlazingSeal

            //////////////////////////////////////////////////////////////////////////////

            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gasketReduce, m_subAssemblyWidth - gasketReduce);

                //Glazing Seals
                part = new Part(4436, "GlazPreSetEPDM", this, 1, peri);
                part.PartGroupType = "GlazingSeal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - gasketReduce, m_subAssemblyWidth - gasketReduce);

                //Glazing Seals
                part = new Part(3904, "GlazWedgEPDM", this, 1, peri);
                part.PartGroupType = "GlazingSeal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // GlazWedgEPDM
            for (int i = 0; i < 16; i++)
            {
                part = new Part(3904, "GlazWedgEPDM", this, 1, m_subAssemblyWidth - stopReduceX2);
                part.PartGroupType = "GlazingSeal-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // WindGuard
            for (int i = 0; i < 1; i++)
            {
                decimal peri = FrameWorks.Functions.Perimeter(m_subAssemblyHieght - windGrdRed, m_subAssemblyWidth - windGrdRed);

                //FrameSeal
                part = new Part(2274, "K_FOLD_Q_Lon", this, 1, peri);
                part.PartGroupType = "FrameSeal-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            #endregion

            #region Hardware

            //////////////////////////////////////////////////////////////////////////////

            // HingeCaseUL
            part = new Part(3627, "HingeCaseUL", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";

            m_parts.Add(part);

            // HingeCaseLL
            part = new Part(3627, "HingeCaseLL", this, 1, 0.0m);
            part.PartGroupType = "Hardware";
            part.PartLabel     = "";

            m_parts.Add(part);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////

            // Cam Handles
            if (m_subAssemblyHieght <= 47.99m)
            {
                //HandleCamLH
                part = new Part(1171, "HandleCamLH", this, 1, 0.0m);
                part.PartGroupType  = "Hardware";
                part.PartLabel      = "";
                part.PartIdentifier = partleader + "." + Convert.ToString(createID++);
                m_parts.Add(part);

                //StrikeWedge

                part = new Part(1174, "StrikeWedge", this, 1, 0.0m);
                part.PartGroupType  = "Hardware";
                part.PartLabel      = "";
                part.PartIdentifier = partleader + "." + Convert.ToString(createID++);
                m_parts.Add(part);
            }
            else
            {
                //HandleCamLH

                part = new Part(1171, "HandleCamLH", this, 1, 0.0m);
                part.PartGroupType  = "Hardware";
                part.PartLabel      = "";
                part.PartIdentifier = partleader + "." + Convert.ToString(createID++);
                m_parts.Add(part);

                //HandleCamLH

                part = new Part(1171, "HandleCamLH", this, 1, 0.0m);
                part.PartGroupType  = "Hardware";
                part.PartLabel      = "";
                part.PartIdentifier = partleader + "." + Convert.ToString(createID++);
                m_parts.Add(part);

                //StrikeWedge

                part = new Part(1174, "StrikeWedge", this, 2, 0.0m);
                part.PartGroupType  = "Hardware";
                part.PartLabel      = "";
                part.PartIdentifier = partleader + "." + Convert.ToString(createID++);
                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            // SashBrackets
            for (int i = 0; i < 4; i++)
            {
                part = new Part(4441, "CornerBrackets", this, 1, ss304CrnBrk);
                part.PartGroupType = "Hardware-Parts";
                part.PartWidth     = part.Source.Width;
                part.PartThick     = part.Source.Height;
                part.PartLabel     = "SS_Angle";

                m_parts.Add(part);
            }

            //////////////////////////////////////////////////////////////////////////////

            #endregion
        }
Example #52
0
 public static float fixedRequestResource(Part part, string resourcename, float resource_amount)
 {
     return((float)fixedRequestResource(part, resourcename, (double)resource_amount));
 }
Example #53
0
 public static Vector3 ZeroWind(CelestialBody body, Part part, Vector3 position)
 {
     return(Vector3.zero);
 }
Example #54
0
 public override bool CanChangePart(ILineItem lineItem, Part newPart)
 {
     return(base.CanChangePart(lineItem, newPart));
 }
Example #55
0
 public virtual void OnDragToPart(KIS_Item item, Part destPart)
 {
 }
Example #56
0
        //Bill of Material
        public override void Build()
        {
            {
                TrackHelper trackHelper = new TrackHelper(panelCount, m_subAssemblyWidth, 0);

                Part   part;
                string partleader = this.Parent.UnitID + "." + this.CreateID.ToString();



                #region TopTrackY


                //TopTrackYOLeft

                part = new Part(3406, "TopTrackYOLeft", this, 1, (trackHelper.DoorPanelWidth) - (stileOverLap));
                part.PartGroupType = "TopTrackY-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);


                // TopTrackYYXX

                part = new Part(3406, "TopTrackYYXX", this, 1, (m_subAssemblyWidth) - 2 * jamB);
                part.PartGroupType = "TopTrackY-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);


                //TopTrackYORight

                part = new Part(3406, "TopTrackYORight", this, 1, (trackHelper.DoorPanelWidth) - (stileOverLap));
                part.PartGroupType = "TopTrackY-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);



                #endregion

                #region HDPE-Parts



                // HDMPHead ^^
                part = new Part(3442, "HDMPHead", this, 1, m_subAssemblyWidth);
                part.PartGroupType = "HDPE-Parts";
                part.PartLabel     = "";

                m_parts.Add(part);



                // HDMPJamb ^^
                for (int i = 0; i < 2; i++)
                {
                    part = new Part(3442, "HDMPJamb", this, 1, m_subAssemblyHieght);
                    part.PartGroupType = "HDPE-Parts";
                    part.PartLabel     = "";

                    m_parts.Add(part);
                }



                #endregion

                #region Frame-Parts


                //JambAng4Int -->>
                for (int i = 0; i < 2; i++)
                {
                    part = new Part(3712, "JambAng4Int", this, 1, m_subAssemblyHieght);
                    part.PartGroupType = "Frame-Parts";
                    part.PartLabel     = "";

                    m_parts.Add(part);
                }
                //*********************************************************************

                //JambAngExt -->>
                for (int i = 0; i < 2; i++)
                {
                    part = new Part(3712, "JambAngExt", this, 1, m_subAssemblyHieght);
                    part.PartGroupType = "Frame-Parts";
                    part.PartLabel     = "";

                    m_parts.Add(part);
                }
                //*********************************************************************


                //HeadAng -->>
                for (int i = 0; i < 2; i++)
                {
                    part = new Part(3711, "HeadAng", this, 1, m_subAssemblyWidth);
                    part.PartGroupType = "Frame-Parts";
                    part.PartLabel     = "";

                    m_parts.Add(part);
                }
                //*********************************************************************

                //HeadAngFill -->>
                for (int i = 0; i < 2; i++)
                {
                    part = new Part(3712, "HeadAngFill", this, 1, (trackHelper.DoorPanelWidth) - (stileOverLap));
                    part.PartGroupType = "Frame-Parts";
                    part.PartLabel     = "";

                    m_parts.Add(part);
                }



                #endregion
            }
        }
 /// <summary>
 /// 部位別リストの取得.
 /// </summary>
 /// <param name="part">部位</param>
 public List <MasterArmorData> GetPartList(Part part)
 {
     return(this.GetRecordList()
            .Where(rec => rec.Part == part)
            .ToList());
 }
Example #58
0
        protected void Update()
        {
            try
            {
                if (!Visible || Hidden || EditorLogic.RootPart == null || EditorLogic.fetch.editorScreen != EditorScreen.Parts)
                {
                    return;
                }

                position.x = Mathf.Clamp(Input.mousePosition.x + 16.0f, 0.0f, Screen.width - position.width);
                position.y = Mathf.Clamp(Screen.height - Input.mousePosition.y, 0.0f, Screen.height - position.height);
                if (position.x < Input.mousePosition.x + 20.0f)
                {
                    position.y = Mathf.Clamp(position.y + 20.0f, 0.0f, Screen.height - position.height);
                }
                if (position.x < Input.mousePosition.x + 16.0f && position.y < Screen.height - Input.mousePosition.y)
                {
                    position.x = Input.mousePosition.x - 3 - position.width;
                }

                RaycastHit rayHit;
                if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out rayHit))
                {
                    part = rayHit.transform.GetComponent <Part>();
                }
                else
                {
                    part = EditorLogic.fetch.ship.parts.Find(p => p.HighlightActive) ?? EditorLogic.SelectedPart;
                }

                if (part != null)
                {
                    if (!part.Equals(selectedPart))
                    {
                        selectedPart = part;
                        ResetInfo();
                    }
                    if (NamesOnly || skipFrame)
                    {
                        skipFrame = false;
                        return;
                    }

                    if (!showInfo && Input.GetMouseButtonDown(2))
                    {
                        showInfo = true;
                    }
                    else if (ClickToOpen && showInfo && Input.GetMouseButtonDown(2))
                    {
                        ResetInfo();
                    }

                    if (showInfo)
                    {
                        PartInfoItem.Release(infoItems);
                        infoItems.Clear();
                        SetCostInfo();
                        SetMassItems();
                        SetResourceItems();
                        SetEngineInfo();
                        SetAlternatorInfo();
                        SetGimbalInfo();
                        SetRcsInfo();
                        SetParachuteInfo();
                        SetSasInfo();
                        SetReactionWheelInfo();
                        SetSolarPanelInfo();
                        SetGeneratorInfo();
                        SetDecouplerInfo();
                        SetTransmitterInfo();
                        SetScienceExperimentInfo();
                        SetScienceContainerInfo();
                        SetSingleActivationInfo();
                    }
                }
                else
                {
                    selectedPart = null;
                }
            }
            catch (Exception ex)
            {
                MyLogger.Exception(ex);
            }
        }
Example #59
0
        private IEnumerator WaitAndSendMsg(Part partToAttach, Vector3 position, Quaternion rotation, Part toPart = null)
        {
            while (!partToAttach.rigidbody)
            {
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Waiting rigidbody to initialize...");
                yield return(new WaitForFixedUpdate());
            }
            if (toPart)
            {
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Rigidbody initialized, setting velocity...");
                partToAttach.rigidbody.velocity        = toPart.rigidbody.velocity;
                partToAttach.rigidbody.angularVelocity = toPart.rigidbody.angularVelocity;
                KAS_Shared.DebugLog("WaitAndAttach(Pointer) - Waiting velocity to apply by waiting 0.1 seconds...");
                yield return(new WaitForSeconds(0.1f));

                partToAttach.transform.position = position;
                partToAttach.transform.rotation = rotation;
                partToAttach.SendMessage("OnAttachPart", toPart, SendMessageOptions.DontRequireReceiver);
            }
            else
            {
                partToAttach.transform.position = position;
                partToAttach.transform.rotation = rotation;
                partToAttach.SendMessage("OnAttachStatic", SendMessageOptions.DontRequireReceiver);
            }
        }
Example #60
0
        private void Start()
        {
            // Apply the modules
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Apply(this);
            }

            // Register us as the parental object for the scatter
            landControl             = transform.parent.GetComponent <PQSLandControl>();
            transform.parent        = landControl.sphere.transform;
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;
            transform.localScale    = Vector3.one;
            scatter = landControl.scatters.First(s => s.scatterName == scatter.scatterName); // I hate Unity
            typeof(PQSLandControl.LandClassScatter).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
            .FirstOrDefault(f => f.FieldType == typeof(GameObject))?.SetValue(scatter, gameObject);
            scatterObjects = new List <GameObject>();
            body           = Part.GetComponentUpwards <CelestialBody>(landControl.gameObject);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested);
            if (!baseMesh && meshes.Count > 0)
            {
                baseMesh = meshes[0];
            }

            // Generate a dummy mesh that is used to replace the mesh KSP want's to render itself.
            if (!_cubeMesh)
            {
                Vector3[] vertices =
                {
                    new Vector3(0, 0, 0),
                    new Vector3(1, 0, 0),
                    new Vector3(1, 1, 0),
                    new Vector3(0, 1, 0),
                    new Vector3(0, 1, 1),
                    new Vector3(1, 1, 1),
                    new Vector3(1, 0, 1),
                    new Vector3(0, 0, 1),
                };

                Int32[] triangles =
                {
                    0, 2, 1, //face front
                    0, 3, 2,
                    2, 3, 4, //face top
                    2, 4, 5,
                    1, 2, 5, //face right
                    1, 5, 6,
                    0, 7, 4, //face left
                    0, 4, 3,
                    5, 4, 7, //face back
                    5, 7, 6,
                    0, 6, 7, //face bottom
                    0, 1, 6
                };

                _cubeMesh = new Mesh {
                    vertices = vertices, triangles = triangles, name = "Kopernicus-CubeDummy"
                };
            }

            scatter.baseMesh = _cubeMesh;

            // PostApply for the Modules
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].PostApply(this);
            }
        }