public void RemovePart(MyPrefabKinematicPart part) { int partsCount = 0; for (int i = 0; i < MyMwcObjectBuilder_PrefabKinematic.MAX_KINEMATIC_PARTS; i++) { if (Parts[i] == part) { Parts[i] = null; } if (Parts[i] != null) { partsCount++; } } if (partsCount == 0) { RemoveLockedHud(); } }
protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig) { MyPrefabConfigurationKinematic prefabKinematicConfig = (MyPrefabConfigurationKinematic)prefabConfig; MyMwcObjectBuilder_PrefabKinematic kinematicBuilder = objectBuilder as MyMwcObjectBuilder_PrefabKinematic; MyModel model = MyModels.GetModelOnlyDummies(m_config.ModelLod0Enum); for (int i = 0; i < prefabKinematicConfig.KinematicParts.Count; i++) { MyPrefabConfigurationKinematicPart kinematicPart = prefabKinematicConfig.KinematicParts[i]; MyModelDummy open, close; if (model.Dummies.TryGetValue(kinematicPart.m_open, out open) && model.Dummies.TryGetValue(kinematicPart.m_close, out close)) { float?kinematicPartHealth = kinematicBuilder.KinematicPartsHealth[i]; float?kinematicPartMaxHealth = kinematicBuilder.KinematicPartsMaxHealth[i]; uint? kinematicPartEntityId = kinematicBuilder.KinematicPartsEntityId[i]; // if health is not set or not destroyed, then create part if (kinematicPartHealth == null || kinematicPartHealth != 0) { MyPrefabKinematicPart newPart = new MyPrefabKinematicPart(m_owner); if (kinematicPartEntityId.HasValue) { newPart.EntityId = new MyEntityIdentifier(kinematicPartEntityId.Value); } Parts[i] = newPart; newPart.Init(this, kinematicPart, prefabKinematicConfig.m_openTime, prefabKinematicConfig.m_closeTime, (MyModelsEnum)kinematicPart.m_modelMovingEnum, open.Matrix, close.Matrix, prefabKinematicConfig.MaterialType, prefabKinematicConfig.m_soundLooping, prefabKinematicConfig.m_soundOpening, prefabKinematicConfig.m_soundClosing /*, m_groupMask*/, kinematicPartHealth, kinematicPartMaxHealth, Activated); } } } //make handler m_sensorHandler = new MyPrefabKinematicSensor(this); MySphereSensorElement sensorEl = new MySphereSensorElement(); sensorEl.Radius = DETECT_RADIUS; sensorEl.LocalPosition = new Vector3(0, 0, 0); sensorEl.DetectRigidBodyTypes = MyConstants.RIGIDBODY_TYPE_SHIP; sensorEl.SpecialDetectingAngle = DETECTION_ANGLE; MySensorDesc senDesc = new MySensorDesc(); senDesc.m_Element = sensorEl; senDesc.m_Matrix = WorldMatrix; senDesc.m_SensorEventHandler = m_sensorHandler; m_sensor = new MySensor(); m_sensor.LoadFromDesc(senDesc); MyPhysics.physicsSystem.GetSensorModule().AddSensor(m_sensor); GetOwner().UpdateAABB(); UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB); if (kinematicBuilder.UseProperties == null) { UseProperties.Init(MyUseType.FromHUB, MyUseType.FromHUB, 3, 4000, false); } else { UseProperties.Init(kinematicBuilder.UseProperties); } UpdateHudAndCloseStatus(); }