Esempio n. 1
0
        private void findInBounds(Bounds bound)
        {
            byte b;
            byte b2;

            Regions.tryGetCoordinate(base.transform.TransformPoint(bound.min), out b, out b2);
            byte b3;
            byte b4;

            Regions.tryGetCoordinate(base.transform.TransformPoint(bound.max), out b3, out b4);
            for (byte b5 = b; b5 <= b3; b5 += 1)
            {
                for (byte b6 = b2; b6 <= b4; b6 += 1)
                {
                    for (int i = 0; i < LevelObjects.objects[(int)b5, (int)b6].Count; i++)
                    {
                        LevelObject levelObject = LevelObjects.objects[(int)b5, (int)b6][i];
                        if (levelObject.asset != null && !(levelObject.transform == null) && levelObject.asset.type != EObjectType.LARGE)
                        {
                            if (!levelObject.isSpeciallyCulled)
                            {
                                Vector3 vector = base.transform.InverseTransformPoint(levelObject.transform.position);
                                if (bound.Contains(vector))
                                {
                                    levelObject.isSpeciallyCulled = true;
                                    this.objects.Add(levelObject);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public static void dropStructure(Structure structure, Vector3 point, float angle_x, float angle_y, float angle_z, ulong owner, ulong group)
        {
            ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, structure.id);

            if (itemStructureAsset != null)
            {
                Vector3 eulerAngles = Quaternion.Euler(-90f, angle_y, 0f).eulerAngles;
                angle_x = (float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
                angle_y = (float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
                angle_z = (float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
                byte            b;
                byte            b2;
                StructureRegion structureRegion;
                if (Regions.tryGetCoordinate(point, out b, out b2) && StructureManager.tryGetRegion(b, b2, out structureRegion))
                {
                    StructureData structureData = new StructureData(structure, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, group, Provider.time);
                    structureRegion.structures.Add(structureData);
                    StructureManager.manager.channel.send("tellStructure", ESteamCall.ALL, b, b2, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        b,
                        b2,
                        structure.id,
                        structureData.point,
                        structureData.angle_x,
                        structureData.angle_y,
                        structureData.angle_z,
                        owner,
                        group,
                        StructureManager.instanceCount += 1u
                    });
                }
            }
        }
Esempio n. 3
0
        // Token: 0x0600283E RID: 10302 RVA: 0x000F36C0 File Offset: 0x000F1AC0
        public static void takeItem(Transform item, byte to_x, byte to_y, byte to_rot, byte to_page)
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(item.position, out b, out b2))
            {
                ItemRegion itemRegion = ItemManager.regions[(int)b, (int)b2];
                for (int i = 0; i < itemRegion.drops.Count; i++)
                {
                    if (itemRegion.drops[i].model == item)
                    {
                        ItemManager.manager.channel.send("askTakeItem", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                        {
                            b,
                            b2,
                            itemRegion.drops[i].instanceID,
                            to_x,
                            to_y,
                            to_rot,
                            to_page
                        });
                        return;
                    }
                }
            }
        }
Esempio n. 4
0
        public static void registerRemoveObject(Transform select)
        {
            if (select == null)
            {
                return;
            }
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(select.position, out b, out b2))
            {
                if (select.CompareTag("Barricade") || select.CompareTag("Structure"))
                {
                    for (int i = 0; i < LevelObjects.buildables[(int)b, (int)b2].Count; i++)
                    {
                        if (LevelObjects.buildables[(int)b, (int)b2][i].transform == select)
                        {
                            LevelObjects.register(new ReunObjectRemove(LevelObjects.step, select, null, LevelObjects.buildables[(int)b, (int)b2][i].asset, select.position, select.rotation, select.localScale));
                            break;
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < LevelObjects.objects[(int)b, (int)b2].Count; j++)
                    {
                        if (LevelObjects.objects[(int)b, (int)b2][j].transform == select)
                        {
                            LevelObjects.register(new ReunObjectRemove(LevelObjects.step, select, LevelObjects.objects[(int)b, (int)b2][j].asset, null, select.position, select.rotation, select.localScale));
                            break;
                        }
                    }
                }
            }
        }
        // Token: 0x060028FF RID: 10495 RVA: 0x000FA6F8 File Offset: 0x000F8AF8
        public static void forage(Transform resource)
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(resource.position, out b, out b2))
            {
                List <ResourceSpawnpoint> list = LevelGround.trees[(int)b, (int)b2];
                ushort num = 0;
                while ((int)num < list.Count)
                {
                    if (resource == list[(int)num].model)
                    {
                        ResourceManager.manager.channel.send("askForage", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                        {
                            b,
                            b2,
                            num
                        });
                        break;
                    }
                    num += 1;
                }
            }
        }
Esempio n. 6
0
        private void OnEnable()
        {
            if (!Provider.isServer)
            {
                return;
            }
            if (this.target != null)
            {
                return;
            }
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(base.transform.position, out b, out b2))
            {
                for (int i = 0; i < LevelObjects.objects[(int)b, (int)b2].Count; i++)
                {
                    LevelObject levelObject = LevelObjects.objects[(int)b, (int)b2][i];
                    if (levelObject.interactable != null && levelObject.id == this.id)
                    {
                        this.target = (levelObject.interactable as InteractableObjectBinaryState);
                        break;
                    }
                }
            }
            if (this.target == null)
            {
                return;
            }
            if (!this.isListening)
            {
                ChatManager.onChatted = (Chatted)Delegate.Combine(ChatManager.onChatted, new Chatted(this.onChatted));
                this.isListening      = true;
            }
        }
Esempio n. 7
0
        private void Update()
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(base.transform.position, out b, out b2) && (b != this.region_x || b2 != this.region_y))
            {
                byte region_x = this.region_x;
                byte region_y = this.region_y;
                this._region_x = b;
                this._region_y = b2;
                if (this.onRegionUpdated != null)
                {
                    this.onRegionUpdated(region_x, region_y, b, b2);
                }
            }
            byte b3;

            LevelNavigation.tryGetBounds(base.transform.position, out b3);
            if (b3 != this.bound)
            {
                byte bound = this.bound;
                this._bound = b3;
                if (this.onBoundUpdated != null)
                {
                    this.onBoundUpdated(bound, b3);
                }
            }
            this.effectNode = null;
            for (int i = 0; i < LevelNodes.nodes.Count; i++)
            {
                Node node = LevelNodes.nodes[i];
                if (node.type == ENodeType.EFFECT)
                {
                    EffectNode effectNode = (EffectNode)node;
                    if (effectNode.shape == ENodeShape.SPHERE)
                    {
                        if ((base.transform.position - effectNode.point).sqrMagnitude < effectNode.editorRadius)
                        {
                            this.effectNode = effectNode;
                            break;
                        }
                    }
                    else if (effectNode.shape == ENodeShape.BOX && Mathf.Abs(base.transform.position.x - effectNode.point.x) < effectNode.bounds.x && Mathf.Abs(base.transform.position.y - effectNode.point.y) < effectNode.bounds.y && Mathf.Abs(base.transform.position.z - effectNode.point.z) < effectNode.bounds.z)
                    {
                        this.effectNode = effectNode;
                        break;
                    }
                }
            }
            AmbianceVolume effectNode2;

            if (this.effectNode == null && AmbianceUtility.isPointInsideVolume(base.transform.position, out effectNode2))
            {
                this.effectNode = effectNode2;
            }
            LevelLighting.updateLocal(MainCamera.instance.transform.position, 0f, this.effectNode);
        }
Esempio n. 8
0
        // Token: 0x0600283F RID: 10303 RVA: 0x000F3794 File Offset: 0x000F1B94
        public static void dropItem(Item item, Vector3 point, bool playEffect, bool isDropped, bool wideSpread)
        {
            if (ItemManager.regions == null || ItemManager.manager == null)
            {
                return;
            }
            if (wideSpread)
            {
                point.x += UnityEngine.Random.Range(-0.75f, 0.75f);
                point.z += UnityEngine.Random.Range(-0.75f, 0.75f);
            }
            else
            {
                point.x += UnityEngine.Random.Range(-0.125f, 0.125f);
                point.z += UnityEngine.Random.Range(-0.125f, 0.125f);
            }
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(point, out b, out b2))
            {
                ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, item.id);
                if (itemAsset != null && !itemAsset.isPro)
                {
                    if (playEffect)
                    {
                        EffectManager.sendEffect(6, EffectManager.SMALL, point);
                    }
                    if (point.y > 0f)
                    {
                        RaycastHit raycastHit;
                        Physics.Raycast(point + Vector3.up, Vector3.down, out raycastHit, Mathf.Min(point.y + 1f, Level.HEIGHT), RayMasks.BLOCK_ITEM);
                        if (raycastHit.collider != null)
                        {
                            point.y = raycastHit.point.y;
                        }
                    }
                    ItemData itemData = new ItemData(item, ItemManager.instanceCount += 1u, point, isDropped);
                    ItemManager.regions[(int)b, (int)b2].items.Add(itemData);
                    ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, b, b2, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        b,
                        b2,
                        item.id,
                        item.amount,
                        item.quality,
                        item.state,
                        point,
                        itemData.instanceID
                    });
                }
            }
        }
