Beispiel #1
0
        public void ImageShouldDrawTransformedImage <TPixel>(TestImageProvider <TPixel> provider, PixelBlenderMode mode)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
                using (var blend = Image.Load <TPixel>(TestFile.Create(TestImages.Bmp.Car).Bytes))
                {
                    Matrix3x2 rotate = Matrix3x2Extensions.CreateRotationDegrees(45F);
                    Matrix3x2 scale  = Matrix3x2Extensions.CreateScale(new SizeF(.25F, .25F));
                    Matrix3x2 matrix = rotate * scale;

                    // Lets center the matrix so we can tell whether any cut-off issues we may have belong to the drawing processor
                    Rectangle srcBounds      = blend.Bounds();
                    Rectangle destBounds     = TransformHelpers.GetTransformedBoundingRectangle(srcBounds, matrix);
                    Matrix3x2 centeredMatrix = TransformHelpers.GetCenteredTransformMatrix(srcBounds, destBounds, matrix);

                    // We pass a new rectangle here based on the dest bounds since we've offset the matrix
                    blend.Mutate(x => x.Transform(
                                     centeredMatrix,
                                     KnownResamplers.Bicubic,
                                     new Rectangle(0, 0, destBounds.Width, destBounds.Height)));

                    var position = new Point((image.Width - blend.Width) / 2, (image.Height - blend.Height) / 2);
                    image.Mutate(x => x.DrawImage(blend, mode, .75F, position));
                    image.DebugSave(provider, new[] { "Transformed" });
                }
        }
Beispiel #2
0
        /// <summary>
        /// Return an Entity that has a DisplayListCamera that contains point <paramref name="hitPoint"/>, or Null
        /// if none matches.
        /// </summary>
        public Entity HitTestCamera(float3 hitPoint)
        {
            // world to screen
            var         env = EntityManager.World.TinyEnvironment();
            DisplayInfo di  = env.GetConfigData <DisplayInfo>();

            Unity.Tiny.Core2D.Rect screenRect = new Unity.Tiny.Core2D.Rect(0.0f, 0.0f, (float)di.width, (float)di.height);
            float2 screenSize = new float2((float)di.width, (float)di.height);
            Entity r          = Entity.Null;
            float  bestDepth  = 0;

            Entities.ForEach((Entity e, ref Camera2D c2d, ref DisplayListCamera dlc, ref LocalToWorld t) =>
            {
                float2 window = TransformHelpers.WorldToWindow(this, e, hitPoint, screenSize);
                Unity.Tiny.Core2D.Rect cRect;
                if (c2d.rect.IsEmpty())
                {
                    cRect = new Unity.Tiny.Core2D.Rect(0, 0, 1, 1);
                }
                else
                {
                    cRect = c2d.rect;
                }
                Unity.Tiny.Core2D.Rect camRect = screenRect.Region(cRect);
                if (camRect.Contains(window))
                {
                    if (r == Entity.Null || c2d.depth > bestDepth)
                    {
                        r         = e;
                        bestDepth = c2d.depth;
                    }
                }
            });
            return(r);
        }
