コード例 #1
0
        private void UpdateGuiParams(idUserInterface gui, idDict args)
        {
            if ((gui == null) || (args == null))
            {
                return;
            }

            foreach (KeyValuePair <string, string> kvp in args.MatchPrefix("gui_parm"))
            {
                gui.State.Set(kvp.Key, kvp.Value);
            }

            gui.State.Set("noninteractive", args.GetBool("gui_noninteractive"));
            gui.StateChanged(idR.Game.Time);
        }
コード例 #2
0
ファイル: idGameEdit.cs プロジェクト: iainmckay/idtech4.net
		private void UpdateGuiParams(idUserInterface gui, idDict args)
		{
			if((gui == null) || (args == null))
			{
				return;
			}

			foreach(KeyValuePair<string, string> kvp in args.MatchPrefix("gui_parm"))
			{
				gui.State.Set(kvp.Key, kvp.Value);
			}

			gui.State.Set("noninteractive", args.GetBool("gui_noninteractive"));
			gui.StateChanged(idR.Game.Time);
		}
コード例 #3
0
ファイル: idGame.cs プロジェクト: iainmckay/idtech4.net
		private bool InhibitEntitySpawn(idDict args)
		{
			bool result = false;

			if(this.IsMultiplayer == true)
			{
				result = args.GetBool("not_multiplayer", false);
			}
			else if(idR.CvarSystem.GetInteger("g_skill") == 0)
			{
				result = args.GetBool("not_easy", false);
			}
			else if(idR.CvarSystem.GetInteger("g_skill") == 1)
			{
				result = args.GetBool("not_medium", false);
			}
			else
			{
				result = args.GetBool("not_hard", false);
			}

			string name;

			if(idR.CvarSystem.GetInteger("g_skill") == 3)
			{
				name = args.GetString("classname").ToLower();

				if((name == "item_medkit") || (name == "item_medkit_small"))
				{
					result = true;
				}
			}

			if(this.IsMultiplayer == true)
			{
				name = args.GetString("classname").ToLower();

				if((name == "weapon_bfg") || (name == "weapon_soulcube"))
				{
					result = true;
				}
			}

			return result;
		}
コード例 #4
0
        private void InitDefaultPhysics(Vector3 origin, Matrix axis)
        {
            string      temp      = _spawnArgs.GetString("clipmodel", "");
            idClipModel clipModel = null;

            // check if a clipmodel key/value pair is set
            if (temp != string.Empty)
            {
                if (idClipModel.CheckModel(temp) != null)
                {
                    clipModel = new idClipModel(temp);
                }
            }

            if (_spawnArgs.GetBool("noclipmodel", false) == false)
            {
                // check if mins/maxs or size key/value pairs are set
                if (clipModel == null)
                {
                    idBounds bounds       = idBounds.Zero;
                    bool     setClipModel = false;

                    if ((_spawnArgs.ContainsKey("mins") == true) &&
                        (_spawnArgs.ContainsKey("maxs") == true))
                    {
                        bounds       = new idBounds(_spawnArgs.GetVector3("mins"), _spawnArgs.GetVector3("maxs"));
                        setClipModel = true;

                        if ((bounds.Min.X > bounds.Max.X) ||
                            (bounds.Min.Y > bounds.Max.Y) ||
                            (bounds.Min.Z > bounds.Max.Z))
                        {
                            idConsole.Error("Invalid bounds '{0}'-'{1}' on entity '{2}'", bounds.Min, bounds.Max, this.Name);
                        }
                    }
                    else if (_spawnArgs.ContainsKey("size") == true)
                    {
                        Vector3 size = _spawnArgs.GetVector3("size");

                        if ((size.X < 0.0f) ||
                            (size.Y < 0.0f) ||
                            (size.Z < 0.0f))
                        {
                            idConsole.Error("Invalid size '{0}' on entity '{1}'", size, this.Name);
                        }

                        setClipModel = true;
                        bounds       = new idBounds(
                            new Vector3(size.X * -0.5f, size.Y * -0.5f, 0.0f),
                            new Vector3(size.X * 0.5f, size.Y * 0.5f, size.Z)
                            );
                    }

                    if (setClipModel == true)
                    {
                        int sideCount = _spawnArgs.GetInteger("cyclinder", 0);

                        idTraceModel traceModel = new idTraceModel();

                        if (sideCount > 0)
                        {
                            idConsole.Warning("TODO: traceModel.SetupCyclinder(bounds, (sideCount < 3) ? 3 : sideCount);");
                        }
                        else if ((sideCount = _spawnArgs.GetInteger("cone", 0)) > 0)
                        {
                            idConsole.Warning("TODO: traceModel.SetupCone(bounds, (sideCount < 3) ? 3 : sideCount);");
                        }
                        else
                        {
                            traceModel.SetupBox(bounds);
                        }

                        clipModel = new idClipModel(traceModel);
                    }
                }

                // check if the visual model can be used as collision model
                if (clipModel == null)
                {
                    temp = _spawnArgs.GetString("model");

                    if (temp != string.Empty)
                    {
                        if (idClipModel.CheckModel(temp) != null)
                        {
                            clipModel = new idClipModel(temp);
                        }
                    }
                }
            }

            _defaultPhysicsObject.Self = this;
            _defaultPhysicsObject.SetClipModel(clipModel, 1.0f);
            _defaultPhysicsObject.SetOrigin(origin);
            _defaultPhysicsObject.SetAxis(axis);

            _physics = _defaultPhysicsObject;
        }
