Beispiel #1
0
        protected override Validation <string, Equipment> CreateService(RigidBody node, ILoggerFactory loggerFactory)
        {
            var key         = Key.TrimToOption().IfNone(() => Name);
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);
            var description = Description.TrimToOption().Map(Tr);

            return
                (from mesh in Mesh
                 .ToValidation("Failed to find the mesh instance.")
                 from colliders in Optional(Colliders).Filter(Enumerable.Any)
                 .ToValidation("Failed to find the collision shape.")
                 from itemMesh in Optional(ItemMesh)
                 .ToValidation("Failed to find the item mesh.")
                 from configurations in Optional(Configurations.Freeze()).Filter(c => Enumerable.Any(c))
                 .ToValidation("Failed to find equipment configuration.")
                 select new Equipment(
                     key,
                     displayName,
                     description,
                     EquipmentType,
                     configurations,
                     colliders,
                     mesh,
                     itemMesh,
                     Optional(Markers).Flatten(),
                     Morphs,
                     node,
                     loggerFactory));
        }
Beispiel #2
0
        protected override Validation <string, T> CreateResource()
        {
            var key         = this.GetKey();
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);

            return(CreateResource(key, displayName));
        }
Beispiel #3
0
        protected override Validation <string, ActionGroup> CreateService(ILoggerFactory loggerFactory)
        {
            var key         = Key.TrimToOption().IfNone(() => Name);
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);

            return(new ActionGroup(key, displayName, Actions, Groups, loggerFactory));
        }
Beispiel #4
0
        protected override Validation <string, T> CreateService(ILoggerFactory loggerFactory)
        {
            var key         = Key.TrimToOption().IfNone(() => Name);
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);
            var description = Description.TrimToOption().Map(Tr);
            var children    = Optional(Children).Flatten().ToMap();

            return(CreateService(key, displayName, description, Optional(Icon), children, loggerFactory));
        }
        protected override Validation <string, T> CreateService(ILoggerFactory loggerFactory)
        {
            var key         = Key.TrimToOption().IfNone(() => Name);
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);

            return
                (from control in PlayerControl
                 .ToValidation("Failed to find the player control.")
                 from service in CreateService(key, displayName, control, loggerFactory)
                 select service);
        }
Beispiel #6
0
        protected override Validation <string, MorphGroup> CreateResource()
        {
            var definitions = Optional(Morphs)
                              .Flatten()
                              .Map(m => m.Validate <IMorphDefinition>())
                              .Sequence();

            return
                (from key in ValidateName
                 from morphs in definitions
                 select new MorphGroup(key, DisplayName.TrimToOption().Map(Tr).IfNone(key), morphs));
        }
Beispiel #7
0
        protected override Validation <string, TCharacter> CreateService(KinematicBody node,
                                                                         ILoggerFactory loggerFactory)
        {
            var key         = Key.TrimToOption().IfNone(() => Name);
            var displayName = DisplayName.TrimToOption().Map(Tr).IfNone(key);

            return
                (from skeleton in Skeleton
                 .ToValidation("Failed to find the skeleton.")
                 from vision in Vision
                 .ToValidation("Failed to find the vision component.")
                 from locomotion in Locomotion
                 .ToValidation("Failed to find the locomotion component.")
                 from race in Race.Validate <TRace>().MapFail(e => $"Invalid race: '{e}'.")
                 from actions in Actions
                 .ToValidation("Failed to find the action set.")
                 from animationManager in AnimationManager
                 .ToValidation("Failed to find the animation manager.")
                 from character in CreateService(
                     key, displayName, race, Attributes, vision, locomotion, skeleton, actions,
                     animationManager, node, loggerFactory)
                 select character);
        }
 protected override Validation <string, TDef> CreateResource()
 {
     return(ValidateName.Bind(key =>
                              CreateResource(key, DisplayName.TrimToOption().Map(Tr).IfNone(key), Hidden)));
 }