public virtual void RedirectToGetCommand <T>(IArtifact artifact, bool printTaking = true) where T : class, ICommand { Debug.Assert(artifact != null); if (printTaking) { if (artifact.IsCarriedByContainer()) { Command.PrintRemovingFirst(artifact); } else { Command.PrintTakingFirst(artifact); } } Command.NextState = Globals.CreateInstance <IGetCommand>(x => { x.PreserveNextState = true; }); Command.CopyCommandData(Command.NextState as ICommand); Command.NextState.NextState = Globals.CreateInstance <T>(x => { x.GetCommandCalled = true; x.ContainerType = Command.ContainerType; }); Command.CopyCommandData(Command.NextState.NextState as ICommand); }
public virtual void ProcessArtifact(IArtifact artifact, IArtifactCategory ac, ref bool nlFlag) { RetCode rc; Debug.Assert(artifact != null); Debug.Assert(ac != null); if (ac.Type == ArtifactType.DisguisedMonster) { ProcessAction(() => gEngine.RevealDisguisedMonster(ActorRoom, artifact), ref nlFlag); } else if (artifact.Weight > 900) { ProcessAction(() => PrintDontBeAbsurd(), ref nlFlag); } else if (artifact.IsUnmovable01()) { ProcessAction(() => PrintCantVerbThat(artifact), ref nlFlag); } else { DobjArtifactCount = 0; DobjArtifactWeight = artifact.Weight; if (artifact.GeneralContainer != null) { rc = artifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.In, true); Debug.Assert(gEngine.IsSuccess(rc)); rc = artifact.GetContainerInfo(ref _dobjArtifactCount, ref _dobjArtifactWeight, ContainerType.On, true); Debug.Assert(gEngine.IsSuccess(rc)); } ActorMonsterInventoryWeight = 0; rc = ActorMonster.GetFullInventoryWeight(ref _actorMonsterInventoryWeight, recurse: true); Debug.Assert(gEngine.IsSuccess(rc)); if (ac.Type == ArtifactType.DeadBody && ac.Field1 != 1) { ProcessAction(() => PrintBestLeftAlone(artifact), ref nlFlag); } else if (!OmitWeightCheck && (DobjArtifactWeight + ActorMonsterInventoryWeight > ActorMonster.GetWeightCarryableGronds())) { ProcessAction(() => PrintTooHeavy(artifact), ref nlFlag); } else if (ac.Type == ArtifactType.BoundMonster) { ProcessAction(() => PrintMustBeFreed(artifact), ref nlFlag); } else { WeaponAffinityMonster = gEngine.GetMonsterList(m => m.IsInRoom(ActorRoom) && m.Weapon == -artifact.Uid - 1 && m != ActorMonster).FirstOrDefault(); if (WeaponAffinityMonster != null) { ProcessAction(() => PrintObjBelongsToActor(artifact, WeaponAffinityMonster), ref nlFlag); } else { IsCarriedByContainer = artifact.IsCarriedByContainer(); artifact.SetCarriedByCharacter(); if (NextState is IRequestCommand) { PrintReceived(artifact); } else if (NextState is IRemoveCommand || IsCarriedByContainer) { PrintRetrieved(artifact); } else { PrintTaken(artifact); } nlFlag = true; } } } }