Esempio n. 9
0
        public static void addSpawn(Vector3 point)
        {
            byte b;
            byte b2;

            if (!Regions.tryGetCoordinate(point, out b, out b2))
            {
                return;
            }
            if ((int)EditorSpawns.selectedZombie >= LevelZombies.tables.Count)
            {
                return;
            }
            LevelZombies.spawns[(int)b, (int)b2].Add(new ZombieSpawnpoint(EditorSpawns.selectedZombie, point));
        }
Esempio n. 10
0
        public static Transform addBuildable(Vector3 position, Quaternion rotation, ushort id)
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(position, out b, out b2))
            {
                LevelBuildableObject levelBuildableObject = new LevelBuildableObject(position, rotation, id);
                levelBuildableObject.enable();
                LevelObjects.buildables[(int)b, (int)b2].Add(levelBuildableObject);
                LevelObjects._total++;
                return(levelBuildableObject.transform);
            }
            return(null);
        }
Esempio n. 11
0
 public static bool tryGetRegion(Transform structure, out byte x, out byte y, out StructureRegion region)
 {
     x      = 0;
     y      = 0;
     region = null;
     if (structure == null)
     {
         return(false);
     }
     if (Regions.tryGetCoordinate(structure.position, out x, out y))
     {
         region = StructureManager.regions[(int)x, (int)y];
         return(true);
     }
     return(false);
 }
