public void SetGuiInfo(idDict dict) { foreach (idWindowVariable var in _vars) { var.SetGuiInfo(dict, var.ToString()); } }
private idUserInterface AddRenderGui(string name, idDict args) { idUserInterface gui = idR.UIManager.FindInterface(name, true, args.ContainsKey("gui_parm")); UpdateGuiParams(gui, args); return gui; }
private idUserInterface AddRenderGui(string name, idDict args) { idUserInterface gui = idR.UIManager.FindInterface(name, true, args.ContainsKey("gui_parm")); UpdateGuiParams(gui, args); return(gui); }
/// <summary> /// /// </summary> /// <remarks> /// Any key/value pair that might change during the course of the game (e.g. via a gui) /// should be initialize here so a gui or other trigger can change something and have it updated /// properly. /// <para/> /// An optional source may be provided if the values reside in an outside dictionary and /// first need copied over to spawnArgs. /// </remarks> /// <param name="source"></param> public virtual void UpdateChangeableSpawnArgs(idDict source) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idConsole.Warning("TODO: idEntity.UpdateChangeableSpawnArgs"); }
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); }
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); }
private void Dispose(bool disposing) { if (this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if (disposing == true) { _state = null; _desktop = null; _bindHandler = null; } _disposed = true; }
private void PreRender() { if (_needsRender == true) { _world.InitFromMap(null); idDict spawnArgs = new idDict(); spawnArgs.Set("classname", "light"); spawnArgs.Set("name", "light_1"); spawnArgs.Set("origin", _lightOrigin); spawnArgs.Set("_color", _lightColor); idConsole.Warning("TODO: lighting"); /*gameEdit->ParseSpawnArgsToRenderLight(&spawnArgs, &rLight); * lightDef = world->AddLightDef(&rLight); * if(!modelName[0]) * { * common->Warning("Window '%s' in gui '%s': no model set", GetName(), GetGui()->GetSourceFile()); * }*/ spawnArgs.Clear(); spawnArgs.Set("classname", "func_static"); spawnArgs.Set("model", _modelName); spawnArgs.Set("origin", _modelOrigin); _worldEntity = idE.GameEdit.ParseSpawnArgsToRenderEntity(spawnArgs); if (_worldEntity.Model != null) { Vector3 v = _modelRotate.ToVector3(); _worldEntity.Axis = v.ToMatrix(); _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _renderEntity = _world.AddEntityDefinition(_worldEntity); } _needsRender.Set(false); } }
public virtual void Init(string name, idWindow win) { string key = name; int length = key.Length; _guiDict = null; if ((length > Prefix.Length) && (key.StartsWith(Prefix) == true)) { key = key.Substring(length - Prefix.Length - 1); SetGuiInfo(win.UserInterface.State, key); win.AddUpdateVariable(this); } else { Set(name); } }
/// <summary> /// The session calls this right before a new level is loaded. /// </summary> /// <param name="clientIndex"></param> /// <param name="playerInfo"></param> public abstract void SetPersistentPlayerInformation(int clientIndex, idDict playerInfo);
/// <summary> /// Sets the user info for a client. /// </summary> /// <param name="clientIndex"></param> /// <param name="userInfo"></param> /// <param name="isClient"></param> /// <param name="canModify">If true, the game can modify the user info. Never true on a network client.</param> /// <returns></returns> public abstract idDict SetUserInformation(int clientIndex, idDict userInfo, bool isClient, bool canModify);
public override void SpawnPlayer(int clientIndex) { idConsole.WriteLine("SpawnPlayer: {0}", clientIndex); idDict args = new idDict(); args.Set("spawn_entnum", clientIndex); args.Set("name", string.Format("player{0}", clientIndex + 1)); // TODO: refactor in to idGameRules args.Set("classname", (this.IsMultiplayer == true) ? "player_doommarine_mp" : "player_doommarine"); idEntity ent = SpawnEntityDef(args); if((ent == null) || (_entities[clientIndex] == null)) { idConsole.Error("Failed to spawn player as {0}", args.GetString("classname")); } // make sure it's a compatible class if((ent is idPlayer) == false) { idConsole.Error("'{0}' spawn the player as a '{1}'. Player spawnclass must be a subclass of Player.", args.GetString("classname"), ent.ClassName); } if(clientIndex >= _clientCount) { _clientCount++; } this.Rules.SpawnPlayer(clientIndex); }
public abstract RenderEntityComponent ParseSpawnArgsToRenderEntity(idDict args);
/// <summary> /// /// </summary> /// <remarks> /// Any key/value pair that might change during the course of the game (e.g. via a gui) /// should be initialize here so a gui or other trigger can change something and have it updated /// properly. /// <para/> /// An optional source may be provided if the values reside in an outside dictionary and /// first need copied over to spawnArgs. /// </remarks> /// <param name="source"></param> public virtual void UpdateChangeableSpawnArgs(idDict source) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } idConsole.Warning("TODO: idEntity.UpdateChangeableSpawnArgs"); }
public static idMapBrush Parse(idLexer lexer, Vector3 origin, bool newFormat = true, float version = idMapFile.CurrentMapVersion) { idToken token; idMapBrushSide side; List<idMapBrushSide> sides = new List<idMapBrushSide>(); idDict dict = new idDict(); Vector3[] planePoints = new Vector3[3]; if(lexer.ExpectTokenString("{") == false) { return null; } do { if((token = lexer.ReadToken()) == null) { lexer.Error("idMapBrush::Parse: unexpected EOF"); return null; } if(token.ToString() == "}") { break; } // here we may have to jump over brush epairs ( only used in editor ) do { // if token is a brace if(token.ToString() == "(") { break; } // the token should be a key string for a key/value pair if(token.Type != TokenType.String) { lexer.Error("idMapBrush::Parse: unexpected {0}, expected ( or epair key string", token.ToString()); return null; } string key = token.ToString(); if(((token = lexer.ReadTokenOnLine()) == null) || (token.Type != TokenType.String)) { lexer.Error("idMapBrush::Parse: expected epair value string not found"); return null; } dict.Set(key, token.ToString()); // try to read the next key if((token = lexer.ReadToken()) == null) { lexer.Error("idMapBrush::Parse: unexpected EOF"); return null; } } while(true); lexer.UnreadToken = token; side = new idMapBrushSide(); sides.Add(side); if(newFormat == true) { float[] tmp = lexer.Parse1DMatrix(4); if(tmp == null) { lexer.Error("idMapBrush::Parse: unable to read brush side plane definition"); return null; } else { side.Plane = new Plane(tmp[0], tmp[1], tmp[2], tmp[3]); } } else { // read the three point plane definition float[] tmp, tmp2, tmp3; if(((tmp = lexer.Parse1DMatrix(3)) == null) || ((tmp2 = lexer.Parse1DMatrix(3)) == null) || ((tmp3 = lexer.Parse1DMatrix(3)) == null)) { lexer.Error("idMapBrush::Parse: unable to read brush side plane definition"); return null; } planePoints[0] = new Vector3(tmp[0], tmp[1], tmp[2]) - origin; planePoints[1] = new Vector3(tmp2[0], tmp2[1], tmp2[2]) - origin; planePoints[2] = new Vector3(tmp3[0], tmp3[1], tmp3[2]) - origin; side.Plane.FromPoints(planePoints[0], planePoints[1], planePoints[2]); } // read the texture matrix // this is odd, because the texmat is 2D relative to default planar texture axis float[,] tmp5 = lexer.Parse2DMatrix(2, 3); if(tmp5 == null) { lexer.Error("idMapBrush::Parse: unable to read brush side texture matrix"); return null; } side.TextureMatrix[0] = new Vector3(tmp5[0, 0], tmp5[0, 1], tmp5[0, 2]); side.TextureMatrix[1] = new Vector3(tmp5[1, 0], tmp5[1, 1], tmp5[1, 2]); side.Origin = origin; // read the material if((token = lexer.ReadTokenOnLine()) == null) { lexer.Error("idMapBrush::Parse: unable to read brush side material"); return null; } // we had an implicit 'textures/' in the old format... if(version < 2.0f) { side.Material = "textures/" + token.ToString(); } else { side.Material = token.ToString(); } // Q2 allowed override of default flags and values, but we don't any more if(lexer.ReadTokenOnLine() != null) { if(lexer.ReadTokenOnLine() != null) { if(lexer.ReadTokenOnLine() != null) { } } } } while(true); if(lexer.ExpectTokenString("}") == false) { return null; } idMapBrush brush = new idMapBrush(); foreach(idMapBrushSide s in sides) { brush.AddSide(s); } brush.Dict = dict; return brush; }
/// <summary> /// Sets the serverinfo at map loads and when it changes. /// </summary> /// <param name="serverInfo"></param> public abstract void SetServerInfo(idDict serverInfo);
/// <summary> /// The session calls this right before a new level is loaded. /// </summary> /// <param name="clientIndex"></param> /// <param name="playerInfo"></param> public abstract void SetPersistentPlayerInformation(int clientIndex, idDict playerInfo);
/// <summary> /// Caches media referenced from in key/value pairs in the given dictionary. /// </summary> /// <remarks> /// This is called after parsing an EntityDef and for each entity spawnArgs before /// merging the entitydef. It could be done post-merge, but that would /// avoid the fast pre-cache check associated with each entityDef. /// </remarks> /// <param name="dict"></param> public abstract void CacheDictionaryMedia(idDict dict);
/// <summary> /// Sets the user info for a client. /// </summary> /// <param name="clientIndex"></param> /// <param name="userInfo"></param> /// <param name="isClient"></param> /// <param name="canModify">If true, the game can modify the user info. Never true on a network client.</param> /// <returns></returns> public abstract idDict SetUserInformation(int clientIndex, idDict userInfo, bool isClient, bool canModify);
private void PreRender() { if(_needsRender == true) { _world.InitFromMap(null); idDict spawnArgs = new idDict(); spawnArgs.Set("classname", "light"); spawnArgs.Set("name", "light_1"); spawnArgs.Set("origin", _lightOrigin); spawnArgs.Set("_color", _lightColor); idConsole.Warning("TODO: lighting"); /*gameEdit->ParseSpawnArgsToRenderLight(&spawnArgs, &rLight); lightDef = world->AddLightDef(&rLight); if(!modelName[0]) { common->Warning("Window '%s' in gui '%s': no model set", GetName(), GetGui()->GetSourceFile()); }*/ spawnArgs.Clear(); spawnArgs.Set("classname", "func_static"); spawnArgs.Set("model", _modelName); spawnArgs.Set("origin", _modelOrigin); _worldEntity = idE.GameEdit.ParseSpawnArgsToRenderEntity(spawnArgs); if(_worldEntity.Model != null) { Vector3 v = _modelRotate.ToVector3(); _worldEntity.Axis = v.ToMatrix(); _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _worldEntity.MaterialParameters[0] = 1; _renderEntity = _world.AddEntityDefinition(_worldEntity); } _needsRender.Set(false); } }
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; }
public virtual void Init(string name, idWindow win) { string key = name; int length = key.Length; _guiDict = null; if((length > Prefix.Length) && (key.StartsWith(Prefix) == true)) { key = key.Substring(length - Prefix.Length - 1); SetGuiInfo(win.UserInterface.State, key); win.AddUpdateVariable(this); } else { Set(name); } }
public idUserInterface() { _referenceCount = 1; _state = new idDict(); }
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; }
public idDeclEntity() : base() { _dict = new idDict(); }
/// <summary> /// This is called after parsing an EntityDef and for each entity spawnArgs before /// merging the entitydef. It could be done post-merge, but that would /// avoid the fast pre-cache check associated with each entityDef. /// </summary> /// <param name="dict"></param> public override void CacheDictionaryMedia(idDict dict) { #region Model foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("model")) { // precache model/animations if((kvp.Value != string.Empty) && (idR.DeclManager.FindType<idDecl>(DeclType.ModelDef, kvp.Value, false) == null)) { // precache the render model idR.RenderModelManager.FindModel(kvp.Value); // precache .cm files only idR.CollisionModelManager.LoadModel(kvp.Value, true); } } #endregion #region Gui foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("gui")) { string keyLower = kvp.Key.ToLower(); if((keyLower == "gui_noninteractive") || (keyLower.StartsWith("gui_parm") == true) || (keyLower == "gui_inventory")) { // unfortunate flag names, they aren't actually a gui } else { idR.DeclManager.MediaPrint(string.Format("Precaching gui {0}", kvp.Value)); idUserInterface gui = new idUserInterface(); if(gui != null) { gui.InitFromFile(kvp.Value); idE.UIManager.Remove(gui); } } } #endregion #region Fx foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("fx")) { idR.DeclManager.MediaPrint(string.Format("Precaching fx {0}", kvp.Value)); idR.DeclManager.FindType<idDecl>(DeclType.Fx, kvp.Value); } #endregion #region Smoke foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("smoke")) { string prtName = kvp.Value; int dash = prtName.IndexOf('-'); if(dash > 0) { prtName = prtName.Substring(0, dash); } idR.DeclManager.FindType(DeclType.Particle, prtName); } #endregion #region Skin foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("skin")) { idR.DeclManager.MediaPrint(string.Format("Precaching skin {0}", kvp.Value)); idR.DeclManager.FindType(DeclType.Skin, kvp.Value); } #endregion #region Def foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("def")) { FindEntityDef(kvp.Value, false); } #endregion #region Misc string value = dict.GetString("s_shader"); if(value != string.Empty) { idR.DeclManager.FindType<idDecl>(DeclType.Sound, value); } value = dict.GetString("texture"); if(value != string.Empty) { idR.DeclManager.FindType<idDecl>(DeclType.Material, value); } Dictionary<string, DeclType> cacheElements = new Dictionary<string, DeclType>() { { "snd", DeclType.Sound }, { "mtr", DeclType.Material }, { "inv_icon", DeclType.Material }, { "pda_name", DeclType.Pda }, { "video", DeclType.Video }, { "audio", DeclType.Audio } }; foreach(KeyValuePair<string, DeclType> element in cacheElements) { foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix(element.Key)) { idR.DeclManager.FindType<idDecl>(element.Value, kvp.Value); } } #endregion }
public idDeclEntity() : base() { _dict = new idDict(); }
public override void SetPersistentPlayerInformation(int clientIndex, idDict playerInfo) { _persistentPlayerInfo[clientIndex] = playerInfo; }
public void SetGuiInfo(idDict dict) { foreach(idWindowVariable var in _vars) { var.SetGuiInfo(dict, var.ToString()); } }
public virtual void SetGuiInfo(idDict dict, string name) { _guiDict = dict; this.Name = name; }
public virtual void SetGuiInfo(idDict dict, string name) { _guiDict = dict; this.Name = name; }
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); }
public idEntity SpawnEntityDef(idDict args, bool setDefaults = true) { _spawnArgs = args; string error = string.Empty; string name = string.Empty; string className = string.Empty; if(_spawnArgs.ContainsKey("name") == false) { error = string.Format(" on '{0}'", name); } name = _spawnArgs.GetString("name", ""); className = _spawnArgs.GetString("classname"); idDeclEntity def = FindEntityDef(className, false); if(def == null) { idConsole.Warning("Unknown classname '{0}'{1}.", className, error); return null; } _spawnArgs.SetDefaults(def.Dict); // check if we should spawn a class object string spawn = _spawnArgs.GetString("spawnclass", null); if(spawn != null) { // need to check all loaded assemblies to find the type we're looking for. Type type = null; foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) { // all entity types must be in the idTech4.Game.Entities namespace. string typeName = string.Format("idTech4.Game.Entities.{0}", spawn); type = asm.GetType(typeName, false, true); if(type != null) { break; } } if(type == null) { idConsole.Warning("Could not spawn '{0}'. Class '{1}' not found{2}.", className, spawn, error); return null; } object obj = type.Assembly.CreateInstance(type.FullName); if(obj == null) { idConsole.Warning("Could not spawn '{0}'. Instance could not be created{1}.", className, error); return null; } idEntity ent = (idEntity) obj; ent.Spawn(); idConsole.DeveloperWriteLine("Spawned {0} ({1})", ent.ClassName, ent.GetType().FullName); return ent; } idConsole.Warning("TODO: Spawnfunc"); // check if we should call a script function to spawn /*spawnArgs.GetString( "spawnfunc", NULL, &spawn ); if ( spawn ) { const function_t *func = program.FindFunction( spawn ); if ( !func ) { Warning( "Could not spawn '%s'. Script function '%s' not found%s.", classname, spawn, error.c_str() ); return false; } idThread *thread = new idThread( func ); thread->DelayedStart( 0 ); return true; } Warning( "%s doesn't include a spawnfunc or spawnclass%s.", classname, error.c_str() ); return false;*/ return null; }
public string AddFrameCommand(idDeclModel modelDef, int frameIndex, idLexer lexer, idDict def) { // make sure we're within bounds if ((frameIndex < 1) || (frameIndex > _anims[0].FrameCount)) { return(string.Format("Frame {0} out of range", frameIndex)); } // frame numbers are 1 based in .def files, but 0 based internally frameIndex--; idToken token; AnimationFrameCommand frameCommand = new AnimationFrameCommand(); if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } string tokenValue = token.ToString(); if (tokenValue == "call") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.ScriptFunction; idConsole.Warning("TODO: fc.function = gameLocal.program.FindFunction( token );"); if (frameCommand.Function == null) { return(string.Format("Function '{0}' not found", tokenValue)); } } else if (tokenValue == "object_call") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.ScriptFunctionObject; frameCommand.String = tokenValue; } else if (tokenValue == "event") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.EventFunction; idConsole.Warning("TODO: idAnim Event"); /*const idEventDef *ev = idEventDef::FindEvent( token ); * if ( !ev ) { * return va( "Event '%s' not found", token.c_str() ); * } * if ( ev->GetNumArgs() != 0 ) { * return va( "Event '%s' has arguments", token.c_str() ); * }*/ frameCommand.String = tokenValue; } else if ((tokenValue == "sound") || (tokenValue == "sound_voice") || (tokenValue == "sound_voice2") || (tokenValue == "sound_body") || (tokenValue == "sound_body2") || (tokenValue == "sound_body3") || (tokenValue == "sound_weapon") || (tokenValue == "sound_global") || (tokenValue == "sound_item") || (tokenValue == "sound_chatter")) { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } switch (tokenValue) { case "sound": frameCommand.Type = AnimationFrameCommandType.Sound; break; case "sound_voice": frameCommand.Type = AnimationFrameCommandType.SoundVoice; break; case "sound_voice2": frameCommand.Type = AnimationFrameCommandType.SoundVoice2; break; case "sound_body": frameCommand.Type = AnimationFrameCommandType.SoundBody; break; case "sound_body2": frameCommand.Type = AnimationFrameCommandType.SoundBody2; break; case "sound_body3": frameCommand.Type = AnimationFrameCommandType.SoundBody3; break; case "sound_weapon": frameCommand.Type = AnimationFrameCommandType.SoundWeapon; break; case "sound_global": frameCommand.Type = AnimationFrameCommandType.SoundGlobal; break; case "sound_item": frameCommand.Type = AnimationFrameCommandType.SoundItem; break; case "sound_chatter": frameCommand.Type = AnimationFrameCommandType.SoundChatter; break; } tokenValue = token.ToString(); if (tokenValue.StartsWith("snd_") == true) { frameCommand.String = tokenValue; } else { frameCommand.SoundMaterial = idE.DeclManager.FindSound(tokenValue); if (frameCommand.SoundMaterial.State == DeclState.Defaulted) { idConsole.Warning("Sound '{0}' not found", tokenValue); } } } else if (tokenValue == "skin") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Skin; if (tokenValue == "none") { frameCommand.Skin = null; } else { frameCommand.Skin = idE.DeclManager.FindSkin(tokenValue); if (frameCommand.Skin == null) { return(string.Format("Skin '{0}' not found", tokenValue)); } } } else if (tokenValue == "fx") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Fx; if (idE.DeclManager.FindType(DeclType.Fx, tokenValue) == null) { return(string.Format("fx '{0}' not found", tokenValue)); } frameCommand.String = tokenValue; } else if (tokenValue == "trigger") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Trigger; frameCommand.String = tokenValue; } else if (tokenValue == "triggerSmokeParticle") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.TriggerSmokeParticle; frameCommand.String = tokenValue; } else if ((tokenValue == "melee") || (tokenValue == "direct_damage") || (tokenValue == "attack_begin")) { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } switch (tokenValue) { case "melee": frameCommand.Type = AnimationFrameCommandType.Melee; break; case "direct_damage": frameCommand.Type = AnimationFrameCommandType.DirectDamage; break; case "attack_begin": frameCommand.Type = AnimationFrameCommandType.BeginAttack; break; } tokenValue = token.ToString(); if (idR.Game.FindEntityDef(tokenValue, false) == null) { return(string.Format("Unknown entityDef '{0}'", tokenValue)); } frameCommand.String = tokenValue; } else if (tokenValue == "attack_end") { frameCommand.Type = AnimationFrameCommandType.EndAttack; } else if (tokenValue == "muzzle_flash") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } tokenValue = token.ToString(); if ((tokenValue != string.Empty) && (modelDef.FindJoint(tokenValue) == null)) { return(string.Format("Joint '{0}' not found", tokenValue)); } frameCommand.Type = AnimationFrameCommandType.MuzzleFlash; frameCommand.String = tokenValue; } else if ((tokenValue == "create_missile") || (tokenValue == "launch_missile")) { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } switch (tokenValue) { case "create_missile": frameCommand.Type = AnimationFrameCommandType.CreateMissile; break; case "launch_missile": frameCommand.Type = AnimationFrameCommandType.LaunchMissile; break; } tokenValue = token.ToString(); frameCommand.String = tokenValue; if (modelDef.FindJoint(tokenValue) == null) { return(string.Format("Joint '{0}' not found", tokenValue)); } } else if (tokenValue == "fire_missile_at_target") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } JointInfo jointInfo = modelDef.FindJoint(token.ToString()); if (jointInfo == null) { return(string.Format("Joint '{0}' not found", token.ToString())); } if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of line"); } frameCommand.Type = AnimationFrameCommandType.FireMissileAtTarget; frameCommand.String = token.ToString(); frameCommand.Index = jointInfo.Index; } else if (tokenValue == "footstep") { frameCommand.Type = AnimationFrameCommandType.Footstep; } else if (tokenValue == "leftfoot") { frameCommand.Type = AnimationFrameCommandType.LeftFoot; } else if (tokenValue == "rightfoot") { frameCommand.Type = AnimationFrameCommandType.RightFoot; } else if (tokenValue == "enableEyeFocus") { frameCommand.Type = AnimationFrameCommandType.EnableEyeFocus; } else if (tokenValue == "disableEyeFocus") { frameCommand.Type = AnimationFrameCommandType.DisableEyeFocus; } else if (tokenValue == "disableGravity") { frameCommand.Type = AnimationFrameCommandType.DisableGravity; } else if (tokenValue == "enableGravity") { frameCommand.Type = AnimationFrameCommandType.EnableGravity; } else if (tokenValue == "jump") { frameCommand.Type = AnimationFrameCommandType.Jump; } else if (tokenValue == "enableClip") { frameCommand.Type = AnimationFrameCommandType.EnableClip; } else if (tokenValue == "disableClip") { frameCommand.Type = AnimationFrameCommandType.DisableClip; } else if (tokenValue == "enableWalkIK") { frameCommand.Type = AnimationFrameCommandType.EnableWalkIk; } else if (tokenValue == "disableWalkIK") { frameCommand.Type = AnimationFrameCommandType.DisableWalkIk; } else if (tokenValue == "enableLegIK") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of file"); } frameCommand.Type = AnimationFrameCommandType.EnableLegIk; frameCommand.Index = int.Parse(token.ToString()); } else if (tokenValue == "disableLegIK") { if ((token = lexer.ReadTokenOnLine()) == null) { return("Unexpected end of file"); } frameCommand.Type = AnimationFrameCommandType.DisableLegIk; frameCommand.Index = int.Parse(token.ToString()); } else if (tokenValue == "recordDemo") { frameCommand.Type = AnimationFrameCommandType.RecordDemo; if ((token = lexer.ReadTokenOnLine()) != null) { frameCommand.String = token.ToString(); } } else if (tokenValue == "aviGame") { frameCommand.Type = AnimationFrameCommandType.AviGame; if ((token = lexer.ReadTokenOnLine()) != null) { frameCommand.String = token.ToString(); } } else { return(string.Format("Unknown command '{0}'", tokenValue)); } // check if we've initialized the frame lookup table if (_frameLookups.Count == 0) { // we haven't, so allocate the table and initialize it for (int i = 0; i < _anims[0].FrameCount; i++) { _frameLookups.Add(new AnimationFrameLookup()); } } // calculate the index of the new command int index = _frameLookups[frameIndex].FirstCommand + _frameLookups[frameIndex].Index; int count = _frameLookups.Count; _frameCommands.Insert(index, frameCommand); // fix the indices of any later frames to account for the inserted command for (int i = frameIndex + 1; i < count; i++) { _frameLookups[i].FirstCommand++; } // increase the number of commands on this frame _frameLookups[frameIndex].Index++; // return with no error return(null); }
public override void SetServerInfo(idDict serverInfo) { _serverInfo = serverInfo; CreateGameRules(); if(this.IsClient == false) { idConsole.Warning("TODO: SetServerInfo"); // TODO /*idBitMsg outMsg = new idBitMsg(); outMsg.InitGame(); outMsg.WriteByte((int) GameReliableMessage.ServerInfo); outMsg.WriteDeltaDict(_serverInfo, null); idR.NetworkSystem.ServerSendReliableMessage(-1, outMsg);*/ } }
public abstract RenderEntityComponent ParseSpawnArgsToRenderEntity(idDict args);
public override idDict SetUserInformation(int clientIndex, idDict userInfo, bool isClient, bool canModify) { bool modifiedInfo = false; _isClient = isClient; if((clientIndex >= 0) && (clientIndex < idR.MaxClients)) { _userInfo[clientIndex] = userInfo; // server sanity if(canModify == true) { int number; modifiedInfo = true; // don't let numeric nicknames, it can be exploited to go around kick and ban commands from the server if(Int32.TryParse(_userInfo[clientIndex].GetString("ui_name"), out number) == true) { _userInfo[clientIndex].Set("ui_name", String.Format("{0}_", _userInfo[clientIndex].GetString("ui_name"))); modifiedInfo = true; } // don't allow dupe nicknames for(int i = 0; i < _clientCount; i++) { if(i == clientIndex) { continue; } if((_entities[i] != null) && (_entities[i] is idPlayer)) { if(_userInfo[clientIndex].GetString("ui_name").ToLower() == _userInfo[i].GetString("ui_name")) { _userInfo[clientIndex].Set("ui_name", string.Format("{0}_", _userInfo[clientIndex].GetString("ui_name"))); modifiedInfo = true; i = -1; // rescan continue; } } } } if((_entities[clientIndex] != null) && (_entities[clientIndex] is idPlayer)) { modifiedInfo |= ((idPlayer) _entities[clientIndex]).UserInfoChanged(canModify); modifiedInfo |= idR.Game.Rules.UserInfoChanged(clientIndex, canModify); } if(this.IsClient == false) { // now mark this client in game _gameRules.EnterGame(clientIndex); } } if(modifiedInfo == true) { return _userInfo[clientIndex]; } return null; }
public static idMapBrush Parse(idLexer lexer, Vector3 origin, bool newFormat = true, float version = idMapFile.CurrentMapVersion) { idToken token; idMapBrushSide side; List <idMapBrushSide> sides = new List <idMapBrushSide>(); idDict dict = new idDict(); Vector3[] planePoints = new Vector3[3]; if (lexer.ExpectTokenString("{") == false) { return(null); } do { if ((token = lexer.ReadToken()) == null) { lexer.Error("idMapBrush::Parse: unexpected EOF"); return(null); } if (token.ToString() == "}") { break; } // here we may have to jump over brush epairs ( only used in editor ) do { // if token is a brace if (token.ToString() == "(") { break; } // the token should be a key string for a key/value pair if (token.Type != TokenType.String) { lexer.Error("idMapBrush::Parse: unexpected {0}, expected ( or epair key string", token.ToString()); return(null); } string key = token.ToString(); if (((token = lexer.ReadTokenOnLine()) == null) || (token.Type != TokenType.String)) { lexer.Error("idMapBrush::Parse: expected epair value string not found"); return(null); } dict.Set(key, token.ToString()); // try to read the next key if ((token = lexer.ReadToken()) == null) { lexer.Error("idMapBrush::Parse: unexpected EOF"); return(null); } }while(true); lexer.UnreadToken = token; side = new idMapBrushSide(); sides.Add(side); if (newFormat == true) { float[] tmp = lexer.Parse1DMatrix(4); if (tmp == null) { lexer.Error("idMapBrush::Parse: unable to read brush side plane definition"); return(null); } else { side.Plane = new Plane(tmp[0], tmp[1], tmp[2], tmp[3]); } } else { // read the three point plane definition float[] tmp, tmp2, tmp3; if (((tmp = lexer.Parse1DMatrix(3)) == null) || ((tmp2 = lexer.Parse1DMatrix(3)) == null) || ((tmp3 = lexer.Parse1DMatrix(3)) == null)) { lexer.Error("idMapBrush::Parse: unable to read brush side plane definition"); return(null); } planePoints[0] = new Vector3(tmp[0], tmp[1], tmp[2]) - origin; planePoints[1] = new Vector3(tmp2[0], tmp2[1], tmp2[2]) - origin; planePoints[2] = new Vector3(tmp3[0], tmp3[1], tmp3[2]) - origin; side.Plane.FromPoints(planePoints[0], planePoints[1], planePoints[2]); } // read the texture matrix // this is odd, because the texmat is 2D relative to default planar texture axis float[,] tmp5 = lexer.Parse2DMatrix(2, 3); if (tmp5 == null) { lexer.Error("idMapBrush::Parse: unable to read brush side texture matrix"); return(null); } side.TextureMatrix[0] = new Vector3(tmp5[0, 0], tmp5[0, 1], tmp5[0, 2]); side.TextureMatrix[1] = new Vector3(tmp5[1, 0], tmp5[1, 1], tmp5[1, 2]); side.Origin = origin; // read the material if ((token = lexer.ReadTokenOnLine()) == null) { lexer.Error("idMapBrush::Parse: unable to read brush side material"); return(null); } // we had an implicit 'textures/' in the old format... if (version < 2.0f) { side.Material = "textures/" + token.ToString(); } else { side.Material = token.ToString(); } // Q2 allowed override of default flags and values, but we don't any more if (lexer.ReadTokenOnLine() != null) { if (lexer.ReadTokenOnLine() != null) { if (lexer.ReadTokenOnLine() != null) { } } } }while(true); if (lexer.ExpectTokenString("}") == false) { return(null); } idMapBrush brush = new idMapBrush(); foreach (idMapBrushSide s in sides) { brush.AddSide(s); } brush.Dict = dict; return(brush); }
private idClip _clip = new idClip(); // collision detection #endregion #region Constructor public idGame() { idR.Game = this; idR.GameEdit = new idGameEdit(); InitCvars(); int count = _userInfo.Length; for(int i = 0; i < count; i++) { _userInfo[i] = new idDict(); _persistentPlayerInfo[i] = new idDict(); } _gameRules = new Singleplayer(); Clear(); }
public idUserInterface() { _referenceCount = 1; _state = new idDict(); }
/// <summary> /// Caches media referenced from in key/value pairs in the given dictionary. /// </summary> /// <remarks> /// This is called after parsing an EntityDef and for each entity spawnArgs before /// merging the entitydef. It could be done post-merge, but that would /// avoid the fast pre-cache check associated with each entityDef. /// </remarks> /// <param name="dict"></param> public abstract void CacheDictionaryMedia(idDict dict);
private void Dispose(bool disposing) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if(disposing == true) { _state = null; _desktop = null; _bindHandler = null; } _disposed = true; }
/// <summary> /// Sets the serverinfo at map loads and when it changes. /// </summary> /// <param name="serverInfo"></param> public abstract void SetServerInfo(idDict serverInfo);
public string AddFrameCommand(idDeclModel modelDef, int frameIndex, idLexer lexer, idDict def) { // make sure we're within bounds if((frameIndex < 1) || (frameIndex > _anims[0].FrameCount)) { return string.Format("Frame {0} out of range", frameIndex); } // frame numbers are 1 based in .def files, but 0 based internally frameIndex--; idToken token; AnimationFrameCommand frameCommand = new AnimationFrameCommand(); if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } string tokenValue = token.ToString(); if(tokenValue == "call") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.ScriptFunction; idConsole.Warning("TODO: fc.function = gameLocal.program.FindFunction( token );"); if(frameCommand.Function == null) { return string.Format("Function '{0}' not found", tokenValue); } } else if(tokenValue == "object_call") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.ScriptFunctionObject; frameCommand.String = tokenValue; } else if(tokenValue == "event") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.EventFunction; idConsole.Warning("TODO: idAnim Event"); /*const idEventDef *ev = idEventDef::FindEvent( token ); if ( !ev ) { return va( "Event '%s' not found", token.c_str() ); } if ( ev->GetNumArgs() != 0 ) { return va( "Event '%s' has arguments", token.c_str() ); }*/ frameCommand.String = tokenValue; } else if((tokenValue == "sound") || (tokenValue == "sound_voice") || (tokenValue == "sound_voice2") || (tokenValue == "sound_body") || (tokenValue == "sound_body2") || (tokenValue == "sound_body3") || (tokenValue == "sound_weapon") || (tokenValue == "sound_global") || (tokenValue == "sound_item") || (tokenValue == "sound_chatter")) { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } switch(tokenValue) { case "sound": frameCommand.Type = AnimationFrameCommandType.Sound; break; case "sound_voice": frameCommand.Type = AnimationFrameCommandType.SoundVoice; break; case "sound_voice2": frameCommand.Type = AnimationFrameCommandType.SoundVoice2; break; case "sound_body": frameCommand.Type = AnimationFrameCommandType.SoundBody; break; case "sound_body2": frameCommand.Type = AnimationFrameCommandType.SoundBody2; break; case "sound_body3": frameCommand.Type = AnimationFrameCommandType.SoundBody3; break; case "sound_weapon": frameCommand.Type = AnimationFrameCommandType.SoundWeapon; break; case "sound_global": frameCommand.Type = AnimationFrameCommandType.SoundGlobal; break; case "sound_item": frameCommand.Type = AnimationFrameCommandType.SoundItem; break; case "sound_chatter": frameCommand.Type = AnimationFrameCommandType.SoundChatter; break; } tokenValue = token.ToString(); if(tokenValue.StartsWith("snd_") == true) { frameCommand.String = tokenValue; } else { frameCommand.SoundMaterial = idE.DeclManager.FindSound(tokenValue); if(frameCommand.SoundMaterial.State == DeclState.Defaulted) { idConsole.Warning("Sound '{0}' not found", tokenValue); } } } else if(tokenValue == "skin") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Skin; if(tokenValue == "none") { frameCommand.Skin = null; } else { frameCommand.Skin = idE.DeclManager.FindSkin(tokenValue); if(frameCommand.Skin == null) { return string.Format("Skin '{0}' not found", tokenValue); } } } else if(tokenValue == "fx") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Fx; if(idE.DeclManager.FindType(DeclType.Fx, tokenValue) == null) { return string.Format("fx '{0}' not found", tokenValue); } frameCommand.String = tokenValue; } else if(tokenValue == "trigger") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.Trigger; frameCommand.String = tokenValue; } else if(tokenValue == "triggerSmokeParticle") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); frameCommand.Type = AnimationFrameCommandType.TriggerSmokeParticle; frameCommand.String = tokenValue; } else if((tokenValue == "melee") || (tokenValue == "direct_damage") || (tokenValue == "attack_begin")) { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } switch(tokenValue) { case "melee": frameCommand.Type = AnimationFrameCommandType.Melee; break; case "direct_damage": frameCommand.Type = AnimationFrameCommandType.DirectDamage; break; case "attack_begin": frameCommand.Type = AnimationFrameCommandType.BeginAttack; break; } tokenValue = token.ToString(); if(idR.Game.FindEntityDef(tokenValue, false) == null) { return string.Format("Unknown entityDef '{0}'", tokenValue); } frameCommand.String = tokenValue; } else if(tokenValue == "attack_end") { frameCommand.Type = AnimationFrameCommandType.EndAttack; } else if(tokenValue == "muzzle_flash") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } tokenValue = token.ToString(); if((tokenValue != string.Empty) && (modelDef.FindJoint(tokenValue) == null)) { return string.Format("Joint '{0}' not found", tokenValue); } frameCommand.Type = AnimationFrameCommandType.MuzzleFlash; frameCommand.String = tokenValue; } else if((tokenValue == "create_missile") || (tokenValue == "launch_missile")) { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } switch(tokenValue) { case "create_missile": frameCommand.Type = AnimationFrameCommandType.CreateMissile; break; case "launch_missile": frameCommand.Type = AnimationFrameCommandType.LaunchMissile; break; } tokenValue = token.ToString(); frameCommand.String = tokenValue; if(modelDef.FindJoint(tokenValue) == null) { return string.Format("Joint '{0}' not found", tokenValue); } } else if(tokenValue == "fire_missile_at_target") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } JointInfo jointInfo = modelDef.FindJoint(token.ToString()); if(jointInfo == null) { return string.Format("Joint '{0}' not found", token.ToString()); } if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of line"; } frameCommand.Type = AnimationFrameCommandType.FireMissileAtTarget; frameCommand.String = token.ToString(); frameCommand.Index = jointInfo.Index; } else if(tokenValue == "footstep") { frameCommand.Type = AnimationFrameCommandType.Footstep; } else if(tokenValue == "leftfoot") { frameCommand.Type = AnimationFrameCommandType.LeftFoot; } else if(tokenValue == "rightfoot") { frameCommand.Type = AnimationFrameCommandType.RightFoot; } else if(tokenValue == "enableEyeFocus") { frameCommand.Type = AnimationFrameCommandType.EnableEyeFocus; } else if(tokenValue == "disableEyeFocus") { frameCommand.Type = AnimationFrameCommandType.DisableEyeFocus; } else if(tokenValue == "disableGravity") { frameCommand.Type = AnimationFrameCommandType.DisableGravity; } else if(tokenValue == "enableGravity") { frameCommand.Type = AnimationFrameCommandType.EnableGravity; } else if(tokenValue == "jump") { frameCommand.Type = AnimationFrameCommandType.Jump; } else if(tokenValue == "enableClip") { frameCommand.Type = AnimationFrameCommandType.EnableClip; } else if(tokenValue == "disableClip") { frameCommand.Type = AnimationFrameCommandType.DisableClip; } else if(tokenValue == "enableWalkIK") { frameCommand.Type = AnimationFrameCommandType.EnableWalkIk; } else if(tokenValue == "disableWalkIK") { frameCommand.Type = AnimationFrameCommandType.DisableWalkIk; } else if(tokenValue == "enableLegIK") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of file"; } frameCommand.Type = AnimationFrameCommandType.EnableLegIk; frameCommand.Index = int.Parse(token.ToString()); } else if(tokenValue == "disableLegIK") { if((token = lexer.ReadTokenOnLine()) == null) { return "Unexpected end of file"; } frameCommand.Type = AnimationFrameCommandType.DisableLegIk; frameCommand.Index = int.Parse(token.ToString()); } else if(tokenValue == "recordDemo") { frameCommand.Type = AnimationFrameCommandType.RecordDemo; if((token = lexer.ReadTokenOnLine()) != null) { frameCommand.String = token.ToString(); } } else if(tokenValue == "aviGame") { frameCommand.Type = AnimationFrameCommandType.AviGame; if((token = lexer.ReadTokenOnLine()) != null) { frameCommand.String = token.ToString(); } } else { return string.Format("Unknown command '{0}'", tokenValue); } // check if we've initialized the frame lookup table if(_frameLookups.Count == 0) { // we haven't, so allocate the table and initialize it for(int i = 0; i < _anims[0].FrameCount; i++) { _frameLookups.Add(new AnimationFrameLookup()); } } // calculate the index of the new command int index = _frameLookups[frameIndex].FirstCommand + _frameLookups[frameIndex].Index; int count = _frameLookups.Count; _frameCommands.Insert(index, frameCommand); // fix the indices of any later frames to account for the inserted command for(int i = frameIndex + 1; i < count; i++) { _frameLookups[i].FirstCommand++; } // increase the number of commands on this frame _frameLookups[frameIndex].Index++; // return with no error return null; }