Exemplo n.º 1
0
        /// <summary>
        /// Pre-process the important bits of input and store in private fields, so they
        /// will be available for validation and the main execute method.
        /// </summary>
        /// <param name="actionInput">The full input specified for executing the command.</param>
        private void PreprocessInput(ActionInput actionInput)
        {
            // Make sure there is a sender.
            this.sender = actionInput.Controller;
            this.session = this.sender as Session;
            if (this.sender == null || this.sender.Thing == null)
            {
                return;
            }

            // Make sure the sender is an actual connected user.
            this.userControlledBehavior = this.sender.Thing.Behaviors.FindFirst<UserControlledBehavior>();
            if (this.userControlledBehavior == null)
            {
                return;
            }

            // Parse and store the desired buffer length, if one was provided.
            string lengthText = actionInput.Tail.ToLower().Trim();
            if (string.IsNullOrEmpty(lengthText))
            {
                this.parseSucceeded = true;
            }
            else if (lengthText == "auto")
            {
                this.parsedBufferLength = -1;
                this.parseSucceeded = true;
            }
            else
            {
                this.parseSucceeded = this.TryParse(lengthText, out this.parsedBufferLength);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerEventProcessor"/> class.
 /// </summary>
 /// <param name="playerBehavior">The player behavior.</param>
 /// <param name="sensesBehavior">The senses behavior.</param>
 /// <param name="userControlledBehavior">The user controlled behavior.</param>
 public PlayerEventProcessor(PlayerBehavior playerBehavior, SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.playerBehavior = playerBehavior;
     this.sensesBehavior = sensesBehavior;
     this.userControlledBehavior = userControlledBehavior;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the PlayerBehavior class.
 /// </summary>
 /// <param name="sensesBehavior">
 /// The senses Behavior.
 /// </param>
 /// <param name="userControlledBehavior">
 /// The user Controlled Behavior.
 /// </param>
 public PlayerBehavior(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
     : this()
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }
Exemplo n.º 4
0
        /// <summary>Prepares the base character.</summary>
        /// <param name="session">The session.</param>
        /// <returns>Filled out base character.</returns>
        public static Thing PrepareBaseCharacter(Session session)
        {
            var movableBehavior = new MovableBehavior();
            var livingBehavior = new LivingBehavior();
            var sensesBehavior = new SensesBehavior();
            var userControlledBehavior = new UserControlledBehavior()
            {
                Controller = session,
            };
            var playerBehavior = new PlayerBehavior(sensesBehavior, userControlledBehavior)
            {
                SessionId = session.ID,
            };

            var player = new Thing(livingBehavior, sensesBehavior, userControlledBehavior, playerBehavior, movableBehavior);

            var game = GameSystemController.Instance;

            // Load the default stats for the current gaming system
            foreach (var gameStat in game.GameStats)
            {
                var currStat = new GameStat(session, gameStat.Name, gameStat.Abbreviation, gameStat.Formula, gameStat.Value, gameStat.MinValue, gameStat.MaxValue, gameStat.Visible);
                player.Stats.Add(currStat.Abbreviation, currStat);
            }

            // Load the secondary stats\attributes for the current gaming system
            foreach (var attribute in game.GameAttributes)
            {
                var newAttribute = new GameAttribute(session, attribute.Name, attribute.Abbreviation, attribute.Formula, attribute.Value, attribute.MinValue, attribute.MaxValue, attribute.Visible);
                player.Attributes.Add(newAttribute.Abbreviation, newAttribute);
            }

            return player;
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a PlayerEventProcessor for this player.
 /// </summary>
 /// <param name="sensesBehavior">A valid SensesBehavior which has already been created for this player.</param>
 /// <param name="userControlledBehavior">A valid UserControlledBehavior which has already been created for this player.</param>
 internal void InitEventProcessor(SensesBehavior sensesBehavior, UserControlledBehavior userControlledBehavior)
 {
     this.EventProcessor = new PlayerEventProcessor(this, sensesBehavior, userControlledBehavior);
 }