Ejemplo n.º 1
0
    public static ushort CellFromGroupID(int groupID, out ushort x, out ushort y)
    {
        ushort num = CullGrid.CellFromGroupID(groupID);

        x = (ushort)(num % CullGrid.grid.cellsWide);
        y = (ushort)(num / CullGrid.grid.cellsWide);
        return(num);
    }
Ejemplo n.º 2
0
    private void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        ushort num;
        ushort num2;

        uLink.NetworkView networkView = info.networkView;
        this.groupID = (int)info.networkView.group;
        this.center  = CullGrid.Flat(networkView.position);
        this.size    = networkView.position.y;
        this.extent  = this.size / 2f;
        CullGrid.CellFromGroupID(this.groupID, out num, out num2);
        base.name = string.Format("GRID-CELL:{0:00000}-[{1},{2}]", this.groupID, num, num2);
        this.y_mc = HeightCast(this.center);
        this.y_xy = HeightCast(new Vector2(this.center.x - this.extent, this.center.y - this.extent));
        this.y_XY = HeightCast(new Vector2(this.center.x + this.extent, this.center.y + this.extent));
        this.y_Xy = HeightCast(new Vector2(this.center.x + this.extent, this.center.y - this.extent));
        this.y_xY = HeightCast(new Vector2(this.center.x - this.extent, this.center.y + this.extent));
        this.y_xc = HeightCast(new Vector2(this.center.x - this.extent, this.center.y));
        this.y_Xc = HeightCast(new Vector2(this.center.x + this.extent, this.center.y));
        this.y_my = HeightCast(new Vector2(this.center.x, this.center.y - this.extent));
        this.y_mY = HeightCast(new Vector2(this.center.x, this.center.y + this.extent));
        base.transform.position = new Vector3(this.center.x, this.y_mc, this.center.y);
        float[] values = new float[] { this.y_xy, this.y_XY, this.y_Xy, this.y_xY, this.y_xc, this.y_Xc, this.y_my, this.y_mY, this.y_mc };
        float   num3   = Mathf.Min(values);

        float[] singleArray2 = new float[] { this.y_xy, this.y_XY, this.y_Xy, this.y_xY, this.y_xc, this.y_Xc, this.y_my, this.y_mY, this.y_mc };
        float   y            = Mathf.Max(singleArray2) - num3;

        this.bounds = new Bounds(new Vector3(this.center.x, num3 + (y * 0.5f), this.center.y), new Vector3(this.size, y, this.size));
        Transform transform = base.transform;

        this.t_xy          = transform.FindChild("BL");
        this.t_XY          = transform.FindChild("FR");
        this.t_Xy          = transform.FindChild("BR");
        this.t_xY          = transform.FindChild("FL");
        this.t_xc          = transform.FindChild("ML");
        this.t_Xc          = transform.FindChild("MR");
        this.t_my          = transform.FindChild("BC");
        this.t_mY          = transform.FindChild("FC");
        this.t_mc          = transform.FindChild("MC");
        this.t_xy.position = new Vector3(this.center.x - this.extent, this.y_xy, this.center.y - this.extent);
        this.t_XY.position = new Vector3(this.center.x + this.extent, this.y_XY, this.center.y + this.extent);
        this.t_Xy.position = new Vector3(this.center.x + this.extent, this.y_Xy, this.center.y - this.extent);
        this.t_xY.position = new Vector3(this.center.x - this.extent, this.y_xY, this.center.y + this.extent);
        this.t_xc.position = new Vector3(this.center.x - this.extent, this.y_xc, this.center.y);
        this.t_Xc.position = new Vector3(this.center.x + this.extent, this.y_Xc, this.center.y);
        this.t_my.position = new Vector3(this.center.x, this.y_my, this.center.y - this.extent);
        this.t_mY.position = new Vector3(this.center.x, this.y_mY, this.center.y + this.extent);
        this.t_mc.position = new Vector3(this.center.x, this.y_mc, this.center.y);
        transform.gameObject.GetComponentInChildren <SkinnedMeshRenderer>().localBounds = new Bounds(new Vector3(0f, this.y_mc - (num3 + (y * 0.5f)), 0f), new Vector3(this.size, y, this.size));
    }
