コード例 #1
0
        private void OnTransformBarricadeRequested(CSteamID instigator, byte x, byte y, ushort plant, uint instanceId,
                                                   ref Vector3 point, ref byte angleX, ref byte angleY, ref byte angleZ, ref bool shouldAllow)
        {
            if (!BarricadeManager.tryGetRegion(x, y, plant, out var region))
            {
                return;
            }

            var index = region.barricades.FindIndex(k => k.instanceID == instanceId);
            var data  = region.barricades[index];
            var drop  = region.drops[index];

            var nativePlayer = Provider.clients.FirstOrDefault(cl => cl?.playerID.steamID == instigator)?.player;
            var player       = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer);

            var @event = new UnturnedBarricadeTransformingEvent(
                new UnturnedBarricadeBuildable(data, drop), player, instigator, point,
                Quaternion.Euler(angleX * 2, angleY * 2, angleZ * 2));

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            var eulerAngles = @event.Rotation.eulerAngles;

            angleX = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angleY = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angleZ = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
        }
コード例 #2
0
        private void OnTransformBarricadeRequested(CSteamID instigator, byte x, byte y, ushort plant, uint instanceID,
                                                   ref Vector3 point, ref byte angle_x, ref byte angle_y, ref byte angle_z, ref bool shouldAllow)
        {
            BarricadeRegion region = BarricadeManager.regions[x, y];
            int             index  = region.barricades.FindIndex(k => k.instanceID == instanceID);

            BarricadeData data = region.barricades[index];
            BarricadeDrop drop = region.drops[index];

            Player nativePlayer = Provider.clients.FirstOrDefault(x => x?.playerID.steamID == instigator)?.player;

            UnturnedPlayer player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer);

            UnturnedBarricadeTransformingEvent @event = new UnturnedBarricadeTransformingEvent(
                new UnturnedBarricadeBuildable(data, drop), player, instigator, point,
                Quaternion.Euler(angle_x * 2, angle_y * 2, angle_z * 2));

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            Vector3 eulerAngles = @event.Rotation.eulerAngles;

            angle_x = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angle_y = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angle_z = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
        }