Beispiel #1
0
 internal static void RemoveObject(CoopGridObject obj)
 {
     if (obj.CurrentNode >= 0)
     {
         CoopTreeGrid.Nodes[obj.CurrentNode].Objects.Remove(obj);
     }
 }
Beispiel #2
0
 internal static void UpdateObject(CoopGridObject obj)
 {
     int num = CoopTreeGrid.CalculateNode(obj.transform.position);
     if (num != obj.CurrentNode)
     {
         CoopTreeGrid.Nodes[obj.CurrentNode].Objects.Remove(obj);
         if (CoopTreeGrid.Nodes[num].Objects == null)
         {
             CoopTreeGrid.Nodes[num].Objects = new List<CoopGridObject>();
         }
         CoopTreeGrid.Nodes[num].Objects.Add(obj);
         obj.CurrentNode = num;
     }
 }
Beispiel #3
0
 internal static void RegisterObject(CoopGridObject obj, bool is_update)
 {
     int num = CoopTreeGrid.CalculateNode(obj.transform.position);
     if (CoopTreeGrid.Nodes[num].Objects == null)
     {
         CoopTreeGrid.Nodes[num].Objects = new List<CoopGridObject>();
     }
     CoopTreeGrid.Nodes[num].Objects.Add(obj);
     obj.CurrentNode = num;
     if (!is_update)
     {
         obj.entity.Freeze(false);
     }
 }
Beispiel #4
0
 internal static void RegisterObject(CoopGridObject obj)
 {
     CoopTreeGrid.RegisterObject(obj, false);
 }
Beispiel #5
0
 internal static void AttachAdjacent(List <GameObject> positions)
 {
     if (CoopTreeGrid.Nodes == null)
     {
         return;
     }
     for (int i = 0; i < CoopTreeGrid.Nodes.Length; i++)
     {
         CoopTreeGrid.Nodes[i].NewHasPlayer = 0;
     }
     for (int j = 0; j < positions.Count; j++)
     {
         Vector3 position = positions[j].transform.position;
         int     num      = Mathf.Clamp(2048 + (int)position.x, 0, 4096);
         int     num2     = Mathf.Clamp(2048 + (int)position.z, 0, 4096);
         int     num3     = Mathf.Clamp(num / 64, 0, 63);
         int     num4     = Mathf.Clamp(num2 / 64, 0, 63);
         for (int k = -2; k < 3; k++)
         {
             for (int l = -2; l < 3; l++)
             {
                 int num5 = num4 + k;
                 int num6 = num3 + l;
                 if (num5 >= 0 && num5 < 64 && num6 >= 0 && num6 < 64)
                 {
                     CoopTreeGrid.Node[] expr_F3_cp_0 = CoopTreeGrid.Nodes;
                     int expr_F3_cp_1 = num5 * 64 + num6;
                     expr_F3_cp_0[expr_F3_cp_1].NewHasPlayer = expr_F3_cp_0[expr_F3_cp_1].NewHasPlayer + 1;
                 }
             }
         }
     }
     for (int m = 0; m < CoopTreeGrid.Nodes.Length; m++)
     {
         CoopTreeGrid.Node node = CoopTreeGrid.Nodes[m];
         if (node.NewHasPlayer > node.OldHasPlayer || (node.NewHasPlayer == 0 && node.NewHasPlayer != node.OldHasPlayer))
         {
             if (node.Trees != null)
             {
                 for (int n = 0; n < node.Trees.Count; n++)
                 {
                     BoltEntity boltEntity = node.Trees[n];
                     if (boltEntity)
                     {
                         if (boltEntity.isAttached)
                         {
                             boltEntity.Freeze(node.NewHasPlayer == 0);
                         }
                     }
                     else
                     {
                         node.Trees.RemoveAt(n);
                         n--;
                     }
                 }
             }
             if (node.Objects != null)
             {
                 for (int num7 = 0; num7 < node.Objects.Count; num7++)
                 {
                     CoopGridObject coopGridObject = node.Objects[num7];
                     if (coopGridObject)
                     {
                         if (coopGridObject.entity && coopGridObject.entity.isAttached)
                         {
                             coopGridObject.entity.Freeze(node.NewHasPlayer == 0);
                         }
                     }
                     else
                     {
                         node.Objects.RemoveAt(num7);
                         num7--;
                     }
                 }
             }
         }
         CoopTreeGrid.Nodes[m].OldHasPlayer = CoopTreeGrid.Nodes[m].NewHasPlayer;
     }
 }