Ejemplo n.º 3
0
    private void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        ushort num;
        ushort num1;

        uLink.NetworkView networkView = info.networkView;
        this.groupID = info.networkView.@group;
        this.center  = CullGrid.Flat(networkView.position);
        this.size    = networkView.position.y;
        this.extent  = this.size / 2f;
        CullGrid.CellFromGroupID(this.groupID, out num, out num1);
        base.name = string.Format("GRID-CELL:{0:00000}-[{1},{2}]", this.groupID, num, num1);
        this.y_mc = CullCell.HeightCast(this.center);
        this.y_xy = CullCell.HeightCast(new Vector2(this.center.x - this.extent, this.center.y - this.extent));
        this.y_XY = CullCell.HeightCast(new Vector2(this.center.x + this.extent, this.center.y + this.extent));
        this.y_Xy = CullCell.HeightCast(new Vector2(this.center.x + this.extent, this.center.y - this.extent));
        this.y_xY = CullCell.HeightCast(new Vector2(this.center.x - this.extent, this.center.y + this.extent));
        this.y_xc = CullCell.HeightCast(new Vector2(this.center.x - this.extent, this.center.y));
        this.y_Xc = CullCell.HeightCast(new Vector2(this.center.x + this.extent, this.center.y));
        this.y_my = CullCell.HeightCast(new Vector2(this.center.x, this.center.y - this.extent));
        this.y_mY = CullCell.HeightCast(new Vector2(this.center.x, this.center.y + this.extent));
        base.transform.position = new Vector3(this.center.x, this.y_mc, this.center.y);
        float single  = Mathf.Min(new float[] { this.y_xy, this.y_XY, this.y_Xy, this.y_xY, this.y_xc, this.y_Xc, this.y_my, this.y_mY, this.y_mc });
        float single1 = Mathf.Max(new float[] { this.y_xy, this.y_XY, this.y_Xy, this.y_xY, this.y_xc, this.y_Xc, this.y_my, this.y_mY, this.y_mc }) - single;

        this.bounds = new Bounds(new Vector3(this.center.x, single + single1 * 0.5f, this.center.y), new Vector3(this.size, single1, this.size));
        Transform bound = base.transform;

        this.t_xy          = bound.FindChild("BL");
        this.t_XY          = bound.FindChild("FR");
        this.t_Xy          = bound.FindChild("BR");
        this.t_xY          = bound.FindChild("FL");
        this.t_xc          = bound.FindChild("ML");
        this.t_Xc          = bound.FindChild("MR");
        this.t_my          = bound.FindChild("BC");
        this.t_mY          = bound.FindChild("FC");
        this.t_mc          = bound.FindChild("MC");
        this.t_xy.position = new Vector3(this.center.x - this.extent, this.y_xy, this.center.y - this.extent);
        this.t_XY.position = new Vector3(this.center.x + this.extent, this.y_XY, this.center.y + this.extent);
        this.t_Xy.position = new Vector3(this.center.x + this.extent, this.y_Xy, this.center.y - this.extent);
        this.t_xY.position = new Vector3(this.center.x - this.extent, this.y_xY, this.center.y + this.extent);
        this.t_xc.position = new Vector3(this.center.x - this.extent, this.y_xc, this.center.y);
        this.t_Xc.position = new Vector3(this.center.x + this.extent, this.y_Xc, this.center.y);
        this.t_my.position = new Vector3(this.center.x, this.y_my, this.center.y - this.extent);
        this.t_mY.position = new Vector3(this.center.x, this.y_mY, this.center.y + this.extent);
        this.t_mc.position = new Vector3(this.center.x, this.y_mc, this.center.y);
        bound.gameObject.GetComponentInChildren <SkinnedMeshRenderer>().localBounds = new Bounds(new Vector3(0f, this.y_mc - (single + single1 * 0.5f), 0f), new Vector3(this.size, single1, this.size));
    }
Ejemplo n.º 4
0
    public static bool GroupIDContainsPoint(int groupID, ref Vector3 worldPoint, out int groupID_point)
    {
        ushort num;

        if (groupID < CullGrid.grid.groupBegin || groupID >= CullGrid.grid.groupEnd)
        {
            groupID_point = NetworkGroup.unassigned.id;
            return(false);
        }
        if (CullGrid.CellContainsPoint(CullGrid.CellFromGroupID(groupID), ref worldPoint, out num))
        {
            groupID_point = groupID;
            return(true);
        }
        groupID_point = CullGrid.GroupIDFromCell(num);
        return(false);
    }