Beispiel #3
0
 public bool IsValidFoundationSpot(Vector3 searchPos)
 {
     if (this._structureComponents.Count == 0)
     {
         return(true);
     }
     foreach (StructureComponent component in this._structureComponents)
     {
         if (component.type == StructureComponent.StructureComponentType.Foundation)
         {
             Vector3 vector2;
             Vector3 vector3;
             Vector3 vector = component.transform.InverseTransformPoint(searchPos);
             bool    flag   = ((this.Approx(Mathf.Abs(vector.x), 5f) && this.Approx(vector.z, 0f)) || (this.Approx(Mathf.Abs(vector.z), 5f) && this.Approx(vector.x, 0f))) && this.Approx(vector.y, 0f);
             bool    flag2  = false;
             if (TransformHelpers.GetGroundInfoTerrainOnly(searchPos + new Vector3(0f, 3.5f, 0f), 3.5f, out vector2, out vector3))
             {
                 flag2 = true;
             }
             if (flag && !flag2)
             {
                 flag = false;
             }
             bool flag3 = false;
             if (flag || flag3)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #4
0
            private static GameObject smethod_183(Spawns.SpawnerLootable spawnerLootable_0)
            {
                GameObject result;

                if (spawnerLootable_0.SpawnedObject == null && spawnerLootable_0.vector3_0 != Vector3.zero && spawnerLootable_0.List.Count > 0)
                {
                    string text = spawnerLootable_0.method_0();
                    if (text != null)
                    {
                        Vector3 vector;
                        Vector3 vector2;
                        TransformHelpers.GetGroundInfo(spawnerLootable_0.vector3_0, out vector, out vector2);
                        if (text == "BoxLoot")
                        {
                            vector.y += 0.35f;
                        }
                        Quaternion     quaternion = Quaternion.Euler(0f, (float)UnityEngine.Random.Range(0, 360), 0f);
                        GameObject     gameObject = NetCull.InstantiateStatic(text, vector, quaternion);
                        LootableObject component  = gameObject.GetComponent <LootableObject>();
                        if (component != null)
                        {
                            component.LootCycle = spawnerLootable_0.List[text].LootCycle;
                            component.lifeTime  = spawnerLootable_0.List[text].LifeTime;
                            component.ResetInvokes();
                        }
                        result = gameObject;
                        return(result);
                    }
                }
                result = spawnerLootable_0.SpawnedObject;
                return(result);
            }
Beispiel #5
0
        internal static List <ShallowMatchedBigLittleParentModel> GetallMatchesShallow()
        {
            using (var _context = new bbbsDbContext())
            {
                var query = (from blpm in _context.BigLittleParentMaps
                             join lpm in _context.LittleParentMaps on blpm.LittleParentMapId equals lpm.Id
                             from ua in _context.UserAccounts
                             where blpm.BigId == ua.Id || lpm.LittleId == ua.Id || lpm.ParentId == ua.Id
                             select new UserAccountWithMatchId
                {
                    MatchId = blpm.Id,
                    FirstName = ua.FirstName,
                    LastName = ua.LastName,
                    Id = ua.Id,
                    Password = ua.Password,
                    UserName = ua.UserName,
                    UserTypeId = ua.UserTypeId,
                    Age = ua.Age
                })
                            .Distinct().ToList();

                var queryDictionary = query.GroupBy(key => new { key.MatchId }, model => new UserAccountModel
                {
                    Id         = model.Id,
                    FirstName  = model.FirstName,
                    LastName   = model.LastName,
                    UserName   = model.UserName,
                    UserTypeId = model.UserTypeId,
                    Password   = model.Password,
                    Age        = model.Age,
                    PictureUrl = model.PictureUrl
                }).ToDictionary(y => y.Key, z => z.ToList());

                List <ShallowMatchedBigLittleParentModel> matches = new List <ShallowMatchedBigLittleParentModel>();
                foreach (var key in queryDictionary.Keys)
                {
                    ShallowMatchedBigLittleParentModel currentMatch = new ShallowMatchedBigLittleParentModel();
                    foreach (var match in queryDictionary[key])
                    {
                        switch (match.UserTypeId)
                        {
                        case 1:
                            currentMatch.Big = TransformHelpers.ModelToUserAccountViewModel(match);
                            break;

                        case 2:
                            currentMatch.Little = TransformHelpers.ModelToUserAccountViewModel(match);;
                            break;

                        case 3:
                            currentMatch.Parent = TransformHelpers.ModelToUserAccountViewModel(match);;
                            break;
                        }
                    }
                    currentMatch.MatchId = key.MatchId;
                    matches.Add(currentMatch);
                }
                return(matches);
            }
        }
Beispiel #6
0
 public static UserAccountModel GetUserAccount(int userId)
 {
     using (var _context = new bbbsDbContext())
     {
         return(TransformHelpers.UserAccountToModel(_context.UserAccounts.FirstOrDefault(x => x.Id == userId)));
     }
 }
        public bool Validate(TransformRouteValidationContext context, IReadOnlyDictionary <string, string> transformValues)
        {
            if (transformValues.TryGetValue(QueryValueParameterKey, out var queryValueParameter))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 2);
                if (!transformValues.TryGetValue(AppendKey, out var _) && !transformValues.TryGetValue(SetKey, out var _))
                {
                    context.Errors.Add(new ArgumentException($"Unexpected parameters for QueryValueParameter: {string.Join(';', transformValues.Keys)}. Expected 'Append' or 'Set'."));
                }
            }
            else if (transformValues.TryGetValue(QueryRouteParameterKey, out var queryRouteParameter))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 2);
                if (!transformValues.TryGetValue(AppendKey, out var _) && !transformValues.TryGetValue(SetKey, out var _))
                {
                    context.Errors.Add(new ArgumentException($"Unexpected parameters for QueryRouteParameter: {string.Join(';', transformValues.Keys)}. Expected 'Append' or 'Set'."));
                }
            }
            else if (transformValues.TryGetValue(QueryRemoveParameterKey, out var removeQueryParameter))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 1);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        public bool Build(TransformBuilderContext context, IReadOnlyDictionary <string, string> transformValues)
        {
            if (transformValues.TryGetValue(PathSetKey, out var pathSet))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                var path = MakePathString(pathSet);
                context.AddPathSet(path);
            }
            else if (transformValues.TryGetValue(PathPrefixKey, out var pathPrefix))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                var path = MakePathString(pathPrefix);
                context.AddPathPrefix(path);
            }
            else if (transformValues.TryGetValue(PathRemovePrefixKey, out var pathRemovePrefix))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                var path = MakePathString(pathRemovePrefix);
                context.AddPathRemovePrefix(path);
            }
            else if (transformValues.TryGetValue(PathPatternKey, out var pathPattern))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                var path = MakePathString(pathPattern);
                // We don't use the extension here because we want to avoid doing a DI lookup for the binder every time.
                context.RequestTransforms.Add(new PathRouteValuesTransform(path.Value !, _binderFactory));
            }
            else
            {
                return(false);
            }

            return(true);
        }
