public PlayerPositionLook(Transform tranform, PositionFlags flags, int tpId) : base(0x32, new byte[0])
        {
            this.Transform = tranform;

            this.Flags      = flags;
            this.TeleportId = tpId;
        }
Exemple #2
0
        public PositionPack(WorldObject wo, bool adminMove = false)
        {
            WorldObject = wo;

            Origin      = new Origin(wo.Location.ObjCellID, wo.Location.Pos);
            Rotation    = wo.Location.Rotation;
            Velocity    = wo.PhysicsObj != null ? wo.PhysicsObj.Velocity : Vector3.Zero; // average or instantaneous?
            PlacementID = wo.Placement;

            // note that this constructor increments the wo position sequence
            InstanceSequence = wo.Sequences.GetCurrentSequence(SequenceType.ObjectInstance);
            PositionSequence = wo.Sequences.GetNextSequence(SequenceType.ObjectPosition);

            if (adminMove)
            {
                TeleportSequence = wo.Sequences.GetNextSequence(SequenceType.ObjectTeleport);
            }
            else
            {
                TeleportSequence = wo.Sequences.GetCurrentSequence(SequenceType.ObjectTeleport);
            }

            ForcePositionSequence = wo.Sequences.GetCurrentSequence(SequenceType.ObjectForcePosition);

            Flags = BuildFlags();
        }
Exemple #3
0
        public Grid(IOsnowaContextManager contextManager, bool contextShouldBePresent = false)
        {
            if (!contextManager.HasContext)
            {
                if (contextShouldBePresent)
                {
                    throw new ArgumentException("Missing context where it's expeteced to be present");
                }
            }
            else
            {
                _positionFlags         = contextManager.Current.PositionFlags;
                _walkability           = contextManager.Current.Walkability;
                _pathfindingDataHolder = contextManager.Current.PathfindingData;
            }

            contextManager.ContextReplaced += newContext =>
            {
                _positionFlags         = newContext.PositionFlags;
                _walkability           = newContext.Walkability;
                _pathfindingDataHolder = newContext.PathfindingData;
            };
            MinPosition = Position.Zero;

            _passingLightFlagAsUlong = Convert.ToUInt64(PositionFlag.PassingLight);
        }
        public UnityGridInfoProvider(ISceneContext sceneContext, IOsnowaContextManager contextManager)
        {
            _sceneContext = sceneContext;

            contextManager.ContextReplaced += newContext => _positionFlags = newContext.PositionFlags;

            _sceneContext.TilemapDefiningOuterBounds.CompressBounds();
            MinPosition = Position.Zero;
            CellSize    = _sceneContext.TilemapDefiningOuterBounds.cellSize.x;
        }
Exemple #5
0
 public OsnowaContext(int xSize, int ySize)
 {
     PositionFlags       = new PositionFlags(xSize, ySize);
     PathfindingData     = new PathfindingDataHolder(xSize, ySize);
     TileMatricesByLayer = new MatrixByte[(int)TilemapLayer.TotalLayersCount];
     Walkability         = new MatrixFloat(xSize, ySize);
     for (int i = 0; i < TileMatricesByLayer.Length; i++)
     {
         TileMatricesByLayer[i] = new MatrixByte(xSize, ySize);
     }
     VisibleEntities = new HashSet <IPositionedEntity>();
 }
Exemple #6
0
        /// <summary>
        /// Marking
        /// </summary>
        private void MarkIsolatedAreas(IOsnowaContext context)
        {
            var           floodSpiller  = new FloodSpiller();
            PositionFlags positionFlags = context.PositionFlags;
            var           stopwatch     = Stopwatch.StartNew();

            byte areaIndex        = 0;
            byte biggestAreaIndex = 0;
            int  maxArea          = 0;

            for (int probeX = 0; probeX < context.PositionFlags.XSize; probeX += 10)
            {
                for (int probeY = 0; probeY < context.PositionFlags.YSize; probeY += 10)
                {
                    bool     isFine       = false;
                    int      totalVisited = 0;
                    Position start        = new Position(probeX, probeY);
                    var      parameters   = new FloodParameters(start.x, start.y)
                    {
                        Qualifier =
                            (x, y) => positionFlags.IsWalkable(x, y),
                        NeighbourProcessor = (x, y, mark) =>
                        {
                            if (!isFine)
                            {
                                isFine     = true;
                                areaIndex += 1;
                            }
                            totalVisited += 1;
                        }
                    };
                    int[,] markMatrix = new int[context.PositionFlags.XSize, context.PositionFlags.YSize];
                    floodSpiller.SpillFlood(parameters, markMatrix);
                    if (totalVisited > 50)
                    {
                        // BUG looks like areas are not isolated, all are of same size of the whole island!
                        // Debug.Log("visited " + totalVisited + "from " + start.x + ", " + start.y + " with index " + areaIndex);
                    }
                    if (totalVisited > maxArea)
                    {
                        maxArea          = totalVisited;
                        biggestAreaIndex = areaIndex;
                    }
                }
            }
            Debug.Log("biggest isolated area index: " + biggestAreaIndex);
            Debug.Log("biggest isolated area index: " + maxArea);
            Debug.Log("marking isolated areas took: " + stopwatch.ElapsedMilliseconds);
        }
Exemple #7
0
        public bool ChannelSetPosition(IBassAudioChannel channel, long position, PositionFlags mode = PositionFlags.Bytes)
        {
            // All BASS channels enter a stopped state once they reach the end.
            // Non-decoding channels remain in the stopped state when seeked afterwards, however decoding channels are put back into a playing state which causes audio to play.
            // Thus, on seek, in order to reproduce the expectations set out by non-decoding channels, manually pause the mixer channel when the decoding channel is stopped.
            if (ChannelIsActive(channel) == PlaybackState.Stopped)
            {
                ChannelPause(channel, true);
            }

            bool result = BassMix.ChannelSetPosition(channel.Handle, position, mode);

            // Perform a flush so that ChannelGetPosition() immediately returns the new value.
            flush();

            return(result);
        }
Exemple #8
0
 public long ChannelGetPosition(IBassAudioChannel channel, PositionFlags mode = PositionFlags.Bytes)
 => BassMix.ChannelGetPosition(channel.Handle);
 public extern static long ChannelGetLength(int Handle, PositionFlags Mode = PositionFlags.Bytes);
Exemple #10
0
 public extern static bool SetChannelPosition(int Handle, long pos, PositionFlags mode = PositionFlags.Bytes);
Exemple #11
0
 public static extern long MixerChannelGetPositionEx(int handle, PositionFlags mode, int delay);
Exemple #12
0
 private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int theight, PositionFlags flags);
Exemple #13
0
 internal async Task SendPlayerLookPositionAsync(Transform poslook, PositionFlags posflags, int tpid = 0)
 {
     await PacketHandler.CreateAsync(new PlayerPositionLook(poslook, posflags, tpid), this.MinecraftStream);
 }
Exemple #14
0
 private void OnContextReplaced(IOsnowaContext newContext)
 {
     _positionFlags           = newContext.PositionFlags;
     _tileMatricesByteByLayer = newContext.TileMatricesByLayer;
 }
Exemple #15
0
 public static extern bool MixerChannelSetPosition(int handle, long pos, PositionFlags mode);
Exemple #16
0
 public extern static long GetChannelPosition(int Handle, PositionFlags mode = PositionFlags.Bytes);
Exemple #17
0
 public static extern long MixerChannelGetPosition(int handle, PositionFlags mode);