protected override async Task RenderComment(SkillFlowComponent component, TextGeneratorContext context)
 {
     foreach (var comment in component.Comments)
     {
         await context.WriteLine($"//{comment}");
     }
 }
        public async Task <TextGeneratorContext> Generate(SkillFlowComponent component, TextGeneratorContext context)
        {
            if (component is Time)
            {
                await context.WriteLine("time");
            }

            return(context);
        }
        public async Task <TextGeneratorContext> Generate(SkillFlowComponent component, TextGeneratorContext context)
        {
            if (component is BGM bgm)
            {
                await context.WriteLine($"BGM {bgm.Uri}");
            }

            return(context);
        }
        protected Task GenerateComment(SkillFlowComponent component, TContext context)
        {
            if (component?.Comments == null || !component.Comments.Any())
            {
                return(Noop(context));
            }

            return(RenderComment(component, context));
        }
        protected Task <TContext> Generate(SkillFlowComponent component, TContext context)
        {
            Type currentType = component.GetType();

            while (currentType != null && !Extensions.ContainsKey(currentType))
            {
                currentType = currentType.BaseType;
            }

            if (currentType == null)
            {
                return(Task.FromResult(context));
            }
            return(Extensions[currentType].Generate(component, context));
        }
Esempio n. 6
0
        public async Task <TextGeneratorContext> Generate(SkillFlowComponent component, TextGeneratorContext context)
        {
            if (component is Roll roll)
            {
                var output = $"roll {roll.Dice}d{roll.Sides}";
                if (roll.Top.HasValue)
                {
                    output = $"{output}k{roll.Top.Value}";
                }

                if (roll.Modifier.HasValue && roll.ModifyAmount.HasValue)
                {
                    output = $"{output} {roll.Modifier.Value} {roll.ModifyAmount.Value}";
                }
                await context.WriteLine(output);
            }

            return(context);
        }
        public async Task <TextGeneratorContext> Generate(SkillFlowComponent component, TextGeneratorContext context)
        {
            if (component is Buy buy)
            {
                await context.WriteString($"buy item=\"{buy.Item}\" success=\"{buy.SuccessScene}\" fail=\"{buy.FailureScene}\"");

                if (!string.IsNullOrWhiteSpace(buy.DeclinedScene))
                {
                    await context.WriteString($" declined=\"{buy.DeclinedScene}\"");
                }
                if (!string.IsNullOrWhiteSpace(buy.AlreadyPurchasedScene))
                {
                    await context.WriteString($" already_purchased=\"{buy.AlreadyPurchasedScene}\"");
                }
                if (!string.IsNullOrWhiteSpace(buy.ErrorScene))
                {
                    await context.WriteString($" error=\"{buy.ErrorScene}\"");
                }

                await context.WriteLine(string.Empty);
            }

            return(context);
        }
 public static InvalidSkillFlowException InvalidComponent(this SkillFlowComponent component,
                                                          SkillFlowComponent candidate) =>
 new InvalidSkillFlowException($"Unable to add {candidate.Type} to {component.Type}");
Esempio n. 9
0
 public InterpreterResult(SkillFlowComponent component)
 {
     Component = component;
 }
 protected virtual Task RenderComment(SkillFlowComponent component, TContext context)
 {
     return(Noop(context));
 }