Beispiel #9
0
        public ConsolidatedUserInformationResponseModel CreateConsolidatedUser([FromBody] JObject jmodel)
        {
            var Model = new ConsolidatedUserInformationInputModel()
            {
                UserAccount = jmodel["user"].ToObject <UserAccountModel>(),
                UserAddress = jmodel["address"].ToObject <UserAddressModel>(),
                ContactInfo = jmodel["contactInfo"].ToObject <ContactInfoModel>(),
                Interests   = jmodel["interests"].ToObject <List <InterestModel> >()
            };

            Model.UserAccount = UserAccountService.CreateUserAccount(Model.UserAccount);
            Model.UserAddress = AddressService.CreateUserAddress(Model.UserAddress);
            Model.ContactInfo.UserAccountId = Model.UserAccount.Id;
            Model.ContactInfo.UserAddressId = Model.UserAddress.Id;
            Model.ContactInfo = ContactInfoService.CreateUserContactInfo(Model.ContactInfo);

            if (Model.Interests != null)
            {
                foreach (var Interest in Model.Interests)
                {
                    var NewMapping = new InterestUserMapModel
                    {
                        UserAccountId = Model.UserAccount.Id,
                        InterestId    = Interest.Id
                    };

                    InterestService.CreateInterestUserMap(NewMapping);
                }
            }

            Model.Interests = InterestService.GetUserInterests(Model.UserAccount.Id);

            return(TransformHelpers.UserInputModelToUserResponseModel(Model));
        }
Beispiel #10
0
        public bool Validate(TransformRouteValidationContext context, IReadOnlyDictionary <string, string> transformValues)
        {
            if (transformValues.TryGetValue(PathSetKey, out var pathSet))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 1);
                CheckPathNotNull(context, PathSetKey, pathSet);
            }
            else if (transformValues.TryGetValue(PathPrefixKey, out var pathPrefix))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 1);
                CheckPathNotNull(context, PathPrefixKey, pathPrefix);
            }
            else if (transformValues.TryGetValue(PathRemovePrefixKey, out var pathRemovePrefix))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 1);
                CheckPathNotNull(context, PathRemovePrefixKey, pathRemovePrefix);
            }
            else if (transformValues.TryGetValue(PathPatternKey, out var pathPattern))
            {
                TransformHelpers.TryCheckTooManyParameters(context, transformValues, expected: 1);
                CheckPathNotNull(context, PathPatternKey, pathPattern);
                // TODO: Validate the pattern format. Does it build?
            }
            else
            {
                return(false);
            }

            return(true);
        }
