コード例 #1
0
        // Token: 0x060026B7 RID: 9911 RVA: 0x000E54EC File Offset: 0x000E38EC
        private IEnumerator teleport()
        {
            yield return(new WaitForSeconds(3f));

            if (this.target != null)
            {
                ZombieSoulTeleporter.nearbyPlayers.Clear();
                PlayerTool.getPlayersInRadius(base.transform.position, this.sqrRadius, ZombieSoulTeleporter.nearbyPlayers);
                for (int i = 0; i < ZombieSoulTeleporter.nearbyPlayers.Count; i++)
                {
                    Player player = ZombieSoulTeleporter.nearbyPlayers[i];
                    if (!player.life.isDead)
                    {
                        short num;
                        short num2;
                        if (player.quests.getFlag(211, out num) && num == 1 && player.quests.getFlag(212, out num2) && num2 == 1 && player.quests.getQuestStatus(213) != ENPCQuestStatus.COMPLETED)
                        {
                            player.quests.sendSetFlag(214, 0);
                            player.quests.sendAddQuest(213);
                            player.sendTeleport(this.targetBoss.position, MeasurementTool.angleToByte(this.targetBoss.rotation.eulerAngles.y));
                        }
                        else
                        {
                            player.sendTeleport(this.target.position, MeasurementTool.angleToByte(this.target.rotation.eulerAngles.y));
                            if (player.equipment.isSelected)
                            {
                                player.equipment.dequip();
                            }
                            player.equipment.canEquip = false;
                        }
                    }
                }
            }
            yield break;
        }
コード例 #2
0
        public static void transformStructure(Transform structure, Vector3 point, float angle_x, float angle_y, float angle_z)
        {
            angle_x = (float)(Mathf.RoundToInt(angle_x / 2f) * 2);
            angle_y = (float)(Mathf.RoundToInt(angle_y / 2f) * 2);
            angle_z = (float)(Mathf.RoundToInt(angle_z / 2f) * 2);
            byte            b;
            byte            b2;
            ushort          num;
            StructureRegion structureRegion;
            StructureDrop   structureDrop;

            if (StructureManager.tryGetInfo(structure, out b, out b2, out num, out structureRegion, out structureDrop))
            {
                StructureManager.manager.channel.send("askTransformStructure", ESteamCall.SERVER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    b,
                    b2,
                    structureDrop.instanceID,
                    point,
                    MeasurementTool.angleToByte(angle_x),
                    MeasurementTool.angleToByte(angle_y),
                    MeasurementTool.angleToByte(angle_z)
                });
            }
        }
コード例 #3
0
ファイル: Data.cs プロジェクト: sky-xk-nge/Unturned
        public void writeQuaternion(string key, Quaternion value)
        {
            Vector3 eulerAngles = value.eulerAngles;

            this.writeByte(key + "_X", MeasurementTool.angleToByte(eulerAngles.x));
            this.writeByte(key + "_Y", MeasurementTool.angleToByte(eulerAngles.y));
            this.writeByte(key + "_Z", MeasurementTool.angleToByte(eulerAngles.z));
        }
コード例 #4
0
 public void askAnimals(CSteamID steamID)
 {
     base.channel.openWrite();
     base.channel.write((ushort)AnimalManager.animals.Count);
     for (int i = 0; i < AnimalManager.animals.Count; i++)
     {
         Animal animal = AnimalManager.animals[i];
         base.channel.write(animal.id, animal.transform.position, MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y), animal.isDead);
     }
     base.channel.closeWrite("tellAnimals", steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
 }
コード例 #5
0
 public void askLighting(CSteamID steamID)
 {
     base.channel.send("tellLighting", steamID, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
     {
         Provider.time,
         LightingManager.cycle,
         LightingManager.offset,
         LevelLighting.moon,
         MeasurementTool.angleToByte(LevelLighting.wind),
         (byte)LevelLighting.rainyness,
         (byte)LevelLighting.snowyness
     });
 }
コード例 #6
0
        // Token: 0x060025BA RID: 9658 RVA: 0x000DCD44 File Offset: 0x000DB144
        public static void save()
        {
            River river = new River(Level.info.path + "/Spawns/Players.dat", false);

            river.writeByte(LevelPlayers.SAVEDATA_VERSION);
            river.writeByte((byte)LevelPlayers.spawns.Count);
            for (int i = 0; i < LevelPlayers.spawns.Count; i++)
            {
                PlayerSpawnpoint playerSpawnpoint = LevelPlayers.spawns[i];
                river.writeSingleVector3(playerSpawnpoint.point);
                river.writeByte(MeasurementTool.angleToByte(playerSpawnpoint.angle));
                river.writeBoolean(playerSpawnpoint.isAlt);
            }
            river.closeRiver();
        }