コード例 #5
0
        public override RenderEntityComponent ParseSpawnArgsToRenderEntity(idDict args)
        {
            RenderEntityComponent renderEntity = new RenderEntityComponent();
            idDeclModel           modelDef     = null;

            string temp = args.GetString("model");

            if (temp != string.Empty)
            {
                modelDef = idE.DeclManager.FindType <idDeclModel>(DeclType.ModelDef, temp, false);

                if (modelDef != null)
                {
                    renderEntity.Model = modelDef.Model;
                }

                if (renderEntity.Model == null)
                {
                    renderEntity.Model = idE.RenderModelManager.FindModel(temp);
                }
            }

            if (renderEntity.Model != null)
            {
                renderEntity.Bounds = renderEntity.Model.GetBounds(renderEntity);
            }
            else
            {
                renderEntity.Bounds = new idBounds();
            }

            temp = args.GetString("skin");

            if (temp != string.Empty)
            {
                renderEntity.CustomSkin = idR.DeclManager.FindSkin(temp);
            }
            else if (modelDef != null)
            {
                renderEntity.CustomSkin = modelDef.DefaultSkin;
            }

            temp = args.GetString("shader");

            if (temp != null)
            {
                renderEntity.CustomMaterial = idR.DeclManager.FindMaterial(temp);
            }

            renderEntity.Origin = args.GetVector3("origin", Vector3.Zero);

            // get the rotation matrix in either full form, or single angle form
            renderEntity.Axis = args.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1");

            if (renderEntity.Axis == Matrix.Identity)
            {
                float angle = args.GetFloat("angle");

                if (angle != 0.0f)
                {
                    renderEntity.Axis = new idAngles(0.0f, angle, 0.0f).ToMatrix();
                }
                else
                {
                    renderEntity.Axis = Matrix.Identity;
                }
            }

            // TODO:
            //renderEntity.ReferencedSound = null;

            // get shader parms
            Vector3 color = args.GetVector3("_color", new Vector3(1, 1, 1));

            float[] materialParms = renderEntity.MaterialParameters;

            materialParms[(int)MaterialParameter.Red]   = color.X;
            materialParms[(int)MaterialParameter.Green] = color.Y;
            materialParms[(int)MaterialParameter.Blue]  = color.Z;

            materialParms[3]  = args.GetFloat("shaderParm3", 1);
            materialParms[4]  = args.GetFloat("shaderParm4", 0);
            materialParms[5]  = args.GetFloat("shaderParm5", 0);
            materialParms[6]  = args.GetFloat("shaderParm6", 0);
            materialParms[7]  = args.GetFloat("shaderParm7", 0);
            materialParms[8]  = args.GetFloat("shaderParm8", 0);
            materialParms[9]  = args.GetFloat("shaderParm9", 0);
            materialParms[10] = args.GetFloat("shaderParm10", 0);
            materialParms[11] = args.GetFloat("shaderParm11", 0);

            renderEntity.MaterialParameters = materialParms;

            // check noDynamicInteractions flag
            renderEntity.NoDynamicInteractions = args.GetBool("noDynamicInteractions");

            // check noshadows flag
            renderEntity.NoShadow = args.GetBool("noshadows");

            // check noselfshadows flag
            renderEntity.NoSelfShadow = args.GetBool("noselfshadows");

            // init any guis, including entity-specific states
            int count = renderEntity.Gui.Length;

            for (int i = 0; i < count; i++)
            {
                temp = args.GetString(i == 0 ? "gui" : string.Format("gui{0}", i + 1));

                if (temp != null)
                {
                    renderEntity.Gui[i] = AddRenderGui(temp, args);
                }
            }

            return(renderEntity);
        }