Beispiel #11
0
        /// <summary>
        ///  Transforms Screen coordinates into World coordinates.
        ///  World space includes the camera transform of the camera closest to
        ///  the input coordinate.
        ///  In 2D setups, the world z coordinate is always set to 0.
        /// </summary>
        public float3 TranslateScreenToWorld(float2 screenCoord)
        {
            // TODO: this should not live in input, but keep it for now for compat
            var         env = World.TinyEnvironment();
            DisplayInfo di  = env.GetConfigData <DisplayInfo>();

            Rect   screenRect = new Rect(0, 0, (float)di.width, (float)di.height);
            float3 result     = float3.zero;
            float2 windowSize = new float2((float)di.width, (float)di.height);
            float  bestdepth  = Single.NegativeInfinity;

            Entities.ForEach((Entity e, ref Camera2D c2d, ref LocalToWorld xform) =>
            {
                Rect cRect;
                if (c2d.rect.IsEmpty())
                {
                    cRect = new Rect(0, 0, 1, 1);
                }
                else
                {
                    cRect = c2d.rect;
                }
                cRect = screenRect.Region(cRect);
                if (cRect.Contains(screenCoord))
                {
                    if (c2d.depth > bestdepth)
                    {
                        result    = TransformHelpers.WindowToWorld(this, e, screenCoord, windowSize);
                        bestdepth = c2d.depth;
                    }
                }
            });
            return(result);
        }
    /*
     * Find the tip for a limb using the supplied info
     * */
    public static BodyPart FindLimbTip(BodyPart tipParent, Component[] hierarchy, string tipName)
    {
        // if the tip parent is null, early out
        if (tipParent == null)
        {
            return(null);
        }

        // the part that will be returned
        BodyPart ret = null;

        // if there is more than one child, find the middle digit using the naming convention
        if (tipParent.bone.childCount > 1)
        {
            // search for children with the matching name
            ArrayList children = new ArrayList();
            int       matches  = 0;
            foreach (Transform child in tipParent.bone)
            {
                children.Add(child.name);
                if (child.name.Contains(tipName))
                {
                    matches++;
                }
            }
            if (matches == 1)
            {
                foreach (Transform child in tipParent.bone)
                {
                    if (child.name.Length < tipName.Length || ret != null)
                    {
                        continue;
                    }
                    if (child.name.Substring(0, tipName.Length) == tipName)
                    {
                        ret = BipedHelpers.AddPartByName(child.name, hierarchy);
                    }
                }
            }

            // if no match was found, this may be a Max Biped, in which case the digits are numbered
            if (ret == null)
            {
                Transform tip = TransformHelpers.GetTransformInHierarchy(hierarchy, tipName + (tipParent.bone.childCount / 2).ToString());
                if (tip != null)
                {
                    ret = BipedHelpers.AddPartByName(tip.name, hierarchy);
                }
            }
        }

        // couldn't find the middle digit, so pick the first child
        if (ret == null && tipParent.bone.childCount > 0)
        {
            ret = BipedHelpers.AddPartByName(tipParent.bone.GetChild(0).name, hierarchy);
        }

        return(ret);
    }
Beispiel #13
0
 public static UserAccountModel GetUserByLogin(LoginRequestModel requestModel)
 {
     using (var _context = new bbbsDbContext())
     {
         return(TransformHelpers.UserAccountToModel(_context.UserAccounts.FirstOrDefault(
                                                        x => x.UserName == requestModel.UserName && x.Password == requestModel.Password
                                                        )));
     }
 }
Beispiel #14
0
        private bool IsPointInsideControlBounds(float2 worldPoint, Entity control)
        {
            var toWorldMatrix      = TransformHelpers.ComputeWorldMatrix(this, control);
            var matrixInverted     = math.inverse(toWorldMatrix);
            var bounds             = GetControlBounds(control);
            var worldPointInverted = math.mul(matrixInverted, new float4(worldPoint.x, worldPoint.y, 0, 1));

            return(bounds.Contains(worldPointInverted.xy));
        }