コード例 #7
0
        public override void grantReward(Player player, bool shouldSend)
        {
            if (!Provider.isServer)
            {
                return;
            }
            Spawnpoint spawnpoint = SpawnpointSystem.getSpawnpoint(this.spawnpoint);

            if (spawnpoint == null)
            {
                Debug.LogError("Failed to find NPC teleport reward spawnpoint: " + this.spawnpoint);
                return;
            }
            player.sendTeleport(spawnpoint.transform.position, MeasurementTool.angleToByte(spawnpoint.transform.rotation.eulerAngles.y));
        }
コード例 #8
0
 // Token: 0x060028BB RID: 10427 RVA: 0x000F7308 File Offset: 0x000F5708
 private void updateLighting()
 {
     LightingManager._time = (Provider.time - LightingManager.offset) % LightingManager.cycle;
     if (Provider.isServer && Time.time - LightingManager.lastWind > LightingManager.windDelay)
     {
         LightingManager.windDelay = (float)UnityEngine.Random.Range(45, 75);
         LightingManager.lastWind  = Time.time;
         LevelLighting.wind        = (float)UnityEngine.Random.Range(0, 360);
         LightingManager.manager.channel.send("tellLightingWind", ESteamCall.OTHERS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
         {
             MeasurementTool.angleToByte(LevelLighting.wind)
         });
     }
     if (LightingManager.day > LevelLighting.bias)
     {
         if (!LightingManager.isCycled)
         {
             LightingManager.isCycled = true;
             if (LevelLighting.moon < LevelLighting.MOON_CYCLES - 1)
             {
                 LevelLighting.moon        += 1;
                 LightingManager.isFullMoon = (LevelLighting.moon == 2);
             }
             else
             {
                 LevelLighting.moon         = 0;
                 LightingManager.isFullMoon = false;
             }
             if (LightingManager.onDayNightUpdated != null)
             {
                 LightingManager.onDayNightUpdated(false);
             }
         }
     }
     else if (LightingManager.isCycled)
     {
         LightingManager.isCycled   = false;
         LightingManager.isFullMoon = false;
         if (LightingManager.onDayNightUpdated != null)
         {
             LightingManager.onDayNightUpdated(true);
         }
     }
     if (!Dedicator.isDedicated)
     {
         LevelLighting.time = LightingManager.day;
     }
 }
コード例 #9
0
        // Token: 0x0600269D RID: 9885 RVA: 0x000E4A44 File Offset: 0x000E2E44
        private IEnumerator teleport()
        {
            yield return(new WaitForSeconds(3f));

            if (this.target != null && this.playerTeleported != null && !this.playerTeleported.life.isDead)
            {
                this.playerTeleported.sendTeleport(this.target.position, MeasurementTool.angleToByte(this.target.rotation.eulerAngles.y));
                if (this.playerTeleported.equipment.isSelected)
                {
                    this.playerTeleported.equipment.dequip();
                }
                this.playerTeleported.equipment.canEquip = true;
            }
            this.playerTeleported = null;
            yield break;
        }
コード例 #10
0
        public static void save()
        {
            River river = new River(Level.info.path + "/Spawns/Vehicles.dat", false);

            river.writeByte(LevelVehicles.SAVEDATA_VERSION);
            river.writeByte((byte)LevelVehicles.tables.Count);
            byte b = 0;

            while ((int)b < LevelVehicles.tables.Count)
            {
                VehicleTable vehicleTable = LevelVehicles.tables[(int)b];
                river.writeColor(vehicleTable.color);
                river.writeString(vehicleTable.name);
                river.writeUInt16(vehicleTable.tableID);
                river.writeByte((byte)vehicleTable.tiers.Count);
                byte b2 = 0;
                while ((int)b2 < vehicleTable.tiers.Count)
                {
                    VehicleTier vehicleTier = vehicleTable.tiers[(int)b2];
                    river.writeString(vehicleTier.name);
                    river.writeSingle(vehicleTier.chance);
                    river.writeByte((byte)vehicleTier.table.Count);
                    byte b3 = 0;
                    while ((int)b3 < vehicleTier.table.Count)
                    {
                        VehicleSpawn vehicleSpawn = vehicleTier.table[(int)b3];
                        river.writeUInt16(vehicleSpawn.vehicle);
                        b3 += 1;
                    }
                    b2 += 1;
                }
                b += 1;
            }
            river.writeUInt16((ushort)LevelVehicles.spawns.Count);
            for (int i = 0; i < LevelVehicles.spawns.Count; i++)
            {
                VehicleSpawnpoint vehicleSpawnpoint = LevelVehicles.spawns[i];
                river.writeByte(vehicleSpawnpoint.type);
                river.writeSingleVector3(vehicleSpawnpoint.point);
                river.writeByte(MeasurementTool.angleToByte(vehicleSpawnpoint.angle));
            }
            river.closeRiver();
        }
