public void tellObjects(CSteamID steamID)
 {
     if (base.channel.checkServer(steamID))
     {
         byte b  = (byte)base.channel.read(Types.BYTE_TYPE);
         byte b2 = (byte)base.channel.read(Types.BYTE_TYPE);
         if (!Regions.checkSafe((int)b, (int)b2))
         {
             return;
         }
         if (ObjectManager.regions[(int)b, (int)b2].isNetworked)
         {
             return;
         }
         ObjectManager.regions[(int)b, (int)b2].isNetworked = true;
         for (;;)
         {
             ushort num = (ushort)base.channel.read(Types.UINT16_TYPE);
             if (num == 65535)
             {
                 break;
             }
             byte[]      state       = (byte[])base.channel.read(Types.BYTE_ARRAY_TYPE);
             LevelObject levelObject = LevelObjects.objects[(int)b, (int)b2][(int)num];
             if (levelObject.interactable != null)
             {
                 levelObject.interactable.updateState(levelObject.asset, state);
             }
             if (levelObject.rubble != null)
             {
                 levelObject.rubble.updateState(levelObject.asset, state);
             }
         }
     }
 }
Esempio n. 2
0
 public void tellItems(CSteamID steamID)
 {
     if (base.channel.checkServer(steamID))
     {
         byte b  = (byte)base.channel.read(Types.BYTE_TYPE);
         byte b2 = (byte)base.channel.read(Types.BYTE_TYPE);
         if (!Regions.checkSafe((int)b, (int)b2))
         {
             return;
         }
         if ((byte)base.channel.read(Types.BYTE_TYPE) == 0)
         {
             if (ItemManager.regions[(int)b, (int)b2].isNetworked)
             {
                 return;
             }
         }
         else if (!ItemManager.regions[(int)b, (int)b2].isNetworked)
         {
             return;
         }
         ItemManager.regions[(int)b, (int)b2].isNetworked = true;
         ushort num = (ushort)base.channel.read(Types.UINT16_TYPE);
         for (int i = 0; i < (int)num; i++)
         {
             object[] array = base.channel.read(Types.UINT16_TYPE, Types.BYTE_TYPE, Types.BYTE_TYPE, Types.BYTE_ARRAY_TYPE, Types.VECTOR3_TYPE, Types.UINT32_TYPE);
             this.spawnItem(b, b2, (ushort)array[0], (byte)array[1], (byte)array[2], (byte[])array[3], (Vector3)array[4], (uint)array[5]);
         }
     }
 }
 public void tellResources(CSteamID steamID, byte x, byte y, bool[] resources)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         if (ResourceManager.regions[(int)x, (int)y].isNetworked)
         {
             return;
         }
         ResourceManager.regions[(int)x, (int)y].isNetworked = true;
         ushort num = 0;
         while ((int)num < resources.Length)
         {
             if (resources[(int)num])
             {
                 LevelGround.trees[(int)x, (int)y][(int)num].wipe();
             }
             else
             {
                 LevelGround.trees[(int)x, (int)y][(int)num].revive();
             }
             num += 1;
         }
     }
 }
Esempio n. 4
0
 public static bool tryGetRegion(byte x, byte y, out StructureRegion region)
 {
     region = null;
     if (Regions.checkSafe((int)x, (int)y))
     {
         region = StructureManager.regions[(int)x, (int)y];
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
 // Token: 0x060030C8 RID: 12488 RVA: 0x0013F870 File Offset: 0x0013DC70
 public static bool tryGetPoint(int x, int y, out Vector3 point)
 {
     point = Vector3.zero;
     if (Regions.checkSafe(x, y))
     {
         point.x = (float)(x * (int)Regions.REGION_SIZE - 4096);
         point.z = (float)(y * (int)Regions.REGION_SIZE - 4096);
         return(true);
     }
     return(false);
 }
 public void askToggleObjectBinaryState(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectBinaryState interactableObjectBinaryState = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectBinaryState;
         if (interactableObjectBinaryState != null && interactableObjectBinaryState.isUsable && !interactableObjectBinaryState.objectAsset.interactabilityRemote)
         {
             if (!interactableObjectBinaryState.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactableObjectBinaryState.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactableObjectBinaryState.objectAsset.applyInteractabilityConditions(player, true);
             interactableObjectBinaryState.objectAsset.grantInteractabilityRewards(player, true);
             ObjectManager.manager.channel.send("tellToggleObjectBinaryState", ESteamCall.ALL, x, y, ObjectManager.OBJECT_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 x,
                 y,
                 index,
                 !interactableObjectBinaryState.isUsed
             });
             LevelObjects.objects[(int)x, (int)y][(int)index].state[0] = ((!interactableObjectBinaryState.isUsed) ? 0 : 1);
         }
     }
 }
Esempio n. 7
0
 // Token: 0x060030C7 RID: 12487 RVA: 0x0013F818 File Offset: 0x0013DC18
 public static bool tryGetCoordinate(Vector3 point, out byte x, out byte y)
 {
     x = byte.MaxValue;
     y = byte.MaxValue;
     if (Regions.checkSafe(point))
     {
         x = (byte)((point.x + 4096f) / (float)Regions.REGION_SIZE);
         y = (byte)((point.z + 4096f) / (float)Regions.REGION_SIZE);
         return(true);
     }
     return(false);
 }
        // Token: 0x06002905 RID: 10501 RVA: 0x000FAB54 File Offset: 0x000F8F54
        public static ResourceSpawnpoint getResourceSpawnpoint(byte x, byte y, ushort index)
        {
            if (!Regions.checkSafe((int)x, (int)y))
            {
                return(null);
            }
            List <ResourceSpawnpoint> list = LevelGround.trees[(int)x, (int)y];

            if ((int)index >= list.Count)
            {
                return(null);
            }
            return(list[(int)index]);
        }
        // Token: 0x060028E2 RID: 10466 RVA: 0x000F8FB0 File Offset: 0x000F73B0
        public static LevelObject getObject(byte x, byte y, ushort index)
        {
            if (!Regions.checkSafe((int)x, (int)y))
            {
                return(null);
            }
            List <LevelObject> list = LevelObjects.objects[(int)x, (int)y];

            if ((int)index >= list.Count)
            {
                return(null);
            }
            return(list[(int)index]);
        }
Esempio n. 10
0
 public void tellItem(CSteamID steamID, byte x, byte y, ushort id, byte amount, byte quality, byte[] state, Vector3 point, uint instanceID)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         if (!ItemManager.regions[(int)x, (int)y].isNetworked)
         {
             return;
         }
         this.spawnItem(x, y, id, amount, quality, state, point, instanceID);
     }
 }
 public void askUseObjectDropper(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectDropper interactableObjectDropper = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectDropper;
         if (interactableObjectDropper != null && interactableObjectDropper.isUsable)
         {
             if (!interactableObjectDropper.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactableObjectDropper.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactableObjectDropper.objectAsset.applyInteractabilityConditions(player, true);
             interactableObjectDropper.objectAsset.grantInteractabilityRewards(player, true);
             interactableObjectDropper.drop();
         }
     }
 }