コード例 #6
0
ファイル: idGameEdit.cs プロジェクト: iainmckay/idtech4.net
		public override RenderEntityComponent ParseSpawnArgsToRenderEntity(idDict args)
		{
			RenderEntityComponent renderEntity = new RenderEntityComponent();
			idDeclModel modelDef = null;
			
			string temp = args.GetString("model");

			if(temp != string.Empty)
			{
				modelDef = idE.DeclManager.FindType<idDeclModel>(DeclType.ModelDef, temp, false);

				if(modelDef != null)
				{
					renderEntity.Model = modelDef.Model;
				}

				if(renderEntity.Model == null)
				{
					renderEntity.Model = idE.RenderModelManager.FindModel(temp);
				}
			}

			if(renderEntity.Model != null)
			{
				renderEntity.Bounds = renderEntity.Model.GetBounds(renderEntity);
			}
			else
			{
				renderEntity.Bounds = new idBounds();
			}

			temp = args.GetString("skin");

			if(temp != string.Empty)
			{
				renderEntity.CustomSkin = idR.DeclManager.FindSkin(temp);
			}
			else if(modelDef != null)
			{
				renderEntity.CustomSkin = modelDef.DefaultSkin;
			}

			temp = args.GetString("shader");

			if(temp != null)
			{
				renderEntity.CustomMaterial = idR.DeclManager.FindMaterial(temp);
			}

			renderEntity.Origin = args.GetVector3("origin", Vector3.Zero);

			// get the rotation matrix in either full form, or single angle form
			renderEntity.Axis = args.GetMatrix("rotation", "1 0 0 0 1 0 0 0 1");

			if(renderEntity.Axis == Matrix.Identity)
			{
				float angle = args.GetFloat("angle");

				if(angle != 0.0f)
				{
					renderEntity.Axis = new idAngles(0.0f, angle, 0.0f).ToMatrix();
				}
				else
				{
					renderEntity.Axis = Matrix.Identity;
				}
			}

			// TODO:
			//renderEntity.ReferencedSound = null;

			// get shader parms
			Vector3 color = args.GetVector3("_color", new Vector3(1, 1, 1));

			float[] materialParms = renderEntity.MaterialParameters;

			materialParms[(int) MaterialParameter.Red] = color.X;
			materialParms[(int) MaterialParameter.Green] = color.Y;
			materialParms[(int) MaterialParameter.Blue] = color.Z;

			materialParms[3] = args.GetFloat("shaderParm3", 1);
			materialParms[4] = args.GetFloat("shaderParm4", 0);
			materialParms[5] = args.GetFloat("shaderParm5", 0);
			materialParms[6] = args.GetFloat("shaderParm6", 0);
			materialParms[7] = args.GetFloat("shaderParm7", 0);
			materialParms[8] = args.GetFloat("shaderParm8", 0);
			materialParms[9] = args.GetFloat("shaderParm9", 0);
			materialParms[10] = args.GetFloat("shaderParm10", 0);
			materialParms[11] = args.GetFloat("shaderParm11", 0);

			renderEntity.MaterialParameters = materialParms;

			// check noDynamicInteractions flag
			renderEntity.NoDynamicInteractions = args.GetBool("noDynamicInteractions");

			// check noshadows flag
			renderEntity.NoShadow = args.GetBool("noshadows");

			// check noselfshadows flag
			renderEntity.NoSelfShadow = args.GetBool("noselfshadows");

			// init any guis, including entity-specific states
			int count = renderEntity.Gui.Length;

			for(int i = 0; i < count; i++)
			{
				temp = args.GetString(i == 0 ? "gui" : string.Format("gui{0}", i + 1));

				if(temp != null)
				{
					renderEntity.Gui[i] = AddRenderGui(temp, args);
				}
			}

			return renderEntity;
		}