コード例 #11
0
        // Token: 0x060026A5 RID: 9893 RVA: 0x000E4DD0 File Offset: 0x000E31D0
        private IEnumerator teleport()
        {
            yield return(new WaitForSeconds(3f));

            if (this.target != null)
            {
                ZombieBossQuest.nearbyPlayers.Clear();
                PlayerTool.getPlayersInRadius(base.transform.position, this.sqrRadius, ZombieBossQuest.nearbyPlayers);
                for (int i = 0; i < ZombieBossQuest.nearbyPlayers.Count; i++)
                {
                    Player player = ZombieBossQuest.nearbyPlayers[i];
                    if (!player.life.isDead)
                    {
                        player.quests.sendRemoveQuest(213);
                        player.quests.setFlag(213, 1);
                        player.sendTeleport(this.target.position, MeasurementTool.angleToByte(this.target.rotation.eulerAngles.y));
                    }
                }
            }
            yield break;
        }
コード例 #12
0
        protected override IEnumerator teleport()
        {
            yield return(new WaitForSeconds(1f));

            if (this.target != null)
            {
                GermanyTeleporterA.nearbyPlayers.Clear();
                PlayerTool.getPlayersInRadius(base.transform.position, this.sqrRadius, GermanyTeleporterA.nearbyPlayers);
                for (int i = 0; i < GermanyTeleporterA.nearbyPlayers.Count; i++)
                {
                    Player player = GermanyTeleporterA.nearbyPlayers[i];
                    if (!player.life.isDead)
                    {
                        if (player.quests.getQuestStatus(248) == ENPCQuestStatus.COMPLETED)
                        {
                            player.sendTeleport(this.target.position, MeasurementTool.angleToByte(this.target.rotation.eulerAngles.y));
                        }
                    }
                }
            }
            yield break;
        }