Esempio n. 12
0
        public static Transform addObject(Vector3 position, Quaternion rotation, Vector3 scale, ushort id, string name, Guid GUID, ELevelObjectPlacementOrigin placementOrigin)
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(position, out b, out b2))
            {
                LevelObject levelObject = new LevelObject(position, rotation, scale, id, name, GUID, placementOrigin, LevelObjects.generateUniqueInstanceID());
                levelObject.enableCollision();
                levelObject.enableVisual();
                levelObject.disableSkybox();
                LevelObjects.objects[(int)b, (int)b2].Add(levelObject);
                LevelObjects._total++;
                return(levelObject.transform);
            }
            return(null);
        }
Esempio n. 13
0
        // Token: 0x060030C6 RID: 12486 RVA: 0x0013F6EC File Offset: 0x0013DAEC
        public static void getRegionsInRadius(Vector3 center, float radius, List <RegionCoordinate> result)
        {
            byte b;
            byte b2;

            if (!Regions.tryGetCoordinate(center, out b, out b2))
            {
                return;
            }
            result.Add(new RegionCoordinate(b, b2));
            Vector3 vector;

            Regions.tryGetPoint((int)b, (int)b2, out vector);
            byte b3 = b;
            byte b4 = b2;

            if (center.x - radius <= vector.x)
            {
                b3 -= 1;
            }
            else if (center.x + radius >= vector.x + (float)Regions.REGION_SIZE)
            {
                b3 += 1;
            }
            if (center.z - radius <= vector.z)
            {
                b4 -= 1;
            }
            else if (center.z + radius >= vector.z + (float)Regions.REGION_SIZE)
            {
                b4 += 1;
            }
            if (b3 != b && Regions.checkSafe((int)b3, (int)b2))
            {
                result.Add(new RegionCoordinate(b3, b2));
            }
            if (b4 != b2 && Regions.checkSafe((int)b, (int)b4))
            {
                result.Add(new RegionCoordinate(b, b4));
            }
            if (b3 != b && b4 != b2 && Regions.checkSafe((int)b3, (int)b4))
            {
                result.Add(new RegionCoordinate(b3, b4));
            }
        }
 // Token: 0x060028E3 RID: 10467 RVA: 0x000F8FF0 File Offset: 0x000F73F0
 public static bool tryGetRegion(Transform transform, out byte x, out byte y, out ushort index)
 {
     x     = 0;
     y     = 0;
     index = 0;
     if (Regions.tryGetCoordinate(transform.position, out x, out y))
     {
         List <LevelObject> list = LevelObjects.objects[(int)x, (int)y];
         index = 0;
         while ((int)index < list.Count)
         {
             if (transform == list[(int)index].transform)
             {
                 return(true);
             }
             index += 1;
         }
     }
     return(false);
 }
 // Token: 0x06002907 RID: 10503 RVA: 0x000FABD0 File Offset: 0x000F8FD0
 public static bool tryGetRegion(Transform resource, out byte x, out byte y, out ushort index)
 {
     x     = 0;
     y     = 0;
     index = 0;
     if (Regions.tryGetCoordinate(resource.position, out x, out y))
     {
         List <ResourceSpawnpoint> list = LevelGround.trees[(int)x, (int)y];
         index = 0;
         while ((int)index < list.Count)
         {
             if (resource == list[(int)index].model || resource == list[(int)index].stump)
             {
                 return(true);
             }
             index += 1;
         }
     }
     return(false);
 }
Esempio n. 16
0
        public static void removeBuildable(Transform select)
        {
            if (select == null)
            {
                return;
            }
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(select.position, out b, out b2))
            {
                for (int i = 0; i < LevelObjects.buildables[(int)b, (int)b2].Count; i++)
                {
                    if (LevelObjects.buildables[(int)b, (int)b2][i].transform == select)
                    {
                        LevelObjects.buildables[(int)b, (int)b2][i].destroy();
                        LevelObjects.buildables[(int)b, (int)b2].RemoveAt(i);
                        LevelObjects._total--;
                        break;
                    }
                }
            }
        }
Esempio n. 17
0
 public static void registerDevkitObject(LevelObject levelObject, out byte x, out byte y)
 {
     if (Regions.tryGetCoordinate(levelObject.transform.position, out x, out y))
     {
         LevelObjects.objects[(int)x, (int)y].Add(levelObject);
         if (LevelObjects.regions[(int)x, (int)y])
         {
             levelObject.enableCollision();
             if (!levelObject.isSpeciallyCulled)
             {
                 levelObject.enableVisual();
             }
             levelObject.disableSkybox();
         }
         else
         {
             levelObject.disableCollision();
             if (!levelObject.isSpeciallyCulled)
             {
                 levelObject.disableVisual();
             }
             if (levelObject.isLandmarkQualityMet)
             {
                 levelObject.enableSkybox();
             }
         }
     }
     else
     {
         levelObject.enableCollision();
         if (!levelObject.isSpeciallyCulled)
         {
             levelObject.enableVisual();
         }
         levelObject.disableSkybox();
     }
 }
Esempio n. 18
0
        public static void getAssetEditor(Transform select, out ObjectAsset objectAsset, out ItemAsset itemAsset)
        {
            objectAsset = null;
            itemAsset   = null;
            if (select == null)
            {
                return;
            }
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(select.position, out b, out b2))
            {
                if (select.CompareTag("Barricade") || select.CompareTag("Structure"))
                {
                    for (int i = 0; i < LevelObjects.buildables[(int)b, (int)b2].Count; i++)
                    {
                        if (LevelObjects.buildables[(int)b, (int)b2][i].transform == select)
                        {
                            itemAsset = LevelObjects.buildables[(int)b, (int)b2][i].asset;
                            return;
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < LevelObjects.objects[(int)b, (int)b2].Count; j++)
                    {
                        if (LevelObjects.objects[(int)b, (int)b2][j].transform == select)
                        {
                            objectAsset = LevelObjects.objects[(int)b, (int)b2][j].asset;
                            return;
                        }
                    }
                }
            }
        }