Beispiel #15
0
 public static UserAccountModel CreateUser(UserAccountModel userModel)
 {
     using (var _context = new bbbsDbContext())
     {
         var newUser = _context.Add(TransformHelpers.ModelToUserAccount(userModel));
         _context.SaveChanges();
         userModel.Id = newUser.Entity.Id;
         return(userModel);
     }
 }
Beispiel #16
0
        /// <summary>
        /// Adds the transform which will add X-Forwarded-* request headers.
        /// </summary>
        public static TransformBuilderContext AddXForwarded(this TransformBuilderContext context, ForwardedTransformActions action = ForwardedTransformActions.Set)
        {
            context.AddXForwardedFor(action: action);
            context.AddXForwardedPrefix(action: action);
            context.AddXForwardedHost(action: action);
            context.AddXForwardedProto(action: action);

            // Remove the Forwarded header when an X-Forwarded transform is enabled
            TransformHelpers.RemoveForwardedHeader(context);
            return(context);
        }
Beispiel #17
0
        /// <inheritdoc/>
        protected override Size GetTransformedDimensions(Size sourceDimensions, Matrix3x2 matrix)
        {
            var sourceRectangle = new Rectangle(0, 0, sourceDimensions.Width, sourceDimensions.Height);

            if (!Matrix3x2.Invert(this.TransformMatrix, out Matrix3x2 sizeMatrix))
            {
                // TODO: Shouldn't we throw an exception instead?
                return(sourceDimensions);
            }

            return(TransformHelpers.GetTransformedBoundingRectangle(sourceRectangle, sizeMatrix).Size);
        }
        public static GameObject SpawnAtPlayer(string prefab, PlayerClient player, int count)
        {
            IDMain    idMain    = player.controllable.idMain;
            Transform transform = idMain.transform;
            Vector3   position;
            Vector3   up;

            idMain.transform.GetGroundInfo(out position, out up);
            Quaternion rotation = TransformHelpers.LookRotationForcedUp(player.transform.forward, up);

            return(World.Spawn(prefab, position, rotation, count));
        }
        public static GameObject SpawnAtPlayer(string prefab, PlayerClient player, int count)
        {
            Vector3   vector;
            Vector3   vector2;
            IDMain    idMain    = player.controllable.idMain;
            Transform transform = idMain.transform;

            idMain.transform.GetGroundInfo(out vector, out vector2);
            Quaternion rotation = TransformHelpers.LookRotationForcedUp(player.transform.forward, vector2);

            return(Spawn(prefab, vector, rotation, count));
        }
Beispiel #20
0
    public static bool GetIDMainFromCollider(Collider collider, out IDMain main)
    {
        IDBase dBase;

        if (!TransformHelpers.GetIDBaseFromCollider(collider, out dBase))
        {
            main = null;
            return(false);
        }
        main = dBase.idMain;
        return(main);
    }
Beispiel #21
0
    public static bool GetGroundInfoNavMesh(Vector3 startPos, out Vector3 pos, float maxVariationFallback, int acceptMask)
    {
        NavMeshHit navMeshHit;

        if (!TransformHelpers.GetGroundInfoNavMesh(startPos, out navMeshHit, maxVariationFallback, acceptMask))
        {
            pos = startPos;
            return(false);
        }
        pos = navMeshHit.position;
        return(true);
    }
Beispiel #22
0
 public static List <UserAccountModel> GetUserAccountsByType(int typeId)
 {
     using (var _context = new bbbsDbContext())
     {
         List <UserAccountModel> userAccountModels = new List <UserAccountModel>();
         foreach (var userAccount in _context.UserAccounts.Where(x => x.UserTypeId == typeId).ToList())
         {
             userAccountModels.Add(TransformHelpers.UserAccountToModel(userAccount));
         }
         return(userAccountModels);
     }
 }
        private void AlignCanvasWithCamera(UICanvas canvas, ref RectTransform rectTransform,
                                           ref Rotation localRotation)
        {
            // I can't use LocalToWorld here, cos it's one frame behind. I need a up-to-date world matrix.
            var toWorldMatrix  = TransformHelpers.ComputeWorldMatrix(this, canvas.camera);
            var cameraWorldPos = toWorldMatrix[3].xy;

            // We are assuming here that uicanvas is always a root, that's why we can assign camera's world position
            // to uicanvas' local position.
            rectTransform.anchoredPosition = cameraWorldPos;

            localRotation.Value = new quaternion(toWorldMatrix);
        }