コード例 #13
0
        // Token: 0x06001E2F RID: 7727 RVA: 0x000A4BF8 File Offset: 0x000A2FF8
        protected override void execute(CSteamID executorID, string parameter)
        {
            if (!Provider.isServer)
            {
                CommandWindow.LogError(this.localization.format("NotRunningErrorText"));
                return;
            }
            string[] componentsFromSerial = Parser.getComponentsFromSerial(parameter, '/');
            if (componentsFromSerial.Length < 1 || componentsFromSerial.Length > 2)
            {
                CommandWindow.LogError(this.localization.format("InvalidParameterErrorText"));
                return;
            }
            bool        flag = componentsFromSerial.Length == 1;
            SteamPlayer steamPlayer;

            if (flag)
            {
                steamPlayer = PlayerTool.getSteamPlayer(executorID);
            }
            else
            {
                PlayerTool.tryGetSteamPlayer(componentsFromSerial[0], out steamPlayer);
            }
            if (steamPlayer == null)
            {
                CommandWindow.LogError(this.localization.format("NoPlayerErrorText", new object[]
                {
                    componentsFromSerial[0]
                }));
                return;
            }
            if (steamPlayer.player.movement.getVehicle() != null)
            {
                CommandWindow.LogError(this.localization.format("NoVehicleErrorText"));
                return;
            }
            SteamPlayer steamPlayer2;

            if (PlayerTool.tryGetSteamPlayer(componentsFromSerial[(!flag) ? 1 : 0], out steamPlayer2))
            {
                steamPlayer.player.sendTeleport(steamPlayer2.player.transform.position, MeasurementTool.angleToByte(steamPlayer2.player.transform.rotation.eulerAngles.y));
                CommandWindow.Log(this.localization.format("TeleportText", new object[]
                {
                    steamPlayer.playerID.playerName,
                    steamPlayer2.playerID.playerName
                }));
            }
            else if (componentsFromSerial[(!flag) ? 1 : 0].Equals(this.localization.format("WaypointCommand"), StringComparison.InvariantCultureIgnoreCase) && steamPlayer.player.quests.isMarkerPlaced)
            {
                Vector3 markerPosition = steamPlayer.player.quests.markerPosition;
                markerPosition.y = 1024f;
                RaycastHit raycastHit;
                if (Physics.Raycast(markerPosition, Vector3.down, out raycastHit, 2048f, RayMasks.WAYPOINT))
                {
                    steamPlayer.player.sendTeleport(raycastHit.point + Vector3.up, MeasurementTool.angleToByte(steamPlayer.player.transform.rotation.eulerAngles.y));
                    CommandWindow.Log(this.localization.format("TeleportText", new object[]
                    {
                        steamPlayer.playerID.playerName,
                        this.localization.format("WaypointText")
                    }));
                }
            }
            else
            {
                Node node = null;
                for (int i = 0; i < LevelNodes.nodes.Count; i++)
                {
                    if (LevelNodes.nodes[i].type == ENodeType.LOCATION && NameTool.checkNames(componentsFromSerial[(!flag) ? 1 : 0], ((LocationNode)LevelNodes.nodes[i]).name))
                    {
                        node = LevelNodes.nodes[i];
                        break;
                    }
                }
                if (node != null)
                {
                    steamPlayer.player.sendTeleport(node.point, MeasurementTool.angleToByte(steamPlayer.player.transform.rotation.eulerAngles.y));
                    CommandWindow.Log(this.localization.format("TeleportText", new object[]
                    {
                        steamPlayer.playerID.playerName,
                        ((LocationNode)node).name
                    }));
                }
                else
                {
                    CommandWindow.LogError(this.localization.format("NoLocationErrorText", new object[]
                    {
                        componentsFromSerial[(!flag) ? 1 : 0]
                    }));
                }
            }
        }
コード例 #14
0
        // Token: 0x0600270D RID: 9997 RVA: 0x000E85C4 File Offset: 0x000E69C4
        private void Update()
        {
            if (!Provider.isServer || !Level.isLoaded)
            {
                return;
            }
            if (AnimalManager.animals == null || AnimalManager.animals.Count == 0)
            {
                return;
            }
            if (AnimalManager.tickingAnimals == null)
            {
                return;
            }
            int num;
            int num2;

            if (Dedicator.isDedicated)
            {
                if (AnimalManager.tickIndex >= AnimalManager.tickingAnimals.Count)
                {
                    AnimalManager.tickIndex = 0;
                }
                num  = AnimalManager.tickIndex;
                num2 = num + 25;
                if (num2 >= AnimalManager.tickingAnimals.Count)
                {
                    num2 = AnimalManager.tickingAnimals.Count;
                }
                AnimalManager.tickIndex = num2;
            }
            else
            {
                num  = 0;
                num2 = AnimalManager.tickingAnimals.Count;
            }
            for (int i = num2 - 1; i >= num; i--)
            {
                Animal animal = AnimalManager.tickingAnimals[i];
                if (animal == null)
                {
                    Debug.LogError("Missing animal " + i);
                }
                else
                {
                    animal.tick();
                }
            }
            if (Dedicator.isDedicated && Time.realtimeSinceStartup - AnimalManager.lastTick > Provider.UPDATE_TIME)
            {
                AnimalManager.lastTick += Provider.UPDATE_TIME;
                if (Time.realtimeSinceStartup - AnimalManager.lastTick > Provider.UPDATE_TIME)
                {
                    AnimalManager.lastTick = Time.realtimeSinceStartup;
                }
                base.channel.useCompression = true;
                this.seq += 1u;
                for (int j = 0; j < Provider.clients.Count; j++)
                {
                    SteamPlayer steamPlayer = Provider.clients[j];
                    if (steamPlayer != null && !(steamPlayer.player == null))
                    {
                        base.channel.openWrite();
                        base.channel.write(this.seq);
                        ushort num3 = 0;
                        int    step = base.channel.step;
                        base.channel.write(num3);
                        int num4 = 0;
                        for (int k = 0; k < AnimalManager.animals.Count; k++)
                        {
                            if (num3 >= 64)
                            {
                                break;
                            }
                            Animal animal2 = AnimalManager.animals[k];
                            if (!(animal2 == null) && animal2.isUpdated)
                            {
                                if ((animal2.transform.position - steamPlayer.player.transform.position).sqrMagnitude > 331776f)
                                {
                                    if ((ulong)(this.seq % 8u) == (ulong)((long)num4))
                                    {
                                        base.channel.write(animal2.index, animal2.transform.position, MeasurementTool.angleToByte(animal2.transform.rotation.eulerAngles.y));
                                        num3 += 1;
                                    }
                                    num4++;
                                }
                                else
                                {
                                    base.channel.write(animal2.index, animal2.transform.position, MeasurementTool.angleToByte(animal2.transform.rotation.eulerAngles.y));
                                    num3 += 1;
                                }
                            }
                        }
                        if (num3 != 0)
                        {
                            int step2 = base.channel.step;
                            base.channel.step = step;
                            base.channel.write(num3);
                            base.channel.step = step2;
                            base.channel.closeWrite("tellAnimalStates", steamPlayer.playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_CHUNK_BUFFER);
                        }
                    }
                }
                base.channel.useCompression = false;
                for (int l = 0; l < AnimalManager.animals.Count; l++)
                {
                    Animal animal3 = AnimalManager.animals[l];
                    if (!(animal3 == null))
                    {
                        animal3.isUpdated = false;
                    }
                }
            }
            this.respawnAnimals();
        }
