void cf::GameSys::GameImplT::Initialize(bool AsClient, bool AsServer, ModelManagerT& ModelMan) { mWeapon = new WeaponT(&ModelMan, "DesertEagle", 0); RunningAsClient=AsClient; RunningAsServer=AsServer; if (RunningAsClient) { // We can initialize most MatSys-related resources only AFTER the global pointers have been set: // MatSys::Renderer, MatSys::TextureMapManager, and MaterialSystem. // These point to the implementations that are provided by the engine main exe module, // and are accessed e.g. by the models and particles constructors. ResMan.Init(); // Materials that should be pre-cached (as many as possible) must be registered with the MatSys *before* the engine triggers the MatSys's pre-caching. // On the other hand, registering materials can only be done *after* GetGame() was called. // So a good place for registering materials that we need within this DLL is for example at the end of GetGame(), or right here. // Registering the materials that our models will use is quite easy, because we just need to find them in the ModelMan each. // (Nothing breaks if the following list is simply deleted, these models just aren't pre-cached then.) // // It *is* however quite stupid that this list is not more tighly coupled to the relevant entity classes. // However, as the time of entity creation (and thus first model access and thus material registry time) is essentially unknown, // it seems simplest to list the models desired for pre-caching right here. // // Another curiosity that I just noticed: Not pre-caching here means not only to register the materials later (on first use), // but also to effectively load and initialize the models only at that later time, what might be very expensive, too! { // And the rest. Observe that static detail models are NOT mentioned (how could they?). ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_torso_3.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_head_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_head_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_weapon_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_weapon_2.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_movement_1.cmdl"); ModelMan.GetModel("Games/Foobarena/Models/Robot/robot_movement_2.cmdl"); } // Precache all sounds known to be used here. m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/9mm_Shot"))); m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/Shotgun_Shot"))); m_PreCacheSounds.PushBack(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/GLauncher_Shot"))); } if (RunningAsServer) { } }
CarriedWeaponPistolT::CarriedWeaponPistolT(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta/Beretta_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Beretta/Beretta_p.cmdl")) { }
CarriedWeapon357T::CarriedWeapon357T(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle/DesertEagle_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/DesertEagle/DesertEagle_p.cmdl")), FireSound(SoundSystem->CreateSound3D(SoundShaderManager->GetSoundShader("Weapon/DesertEagle_Shot1"))) { }
CarriedWeaponGaussT::CarriedWeaponGaussT(ModelManagerT& ModelMan) : CarriedWeaponT(ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss/Gauss_v.cmdl"), ModelMan.GetModel("Games/DeathMatch/Models/Weapons/Gauss/Gauss_p.cmdl")) { }