public VerbSettings(VerbsV0 id, int x_pos, int y_pos, string name) { this.id = id; this.x_pos = x_pos; this.y_pos = y_pos; this.name = name; }
void SetMode(Engine0Mode mode) { UserStates state; _currentMode = mode; switch (_currentMode) { case Engine0Mode.Cutscene: if (Game.Features.HasFlag(GameFeatures.Demo)) { if (Variables[11] != 0) { _drawDemo = true; } } _redrawSentenceLine = false; // Note: do not change freeze state here state = UserStates.SetIFace | UserStates.SetCursor; break; case Engine0Mode.Keypad: if (Game.Features.HasFlag(GameFeatures.Demo)) { if (Game.Features.HasFlag(GameFeatures.Demo)) { _drawDemo = true; } } _redrawSentenceLine = false; state = UserStates.SetIFace | UserStates.SetCursor | UserStates.CursorOn | UserStates.SetFreeze | UserStates.FreezeOn; break; case Engine0Mode.Normal: case Engine0Mode.NoNewKid: if (Game.Features.HasFlag(GameFeatures.Demo)) { ResetVerbs(); _activeVerb = VerbsV0.WalkTo; _redrawSentenceLine = true; _drawDemo = false; } state = UserStates.SetIFace | UserStates.IFaceAll | UserStates.SetCursor | UserStates.CursorOn | UserStates.SetFreeze; break; default: throw new NotSupportedException(string.Format("Invalid mode: {0}", mode)); } SetUserState(state); }
void ResetSentence() { _activeVerb = VerbsV0.WalkTo; _activeObject = 0; _activeObject2 = 0; _walkToObjectState = WalkToObjectState.Done; _redrawSentenceLine = true; SentenceNum = 0; _sentenceNestedCount = 0; }
VerbPrepsV0 VerbPrepIdType(VerbsV0 verbid) { switch (verbid) { case VerbsV0.Use: // depends on object1 return(VerbPrepsV0.Object); case VerbsV0.Give: return(VerbPrepsV0.To); case VerbsV0.Unlock: case VerbsV0.Fix: return(VerbPrepsV0.With); default: return(VerbPrepsV0.None); } }
void DrawSentenceLine() { _redrawSentenceLine = false; if (!_userState.HasFlag(UserStates.IFaceSentence)) { return; } ClearSentenceLine(); if (_activeVerb == VerbsV0.NewKid) { _sentenceBuf = ""; for (int i = 0; i < 3; ++i) { string actorName; int actorId = Variables[97 + i]; if (actorId == 0) { // after usage of the radiation suit, kid vars are set to 0 actorName = " "; } else { var a = Actors[actorId]; actorName = a.Name.GetText(); } _sentenceBuf += string.Format("{0,-13}", actorName); } FlushSentenceLine(); return; } // Current Verb if (_activeVerb == VerbsV0.None) { _activeVerb = VerbsV0.WalkTo; } var verbName = Verbs[(int)_activeVerb].Text; _sentenceBuf = verbName.GetText(); if (_activeObject != 0) { // Draw the 1st active object DrawSentenceObject(_activeObject); // Append verb preposition var sentencePrep = ActiveVerbPrep(); if (sentencePrep != 0) { DrawPreposition((int)sentencePrep); // Draw the 2nd active object if (_activeObject2 != 0) { DrawSentenceObject(_activeObject2); } } } FlushSentenceLine(); }
protected override void CheckAndRunSentenceScript() { if (CheckPendingWalkAction()) { return; } if (SentenceNum == 0 || Sentence[SentenceNum - 1].IsFrozen) { return; } var st = Sentence[SentenceNum - 1]; if (st.Preposition && st.ObjectB == st.ObjectA) { SentenceNum--; return; } CurrentScript = 0xFF; // assert(st.objectA); // If two objects are involved, at least one must be in the actors inventory if (st.ObjectB != 0 && (OBJECT_V0_TYPE(st.ObjectA) != ObjectV0Type.Foreground || ResourceManager.ObjectOwnerTable[st.ObjectA] != Variables[VariableEgo.Value]) && (OBJECT_V0_TYPE(st.ObjectB) != ObjectV0Type.Foreground || ResourceManager.ObjectOwnerTable[st.ObjectB] != Variables[VariableEgo.Value])) { if (GetVerbEntrypointCore(st.ObjectA, (int)VerbsV0.PickUp) != 0) { DoSentence((int)VerbsV0.PickUp, st.ObjectA, 0); } else if (GetVerbEntrypointCore(st.ObjectB, (int)VerbsV0.PickUp) != 0) { DoSentence((int)VerbsV0.PickUp, st.ObjectB, 0); } else { SentenceNum--; } return; } _cmdVerb = (VerbsV0)st.Verb; _cmdObject = st.ObjectA; _cmdObject2 = st.ObjectB; SentenceNum--; // abort sentence execution if the number of nested scripts is too high. // This might happen for instance if the sentence command depends on an // object that the actor has to pick-up in a nested doSentence() call. // If the actor is not able to pick-up the object (e.g. because it is not // reachable or pickupable) a nested pick-up command is triggered again // and again, so the actual sentence command will never be executed. // In this case the sentence command has to be aborted. _sentenceNestedCount++; if (_sentenceNestedCount > 6) { _sentenceNestedCount = 0; SentenceNum = 0; return; } if (GetWhereIsObject(st.ObjectA) != WhereIsObject.Inventory) { if (_currentMode != Engine0Mode.Keypad) { WalkToActorOrObject(st.ObjectA); return; } } else if (st.ObjectB != 0 && GetWhereIsObject(st.ObjectB) != WhereIsObject.Inventory) { WalkToActorOrObject(st.ObjectB); return; } RunSentenceScript(); if (_currentMode == Engine0Mode.Keypad) { _walkToObjectState = WalkToObjectState.Done; } }
VerbPrepsV0 VerbPrepIdType(VerbsV0 verbid) { switch (verbid) { case VerbsV0.Use: // depends on object1 return VerbPrepsV0.Object; case VerbsV0.Give: return VerbPrepsV0.To; case VerbsV0.Unlock: case VerbsV0.Fix: return VerbPrepsV0.With; default: return VerbPrepsV0.None; } }
void DrawSentenceLine() { _redrawSentenceLine = false; if (!_userState.HasFlag(UserStates.IFaceSentence)) return; ClearSentenceLine(); if (_activeVerb == VerbsV0.NewKid) { _sentenceBuf = ""; for (int i = 0; i < 3; ++i) { string actorName; int actorId = Variables[97 + i]; if (actorId == 0) { // after usage of the radiation suit, kid vars are set to 0 actorName = " "; } else { var a = Actors[actorId]; actorName = a.Name.GetText(); } _sentenceBuf += string.Format("{0,-13}", actorName); } FlushSentenceLine(); return; } // Current Verb if (_activeVerb == VerbsV0.None) _activeVerb = VerbsV0.WalkTo; var verbName = Verbs[(int)_activeVerb].Text; _sentenceBuf = verbName.GetText(); if (_activeObject != 0) { // Draw the 1st active object DrawSentenceObject(_activeObject); // Append verb preposition var sentencePrep = ActiveVerbPrep(); if (sentencePrep != 0) { DrawPreposition((int)sentencePrep); // Draw the 2nd active object if (_activeObject2 != 0) DrawSentenceObject(_activeObject2); } } FlushSentenceLine(); }
protected override void CheckAndRunSentenceScript() { if (CheckPendingWalkAction()) return; if (SentenceNum == 0 || Sentence[SentenceNum - 1].IsFrozen) return; var st = Sentence[SentenceNum - 1]; if (st.Preposition && st.ObjectB == st.ObjectA) { SentenceNum--; return; } CurrentScript = 0xFF; // assert(st.objectA); // If two objects are involved, at least one must be in the actors inventory if (st.ObjectB != 0 && (OBJECT_V0_TYPE(st.ObjectA) != ObjectV0Type.Foreground || ResourceManager.ObjectOwnerTable[st.ObjectA] != Variables[VariableEgo.Value]) && (OBJECT_V0_TYPE(st.ObjectB) != ObjectV0Type.Foreground || ResourceManager.ObjectOwnerTable[st.ObjectB] != Variables[VariableEgo.Value])) { if (GetVerbEntrypointCore(st.ObjectA, (int)VerbsV0.PickUp) != 0) DoSentence((int)VerbsV0.PickUp, st.ObjectA, 0); else if (GetVerbEntrypointCore(st.ObjectB, (int)VerbsV0.PickUp) != 0) DoSentence((int)VerbsV0.PickUp, st.ObjectB, 0); else SentenceNum--; return; } _cmdVerb = (VerbsV0)st.Verb; _cmdObject = st.ObjectA; _cmdObject2 = st.ObjectB; SentenceNum--; // abort sentence execution if the number of nested scripts is too high. // This might happen for instance if the sentence command depends on an // object that the actor has to pick-up in a nested doSentence() call. // If the actor is not able to pick-up the object (e.g. because it is not // reachable or pickupable) a nested pick-up command is triggered again // and again, so the actual sentence command will never be executed. // In this case the sentence command has to be aborted. _sentenceNestedCount++; if (_sentenceNestedCount > 6) { _sentenceNestedCount = 0; SentenceNum = 0; return; } if (GetWhereIsObject(st.ObjectA) != WhereIsObject.Inventory) { if (_currentMode != Engine0Mode.Keypad) { WalkToActorOrObject(st.ObjectA); return; } } else if (st.ObjectB != 0 && GetWhereIsObject(st.ObjectB) != WhereIsObject.Inventory) { WalkToActorOrObject(st.ObjectB); return; } RunSentenceScript(); if (_currentMode == Engine0Mode.Keypad) { _walkToObjectState = WalkToObjectState.Done; } }
void SetMode(Engine0Mode mode) { UserStates state; _currentMode = mode; switch (_currentMode) { case Engine0Mode.Cutscene: if (Game.Features.HasFlag(GameFeatures.Demo)) { if (Variables[11] != 0) _drawDemo = true; } _redrawSentenceLine = false; // Note: do not change freeze state here state = UserStates.SetIFace | UserStates.SetCursor; break; case Engine0Mode.Keypad: if (Game.Features.HasFlag(GameFeatures.Demo)) { if (Game.Features.HasFlag(GameFeatures.Demo)) _drawDemo = true; } _redrawSentenceLine = false; state = UserStates.SetIFace | UserStates.SetCursor | UserStates.CursorOn | UserStates.SetFreeze | UserStates.FreezeOn; break; case Engine0Mode.Normal: case Engine0Mode.NoNewKid: if (Game.Features.HasFlag(GameFeatures.Demo)) { ResetVerbs(); _activeVerb = VerbsV0.WalkTo; _redrawSentenceLine = true; _drawDemo = false; } state = UserStates.SetIFace | UserStates.IFaceAll | UserStates.SetCursor | UserStates.CursorOn | UserStates.SetFreeze; break; default: throw new NotSupportedException(string.Format("Invalid mode: {0}", mode)); } SetUserState(state); }