コード例 #15
0
ファイル: Animal.cs プロジェクト: sky-xk-nge/Unturned
 public void sendRevive(Vector3 position, float angle)
 {
     AnimalManager.sendAnimalAlive(this, position, MeasurementTool.angleToByte(angle));
 }
コード例 #16
0
        // Token: 0x0600287A RID: 10362 RVA: 0x000F56AC File Offset: 0x000F3AAC
        private void arenaSpawn()
        {
            for (byte b = 0; b < Regions.WORLD_SIZE; b += 1)
            {
                for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
                {
                    if (LevelItems.spawns[(int)b, (int)b2].Count > 0)
                    {
                        for (int i = 0; i < LevelItems.spawns[(int)b, (int)b2].Count; i++)
                        {
                            ItemSpawnpoint itemSpawnpoint = LevelItems.spawns[(int)b, (int)b2][i];
                            ushort         item           = LevelItems.getItem(itemSpawnpoint);
                            if (item != 0)
                            {
                                Item item2 = new Item(item, EItemOrigin.ADMIN);
                                ItemManager.dropItem(item2, itemSpawnpoint.point, false, false, false);
                            }
                        }
                    }
                }
            }
            List <VehicleSpawnpoint> spawns = LevelVehicles.spawns;

            for (int j = 0; j < spawns.Count; j++)
            {
                VehicleSpawnpoint vehicleSpawnpoint = spawns[j];
                ushort            vehicle           = LevelVehicles.getVehicle(vehicleSpawnpoint);
                if (vehicle != 0)
                {
                    Vector3 point = vehicleSpawnpoint.point;
                    point.y += 1f;
                    VehicleManager.spawnVehicle(vehicle, point, Quaternion.Euler(0f, vehicleSpawnpoint.angle, 0f));
                }
            }
            List <PlayerSpawnpoint> altSpawns = LevelPlayers.getAltSpawns();
            float num = LevelManager.arenaCurrentRadius - SafezoneNode.MIN_SIZE;

            num *= num;
            for (int k = altSpawns.Count - 1; k >= 0; k--)
            {
                PlayerSpawnpoint playerSpawnpoint = altSpawns[k];
                float            num2             = Mathf.Pow(playerSpawnpoint.point.x - LevelManager.arenaCurrentCenter.x, 2f) + Mathf.Pow(playerSpawnpoint.point.z - LevelManager.arenaCurrentCenter.z, 2f);
                if (num2 > num)
                {
                    altSpawns.RemoveAt(k);
                }
            }
            for (int l = 0; l < Provider.clients.Count; l++)
            {
                if (altSpawns.Count == 0)
                {
                    break;
                }
                SteamPlayer steamPlayer = Provider.clients[l];
                if (steamPlayer != null && !(steamPlayer.player == null) && !steamPlayer.player.life.isDead)
                {
                    int index = UnityEngine.Random.Range(0, altSpawns.Count);
                    PlayerSpawnpoint playerSpawnpoint2 = altSpawns[index];
                    altSpawns.RemoveAt(index);
                    ArenaPlayer arenaPlayer = new ArenaPlayer(steamPlayer);
                    arenaPlayer.steamPlayer.player.life.sendRevive();
                    arenaPlayer.steamPlayer.player.sendTeleport(playerSpawnpoint2.point, MeasurementTool.angleToByte(playerSpawnpoint2.angle));
                    LevelManager.arenaPlayers.Add(arenaPlayer);
                    foreach (ArenaLoadout arenaLoadout in Level.info.configData.Arena_Loadouts)
                    {
                        for (ushort num3 = 0; num3 < arenaLoadout.Amount; num3 += 1)
                        {
                            ushort newID = SpawnTableTool.resolve(arenaLoadout.Table_ID);
                            arenaPlayer.steamPlayer.player.inventory.forceAddItemAuto(new Item(newID, true), true, false, true, false);
                        }
                    }
                }
            }
            this.arenaAirdrop();
            LevelManager.arenaState = EArenaState.PLAY;
            base.channel.send("tellLevelNumber", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
            {
                (byte)LevelManager.arenaPlayers.Count
            });
        }
