/// <summary>
        ///   Creates a new <see cref="BehaviorChainConfiguration"/> from this
        ///   template.
        /// </summary>
        // TODO: Comment.
        internal BehaviorChainConfiguration CreateConfiguration(
            IBehaviorFactoryConfiguration factoryConfiguration
            )
        {
            Check.NotNull(factoryConfiguration, nameof(factoryConfiguration));

            var config = new BehaviorChainConfiguration();
            IBehaviorFactory factory = factoryConfiguration.GetFactory(_factoryProvider);

            foreach (BehaviorChainItemTemplate itemTemplate in _itemTemplates)
            {
                BehaviorKey key = itemTemplate.Key;

                if (itemTemplate.State == DefaultBehaviorState.DisabledWithoutFactory)
                {
                    config.Append(key);
                }
                else
                {
                    IBehavior instance = factory.Create(key);
                    config.Append(key, instance);

                    if (itemTemplate.State == DefaultBehaviorState.Enabled)
                    {
                        config.Enable(key);
                    }
                }
            }

            return(config);
        }
Exemple #2
0
        private void ExecuteCreateCommand(string[] creationArgs)
        {
            var name   = creationArgs[1];
            var health = int.Parse(creationArgs[2]);
            var damage = int.Parse(creationArgs[3]);

            var behaviorType = creationArgs[4];
            var behavior     = behaviorFactory.Create(behaviorType);

            var attackType = creationArgs[5];
            var attack     = attackFactory.Create(attackType);

            var blob = blobFactory.Create(name, health, damage, behavior, attack);

            if (this.shouldReportEvents)
            {
                blob.OnBehaviorToggled += this.PrintBehaviorToggled;
                blob.OnBlobDead        += this.PrintBlobDead;
            }

            this.blobData.AddBlob(blob);
        }