Esempio n. 12
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: 0x060028DE RID: 10462 RVA: 0x000F8D00 File Offset: 0x000F7100
 public static void askClearRegionObjects(byte x, byte y)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         if (LevelObjects.objects[(int)x, (int)y].Count > 0)
         {
             ObjectManager.manager.channel.send("tellClearRegionObjects", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 x,
                 y
             });
         }
     }
 }
Esempio n. 14
0
 public static void askClearRegionStructures(byte x, byte y)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         StructureRegion structureRegion = StructureManager.regions[(int)x, (int)y];
         if (structureRegion.structures.Count > 0)
         {
             structureRegion.structures.Clear();
             StructureManager.manager.channel.send("tellClearRegionStructures", ESteamCall.ALL, x, y, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 x,
                 y
             });
         }
     }
 }
Esempio n. 15
0
 // Token: 0x06002843 RID: 10307 RVA: 0x000F3CF0 File Offset: 0x000F20F0
 public static void askClearRegionItems(byte x, byte y)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         ItemRegion itemRegion = ItemManager.regions[(int)x, (int)y];
         if (itemRegion.items.Count > 0)
         {
             itemRegion.items.Clear();
             ItemManager.manager.channel.send("tellClearRegionItems", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 x,
                 y
             });
         }
     }
 }
Esempio n. 16
0
 public void askUseObjectQuest(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 1600f)
         {
             return;
         }
         InteractableObject interactable = LevelObjects.objects[(int)x, (int)y][(int)index].interactable;
         if (interactable != null && (interactable is InteractableObjectQuest || interactable is InteractableObjectNote))
         {
             if (!interactable.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactable.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactable.objectAsset.applyInteractabilityConditions(player, false);
             interactable.objectAsset.grantInteractabilityRewards(player, false);
         }
     }
 }
 public void askUseObjectNPC(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectNPC interactableObjectNPC = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectNPC;
         if (interactableObjectNPC != null)
         {
             if (!interactableObjectNPC.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             player.quests.checkNPC = interactableObjectNPC;
         }
     }
 }
Esempio n. 18
0
 // Token: 0x0600284E RID: 10318 RVA: 0x000F4AEC File Offset: 0x000F2EEC
 private void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex)
 {
     if (step == 0)
     {
         for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
         {
             for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
             {
                 if (player.channel.isOwner && ItemManager.regions[(int)b, (int)b2].isNetworked && !Regions.checkArea(b, b2, new_x, new_y, ItemManager.ITEM_REGIONS))
                 {
                     ItemManager.regions[(int)b, (int)b2].destroy();
                     ItemManager.regions[(int)b, (int)b2].isNetworked = false;
                 }
                 if (Provider.isServer && player.movement.loadedRegions[(int)b, (int)b2].isItemsLoaded && !Regions.checkArea(b, b2, new_x, new_y, ItemManager.ITEM_REGIONS))
                 {
                     player.movement.loadedRegions[(int)b, (int)b2].isItemsLoaded = false;
                 }
             }
         }
     }
     if (step == 5 && Provider.isServer && Regions.checkSafe((int)new_x, (int)new_y))
     {
         for (int i = (int)(new_x - ItemManager.ITEM_REGIONS); i <= (int)(new_x + ItemManager.ITEM_REGIONS); i++)
         {
             for (int j = (int)(new_y - ItemManager.ITEM_REGIONS); j <= (int)(new_y + ItemManager.ITEM_REGIONS); j++)
             {
                 if (Regions.checkSafe((int)((byte)i), (int)((byte)j)) && !player.movement.loadedRegions[i, j].isItemsLoaded)
                 {
                     if (player.channel.isOwner)
                     {
                         this.generateItems((byte)i, (byte)j);
                     }
                     player.movement.loadedRegions[i, j].isItemsLoaded = true;
                     this.askItems(player.channel.owner.playerID.steamID, (byte)i, (byte)j);
                 }
             }
         }
     }
 }
Esempio n. 19
0
 private void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex)
 {
     if (step == 0)
     {
         for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
         {
             for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
             {
                 if (Provider.isServer)
                 {
                     if (player.movement.loadedRegions[(int)b, (int)b2].isStructuresLoaded && !Regions.checkArea(b, b2, new_x, new_y, StructureManager.STRUCTURE_REGIONS))
                     {
                         player.movement.loadedRegions[(int)b, (int)b2].isStructuresLoaded = false;
                     }
                 }
                 else if (player.channel.isOwner && StructureManager.regions[(int)b, (int)b2].isNetworked && !Regions.checkArea(b, b2, new_x, new_y, StructureManager.STRUCTURE_REGIONS))
                 {
                     StructureManager.regions[(int)b, (int)b2].destroy();
                     StructureManager.regions[(int)b, (int)b2].isNetworked = false;
                 }
             }
         }
     }
     if (step == 1 && Dedicator.isDedicated && Regions.checkSafe((int)new_x, (int)new_y))
     {
         for (int i = (int)(new_x - StructureManager.STRUCTURE_REGIONS); i <= (int)(new_x + StructureManager.STRUCTURE_REGIONS); i++)
         {
             for (int j = (int)(new_y - StructureManager.STRUCTURE_REGIONS); j <= (int)(new_y + StructureManager.STRUCTURE_REGIONS); j++)
             {
                 if (Regions.checkSafe((int)((byte)i), (int)((byte)j)) && !player.movement.loadedRegions[i, j].isStructuresLoaded)
                 {
                     player.movement.loadedRegions[i, j].isStructuresLoaded = true;
                     this.askStructures(player.channel.owner.playerID.steamID, (byte)i, (byte)j);
                 }
             }
         }
     }
 }
 public void tellObjectResource(CSteamID steamID, byte x, byte y, ushort index, ushort amount)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         ObjectRegion objectRegion = ObjectManager.regions[(int)x, (int)y];
         if (!Provider.isServer && !objectRegion.isNetworked)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         InteractableObjectResource interactableObjectResource = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectResource;
         if (interactableObjectResource != null)
         {
             interactableObjectResource.updateAmount(amount);
         }
     }
 }
 public void tellObjectRubble(CSteamID steamID, byte x, byte y, ushort index, byte section, bool isAlive, Vector3 ragdoll)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         ObjectRegion objectRegion = ObjectManager.regions[(int)x, (int)y];
         if (!Provider.isServer && !objectRegion.isNetworked)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         InteractableObjectRubble rubble = LevelObjects.objects[(int)x, (int)y][(int)index].rubble;
         if (rubble != null)
         {
             rubble.updateRubble(section, isAlive, true, ragdoll);
         }
     }
 }
 public void tellToggleObjectBinaryState(CSteamID steamID, byte x, byte y, ushort index, bool isUsed)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         ObjectRegion objectRegion = ObjectManager.regions[(int)x, (int)y];
         if (!Provider.isServer && !objectRegion.isNetworked)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         InteractableObjectBinaryState interactableObjectBinaryState = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectBinaryState;
         if (interactableObjectBinaryState != null)
         {
             interactableObjectBinaryState.updateToggle(isUsed);
         }
     }
 }
 public void askForage(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         List <ResourceSpawnpoint> list = LevelGround.trees[(int)x, (int)y];
         if ((int)index >= list.Count)
         {
             return;
         }
         if (list[(int)index].isDead)
         {
             return;
         }
         ResourceAsset resourceAsset = (ResourceAsset)Assets.find(EAssetType.RESOURCE, LevelGround.resources[(int)list[(int)index].type].id);
         if (resourceAsset == null || !resourceAsset.isForage)
         {
             return;
         }
         list[(int)index].askDamage(1);
         if (resourceAsset.explosion != 0)
         {
             EffectManager.sendEffect(resourceAsset.explosion, x, y, ResourceManager.RESOURCE_REGIONS, list[(int)index].point);
         }
         ushort num;
         if (resourceAsset.rewardID != 0)
         {
             num = SpawnTableTool.resolve(resourceAsset.rewardID);
         }
         else
         {
             num = resourceAsset.log;
         }
         if (num != 0)
         {
             player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true);
             if (UnityEngine.Random.value < player.skills.mastery(2, 5))
             {
                 player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true);
             }
         }
         player.sendStat(EPlayerStat.FOUND_PLANTS);
         player.skills.askPay(1u);
         ResourceManager.manager.channel.send("tellResourceDead", ESteamCall.ALL, x, y, ResourceManager.RESOURCE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
         {
             x,
             y,
             index,
             Vector3.zero
         });
     }
 }