コード例 #17
0
        private static void loadRegion(byte version, River river, StructureRegion region)
        {
            ushort num = river.readUInt16();

            for (ushort num2 = 0; num2 < num; num2 += 1)
            {
                ushort  num3   = river.readUInt16();
                ushort  num4   = river.readUInt16();
                Vector3 vector = river.readSingleVector3();
                byte    b      = 0;
                if (version > 4)
                {
                    b = river.readByte();
                }
                byte b2 = river.readByte();
                byte b3 = 0;
                if (version > 4)
                {
                    b3 = river.readByte();
                }
                ulong num5 = 0UL;
                ulong num6 = 0UL;
                if (version > 2)
                {
                    num5 = river.readUInt64();
                    num6 = river.readUInt64();
                }
                uint newObjActiveDate;
                if (version > 3)
                {
                    newObjActiveDate = river.readUInt32();
                    if (Provider.time - StructureManager.serverActiveDate > Provider.modeConfigData.Structures.Decay_Time / 2u)
                    {
                        newObjActiveDate = Provider.time;
                    }
                }
                else
                {
                    newObjActiveDate = Provider.time;
                }
                ItemStructureAsset itemStructureAsset;
                try
                {
                    itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, num3);
                }
                catch
                {
                    itemStructureAsset = null;
                }
                if (itemStructureAsset != null)
                {
                    if (version < 5)
                    {
                        Vector3 eulerAngles = Quaternion.Euler(-90f, (float)(b2 * 2), 0f).eulerAngles;
                        b  = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2));
                        b2 = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2));
                        b3 = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2));
                    }
                    region.structures.Add(new StructureData(new Structure(num3, num4, itemStructureAsset), vector, b, b2, b3, num5, num6, newObjActiveDate));
                    StructureManager.manager.spawnStructure(region, num3, vector, b, b2, b3, (byte)Mathf.RoundToInt((float)num4 / (float)itemStructureAsset.health * 100f), num5, num6, StructureManager.instanceCount += 1u);
                }
            }
        }