Beispiel #24
0
        public static UserAddressModel GetAddressForUser(int userAccountId)
        {
            using (var _context = new bbbsDbContext())
            {
                var userAddress = (from address in _context.UserAddresses
                                   join contactinfo in _context.ContactInfo on address.Id equals contactinfo.UserAddressId
                                   join useraccount in _context.UserAccounts on userAccountId equals useraccount.Id
                                   select address
                                   ).FirstOrDefault();

                return(TransformHelpers.ModelToAddress(userAddress));
            }
        }
Beispiel #25
0
        public ConsolidatedUserInformationResponseModel GetConsolidatedUserInfo(int UserId)

        {
            var newModel = new ConsolidatedUserInformationResponseModel();

            newModel.user    = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(UserId));
            newModel.address = AddressService.GetAddressForUser(UserId);
            newModel.contactInfo.UserAddressId = newModel.address.Id;
            newModel.contactInfo = ContactInfoService.GetUserContactInfo(UserId);
            newModel.interests   = InterestService.GetUserInterests(UserId);

            return(newModel);
        }
Beispiel #26
0
    private void UpdateDisplacement(bool on)
    {
        Vector3 vector3  = new Vector3();
        Vector2 vector2  = new Vector2();
        Vector2 vector21 = new Vector2();
        Camera  camera;

        if (!on)
        {
            Shader.SetGlobalVector("_DisplacementWorldMin", Vector2.zero);
            Shader.SetGlobalVector("_DisplacementWorldMax", Vector2.zero);
            return;
        }
        FPGrassDisplacementCamera fPGrassDisplacementCamera = FPGrassDisplacementCamera.Get();

        if (fPGrassDisplacementCamera == null)
        {
            camera = null;
        }
        else
        {
            camera = fPGrassDisplacementCamera.camera;
        }
        Camera vector31 = camera;

        if (vector31 == null)
        {
            return;
        }
        float   single   = vector31.orthographicSize;
        float   single1  = single / (float)vector31.targetTexture.width;
        Vector3 vector32 = base.camera.transform.position;

        if (TransformHelpers.Dist2D(vector32, vector31.transform.position) > 5f)
        {
            vector3.x = Mathf.Round(vector32.x / single1) * single1;
            vector3.y = Mathf.Round(vector32.y / single1) * single1;
            vector3.z = Mathf.Round(vector32.z / single1) * single1;
            vector31.transform.position = vector3 + new Vector3(0f, 50f, 0f);
        }
        Vector3 vector33 = vector31.transform.position;

        vector2.x  = vector33.x - single;
        vector2.y  = vector33.z - single;
        vector21.x = vector33.x + single;
        vector21.y = vector33.z + single;
        Shader.SetGlobalVector("_DisplacementWorldMin", vector2);
        Shader.SetGlobalVector("_DisplacementWorldMax", vector21);
        vector31.Render();
    }
Beispiel #27
0
        float3 GetWorldPosition(float2 screenPosition)
        {
            var env         = World.TinyEnvironment();
            var displayInfo = env.GetConfigData <DisplayInfo>();
            var inputSystem = World.GetExistingSystem <InputSystem>();

            var cameraEntity = Entity.Null;

            Entities.WithAll <Camera2D>().ForEach((Entity entity) => { cameraEntity = entity; });
            var windowPosition = new float2(screenPosition.x, screenPosition.y);
            var windowSize     = new float2(displayInfo.width, displayInfo.height);

            return(TransformHelpers.WindowToWorld(this, cameraEntity, windowPosition, windowSize));
        }