Esempio n. 24
0
 public void askTakeItem(CSteamID steamID, byte x, byte y, uint instanceID, byte to_x, byte to_y, byte to_rot, byte to_page)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if (player.animator.gesture == EPlayerGesture.ARREST_START)
         {
             return;
         }
         ItemRegion itemRegion = ItemManager.regions[(int)x, (int)y];
         ushort     num        = 0;
         while ((int)num < itemRegion.items.Count)
         {
             if (itemRegion.items[(int)num].instanceID == instanceID)
             {
                 if (Dedicator.isDedicated && (itemRegion.items[(int)num].point - player.transform.position).sqrMagnitude > 400f)
                 {
                     return;
                 }
                 bool flag;
                 if (to_page == 255)
                 {
                     flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, true);
                 }
                 else
                 {
                     flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, to_x, to_y, to_page, to_rot);
                 }
                 if (flag)
                 {
                     if (!player.equipment.wasTryingToSelect && !player.equipment.isSelected)
                     {
                         player.animator.sendGesture(EPlayerGesture.PICKUP, true);
                     }
                     EffectManager.sendEffect(7, EffectManager.SMALL, ItemManager.regions[(int)x, (int)y].items[(int)num].point);
                     ItemManager.regions[(int)x, (int)y].items.RemoveAt((int)num);
                     player.sendStat(EPlayerStat.FOUND_ITEMS);
                     base.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                     {
                         x,
                         y,
                         instanceID
                     });
                 }
                 else
                 {
                     player.sendMessage(EPlayerMessage.SPACE);
                 }
                 return;
             }
             else
             {
                 num += 1;
             }
         }
     }
 }
 // Token: 0x06002EB3 RID: 11955 RVA: 0x001309B4 File Offset: 0x0012EDB4
 private void Update()
 {
     if (!this.isBuilding)
     {
         return;
     }
     this.ray = MainCamera.instance.ScreenPointToRay(Input.mousePosition);
     Physics.Raycast(this.ray, out this.worldHit, 256f, RayMasks.EDITOR_WORLD);
     Physics.Raycast(this.ray, out this.buildableHit, 256f, RayMasks.EDITOR_BUILDABLE);
     Physics.Raycast(this.ray, out this.logicHit, 256f, RayMasks.VIEWMODEL);
     if (GUIUtility.hotControl == 0)
     {
         if (Input.GetKey(ControlsSettings.secondary))
         {
             this.handleType = EDragType.NONE;
             if (this.isDragging)
             {
                 this._dragStart  = Vector2.zero;
                 this._dragEnd    = Vector2.zero;
                 this._isDragging = false;
                 if (this.onDragStopped != null)
                 {
                     this.onDragStopped();
                 }
                 this.clearSelection();
             }
             return;
         }
         if (this.handleType != EDragType.NONE)
         {
             if (!Input.GetKey(ControlsSettings.primary))
             {
                 this.applySelection();
                 this.handleType = EDragType.NONE;
             }
             else
             {
                 if (this.handleType == EDragType.TRANSFORM_X)
                 {
                     this.transformGroup(this.handle.right, this.handle.up);
                 }
                 else if (this.handleType == EDragType.TRANSFORM_Y)
                 {
                     this.transformGroup(this.handle.up, this.handle.right);
                 }
                 else if (this.handleType == EDragType.TRANSFORM_Z)
                 {
                     this.transformGroup(this.handle.forward, this.handle.up);
                 }
                 else if (this.handleType == EDragType.PLANE_X)
                 {
                     this.planeGroup(this.handle.right);
                 }
                 else if (this.handleType == EDragType.PLANE_Y)
                 {
                     this.planeGroup(this.handle.up);
                 }
                 else if (this.handleType == EDragType.PLANE_Z)
                 {
                     this.planeGroup(this.handle.forward);
                 }
                 if (this.handleType == EDragType.ROTATION_X)
                 {
                     this.rotateGroup(this.handle.right, Vector3.right);
                 }
                 else if (this.handleType == EDragType.ROTATION_Y)
                 {
                     this.rotateGroup(this.handle.up, Vector3.up);
                 }
                 else if (this.handleType == EDragType.ROTATION_Z)
                 {
                     this.rotateGroup(this.handle.forward, Vector3.forward);
                 }
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             this.dragMode = EDragMode.TRANSFORM;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             this.dragMode = EDragMode.ROTATE;
         }
         if (Input.GetKeyDown(KeyCode.B) && this.selection.Count > 0 && Input.GetKey(KeyCode.LeftControl))
         {
             this.copyPosition = this.handle.position;
             this.copyRotation = this.handle.rotation;
         }
         if (Input.GetKeyDown(KeyCode.N) && this.selection.Count > 0 && this.copyPosition != Vector3.zero && Input.GetKey(KeyCode.LeftControl))
         {
             this.pointSelection();
             this.handle.position = this.copyPosition;
             this.handle.rotation = this.copyRotation;
             this.updateGroup();
             this.applySelection();
         }
         if (this.handleType == EDragType.NONE)
         {
             if (Input.GetKeyDown(ControlsSettings.primary))
             {
                 if (this.logicHit.transform != null && (this.logicHit.transform.name == "Arrow_X" || this.logicHit.transform.name == "Arrow_Y" || this.logicHit.transform.name == "Arrow_Z" || this.logicHit.transform.name == "Plane_X" || this.logicHit.transform.name == "Plane_Y" || this.logicHit.transform.name == "Plane_Z" || this.logicHit.transform.name == "Circle_X" || this.logicHit.transform.name == "Circle_Y" || this.logicHit.transform.name == "Circle_Z"))
                 {
                     this.mouseOrigin     = Input.mousePosition;
                     this.transformOrigin = this.handle.position;
                     this.rotateOrigin    = this.handle.rotation;
                     this.handleOffset    = this.logicHit.point - this.handle.position;
                     this.pointSelection();
                     if (this.logicHit.transform.name == "Arrow_X")
                     {
                         this.handleType = EDragType.TRANSFORM_X;
                     }
                     else if (this.logicHit.transform.name == "Arrow_Y")
                     {
                         this.handleType = EDragType.TRANSFORM_Y;
                     }
                     else if (this.logicHit.transform.name == "Arrow_Z")
                     {
                         this.handleType = EDragType.TRANSFORM_Z;
                     }
                     else if (this.logicHit.transform.name == "Plane_X")
                     {
                         this.handleType = EDragType.PLANE_X;
                     }
                     else if (this.logicHit.transform.name == "Plane_Y")
                     {
                         this.handleType = EDragType.PLANE_Y;
                     }
                     else if (this.logicHit.transform.name == "Plane_Z")
                     {
                         this.handleType = EDragType.PLANE_Z;
                     }
                     else if (this.logicHit.transform.name == "Circle_X")
                     {
                         this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f);
                         this.handleType     = EDragType.ROTATION_X;
                     }
                     else if (this.logicHit.transform.name == "Circle_Y")
                     {
                         this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f);
                         this.handleType     = EDragType.ROTATION_Y;
                     }
                     else if (this.logicHit.transform.name == "Circle_Z")
                     {
                         this.rotateInverted = (Vector3.Dot(this.logicHit.point - this.handle.position, MainCamera.instance.transform.up) < 0f);
                         this.handleType     = EDragType.ROTATION_Z;
                     }
                 }
                 else
                 {
                     Transform transform = this.buildableHit.transform;
                     if (transform != null && (transform.CompareTag("Barricade") || transform.CompareTag("Structure")))
                     {
                         InteractableDoorHinge component = transform.GetComponent <InteractableDoorHinge>();
                         if (component != null)
                         {
                             transform = component.transform.parent.parent;
                         }
                         if (Input.GetKey(ControlsSettings.modify))
                         {
                             if (this.containsSelection(transform))
                             {
                                 this.removeSelection(transform);
                             }
                             else
                             {
                                 this.addSelection(transform);
                             }
                         }
                         else if (this.containsSelection(transform))
                         {
                             this.clearSelection();
                         }
                         else
                         {
                             this.clearSelection();
                             this.addSelection(transform);
                         }
                     }
                     else
                     {
                         if (!this.isDragging)
                         {
                             this._dragStart.x = PlayerUI.window.mouse_x;
                             this._dragStart.y = PlayerUI.window.mouse_y;
                         }
                         if (!Input.GetKey(ControlsSettings.modify))
                         {
                             this.clearSelection();
                         }
                     }
                 }
             }
             else if (Input.GetKey(ControlsSettings.primary) && this.dragStart.x != 0f)
             {
                 this._dragEnd.x = PlayerUI.window.mouse_x;
                 this._dragEnd.y = PlayerUI.window.mouse_y;
                 if (this.isDragging || Mathf.Abs(this.dragEnd.x - this.dragStart.x) > 50f || Mathf.Abs(this.dragEnd.x - this.dragStart.x) > 50f)
                 {
                     int num  = (int)this.dragStart.x;
                     int num2 = (int)this.dragStart.y;
                     if (this.dragEnd.x < this.dragStart.x)
                     {
                         num = (int)this.dragEnd.x;
                     }
                     if (this.dragEnd.y < this.dragStart.y)
                     {
                         num2 = (int)this.dragEnd.y;
                     }
                     int num3 = (int)this.dragEnd.x;
                     int num4 = (int)this.dragEnd.y;
                     if (this.dragStart.x > this.dragEnd.x)
                     {
                         num3 = (int)this.dragStart.x;
                     }
                     if (this.dragStart.y > this.dragEnd.y)
                     {
                         num4 = (int)this.dragStart.y;
                     }
                     if (this.onDragStarted != null)
                     {
                         this.onDragStarted(num, num2, num3, num4);
                     }
                     if (!this.isDragging)
                     {
                         this._isDragging = true;
                         this.dragable.Clear();
                         byte region_x = Player.player.movement.region_x;
                         byte region_y = Player.player.movement.region_y;
                         if (Regions.checkSafe((int)region_x, (int)region_y))
                         {
                             for (int i = 0; i < BarricadeManager.plants.Count; i++)
                             {
                                 BarricadeRegion barricadeRegion = BarricadeManager.plants[i];
                                 for (int j = 0; j < barricadeRegion.drops.Count; j++)
                                 {
                                     BarricadeDrop barricadeDrop = barricadeRegion.drops[j];
                                     if (!(barricadeDrop.model == null))
                                     {
                                         Vector3 newScreen = MainCamera.instance.WorldToScreenPoint(barricadeDrop.model.position);
                                         if (newScreen.z >= 0f)
                                         {
                                             newScreen.y = (float)Screen.height - newScreen.y;
                                             this.dragable.Add(new EditorDrag(barricadeDrop.model, newScreen));
                                         }
                                     }
                                 }
                             }
                             for (int k = (int)(region_x - 1); k <= (int)(region_x + 1); k++)
                             {
                                 for (int l = (int)(region_y - 1); l <= (int)(region_y + 1); l++)
                                 {
                                     if (Regions.checkSafe((int)((byte)k), (int)((byte)l)))
                                     {
                                         for (int m = 0; m < BarricadeManager.regions[k, l].drops.Count; m++)
                                         {
                                             BarricadeDrop barricadeDrop2 = BarricadeManager.regions[k, l].drops[m];
                                             if (!(barricadeDrop2.model == null))
                                             {
                                                 Vector3 newScreen2 = MainCamera.instance.WorldToScreenPoint(barricadeDrop2.model.position);
                                                 if (newScreen2.z >= 0f)
                                                 {
                                                     newScreen2.y = (float)Screen.height - newScreen2.y;
                                                     this.dragable.Add(new EditorDrag(barricadeDrop2.model, newScreen2));
                                                 }
                                             }
                                         }
                                         for (int n = 0; n < StructureManager.regions[k, l].drops.Count; n++)
                                         {
                                             StructureDrop structureDrop = StructureManager.regions[k, l].drops[n];
                                             if (structureDrop != null)
                                             {
                                                 Vector3 newScreen3 = MainCamera.instance.WorldToScreenPoint(structureDrop.model.position);
                                                 if (newScreen3.z >= 0f)
                                                 {
                                                     newScreen3.y = (float)Screen.height - newScreen3.y;
                                                     this.dragable.Add(new EditorDrag(structureDrop.model, newScreen3));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (!Input.GetKey(ControlsSettings.modify))
                     {
                         for (int num5 = 0; num5 < this.selection.Count; num5++)
                         {
                             if (!(this.selection[num5].transform == null))
                             {
                                 Vector3 vector = MainCamera.instance.WorldToScreenPoint(this.selection[num5].transform.position);
                                 if (vector.z < 0f)
                                 {
                                     this.removeSelection(this.selection[num5].transform);
                                 }
                                 else
                                 {
                                     vector.y = (float)Screen.height - vector.y;
                                     if (vector.x < (float)num || vector.y < (float)num2 || vector.x > (float)num3 || vector.y > (float)num4)
                                     {
                                         this.removeSelection(this.selection[num5].transform);
                                     }
                                 }
                             }
                         }
                     }
                     for (int num6 = 0; num6 < this.dragable.Count; num6++)
                     {
                         EditorDrag editorDrag = this.dragable[num6];
                         if (!(editorDrag.transform == null))
                         {
                             if (!(editorDrag.transform.parent == this.group))
                             {
                                 if (editorDrag.screen.x >= (float)num && editorDrag.screen.y >= (float)num2 && editorDrag.screen.x <= (float)num3 && editorDrag.screen.y <= (float)num4)
                                 {
                                     this.addSelection(editorDrag.transform);
                                 }
                             }
                         }
                     }
                 }
             }
             if (this.selection.Count > 0 && Input.GetKeyDown(ControlsSettings.tool_2) && this.worldHit.transform != null)
             {
                 this.pointSelection();
                 this.handle.position = this.worldHit.point;
                 if (Input.GetKey(ControlsSettings.snap))
                 {
                     this.handle.position += this.worldHit.normal * this.snapTransform;
                 }
                 this.updateGroup();
                 this.applySelection();
             }
         }
     }
     if (Input.GetKeyUp(ControlsSettings.primary) && this.dragStart.x != 0f)
     {
         this._dragStart = Vector2.zero;
         if (this.isDragging)
         {
             this._dragEnd    = Vector2.zero;
             this._isDragging = false;
             if (this.onDragStopped != null)
             {
                 this.onDragStopped();
             }
         }
     }
 }
 // Token: 0x06003516 RID: 13590 RVA: 0x0015F8A4 File Offset: 0x0015DCA4
 private static void update(int x, int y)
 {
     for (int i = 0; i < (int)EditorLevelVisibilityUI.DEBUG_SIZE; i++)
     {
         for (int j = 0; j < (int)EditorLevelVisibilityUI.DEBUG_SIZE; j++)
         {
             int        num        = i * (int)EditorLevelVisibilityUI.DEBUG_SIZE + j;
             int        num2       = x - (int)(EditorLevelVisibilityUI.DEBUG_SIZE / 2) + i;
             int        num3       = y - (int)(EditorLevelVisibilityUI.DEBUG_SIZE / 2) + j;
             SleekLabel sleekLabel = EditorLevelVisibilityUI.regionLabels[num];
             if (Regions.checkSafe(num2, num3))
             {
                 int    num4 = LevelObjects.objects[num2, num3].Count + LevelGround.trees[num2, num3].Count;
                 int    num5 = LevelObjects.total + LevelGround.total;
                 double num6 = Math.Round((double)num4 / (double)num5 * 1000.0) / 10.0;
                 int    num7 = 0;
                 for (int k = 0; k < LevelObjects.objects[num2, num3].Count; k++)
                 {
                     LevelObject levelObject = LevelObjects.objects[num2, num3][k];
                     if (levelObject.transform)
                     {
                         levelObject.transform.GetComponents <MeshFilter>(EditorLevelVisibilityUI.meshes);
                         if (EditorLevelVisibilityUI.meshes.Count == 0)
                         {
                             Transform transform = levelObject.transform.FindChild("Model_0");
                             if (transform)
                             {
                                 transform.GetComponentsInChildren <MeshFilter>(true, EditorLevelVisibilityUI.meshes);
                             }
                         }
                         if (EditorLevelVisibilityUI.meshes.Count != 0)
                         {
                             for (int l = 0; l < EditorLevelVisibilityUI.meshes.Count; l++)
                             {
                                 Mesh sharedMesh = EditorLevelVisibilityUI.meshes[l].sharedMesh;
                                 if (sharedMesh)
                                 {
                                     num7 += sharedMesh.triangles.Length;
                                 }
                             }
                         }
                     }
                 }
                 for (int m = 0; m < LevelGround.trees[num2, num3].Count; m++)
                 {
                     ResourceSpawnpoint resourceSpawnpoint = LevelGround.trees[num2, num3][m];
                     if (resourceSpawnpoint.model)
                     {
                         resourceSpawnpoint.model.GetComponents <MeshFilter>(EditorLevelVisibilityUI.meshes);
                         if (EditorLevelVisibilityUI.meshes.Count == 0)
                         {
                             Transform transform2 = resourceSpawnpoint.model.FindChild("Model_0");
                             if (transform2)
                             {
                                 transform2.GetComponentsInChildren <MeshFilter>(true, EditorLevelVisibilityUI.meshes);
                             }
                         }
                         if (EditorLevelVisibilityUI.meshes.Count != 0)
                         {
                             for (int n = 0; n < EditorLevelVisibilityUI.meshes.Count; n++)
                             {
                                 Mesh sharedMesh2 = EditorLevelVisibilityUI.meshes[n].sharedMesh;
                                 if (sharedMesh2)
                                 {
                                     num7 += sharedMesh2.triangles.Length;
                                 }
                             }
                         }
                     }
                 }
                 long  num8    = (long)num4 * (long)num7;
                 float quality = Mathf.Clamp01((float)(1.0 - (double)num8 / 50000000.0));
                 sleekLabel.text = EditorLevelVisibilityUI.localization.format("Point", new object[]
                 {
                     num2,
                     num3
                 });
                 SleekLabel sleekLabel2 = sleekLabel;
                 sleekLabel2.text = sleekLabel2.text + "\n" + EditorLevelVisibilityUI.localization.format("Objects", new object[]
                 {
                     num4,
                     num6
                 });
                 SleekLabel sleekLabel3 = sleekLabel;
                 sleekLabel3.text = sleekLabel3.text + "\n" + EditorLevelVisibilityUI.localization.format("Triangles", new object[]
                 {
                     num7
                 });
                 if (num4 == 0 && num7 == 0)
                 {
                     sleekLabel.foregroundColor = Color.white;
                 }
                 else
                 {
                     sleekLabel.foregroundColor = ItemTool.getQualityColor(quality);
                 }
             }
         }
     }
 }
Esempio n. 27
0
 private void Update()
 {
     if (!EditorObjects.isBuilding)
     {
         return;
     }
     if (GUIUtility.hotControl == 0)
     {
         if (EditorInteract.isFlying)
         {
             EditorObjects.handleType = EDragType.NONE;
             if (EditorObjects.isDragging)
             {
                 EditorObjects._dragStart  = Vector2.zero;
                 EditorObjects._dragEnd    = Vector2.zero;
                 EditorObjects._isDragging = false;
                 if (EditorObjects.onDragStopped != null)
                 {
                     EditorObjects.onDragStopped();
                 }
                 EditorObjects.clearSelection();
             }
             return;
         }
         if (EditorObjects.handleType != EDragType.NONE)
         {
             if (!Input.GetKey(ControlsSettings.primary))
             {
                 if (EditorObjects.dragMode == EDragMode.SCALE)
                 {
                     for (int i = 0; i < EditorObjects.selection.Count; i++)
                     {
                         EditorObjects.selection[i].transform.parent = EditorObjects.selection[i].parent;
                     }
                     EditorObjects.group.localScale = Vector3.one;
                     for (int j = 0; j < EditorObjects.selection.Count; j++)
                     {
                         EditorObjects.selection[j].transform.parent = EditorObjects.group;
                     }
                 }
                 EditorObjects.applySelection();
                 EditorObjects.handleType = EDragType.NONE;
             }
             else
             {
                 if (EditorObjects.handleType == EDragType.TRANSFORM_X)
                 {
                     EditorObjects.transformGroup(EditorObjects.handle.right, EditorObjects.handle.up);
                 }
                 else if (EditorObjects.handleType == EDragType.TRANSFORM_Y)
                 {
                     EditorObjects.transformGroup(EditorObjects.handle.up, EditorObjects.handle.right);
                 }
                 else if (EditorObjects.handleType == EDragType.TRANSFORM_Z)
                 {
                     EditorObjects.transformGroup(EditorObjects.handle.forward, EditorObjects.handle.up);
                 }
                 else if (EditorObjects.handleType == EDragType.PLANE_X)
                 {
                     EditorObjects.planeGroup(EditorObjects.handle.right);
                 }
                 else if (EditorObjects.handleType == EDragType.PLANE_Y)
                 {
                     EditorObjects.planeGroup(EditorObjects.handle.up);
                 }
                 else if (EditorObjects.handleType == EDragType.PLANE_Z)
                 {
                     EditorObjects.planeGroup(EditorObjects.handle.forward);
                 }
                 if (EditorObjects.handleType == EDragType.ROTATION_X)
                 {
                     EditorObjects.rotateGroup(EditorObjects.handle.right, Vector3.right);
                 }
                 else if (EditorObjects.handleType == EDragType.ROTATION_Y)
                 {
                     EditorObjects.rotateGroup(EditorObjects.handle.up, Vector3.up);
                 }
                 else if (EditorObjects.handleType == EDragType.ROTATION_Z)
                 {
                     EditorObjects.rotateGroup(EditorObjects.handle.forward, Vector3.forward);
                 }
                 else if (EditorObjects.handleType == EDragType.SCALE_X)
                 {
                     EditorObjects.scaleGroup(EditorObjects.handle.right, Vector3.right, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.x);
                 }
                 else if (EditorObjects.handleType == EDragType.SCALE_Y)
                 {
                     EditorObjects.scaleGroup(EditorObjects.handle.up, Vector3.up, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.y);
                 }
                 else if (EditorObjects.handleType == EDragType.SCALE_Z)
                 {
                     EditorObjects.scaleGroup(EditorObjects.handle.forward, Vector3.forward, EditorObjects.handle.localScale.x * EditorObjects.scaleHandle.localScale.z);
                 }
                 else if (EditorObjects.handleType == EDragType.SIZE)
                 {
                     EditorObjects.sizeGroup(EditorObjects.handle.localScale.x);
                 }
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             EditorObjects.dragMode = EDragMode.TRANSFORM;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             EditorObjects.dragMode = EDragMode.ROTATE;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_3))
         {
             EditorObjects.dragMode = EDragMode.SCALE;
         }
         if ((Input.GetKeyDown(127) || Input.GetKeyDown(8)) && EditorObjects.selection.Count > 0)
         {
             LevelObjects.step++;
             for (int k = 0; k < EditorObjects.selection.Count; k++)
             {
                 EditorObjects.selection[k].transform.parent = EditorObjects.selection[k].parent;
                 LevelObjects.registerRemoveObject(EditorObjects.selection[k].transform);
             }
             EditorObjects.selection.Clear();
             EditorObjects.calculateHandleOffsets();
         }
         if (Input.GetKeyDown(122) && Input.GetKey(306))
         {
             EditorObjects.clearSelection();
             LevelObjects.undo();
         }
         if (Input.GetKeyDown(120) && Input.GetKey(306))
         {
             EditorObjects.clearSelection();
             LevelObjects.redo();
         }
         if (Input.GetKeyDown(98) && EditorObjects.selection.Count > 0 && Input.GetKey(306))
         {
             EditorObjects.copyPosition = EditorObjects.handle.position;
             EditorObjects.copyRotation = EditorObjects.handle.rotation;
             if (EditorObjects.selection.Count == 1)
             {
                 EditorObjects.copyScale   = EditorObjects.selection[0].transform.localScale;
                 EditorObjects.copyScale.x = EditorObjects.copyScale.x * EditorObjects.group.localScale.x;
                 EditorObjects.copyScale.y = EditorObjects.copyScale.y * EditorObjects.group.localScale.y;
                 EditorObjects.copyScale.z = EditorObjects.copyScale.z * EditorObjects.group.localScale.z;
             }
             else
             {
                 EditorObjects.copyScale = Vector3.one;
             }
         }
         if (Input.GetKeyDown(110) && EditorObjects.selection.Count > 0 && EditorObjects.copyPosition != Vector3.zero && Input.GetKey(306))
         {
             EditorObjects.pointSelection();
             EditorObjects.handle.position = EditorObjects.copyPosition;
             EditorObjects.handle.rotation = EditorObjects.copyRotation;
             if (EditorObjects.selection.Count == 1)
             {
                 EditorObjects.group.localScale = EditorObjects.copyScale;
             }
             EditorObjects.updateGroup();
             EditorObjects.applySelection();
         }
         if (Input.GetKeyDown(99) && EditorObjects.selection.Count > 0 && Input.GetKey(306))
         {
             EditorObjects.copies.Clear();
             for (int l = 0; l < EditorObjects.selection.Count; l++)
             {
                 ObjectAsset objectAsset;
                 ItemAsset   itemAsset;
                 LevelObjects.getAssetEditor(EditorObjects.selection[l].transform, out objectAsset, out itemAsset);
                 if (objectAsset != null || itemAsset != null)
                 {
                     EditorObjects.copies.Add(new EditorCopy(EditorObjects.selection[l].transform.position, EditorObjects.selection[l].transform.rotation, EditorObjects.selection[l].transform.localScale, objectAsset, itemAsset));
                 }
             }
         }
         if (Input.GetKeyDown(118) && EditorObjects.copies.Count > 0 && Input.GetKey(306))
         {
             EditorObjects.clearSelection();
             LevelObjects.step++;
             for (int m = 0; m < EditorObjects.copies.Count; m++)
             {
                 Transform transform = LevelObjects.registerAddObject(EditorObjects.copies[m].position, EditorObjects.copies[m].rotation, EditorObjects.copies[m].scale, EditorObjects.copies[m].objectAsset, EditorObjects.copies[m].itemAsset);
                 if (transform != null)
                 {
                     EditorObjects.addSelection(transform);
                 }
             }
         }
         if (EditorObjects.handleType == EDragType.NONE)
         {
             if (Input.GetKeyDown(ControlsSettings.primary))
             {
                 if (EditorInteract.logicHit.transform != null && (EditorInteract.logicHit.transform.name == "Arrow_X" || EditorInteract.logicHit.transform.name == "Arrow_Y" || EditorInteract.logicHit.transform.name == "Arrow_Z" || EditorInteract.logicHit.transform.name == "Plane_X" || EditorInteract.logicHit.transform.name == "Plane_Y" || EditorInteract.logicHit.transform.name == "Plane_Z" || EditorInteract.logicHit.transform.name == "Circle_X" || EditorInteract.logicHit.transform.name == "Circle_Y" || EditorInteract.logicHit.transform.name == "Circle_Z" || EditorInteract.logicHit.transform.name == "Scale_X" || EditorInteract.logicHit.transform.name == "Scale_Y" || EditorInteract.logicHit.transform.name == "Scale_Z" || EditorInteract.logicHit.transform.name == "Size"))
                 {
                     EditorObjects.mouseOrigin     = Input.mousePosition;
                     EditorObjects.transformOrigin = EditorObjects.handle.position;
                     EditorObjects.rotateOrigin    = EditorObjects.handle.rotation;
                     EditorObjects.scaleOrigin     = EditorObjects.group.localScale;
                     EditorObjects.handleOffset    = EditorInteract.logicHit.point - EditorObjects.handle.position;
                     EditorObjects.pointSelection();
                     if (EditorInteract.logicHit.transform.name == "Arrow_X")
                     {
                         EditorObjects.handleType = EDragType.TRANSFORM_X;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Arrow_Y")
                     {
                         EditorObjects.handleType = EDragType.TRANSFORM_Y;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Arrow_Z")
                     {
                         EditorObjects.handleType = EDragType.TRANSFORM_Z;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Plane_X")
                     {
                         EditorObjects.handleType = EDragType.PLANE_X;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Plane_Y")
                     {
                         EditorObjects.handleType = EDragType.PLANE_Y;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Plane_Z")
                     {
                         EditorObjects.handleType = EDragType.PLANE_Z;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Circle_X")
                     {
                         EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f);
                         EditorObjects.handleType     = EDragType.ROTATION_X;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Circle_Y")
                     {
                         EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f);
                         EditorObjects.handleType     = EDragType.ROTATION_Y;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Circle_Z")
                     {
                         EditorObjects.rotateInverted = (Vector3.Dot(EditorInteract.logicHit.point - EditorObjects.handle.position, MainCamera.instance.transform.up) < 0f);
                         EditorObjects.handleType     = EDragType.ROTATION_Z;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Scale_X")
                     {
                         EditorObjects.handleType = EDragType.SCALE_X;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Scale_Y")
                     {
                         EditorObjects.handleType = EDragType.SCALE_Y;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Scale_Z")
                     {
                         EditorObjects.handleType = EDragType.SCALE_Z;
                     }
                     else if (EditorInteract.logicHit.transform.name == "Size")
                     {
                         EditorObjects.handleType = EDragType.SIZE;
                     }
                 }
                 else if (EditorInteract.objectHit.transform != null)
                 {
                     if (Input.GetKey(ControlsSettings.modify))
                     {
                         if (EditorObjects.containsSelection(EditorInteract.objectHit.transform))
                         {
                             EditorObjects.removeSelection(EditorInteract.objectHit.transform);
                         }
                         else
                         {
                             EditorObjects.addSelection(EditorInteract.objectHit.transform);
                         }
                     }
                     else if (EditorObjects.containsSelection(EditorInteract.objectHit.transform))
                     {
                         EditorObjects.clearSelection();
                     }
                     else
                     {
                         EditorObjects.clearSelection();
                         EditorObjects.addSelection(EditorInteract.objectHit.transform);
                     }
                 }
                 else
                 {
                     if (!EditorObjects.isDragging)
                     {
                         EditorObjects._dragStart.x = EditorUI.window.mouse_x;
                         EditorObjects._dragStart.y = EditorUI.window.mouse_y;
                     }
                     if (!Input.GetKey(ControlsSettings.modify))
                     {
                         EditorObjects.clearSelection();
                     }
                 }
             }
             else if (Input.GetKey(ControlsSettings.primary) && EditorObjects.dragStart.x != 0f)
             {
                 EditorObjects._dragEnd.x = EditorUI.window.mouse_x;
                 EditorObjects._dragEnd.y = EditorUI.window.mouse_y;
                 if (EditorObjects.isDragging || Mathf.Abs(EditorObjects.dragEnd.x - EditorObjects.dragStart.x) > 50f || Mathf.Abs(EditorObjects.dragEnd.x - EditorObjects.dragStart.x) > 50f)
                 {
                     int num  = (int)EditorObjects.dragStart.x;
                     int num2 = (int)EditorObjects.dragStart.y;
                     if (EditorObjects.dragEnd.x < EditorObjects.dragStart.x)
                     {
                         num = (int)EditorObjects.dragEnd.x;
                     }
                     if (EditorObjects.dragEnd.y < EditorObjects.dragStart.y)
                     {
                         num2 = (int)EditorObjects.dragEnd.y;
                     }
                     int num3 = (int)EditorObjects.dragEnd.x;
                     int num4 = (int)EditorObjects.dragEnd.y;
                     if (EditorObjects.dragStart.x > EditorObjects.dragEnd.x)
                     {
                         num3 = (int)EditorObjects.dragStart.x;
                     }
                     if (EditorObjects.dragStart.y > EditorObjects.dragEnd.y)
                     {
                         num4 = (int)EditorObjects.dragStart.y;
                     }
                     if (EditorObjects.onDragStarted != null)
                     {
                         EditorObjects.onDragStarted(num, num2, num3, num4);
                     }
                     if (!EditorObjects.isDragging)
                     {
                         EditorObjects._isDragging = true;
                         EditorObjects.dragable.Clear();
                         byte region_x = Editor.editor.area.region_x;
                         byte region_y = Editor.editor.area.region_y;
                         if (Regions.checkSafe((int)region_x, (int)region_y))
                         {
                             for (int n = (int)(region_x - 1); n <= (int)(region_x + 1); n++)
                             {
                                 for (int num5 = (int)(region_y - 1); num5 <= (int)(region_y + 1); num5++)
                                 {
                                     if (Regions.checkSafe((int)((byte)n), (int)((byte)num5)) && LevelObjects.regions[n, num5])
                                     {
                                         for (int num6 = 0; num6 < LevelObjects.objects[n, num5].Count; num6++)
                                         {
                                             LevelObject levelObject = LevelObjects.objects[n, num5][num6];
                                             if (!(levelObject.transform == null))
                                             {
                                                 Vector3 newScreen = MainCamera.instance.WorldToScreenPoint(levelObject.transform.position);
                                                 if (newScreen.z >= 0f)
                                                 {
                                                     newScreen.y = (float)Screen.height - newScreen.y;
                                                     EditorObjects.dragable.Add(new EditorDrag(levelObject.transform, newScreen));
                                                 }
                                             }
                                         }
                                         for (int num7 = 0; num7 < LevelObjects.buildables[n, num5].Count; num7++)
                                         {
                                             LevelBuildableObject levelBuildableObject = LevelObjects.buildables[n, num5][num7];
                                             if (!(levelBuildableObject.transform == null))
                                             {
                                                 Vector3 newScreen2 = MainCamera.instance.WorldToScreenPoint(levelBuildableObject.transform.position);
                                                 if (newScreen2.z >= 0f)
                                                 {
                                                     newScreen2.y = (float)Screen.height - newScreen2.y;
                                                     EditorObjects.dragable.Add(new EditorDrag(levelBuildableObject.transform, newScreen2));
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (!Input.GetKey(ControlsSettings.modify))
                     {
                         for (int num8 = 0; num8 < EditorObjects.selection.Count; num8++)
                         {
                             Vector3 vector = MainCamera.instance.WorldToScreenPoint(EditorObjects.selection[num8].transform.position);
                             if (vector.z < 0f)
                             {
                                 EditorObjects.removeSelection(EditorObjects.selection[num8].transform);
                             }
                             else
                             {
                                 vector.y = (float)Screen.height - vector.y;
                                 if (vector.x < (float)num || vector.y < (float)num2 || vector.x > (float)num3 || vector.y > (float)num4)
                                 {
                                     EditorObjects.removeSelection(EditorObjects.selection[num8].transform);
                                 }
                             }
                         }
                     }
                     for (int num9 = 0; num9 < EditorObjects.dragable.Count; num9++)
                     {
                         EditorDrag editorDrag = EditorObjects.dragable[num9];
                         if (!(editorDrag.transform == null))
                         {
                             if (!(editorDrag.transform.parent == EditorObjects.group))
                             {
                                 if (editorDrag.screen.x >= (float)num && editorDrag.screen.y >= (float)num2 && editorDrag.screen.x <= (float)num3 && editorDrag.screen.y <= (float)num4)
                                 {
                                     EditorObjects.addSelection(editorDrag.transform);
                                 }
                             }
                         }
                     }
                 }
             }
             if (EditorObjects.selection.Count > 0)
             {
                 if (Input.GetKeyDown(ControlsSettings.tool_2) && EditorInteract.worldHit.transform != null)
                 {
                     EditorObjects.pointSelection();
                     EditorObjects.handle.position = EditorInteract.worldHit.point;
                     if (Input.GetKey(ControlsSettings.snap))
                     {
                         EditorObjects.handle.position += EditorInteract.worldHit.normal * EditorObjects.snapTransform;
                     }
                     EditorObjects.updateGroup();
                     EditorObjects.applySelection();
                 }
                 if (Input.GetKeyDown(ControlsSettings.focus))
                 {
                     MainCamera.instance.transform.parent.position = EditorObjects.handle.position - 15f * MainCamera.instance.transform.forward;
                 }
             }
             else if (EditorInteract.worldHit.transform != null)
             {
                 if (EditorInteract.worldHit.transform.CompareTag("Large") || EditorInteract.worldHit.transform.CompareTag("Medium") || EditorInteract.worldHit.transform.CompareTag("Small") || EditorInteract.worldHit.transform.CompareTag("Barricade") || EditorInteract.worldHit.transform.CompareTag("Structure"))
                 {
                     ObjectAsset objectAsset2;
                     ItemAsset   itemAsset2;
                     LevelObjects.getAssetEditor(EditorInteract.worldHit.transform, out objectAsset2, out itemAsset2);
                     if (objectAsset2 != null)
                     {
                         EditorUI.hint(EEditorMessage.FOCUS, objectAsset2.objectName);
                     }
                     else if (itemAsset2 != null)
                     {
                         EditorUI.hint(EEditorMessage.FOCUS, itemAsset2.itemName);
                     }
                 }
                 if (Input.GetKeyDown(ControlsSettings.tool_2))
                 {
                     EditorObjects.handle.position = EditorInteract.worldHit.point;
                     if (Input.GetKey(ControlsSettings.snap))
                     {
                         EditorObjects.handle.position += EditorInteract.worldHit.normal * EditorObjects.snapTransform;
                     }
                     EditorObjects.handle.rotation = Quaternion.Euler(-90f, 0f, 0f);
                     if (EditorObjects.selectedObjectAsset != null || EditorObjects.selectedItemAsset != null)
                     {
                         LevelObjects.step++;
                         Transform transform2 = LevelObjects.registerAddObject(EditorObjects.handle.position, EditorObjects.handle.rotation, Vector3.one, EditorObjects.selectedObjectAsset, EditorObjects.selectedItemAsset);
                         if (transform2 != null)
                         {
                             EditorObjects.addSelection(transform2);
                         }
                     }
                 }
             }
         }
     }
     if (Input.GetKeyUp(ControlsSettings.primary) && EditorObjects.dragStart.x != 0f)
     {
         EditorObjects._dragStart = Vector2.zero;
         if (EditorObjects.isDragging)
         {
             EditorObjects._dragEnd    = Vector2.zero;
             EditorObjects._isDragging = false;
             if (EditorObjects.onDragStopped != null)
             {
                 EditorObjects.onDragStopped();
             }
         }
     }
 }
Esempio n. 28
0
 private static void onRegionUpdated(Player player, byte old_x, byte old_y, byte new_x, byte new_y, byte step, ref bool canIncrementIndex)
 {
     if (step != 0)
     {
         return;
     }
     for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
     {
         for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
         {
             if (LevelObjects.regions[(int)b, (int)b2] && !Regions.checkArea(b, b2, new_x, new_y, LevelObjects.OBJECT_REGIONS))
             {
                 LevelObjects.regions[(int)b, (int)b2] = false;
                 if (LevelObjects.shouldInstantlyLoad)
                 {
                     List <LevelObject> list = LevelObjects.objects[(int)b, (int)b2];
                     for (int i = 0; i < list.Count; i++)
                     {
                         list[i].disableCollision();
                         if (!list[i].isSpeciallyCulled)
                         {
                             list[i].disableVisual();
                             if (list[i].isLandmarkQualityMet)
                             {
                                 list[i].enableSkybox();
                             }
                         }
                     }
                 }
                 else
                 {
                     LevelObjects.loads[(int)b, (int)b2] = 0;
                 }
                 if (Level.isEditor)
                 {
                     List <LevelBuildableObject> list2 = LevelObjects.buildables[(int)b, (int)b2];
                     for (int j = 0; j < list2.Count; j++)
                     {
                         list2[j].disable();
                     }
                 }
             }
         }
     }
     if (Regions.checkSafe((int)new_x, (int)new_y))
     {
         for (int k = (int)(new_x - LevelObjects.OBJECT_REGIONS); k <= (int)(new_x + LevelObjects.OBJECT_REGIONS); k++)
         {
             for (int l = (int)(new_y - LevelObjects.OBJECT_REGIONS); l <= (int)(new_y + LevelObjects.OBJECT_REGIONS); l++)
             {
                 if (Regions.checkSafe((int)((byte)k), (int)((byte)l)) && !LevelObjects.regions[k, l])
                 {
                     LevelObjects.regions[k, l] = true;
                     if (LevelObjects.shouldInstantlyLoad)
                     {
                         List <LevelObject> list3 = LevelObjects.objects[k, l];
                         for (int m = 0; m < list3.Count; m++)
                         {
                             list3[m].enableCollision();
                             if (!list3[m].isSpeciallyCulled)
                             {
                                 list3[m].enableVisual();
                                 list3[m].disableSkybox();
                             }
                         }
                     }
                     else
                     {
                         LevelObjects.loads[k, l] = 0;
                     }
                     if (Level.isEditor)
                     {
                         List <LevelBuildableObject> list4 = LevelObjects.buildables[k, l];
                         for (int n = 0; n < list4.Count; n++)
                         {
                             list4[n].enable();
                         }
                     }
                 }
             }
         }
     }
     Level.isLoadingArea = false;
     LevelObjects.shouldInstantlyLoad = false;
 }