コード例 #18
0
        public static void load()
        {
            bool flag = false;

            if (LevelSavedata.fileExists("/Structures.dat") && Level.info.type == ELevelType.SURVIVAL)
            {
                River river = LevelSavedata.openRiver("/Structures.dat", true);
                byte  b     = river.readByte();
                if (b > 3)
                {
                    StructureManager.serverActiveDate = river.readUInt32();
                }
                else
                {
                    StructureManager.serverActiveDate = Provider.time;
                }
                if (b > 1)
                {
                    for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1)
                    {
                        for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1)
                        {
                            StructureRegion region = StructureManager.regions[(int)b2, (int)b3];
                            StructureManager.loadRegion(b, river, region);
                        }
                    }
                }
                if (b < 6)
                {
                    flag = true;
                }
            }
            else
            {
                flag = true;
            }
            if (flag && LevelObjects.buildables != null)
            {
                for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1)
                {
                    for (byte b5 = 0; b5 < Regions.WORLD_SIZE; b5 += 1)
                    {
                        List <LevelBuildableObject> list = LevelObjects.buildables[(int)b4, (int)b5];
                        if (list != null && list.Count != 0)
                        {
                            StructureRegion structureRegion = StructureManager.regions[(int)b4, (int)b5];
                            for (int i = 0; i < list.Count; i++)
                            {
                                LevelBuildableObject levelBuildableObject = list[i];
                                if (levelBuildableObject != null)
                                {
                                    ItemStructureAsset itemStructureAsset = levelBuildableObject.asset as ItemStructureAsset;
                                    if (itemStructureAsset != null)
                                    {
                                        Vector3       eulerAngles   = levelBuildableObject.rotation.eulerAngles;
                                        byte          newAngle_X    = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2));
                                        byte          newAngle_Y    = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2));
                                        byte          newAngle_Z    = MeasurementTool.angleToByte((float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2));
                                        Structure     structure     = new Structure(itemStructureAsset.id, itemStructureAsset.health, itemStructureAsset);
                                        StructureData structureData = new StructureData(structure, levelBuildableObject.point, newAngle_X, newAngle_Y, newAngle_Z, 0UL, 0UL, uint.MaxValue);
                                        structureRegion.structures.Add(structureData);
                                        StructureManager.manager.spawnStructure(structureRegion, structure.id, structureData.point, structureData.angle_x, structureData.angle_y, structureData.angle_z, (byte)Mathf.RoundToInt((float)structure.health / (float)itemStructureAsset.health * 100f), 0UL, 0UL, StructureManager.instanceCount += 1u);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Level.isLoadingStructures = false;
        }
コード例 #19
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
                    });
                }
            }
        }
コード例 #20
0
        protected override void execute(CSteamID executorID, string parameter)
        {
            if (!Provider.isServer)
            {
                CommandWindow.LogError(this.localization.format("NotRunningErrorText"));
                return;
            }
            string[] componentsFromSerial = Parser.getComponentsFromSerial(parameter, '/');
            if (componentsFromSerial.Length < 1 || componentsFromSerial.Length > 2)
            {
                CommandWindow.LogError(this.localization.format("InvalidParameterErrorText"));
                return;
            }
            bool        flag = componentsFromSerial.Length == 1;
            SteamPlayer steamPlayer;

            if (flag)
            {
                steamPlayer = PlayerTool.getSteamPlayer(executorID);
            }
            else
            {
                PlayerTool.tryGetSteamPlayer(componentsFromSerial[0], out steamPlayer);
            }
            if (steamPlayer == null)
            {
                CommandWindow.LogError(this.localization.format("NoPlayerErrorText", new object[]
                {
                    componentsFromSerial[0]
                }));
                return;
            }
            if (steamPlayer.player.movement.getVehicle() != null)
            {
                CommandWindow.LogError(this.localization.format("NoVehicleErrorText"));
                return;
            }
            SteamPlayer steamPlayer2;

            if (PlayerTool.tryGetSteamPlayer(componentsFromSerial[(!flag) ? 1 : 0], out steamPlayer2))
            {
                steamPlayer.player.sendTeleport(steamPlayer2.player.transform.position, MeasurementTool.angleToByte(steamPlayer2.player.transform.rotation.eulerAngles.y));
                CommandWindow.Log(this.localization.format("TeleportText", new object[]
                {
                    steamPlayer.playerID.playerName,
                    steamPlayer2.playerID.playerName
                }));
            }
            else
            {
                Node node = null;
                for (int i = 0; i < LevelNodes.nodes.Count; i++)
                {
                    if (LevelNodes.nodes[i].type == ENodeType.LOCATION && NameTool.checkNames(componentsFromSerial[(!flag) ? 1 : 0], ((LocationNode)LevelNodes.nodes[i]).name))
                    {
                        node = LevelNodes.nodes[i];
                        break;
                    }
                }
                if (node != null)
                {
                    steamPlayer.player.sendTeleport(node.point, MeasurementTool.angleToByte(steamPlayer.player.transform.rotation.eulerAngles.y));
                    CommandWindow.Log(this.localization.format("TeleportText", new object[]
                    {
                        steamPlayer.playerID.playerName,
                        ((LocationNode)node).name
                    }));
                }
                else
                {
                    CommandWindow.LogError(this.localization.format("NoLocationErrorText", new object[]
                    {
                        componentsFromSerial[(!flag) ? 1 : 0]
                    }));
                }
            }
        }
コード例 #21
0
 // Token: 0x06002700 RID: 9984 RVA: 0x000E7B1C File Offset: 0x000E5F1C
 public void sendAnimal(Animal animal)
 {
     base.channel.write(animal.id, animal.transform.position, MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y), animal.isDead);
 }