public virtual void Detach(bool isWelding) { if (isWelding == false) { m_parentBlock = null; } }
public virtual void Detach(bool isWelding) { if (!isWelding) { this.m_parentBlock = null; } }
public override void OnRegisteredToGridSystems() { base.OnRegisteredToGridSystems(); if (Sync.IsServer) { if (m_parentId != null) { MyMechanicalConnectionBlockBase parent = null; MyEntities.TryGetEntityById <MyMechanicalConnectionBlockBase>(m_parentId.Value, out parent); if (parent != null && parent.CubeGrid != null && parent.Closed == false) { parent.ReattachTop(this); } } CubeGrid.OnGridSplit += CubeGrid_OnGridSplit; } }
public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid) { base.Init(builder, cubeGrid); MyObjectBuilder_AttachableTopBlockBase base2 = builder as MyObjectBuilder_AttachableTopBlockBase; if (base2 != null) { if (!base2.YieldLastComponent) { base.SlimBlock.DisableLastComponentYield(); } if (base2.ParentEntityId != 0) { VRage.Game.Entity.MyEntity entity; Sandbox.Game.Entities.MyEntities.TryGetEntityById(base2.ParentEntityId, out entity, false); MyMechanicalConnectionBlockBase base3 = entity as MyMechanicalConnectionBlockBase; if (base3 != null) { base3.MarkForReattach(); } } } this.LoadDummies(); }
public override void Attach(MyMechanicalConnectionBlockBase pistonBase) { base.Attach(pistonBase); m_pistonBlock = pistonBase as MyPistonBase; }
public virtual void Attach(MyMechanicalConnectionBlockBase parent) { m_parentBlock = parent; }
public override void Attach(MyMechanicalConnectionBlockBase parent) { base.Attach(parent); this.m_isSuspensionMounted = base.Stator is MyMotorSuspension; }
private bool SteeringLogic() { Vector3 vector2; Color? nullable; if (!base.IsFunctional) { return(false); } MyGridPhysics physics = base.CubeGrid.Physics; if (physics == null) { return(false); } if ((base.Stator != null) && MyFixedGrids.IsRooted(base.Stator.CubeGrid)) { return(false); } if (this.m_slipCountdown > 0) { this.m_slipCountdown--; } if (this.m_staticHitCount == 0) { if (this.m_contactCountdown <= 0) { return(false); } this.m_contactCountdown--; if (this.m_contactCountdown == 0) { this.m_frictionCollector = 0f; this.m_contactNormals.Clear(); return(false); } } Vector3 linearVelocity = physics.LinearVelocity; if (MyUtils.IsZero(ref linearVelocity, 1E-05f) || !physics.IsActive) { return(false); } MatrixD worldMatrix = base.WorldMatrix; Vector3D centerOfMassWorld = physics.CenterOfMassWorld; if (!this.m_contactNormals.GetAvgNormal(out vector2)) { return(false); } this.LastUsedGroundNormal = vector2; Vector3 up = (Vector3)worldMatrix.Up; Vector3 guideVector = Vector3.Cross(vector2, up); linearVelocity = Vector3.ProjectOnPlane(ref linearVelocity, ref vector2); Vector3 direction = Vector3.ProjectOnVector(ref linearVelocity, ref guideVector); Vector3 vector6 = direction - linearVelocity; if (MyUtils.IsZero(ref vector6, 1E-05f)) { return(false); } bool flag = false; bool flag2 = false; float num = 6f * this.m_frictionCollector; Vector3 vec = Vector3.ProjectOnVector(ref vector6, ref up); float num2 = vec.Length(); bool flag3 = num2 > num; if (!flag3 && (this.m_slipCountdown == 0)) { if (num2 < 0.1) { flag2 = true; } } else { flag = true; vec = (vec * ((1f / num2) * num)) * (1f - MyPhysicsConfig.WheelSlipCutAwayRatio); if (flag3) { this.m_slipCountdown = MyPhysicsConfig.WheelSlipCountdown; } } if (!flag2) { vec *= 1f - ((1f - this.m_frictionCollector) * MyPhysicsConfig.WheelSurfaceMaterialSteerRatio); Vector3 vector9 = Vector3.ProjectOnPlane(ref vec, ref vector2); MyMechanicalConnectionBlockBase stator = base.Stator; MyPhysicsBody body = null; if (stator != null) { body = base.Stator.CubeGrid.Physics; } vector9 *= 0.1f; if (body == null) { physics.ApplyImpulse(vector9 * physics.Mass, centerOfMassWorld); } else { Vector3D zero = Vector3D.Zero; MyMotorSuspension suspension = stator as MyMotorSuspension; if (suspension != null) { Vector3 vector10; vector9 *= MyMath.Clamp(suspension.Friction * 2f, 0f, 1f); suspension.GetCoMVectors(out vector10); zero = Vector3D.TransformNormal(-vector10, stator.CubeGrid.WorldMatrix); } Vector3D pos = centerOfMassWorld + zero; float wheelImpulseBlending = MyPhysicsConfig.WheelImpulseBlending; vector9 = (this.m_lastFrameImpuse * wheelImpulseBlending) + (vector9 * (1f - wheelImpulseBlending)); this.m_lastFrameImpuse = vector9; body.ApplyImpulse(vector9 * body.Mass, pos); if (MyDebugDrawSettings.DEBUG_DRAW_WHEEL_PHYSICS) { nullable = null; MyRenderProxy.DebugDrawArrow3DDir(pos, -zero, Color.Red, nullable, false, 0.1, null, 0.5f, false); MyRenderProxy.DebugDrawSphere(pos, 0.1f, Color.Yellow, 1f, false, false, true, false); } } } if (MyDebugDrawSettings.DEBUG_DRAW_WHEEL_PHYSICS) { nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld, linearVelocity, Color.Yellow, nullable, false, 0.1, null, 0.5f, false); nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld, direction, Color.Blue, nullable, false, 0.1, null, 0.5f, false); nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld, vec, Color.MediumPurple, nullable, false, 0.1, null, 0.5f, false); nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld + linearVelocity, vector6, Color.Red, nullable, false, 0.1, null, 0.5f, false); nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld + up, vector2, Color.AliceBlue, nullable, false, 0.1, null, 0.5f, false); nullable = null; MyRenderProxy.DebugDrawArrow3DDir(centerOfMassWorld, Vector3.ProjectOnPlane(ref vec, ref vector2), flag ? Color.DarkRed : Color.IndianRed, nullable, false, 0.1, null, 0.5f, false); if (this.m_slipCountdown > 0) { MyRenderProxy.DebugDrawText3D(centerOfMassWorld + (up * 2f), "Drift", Color.Red, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } MyRenderProxy.DebugDrawText3D(centerOfMassWorld + (up * 1.2f), this.m_staticHitCount.ToString(), Color.Red, 1f, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, -1, false); } return(!flag2); }
public virtual void Attach(MyMechanicalConnectionBlockBase stator) { m_parentBlock = stator; }