Beispiel #6
0
 public static void RegisterObject(CoopGridObject obj)
 {
     CoopTreeGrid.RegisterObject(obj, false);
 }
Beispiel #7
0
    public static void AttachAdjacent(List <GameObject> positions)
    {
        if (CoopTreeGrid.Nodes == null)
        {
            return;
        }
        for (int i = 0; i < CoopTreeGrid.Nodes.Length; i++)
        {
            CoopTreeGrid.Nodes[i].NewHasPlayer = 0;
        }
        for (int j = 0; j < positions.Count; j++)
        {
            Vector3 position = positions[j].transform.position;
            int     num      = Mathf.Clamp(2048 + (int)position.x, 0, 4096);
            int     num2     = Mathf.Clamp(2048 + (int)position.z, 0, 4096);
            int     num3     = Mathf.Clamp(num / 64, 0, 63);
            int     num4     = Mathf.Clamp(num2 / 64, 0, 63);
            for (int k = -2; k < 3; k++)
            {
                for (int l = -2; l < 3; l++)
                {
                    int num5 = num4 + k;
                    int num6 = num3 + l;
                    if (num5 >= 0 && num5 < 64 && num6 >= 0 && num6 < 64)
                    {
                        CoopTreeGrid.Node[] nodes = CoopTreeGrid.Nodes;
                        int num7 = num5 * 64 + num6;
                        nodes[num7].NewHasPlayer = nodes[num7].NewHasPlayer + 1;
                    }
                }
            }
        }
        for (int m = 0; m < CoopTreeGrid.Nodes.Length; m++)
        {
            CoopTreeGrid.Node node = CoopTreeGrid.Nodes[m];
            bool flag  = node.NewHasPlayer == 0;
            bool flag2 = CoopTreeGrid.NodeToSweepIndex(m) == CoopTreeGrid.SweepNodeIndex;
            if (node.NewHasPlayer > node.OldHasPlayer || (node.NewHasPlayer == 0 && node.NewHasPlayer != node.OldHasPlayer) || flag2)
            {
                if (flag && flag2)
                {
                    flag = false;
                    CoopTreeGrid.Nodes[m].NewHasPlayer = -1;
                }
                if (node.Trees != null)
                {
                    for (int n = 0; n < node.Trees.Count; n++)
                    {
                        BoltEntity boltEntity = node.Trees[n];
                        if (boltEntity)
                        {
                            if (boltEntity.isAttached)
                            {
                                boltEntity.Freeze(flag);
                            }
                        }
                        else
                        {
                            node.Trees.RemoveAt(n);
                            n--;
                        }
                    }
                }
                if (node.Objects != null)
                {
                    for (int num8 = 0; num8 < node.Objects.Count; num8++)
                    {
                        CoopGridObject coopGridObject = node.Objects[num8];
                        if (coopGridObject && coopGridObject.entity)
                        {
                            if (coopGridObject.entity.isAttached)
                            {
                                coopGridObject.entity.Freeze(flag);
                            }
                        }
                        else
                        {
                            node.Objects.RemoveAt(num8);
                            num8--;
                        }
                    }
                }
            }
            CoopTreeGrid.Nodes[m].OldHasPlayer = CoopTreeGrid.Nodes[m].NewHasPlayer;
        }
        int num9 = CoopTreeGrid.SweepToNodeIndex(CoopTreeGrid.SweepNodeIndex);

        if (num9 < CoopTreeGrid.Nodes.Length)
        {
            CoopTreeGrid.SweepNodeIndex++;
        }
        else if (num9 == CoopTreeGrid.Nodes.Length + 4)
        {
            CoopTreeGrid.SweepNodeIndex++;
            Debug.Log("Finished tree grid sweep");
        }
    }