Beispiel #1
0
        public override void Execute()
        {
            RetCode rc;

            Debug.Assert(DobjArtifact != null);

            DobjArtAc = DobjArtifact.GetArtifactCategory(ArtTypes, false);

            if (DobjArtAc == null)
            {
                PrintNotWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (DobjArtAc.Type == ArtifactType.Wearable)
            {
                NextState = Globals.CreateInstance <IWearCommand>();

                CopyCommandData(NextState as ICommand);

                goto Cleanup;
            }

            if (!DobjArtifact.IsReadyableByCharacter())
            {
                PrintNotReadyableWeapon(DobjArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            if (!DobjArtifact.IsCarriedByCharacter())
            {
                if (!GetCommandCalled)
                {
                    RedirectToGetCommand <IReadyCommand>(DobjArtifact);
                }
                else if (DobjArtifact.DisguisedMonster == null)
                {
                    NextState = Globals.CreateInstance <IStartState>();
                }

                goto Cleanup;
            }

            // can't use two-handed weapon while wearing shield

            if (gGameState.Sh > 0 && DobjArtAc.Field5 > 1)
            {
                ShieldArtifact = gADB[gGameState.Sh];

                Debug.Assert(ShieldArtifact != null);

                PrintCantReadyWeaponWithShield(DobjArtifact, ShieldArtifact);

                NextState = Globals.CreateInstance <IStartState>();

                goto Cleanup;
            }

            ActorWeapon = gADB[ActorMonster.Weapon];

            if (ActorWeapon != null)
            {
                rc = ActorWeapon.RemoveStateDesc(ActorWeapon.GetReadyWeaponDesc());

                Debug.Assert(gEngine.IsSuccess(rc));
            }

            ActorMonster.Weapon = DobjArtifact.Uid;

            rc = DobjArtifact.AddStateDesc(DobjArtifact.GetReadyWeaponDesc());

            Debug.Assert(gEngine.IsSuccess(rc));

            gOut.Print("{0} readied.", DobjArtifact.GetNoneName(true, false));

            ProcessEvents(EventType.AfterReadyArtifact);

            if (GotoCleanup)
            {
                goto Cleanup;
            }

Cleanup:

            if (NextState == null)
            {
                NextState = Globals.CreateInstance <IMonsterStartState>();
            }
        }