Example #1
0
        public bool FindNearestNotBrickFromWorldLocNonFow(ref VInt3 newPos, ActorRoot ar)
        {
            VInt3 vInt  = new VInt3(newPos.x, newPos.z, 0);
            VInt2 vInt2 = VInt2.zero;

            this.LevelGrid.WorldPosToGrid(vInt, out vInt2.x, out vInt2.y);
            bool flag = false;

            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            if (this.QueryAttr(vInt2, out sViewBlockAttr) && sViewBlockAttr.BlockType == 2)
            {
                flag = true;
            }
            else if (!PathfindingUtility.IsValidTarget(ar, newPos))
            {
                flag = true;
            }
            if (!flag)
            {
                return(true);
            }
            VInt2 zero = VInt2.zero;

            if (this.FindNearestGrid(vInt2, vInt, FieldObj.EViewBlockType.Brick, true, 4, ar, out zero))
            {
                vInt2 = zero;
                VInt3 zero2 = VInt3.zero;
                this.LevelGrid.GridToWorldPos(vInt2.x, vInt2.y, out zero2);
                newPos = new VInt3(zero2.x, newPos.y, zero2.y);
                return(true);
            }
            return(false);
        }
Example #2
0
        public bool FindNearestGrid(VInt2 inCenterCell, VInt3 inCenterPosWorld, FieldObj.EViewBlockType inBlockType, bool bNonType, int inThicknessMax, ActorRoot ar, out VInt2 result)
        {
            result = VInt2.zero;
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            bool         flag  = false;
            int          num   = 1;
            List <VInt2> list  = new List <VInt2>();
            List <VInt2> list2 = new List <VInt2>();

            while (!flag && num <= inThicknessMax)
            {
                list2.Clear();
                this.CollectNeighbourGrids(list2, list, inCenterCell, num);
                num++;
                list.AddRange(list2);
                if (list2.get_Count() > 0)
                {
                    for (int i = list2.get_Count() - 1; i >= 0; i--)
                    {
                        this.QueryAttr(list2.get_Item(i), out sViewBlockAttr);
                        if ((bNonType && sViewBlockAttr.BlockType == (byte)inBlockType) || (!bNonType && sViewBlockAttr.BlockType != (byte)inBlockType))
                        {
                            list2.RemoveAt(i);
                        }
                    }
                }
                if (list2.get_Count() > 0)
                {
                    long num2 = 2147483647L;
                    for (int j = 0; j < list2.get_Count(); j++)
                    {
                        VInt2 vInt = list2.get_Item(j);
                        VInt3 zero = VInt3.zero;
                        this.LevelGrid.GridToWorldPos(vInt.x, vInt.y, out zero);
                        long sqrMagnitudeLong = (inCenterPosWorld - zero).sqrMagnitudeLong;
                        if (sqrMagnitudeLong < num2)
                        {
                            if (ar == null)
                            {
                                flag   = true;
                                num2   = sqrMagnitudeLong;
                                result = list2.get_Item(j);
                            }
                            else
                            {
                                VInt3 target = new VInt3(zero.x, 0, zero.y);
                                if (PathfindingUtility.IsValidTarget(ar, target))
                                {
                                    flag   = true;
                                    num2   = sqrMagnitudeLong;
                                    result = list2.get_Item(j);
                                }
                            }
                        }
                    }
                }
            }
            return(flag);
        }
Example #3
0
 public bool AddViewBlockAttr(byte inViewBlockId, byte inBlockType, byte inLightType)
 {
     if (!this.ViewBlockAttrMap.ContainsKey(inViewBlockId) && inViewBlockId > 0)
     {
         FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
         sViewBlockAttr.BlockType = inBlockType;
         sViewBlockAttr.LightType = inLightType;
         this.ViewBlockAttrMap.Add(inViewBlockId, sViewBlockAttr);
         return(true);
     }
     return(false);
 }
Example #4
0
        public FieldObj.EViewBlockType QueryAttr(VInt3 inActorLoc)
        {
            inActorLoc = new VInt3(inActorLoc.x, inActorLoc.z, 0);
            VInt2 zero = VInt2.zero;

            this.WorldPosToGrid(inActorLoc, out zero.x, out zero.y);
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            if (this.m_pFieldObj.QueryAttr(zero, out sViewBlockAttr))
            {
                return((FieldObj.EViewBlockType)sViewBlockAttr.BlockType);
            }
            return(FieldObj.EViewBlockType.None);
        }
Example #5
0
        public bool IsSurfaceCellVisibleConsiderNeighbor(VInt3 worldLoc, COM_PLAYERCAMP camp)
        {
            VInt2 vInt = VInt2.zero;

            this.WorldPosToGrid(worldLoc, out vInt.x, out vInt.y);
            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            if (this.m_pFieldObj.QueryAttr(vInt, out sViewBlockAttr) && sViewBlockAttr.BlockType == 2)
            {
                VInt2 zero = VInt2.zero;
                if (this.m_pFieldObj.FindNearestGrid(vInt, worldLoc, FieldObj.EViewBlockType.Brick, true, 3, null, out zero))
                {
                    vInt = zero;
                }
            }
            DebugHelper.Assert(camp != COM_PLAYERCAMP.COM_PLAYERCAMP_COUNT);
            return(this.IsVisible(vInt.x, vInt.y, camp));
        }
Example #6
0
        public bool IsAreaPermanentLit(int x, int y, COM_PLAYERCAMP inCamp)
        {
            VInt2 inCell = new VInt2(x, y);

            FieldObj.SViewBlockAttr sViewBlockAttr = default(FieldObj.SViewBlockAttr);
            if (this.QueryAttr(inCell, out sViewBlockAttr))
            {
                if (sViewBlockAttr.LightType == 3)
                {
                    return(true);
                }
                if (sViewBlockAttr.LightType == 1 && inCamp == COM_PLAYERCAMP.COM_PLAYERCAMP_1)
                {
                    return(true);
                }
                if (sViewBlockAttr.LightType == 2 && inCamp == COM_PLAYERCAMP.COM_PLAYERCAMP_2)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #7
0
 public bool QueryAttr(FieldObj inFieldObj, out FieldObj.SViewBlockAttr outAttr)
 {
     return(inFieldObj.ViewBlockAttrMap.TryGetValue(this.m_viewBlockId, ref outAttr));
 }
Example #8
0
 public bool QueryAttr(VInt2 inCell, out FieldObj.SViewBlockAttr outAttr)
 {
     return(this.LevelGrid.GetGridCell(inCell).QueryAttr(this, out outAttr));
 }
Example #9
0
 public bool QueryAttr(int x, int y, out FieldObj.SViewBlockAttr outAttr)
 {
     return(this.LevelGrid.GetGridCell(x, y).QueryAttr(this, out outAttr));
 }