Beispiel #28
0
        public bool Build(TransformBuilderContext context, IReadOnlyDictionary <string, string> transformValues)
        {
            if (transformValues.TryGetValue(RequestHeadersCopyKey, out var copyHeaders))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                context.CopyRequestHeaders = bool.Parse(copyHeaders);
            }
            else if (transformValues.TryGetValue(RequestHeaderOriginalHostKey, out var originalHost))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                context.AddOriginalHost(bool.Parse(originalHost));
            }
            else if (transformValues.TryGetValue(RequestHeaderKey, out var headerName))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 2);
                if (transformValues.TryGetValue(SetKey, out var setValue))
                {
                    context.AddRequestHeader(headerName, setValue, append: false);
                }
                else if (transformValues.TryGetValue(AppendKey, out var appendValue))
                {
                    context.AddRequestHeader(headerName, appendValue, append: true);
                }
                else
                {
                    throw new ArgumentException($"Unexpected parameters for RequestHeader: {string.Join(';', transformValues.Keys)}. Expected 'Set' or 'Append'");
                }
            }
            else if (transformValues.TryGetValue(RequestHeaderRemoveKey, out var removeHeaderName))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                context.AddRequestHeaderRemove(removeHeaderName);
            }
            else if (transformValues.TryGetValue(RequestHeadersAllowedKey, out var allowedHeaders))
            {
                TransformHelpers.CheckTooManyParameters(transformValues, expected: 1);
                var headersList = allowedHeaders.Split(';', options: StringSplitOptions.RemoveEmptyEntries
#if NET
                                                       | StringSplitOptions.TrimEntries
#endif
                                                       );
                context.AddRequestHeadersAllowed(headersList);
            }
            else
            {
                return(false);
            }

            return(true);
        }
Beispiel #29
0
        internal static MatchedBigLittleParentModel GetMatch(int matchId)
        {
            using (var _context = new bbbsDbContext())
            {
                MatchedBigLittleParentModel matchedBLPM = new MatchedBigLittleParentModel();
                var matchedUsers = (from ua in _context.UserAccounts
                                    from lpm in _context.LittleParentMaps
                                    from blpm in _context.BigLittleParentMaps
                                    where lpm.Id == blpm.LittleParentMapId &&
                                    ((blpm.Id == matchId) && (ua.Id == lpm.LittleId || ua.Id == lpm.ParentId || ua.Id == blpm.BigId))
                                    select ua).Distinct().ToList();

                if (matchedUsers != null)
                {
                    matchedBLPM.MatchId = matchId;
                    foreach (var match in matchedUsers)
                    {
                        var newModel = new ConsolidatedUserInformationResponseModel();

                        newModel.user    = TransformHelpers.ModelToUserAccountViewModel(UserAccountService.GetUserAccount(match.Id));
                        newModel.address = AddressService.GetAddressForUser(match.Id);
                        newModel.contactInfo.UserAddressId = newModel.address.Id;
                        newModel.contactInfo = ContactInfoService.GetUserContactInfo(match.Id);
                        newModel.interests   = InterestService.GetUserInterests(match.Id);

                        switch (match.UserTypeId)
                        {
                        case 1:
                            matchedBLPM.Big = newModel;
                            break;

                        case 2:
                            matchedBLPM.Little = newModel;
                            break;

                        case 3:
                            matchedBLPM.Parent = newModel;
                            break;
                        }
                    }
                    matchedBLPM.sharedInterests = InterestService.GetSharedInterest(matchedBLPM.Big.user.Id, matchedBLPM.Little.user.Id).ToList();
                    return(matchedBLPM);
                }
                else
                {
                    return(null);
                }
            }
        }
        public static bool LookAtPosition(PlayerClient player, out Vector3 position, [Optional, DefaultParameterValue(100f)] float maxDistance)
        {
            RaycastHit hit;

            position = new Vector3(0f, 0f, 0f);
            Character idMain = player.controllable.idMain;

            if ((idMain != null) && Physics.Raycast(idMain.eyesRay, out hit, maxDistance, -1))
            {
                Vector3 vector;
                TransformHelpers.GetGroundInfo(hit.point, 100f, out position, out vector);
                return(true);
            }
            return(false);
        }