public void Init(MyPrefabKinematic owner, MyPrefabConfigurationKinematicPart config, float openTime, float closeTime, MyModelsEnum modelEnum, Matrix open, Matrix close, MyMaterialType matType, MySoundCuesEnum?loopSound, MySoundCuesEnum?startSound, MySoundCuesEnum?endSound /*, MyGroupMask grpMask*/, float?health, float?maxHealth, bool activated)
        {
            m_needsUpdate = config.NeedsUpdate;
            m_openTime    = openTime * 1000;
            m_closeTime   = closeTime * 1000;
            m_radialState = MAX_RADIAL_STATE;// 0;
            m_config      = config;

            m_loopSoundCue  = loopSound;
            m_startSoundCue = startSound;
            m_endSoundCue   = endSound;

            m_openLocalPosition = open.Translation - close.Translation;

            m_looping = false;

            m_ownerKinematic = owner;
            m_lastUpdateTime = 0;

            MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.PrefabKinematicPart, config.PrefabId);

            objbuilder.EntityId = MyEntityIdentifier.ToNullableInt(EntityId);

            StringBuilder hudLabelTextSb = null;

            base.Init(hudLabelTextSb, modelEnum, null, owner, null, objbuilder);
            if (maxHealth != null)
            {
                MaxHealth = maxHealth.Value;
            }
            if (health != null)
            {
                Health = health.Value;
            }

            //LocalMatrix = Matrix.Invert(MyMath.NormalizeMatrix(close));
            LocalMatrix = Matrix.CreateTranslation(Vector3.Zero);

            InitTrianglePhysics(matType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART);

            SetState(KinematicPrefabStateEnum.Sleeping);

            if (activated)
            {
                PersistentFlags &= ~MyPersistentEntityFlags.Deactivated;
            }
            else
            {
                PersistentFlags |= MyPersistentEntityFlags.Deactivated;
            }
            //StartClosing();
        }
Beispiel #2
0
 public MyPrefabKinematicSensor(MyPrefabKinematic owner)
 {
     m_owner   = owner;
     m_counter = 0;
 }
        /// <summary>
        /// CreatePrefab
        /// </summary>
        /// <param name="hudLabelText"></param>
        /// <param name="objBuilder"></param>
        /// <returns></returns>
        public MyPrefabBase CreatePrefab(string hudLabelText, MyPrefabContainer prefabContainer, MyMwcObjectBuilder_PrefabBase prefabBuilder)
        {
            Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPrefabFactory.CreatePrefab");

            MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(prefabBuilder.GetObjectBuilderType(), prefabBuilder.GetObjectBuilderId().Value);
            Vector3 relativePosition = MyPrefabContainer.GetRelativePositionInAbsoluteCoords(prefabBuilder.PositionInContainer);
            Matrix prefabLocalOrientation = Matrix.CreateFromYawPitchRoll(prefabBuilder.AnglesInContainer.X, prefabBuilder.AnglesInContainer.Y, prefabBuilder.AnglesInContainer.Z);

            MyPrefabBase prefab = null;
            if (config is MyPrefabConfigurationKinematic)
            {
                prefab = new MyPrefabKinematic(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLight)
            {
                prefab = new MyPrefabLight(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLargeWeapon)
            {
                prefab = new MyPrefabLargeWeapon(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationSound)
            {
                prefab = new MyPrefabSound(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationParticles)
            {
                prefab = new MyPrefabParticles(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLargeShip)
            {
                prefab = new MyPrefabLargeShip(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationHangar)
            {
                prefab = new MyPrefabHangar(prefabContainer);                
            }
            else if(config is MyPrefabConfigurationFoundationFactory)
            {
                prefab = new MyPrefabFoundationFactory(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationSecurityControlHUB) 
            {
                prefab = new MyPrefabSecurityControlHUB(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationBankNode) 
            {
                prefab = new MyPrefabBankNode(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationGenerator) 
            {
                prefab = new MyPrefabGenerator(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationScanner) 
            {
                prefab = new MyPrefabScanner(prefabContainer);
            }
            else if (config is MyPrefabConfigurationCamera)
            {
                prefab = new MyPrefabCamera(prefabContainer);
            }
            else if (config is MyPrefabConfigurationAlarm)
            {
                prefab = new MyPrefabAlarm(prefabContainer);
            }            
            else
            {
                prefab = new MyPrefab(prefabContainer);
                //prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);
            }
            prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);

            Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            return prefab;
        }
 public MyPrefabKinematicSensor(MyPrefabKinematic owner)
 {
     m_owner = owner;
     m_counter = 0;
 }