Esempio n. 19
0
 public static ObjectAsset getAsset(Transform select)
 {
     if (select != null)
     {
         DevkitHierarchyWorldObject component = select.GetComponent <DevkitHierarchyWorldObject>();
         if (component != null && component.levelObject != null)
         {
             return(component.levelObject.asset);
         }
         byte b;
         byte b2;
         if (Regions.tryGetCoordinate(select.position, out b, out b2))
         {
             for (int i = 0; i < LevelObjects.objects[(int)b, (int)b2].Count; i++)
             {
                 if (LevelObjects.objects[(int)b, (int)b2][i].transform == select)
                 {
                     return(LevelObjects.objects[(int)b, (int)b2][i].asset);
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 20
0
        public static void transformObject(Transform select, Vector3 toPosition, Quaternion toRotation, Vector3 toScale, Vector3 fromPosition, Quaternion fromRotation, Vector3 fromScale)
        {
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(fromPosition, out b, out b2))
            {
                byte b3;
                byte b4;
                if (Regions.tryGetCoordinate(toPosition, out b3, out b4))
                {
                    LevelObject levelObject = null;
                    int         index       = -1;
                    for (int i = 0; i < LevelObjects.objects[(int)b, (int)b2].Count; i++)
                    {
                        if (LevelObjects.objects[(int)b, (int)b2][i].transform == select)
                        {
                            levelObject = LevelObjects.objects[(int)b, (int)b2][i];
                            index       = i;
                            break;
                        }
                    }
                    if (levelObject != null)
                    {
                        if (b != b3 || b2 != b4)
                        {
                            LevelObjects.objects[(int)b, (int)b2].RemoveAt(index);
                            LevelObjects.objects[(int)b3, (int)b4].Add(levelObject);
                        }
                        if (levelObject.transform != null)
                        {
                            levelObject.transform.position   = toPosition;
                            levelObject.transform.rotation   = toRotation;
                            levelObject.transform.localScale = toScale;
                        }
                        if (levelObject.skybox != null)
                        {
                            levelObject.skybox.position   = toPosition;
                            levelObject.skybox.rotation   = toRotation;
                            levelObject.skybox.localScale = toScale;
                        }
                    }
                    else
                    {
                        LevelBuildableObject levelBuildableObject = null;
                        int index2 = -1;
                        for (int j = 0; j < LevelObjects.buildables[(int)b, (int)b2].Count; j++)
                        {
                            if (LevelObjects.buildables[(int)b, (int)b2][j].transform == select)
                            {
                                levelBuildableObject = LevelObjects.buildables[(int)b, (int)b2][j];
                                index2 = j;
                                break;
                            }
                        }
                        if (levelBuildableObject != null)
                        {
                            if (b != b3 || b2 != b4)
                            {
                                LevelObjects.buildables[(int)b, (int)b2].RemoveAt(index2);
                                LevelObjects.buildables[(int)b3, (int)b4].Add(levelBuildableObject);
                            }
                            if (levelBuildableObject.transform != null)
                            {
                                levelBuildableObject.transform.position = toPosition;
                                levelBuildableObject.transform.rotation = toRotation;
                            }
                        }
                        else
                        {
                            select.position   = fromPosition;
                            select.rotation   = fromRotation;
                            select.localScale = fromScale;
                        }
                    }
                }
                else
                {
                    select.position   = fromPosition;
                    select.rotation   = fromRotation;
                    select.localScale = fromScale;
                }
            }
            else
            {
                select.position   = fromPosition;
                select.rotation   = fromRotation;
                select.localScale = fromScale;
            }
        }
        // Token: 0x060028FE RID: 10494 RVA: 0x000FA378 File Offset: 0x000F8778
        public static void damage(Transform resource, Vector3 direction, float damage, float times, float drop, out EPlayerKill kill, out uint xp)
        {
            xp   = 0u;
            kill = EPlayerKill.NONE;
            byte b;
            byte b2;

            if (Regions.tryGetCoordinate(resource.position, out b, out b2))
            {
                List <ResourceSpawnpoint> list = LevelGround.trees[(int)b, (int)b2];
                ushort num = 0;
                while ((int)num < list.Count)
                {
                    if (resource == list[(int)num].model)
                    {
                        if (!list[(int)num].isDead)
                        {
                            ushort num2 = (ushort)(damage * times);
                            list[(int)num].askDamage(num2);
                            if (list[(int)num].isDead)
                            {
                                kill = EPlayerKill.RESOURCE;
                                ResourceAsset asset = list[(int)num].asset;
                                if (list[(int)num].asset != null)
                                {
                                    if (asset.explosion != 0)
                                    {
                                        if (asset.hasDebris)
                                        {
                                            EffectManager.sendEffect(asset.explosion, b, b2, ResourceManager.RESOURCE_REGIONS, resource.position + Vector3.up * 8f);
                                        }
                                        else
                                        {
                                            EffectManager.sendEffect(asset.explosion, b, b2, ResourceManager.RESOURCE_REGIONS, resource.position);
                                        }
                                    }
                                    if (asset.rewardID != 0)
                                    {
                                        direction.y = 0f;
                                        direction.Normalize();
                                        int num3 = (int)((float)UnityEngine.Random.Range((int)asset.rewardMin, (int)(asset.rewardMax + 1)) * drop);
                                        for (int i = 0; i < num3; i++)
                                        {
                                            ushort num4 = SpawnTableTool.resolve(asset.rewardID);
                                            if (num4 != 0)
                                            {
                                                if (asset.hasDebris)
                                                {
                                                    ItemManager.dropItem(new Item(num4, EItemOrigin.NATURE), resource.position + direction * (float)(2 + i) + new Vector3(0f, 2f, 0f), false, Dedicator.isDedicated, true);
                                                }
                                                else
                                                {
                                                    ItemManager.dropItem(new Item(num4, EItemOrigin.NATURE), resource.position + new Vector3(UnityEngine.Random.Range(-2f, 2f), 2f, UnityEngine.Random.Range(-2f, 2f)), false, Dedicator.isDedicated, true);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (asset.log != 0)
                                        {
                                            int num5 = (int)((float)UnityEngine.Random.Range(3, 7) * drop);
                                            for (int j = 0; j < num5; j++)
                                            {
                                                ItemManager.dropItem(new Item(asset.log, EItemOrigin.NATURE), resource.position + direction * (float)(2 + j * 2) + Vector3.up, false, Dedicator.isDedicated, true);
                                            }
                                        }
                                        if (asset.stick != 0)
                                        {
                                            int num6 = (int)((float)UnityEngine.Random.Range(2, 5) * drop);
                                            for (int k = 0; k < num6; k++)
                                            {
                                                float f = UnityEngine.Random.Range(0f, 6.28318548f);
                                                ItemManager.dropItem(new Item(asset.stick, EItemOrigin.NATURE), resource.position + new Vector3(Mathf.Sin(f) * 3f, 1f, Mathf.Cos(f) * 3f), false, Dedicator.isDedicated, true);
                                            }
                                        }
                                    }
                                    xp = asset.rewardXP;
                                }
                                ResourceManager.manager.channel.send("tellResourceDead", ESteamCall.ALL, b, b2, ResourceManager.RESOURCE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                                {
                                    b,
                                    b2,
                                    num,
                                    direction * (float)num2
                                });
                            }
                        }
                        break;
                    }
                    num += 1;
                }
            }
        }
Esempio n. 22
0
 public RegionCoord(Vector3 position)
 {
     Regions.tryGetCoordinate(position, out this.x, out this.y);
 }
Esempio n. 23
0
 public static void load()
 {
     LevelObjects._models                 = new GameObject().transform;
     LevelObjects.models.name             = "Objects";
     LevelObjects.models.parent           = Level.level;
     LevelObjects.models.tag              = "Logic";
     LevelObjects.models.gameObject.layer = LayerMasks.LOGIC;
     LevelObjects._objects                = new List <LevelObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE];
     LevelObjects._buildables             = new List <LevelBuildableObject> [(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE];
     LevelObjects._total              = 0;
     LevelObjects._regions            = new bool[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE];
     LevelObjects._loads              = new int[(int)Regions.WORLD_SIZE, (int)Regions.WORLD_SIZE];
     LevelObjects.shouldInstantlyLoad = true;
     LevelObjects.isHierarchyReady    = false;
     for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
     {
         for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
         {
             LevelObjects.loads[(int)b, (int)b2] = -1;
         }
     }
     for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1)
     {
         for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1)
         {
             LevelObjects.objects[(int)b3, (int)b4]    = new List <LevelObject>();
             LevelObjects.buildables[(int)b3, (int)b4] = new List <LevelBuildableObject>();
         }
     }
     if (Level.info.configData.Use_Legacy_Objects)
     {
         if (ReadWrite.fileExists(Level.info.path + "/Level/Objects.dat", false, false))
         {
             River river = new River(Level.info.path + "/Level/Objects.dat", false);
             byte  b5    = river.readByte();
             bool  flag  = true;
             if (b5 > 0)
             {
                 if (b5 > 1 && b5 < 3)
                 {
                     river.readSteamID();
                 }
                 if (b5 > 8)
                 {
                     LevelObjects.availableInstanceID = river.readUInt32();
                 }
                 else
                 {
                     LevelObjects.availableInstanceID = 1u;
                 }
                 for (byte b6 = 0; b6 < Regions.WORLD_SIZE; b6 += 1)
                 {
                     for (byte b7 = 0; b7 < Regions.WORLD_SIZE; b7 += 1)
                     {
                         ushort num = river.readUInt16();
                         for (ushort num2 = 0; num2 < num; num2 += 1)
                         {
                             Vector3    vector      = river.readSingleVector3();
                             Quaternion newRotation = river.readSingleQuaternion();
                             Vector3    newScale;
                             if (b5 > 3)
                             {
                                 newScale = river.readSingleVector3();
                             }
                             else
                             {
                                 newScale = Vector3.one;
                             }
                             ushort num3    = river.readUInt16();
                             string newName = string.Empty;
                             if (b5 > 5)
                             {
                                 newName = river.readString();
                             }
                             Guid newGUID = Guid.Empty;
                             if (b5 > 7)
                             {
                                 newGUID = river.readGUID();
                             }
                             ELevelObjectPlacementOrigin newPlacementOrigin = ELevelObjectPlacementOrigin.MANUAL;
                             if (b5 > 6)
                             {
                                 newPlacementOrigin = (ELevelObjectPlacementOrigin)river.readByte();
                             }
                             uint newInstanceID;
                             if (b5 > 8)
                             {
                                 newInstanceID = river.readUInt32();
                             }
                             else
                             {
                                 newInstanceID = LevelObjects.generateUniqueInstanceID();
                             }
                             if (num3 != 0)
                             {
                                 LevelObject levelObject = new LevelObject(vector, newRotation, newScale, num3, newName, newGUID, newPlacementOrigin, newInstanceID);
                                 if (levelObject.asset == null)
                                 {
                                     flag = false;
                                 }
                                 if (Level.isEditor)
                                 {
                                     byte b8;
                                     byte b9;
                                     Regions.tryGetCoordinate(vector, out b8, out b9);
                                     if (b8 != b6 || b9 != b7)
                                     {
                                         Debug.LogError(string.Concat(new object[]
                                         {
                                             num3,
                                             " should be in ",
                                             b8,
                                             ", ",
                                             b9,
                                             " but was in ",
                                             b6,
                                             ", ",
                                             b7,
                                             "!"
                                         }));
                                     }
                                     LevelObjects.objects[(int)b8, (int)b9].Add(levelObject);
                                 }
                                 else
                                 {
                                     LevelObjects.objects[(int)b6, (int)b7].Add(levelObject);
                                 }
                                 LevelObjects._total++;
                             }
                         }
                     }
                 }
             }
             if (flag)
             {
                 LevelObjects._hash = river.getHash();
             }
             else
             {
                 LevelObjects._hash = new byte[20];
             }
             river.closeRiver();
         }
         else
         {
             for (byte b10 = 0; b10 < Regions.WORLD_SIZE; b10 += 1)
             {
                 for (byte b11 = 0; b11 < Regions.WORLD_SIZE; b11 += 1)
                 {
                     if (ReadWrite.fileExists(string.Concat(new object[]
                     {
                         Level.info.path,
                         "/Objects/Objects_",
                         b10,
                         "_",
                         b11,
                         ".dat"
                     }), false, false))
                     {
                         River river2 = new River(string.Concat(new object[]
                         {
                             Level.info.path,
                             "/Objects/Objects_",
                             b10,
                             "_",
                             b11,
                             ".dat"
                         }), false);
                         byte b12 = river2.readByte();
                         if (b12 > 0)
                         {
                             ushort num4 = river2.readUInt16();
                             for (ushort num5 = 0; num5 < num4; num5 += 1)
                             {
                                 Vector3    position = river2.readSingleVector3();
                                 Quaternion rotation = river2.readSingleQuaternion();
                                 ushort     num6     = river2.readUInt16();
                                 string     empty    = string.Empty;
                                 Guid       empty2   = Guid.Empty;
                                 ELevelObjectPlacementOrigin placementOrigin = ELevelObjectPlacementOrigin.MANUAL;
                                 if (num6 != 0)
                                 {
                                     LevelObjects.addObject(position, rotation, Vector3.one, num6, empty, empty2, placementOrigin);
                                 }
                             }
                         }
                         river2.closeRiver();
                     }
                 }
             }
             LevelObjects._hash = new byte[20];
         }
     }
     else
     {
         LevelObjects._hash = new byte[20];
     }
     if ((Provider.isServer || Level.isEditor) && ReadWrite.fileExists(Level.info.path + "/Level/Buildables.dat", false, false))
     {
         River river3 = new River(Level.info.path + "/Level/Buildables.dat", false);
         river3.readByte();
         for (byte b13 = 0; b13 < Regions.WORLD_SIZE; b13 += 1)
         {
             for (byte b14 = 0; b14 < Regions.WORLD_SIZE; b14 += 1)
             {
                 ushort num7 = river3.readUInt16();
                 for (ushort num8 = 0; num8 < num7; num8 += 1)
                 {
                     Vector3    vector2      = river3.readSingleVector3();
                     Quaternion newRotation2 = river3.readSingleQuaternion();
                     ushort     num9         = river3.readUInt16();
                     if (num9 != 0)
                     {
                         LevelBuildableObject item = new LevelBuildableObject(vector2, newRotation2, num9);
                         if (Level.isEditor)
                         {
                             byte b15;
                             byte b16;
                             Regions.tryGetCoordinate(vector2, out b15, out b16);
                             if (b15 != b13 || b16 != b14)
                             {
                                 Debug.LogError(string.Concat(new object[]
                                 {
                                     num9,
                                     " should be in ",
                                     b15,
                                     ", ",
                                     b16,
                                     " but was in ",
                                     b13,
                                     ", ",
                                     b14,
                                     "!"
                                 }));
                             }
                             LevelObjects.buildables[(int)b15, (int)b16].Add(item);
                         }
                         else
                         {
                             LevelObjects.buildables[(int)b13, (int)b14].Add(item);
                         }
                         LevelObjects._total++;
                     }
                 }
             }
         }
         river3.closeRiver();
     }
     if (Level.info.configData.Use_Legacy_Objects && !Dedicator.isDedicated && !Level.isEditor)
     {
         for (byte b17 = 0; b17 < Regions.WORLD_SIZE; b17 += 1)
         {
             for (byte b18 = 0; b18 < Regions.WORLD_SIZE; b18 += 1)
             {
                 for (int i = 0; i < LevelObjects.objects[(int)b17, (int)b18].Count; i++)
                 {
                     LevelObject levelObject2 = LevelObjects.objects[(int)b17, (int)b18][i];
                     if (levelObject2.asset != null && !(levelObject2.transform == null))
                     {
                         if (levelObject2.asset.lod != EObjectLOD.NONE)
                         {
                             ObjectsLOD objectsLOD = levelObject2.transform.gameObject.AddComponent <ObjectsLOD>();
                             objectsLOD.lod    = levelObject2.asset.lod;
                             objectsLOD.bias   = levelObject2.asset.lodBias;
                             objectsLOD.center = levelObject2.asset.lodCenter;
                             objectsLOD.size   = levelObject2.asset.lodSize;
                             objectsLOD.calculateBounds();
                         }
                     }
                 }
             }
         }
     }
     if (Level.isEditor)
     {
         LevelObjects.reun  = new IReun[256];
         LevelObjects.step  = 0;
         LevelObjects.frame = 0;
     }
 }
Esempio n. 24
0
 // Token: 0x06002560 RID: 9568 RVA: 0x000D90CC File Offset: 0x000D74CC
 public static void load()
 {
     LevelNodes._models                 = new GameObject().transform;
     LevelNodes.models.name             = "Nodes";
     LevelNodes.models.parent           = Level.level;
     LevelNodes.models.tag              = "Logic";
     LevelNodes.models.gameObject.layer = LayerMasks.LOGIC;
     LevelNodes._nodes = new List <Node>();
     if (ReadWrite.fileExists(Level.info.path + "/Environment/Nodes.dat", false, false))
     {
         River river = new River(Level.info.path + "/Environment/Nodes.dat", false);
         byte  b     = river.readByte();
         if (b > 0)
         {
             ushort num = (ushort)river.readByte();
             for (ushort num2 = 0; num2 < num; num2 += 1)
             {
                 Vector3   vector    = river.readSingleVector3();
                 ENodeType enodeType = (ENodeType)river.readByte();
                 if (enodeType == ENodeType.LOCATION)
                 {
                     string newName = river.readString();
                     LevelNodes.nodes.Add(new LocationNode(vector, newName));
                 }
                 else if (enodeType == ENodeType.SAFEZONE)
                 {
                     float newRadius = river.readSingle();
                     bool  newHeight = false;
                     if (b > 1)
                     {
                         newHeight = river.readBoolean();
                     }
                     bool newNoWeapons = true;
                     if (b > 4)
                     {
                         newNoWeapons = river.readBoolean();
                     }
                     bool newNoBuildables = true;
                     if (b > 4)
                     {
                         newNoBuildables = river.readBoolean();
                     }
                     LevelNodes.nodes.Add(new SafezoneNode(vector, newRadius, newHeight, newNoWeapons, newNoBuildables));
                 }
                 else if (enodeType == ENodeType.PURCHASE)
                 {
                     float  newRadius2 = river.readSingle();
                     ushort newID      = river.readUInt16();
                     uint   newCost    = river.readUInt32();
                     LevelNodes.nodes.Add(new PurchaseNode(vector, newRadius2, newID, newCost));
                 }
                 else if (enodeType == ENodeType.ARENA)
                 {
                     float newRadius3 = river.readSingle();
                     LevelNodes.nodes.Add(new ArenaNode(vector, newRadius3));
                 }
                 else if (enodeType == ENodeType.DEADZONE)
                 {
                     float newRadius4 = river.readSingle();
                     LevelNodes.nodes.Add(new DeadzoneNode(vector, newRadius4));
                 }
                 else if (enodeType == ENodeType.AIRDROP)
                 {
                     ushort num3 = river.readUInt16();
                     byte   b2;
                     byte   b3;
                     if (SpawnTableTool.resolve(num3) == 0 && Regions.tryGetCoordinate(vector, out b2, out b3))
                     {
                         Assets.errors.Add(string.Concat(new object[]
                         {
                             Level.info.name,
                             " airdrop references invalid spawn table ",
                             num3,
                             " at (",
                             b2,
                             ", ",
                             b3,
                             ")!"
                         }));
                     }
                     LevelNodes.nodes.Add(new AirdropNode(vector, num3));
                 }
                 else if (enodeType == ENodeType.EFFECT)
                 {
                     byte newShape = 0;
                     if (b > 2)
                     {
                         newShape = river.readByte();
                     }
                     float   newRadius5 = river.readSingle();
                     Vector3 newBounds  = Vector3.one;
                     if (b > 2)
                     {
                         newBounds = river.readSingleVector3();
                     }
                     ushort newID2        = river.readUInt16();
                     bool   newNoWater    = river.readBoolean();
                     bool   newNoLighting = false;
                     if (b > 3)
                     {
                         newNoLighting = river.readBoolean();
                     }
                     LevelNodes.nodes.Add(new EffectNode(vector, (ENodeShape)newShape, newRadius5, newBounds, newID2, newNoWater, newNoLighting));
                 }
             }
         }
         river.closeRiver();
     }
 }
Esempio n. 25
0
        public void tellTransformStructure(CSteamID steamID, byte x, byte y, uint instanceID, Vector3 point, byte angle_x, byte angle_y, byte angle_z)
        {
            StructureRegion structureRegion;

            if (base.channel.checkServer(steamID) && StructureManager.tryGetRegion(x, y, out structureRegion))
            {
                if (!Provider.isServer && !structureRegion.isNetworked)
                {
                    return;
                }
                StructureData structureData = null;
                StructureDrop structureDrop = null;
                ushort        num           = 0;
                while ((int)num < structureRegion.drops.Count)
                {
                    if (structureRegion.drops[(int)num].instanceID == instanceID)
                    {
                        if (Provider.isServer)
                        {
                            structureData = structureRegion.structures[(int)num];
                        }
                        structureDrop = structureRegion.drops[(int)num];
                        break;
                    }
                    num += 1;
                }
                if (structureDrop == null)
                {
                    return;
                }
                structureDrop.model.position = point;
                structureDrop.model.rotation = Quaternion.Euler((float)(angle_x * 2), (float)(angle_y * 2), (float)(angle_z * 2));
                byte b;
                byte b2;
                if (Regions.tryGetCoordinate(point, out b, out b2) && (x != b || y != b2))
                {
                    StructureRegion structureRegion2 = StructureManager.regions[(int)b, (int)b2];
                    structureRegion.drops.RemoveAt((int)num);
                    if (structureRegion2.isNetworked || Provider.isServer)
                    {
                        structureRegion2.drops.Add(structureDrop);
                    }
                    else if (!Provider.isServer)
                    {
                        Object.Destroy(structureDrop.model.gameObject);
                    }
                    if (Provider.isServer)
                    {
                        structureRegion.structures.RemoveAt((int)num);
                        structureRegion2.structures.Add(structureData);
                    }
                }
                if (Provider.isServer)
                {
                    structureData.point   = point;
                    structureData.angle_x = angle_x;
                    structureData.angle_y = angle_y;
                    structureData.angle_z = angle_z;
                }
            }
        }
Esempio n. 26
0
        public void calculateBounds()
        {
            this.cullMagnitude    = 64f * this.bias;
            this.sqrCullMagnitude = this.cullMagnitude * this.cullMagnitude;
            if (this.lod == EObjectLOD.MESH)
            {
                ObjectsLOD.meshes.Clear();
                base.GetComponentsInChildren <MeshFilter>(true, ObjectsLOD.meshes);
                if (ObjectsLOD.meshes.Count == 0)
                {
                    base.enabled = false;
                    return;
                }
                Bounds item = default(Bounds);
                for (int i = 0; i < ObjectsLOD.meshes.Count; i++)
                {
                    Mesh sharedMesh = ObjectsLOD.meshes[i].sharedMesh;
                    if (!(sharedMesh == null))
                    {
                        Bounds bounds = sharedMesh.bounds;
                        item.Encapsulate(bounds.min);
                        item.Encapsulate(bounds.max);
                    }
                }
                item.Expand(-1f);
                item.center += this.center;
                item.size   += this.size;
                if (item.size.x < 1f || item.size.y < 1f || item.size.z < 1f)
                {
                    base.enabled = false;
                    return;
                }
                this.bounds = new List <Bounds>();
                this.bounds.Add(item);
            }
            else if (this.lod == EObjectLOD.AREA)
            {
                ObjectsLOD.areas.Clear();
                base.GetComponentsInChildren <OcclusionArea>(true, ObjectsLOD.areas);
                if (ObjectsLOD.areas.Count == 0)
                {
                    base.enabled = false;
                    return;
                }
                this.bounds = new List <Bounds>();
                for (int j = 0; j < ObjectsLOD.areas.Count; j++)
                {
                    OcclusionArea occlusionArea = ObjectsLOD.areas[j];
                    Bounds        item2;
                    item2..ctor(occlusionArea.transform.localPosition + occlusionArea.center, new Vector3(occlusionArea.size.x, occlusionArea.size.z, occlusionArea.size.y));
                    this.bounds.Add(item2);
                }
            }
            this.objects = new List <LevelObject>();
            for (int k = 0; k < this.bounds.Count; k++)
            {
                Bounds bounds2 = this.bounds[k];
                this.cullCenter += bounds2.center;
            }
            this.cullCenter /= (float)this.bounds.Count;
            this.cullCenter  = base.transform.TransformPoint(this.cullCenter);
            byte b;
            byte b2;

            Regions.tryGetCoordinate(this.cullCenter, out b, out b2);
            for (int l = (int)(b - 1); l <= (int)(b + 1); l++)
            {
                for (int m = (int)(b2 - 1); m <= (int)(b2 + 1); m++)
                {
                    for (int n = 0; n < LevelObjects.objects[l, m].Count; n++)
                    {
                        LevelObject levelObject = LevelObjects.objects[l, m][n];
                        if (levelObject.asset != null && !(levelObject.transform == null) && levelObject.asset.type != EObjectType.LARGE)
                        {
                            if (!levelObject.isSpeciallyCulled)
                            {
                                Vector3 vector = base.transform.InverseTransformPoint(levelObject.transform.position);
                                bool    flag   = false;
                                for (int num = 0; num < this.bounds.Count; num++)
                                {
                                    if (this.bounds[num].Contains(vector))
                                    {
                                        flag = true;
                                        break;
                                    }
                                }
                                if (flag)
                                {
                                    levelObject.isSpeciallyCulled = true;
                                    this.objects.Add(levelObject);
                                }
                            }
                        }
                    }
                }
            }
            if (this.objects.Count == 0)
            {
                base.enabled = false;
                return;
            }
        }