コード例 #1
0
        public static void UnsetSlotsFromThread(IntPtr ThreadHandle, SlotFlags SlotMask)
        {
            var cxt = new CONTEXT();

            // The only registers we care about are the debug registers
            cxt.ContextFlags = (uint)CONTEXT_FLAGS.CONTEXT_DEBUG_REGISTERS;

            // Read the register values
            if (!Kernel32.GetThreadContext(ThreadHandle, cxt))
            {
                throw new BreakPointException("Failed to get thread context");
            }

            for (var i = 0; i < Kernel32.MaxHardwareBreakpointsCount; ++i)
            {
                if (SlotMask.HasFlag((SlotFlags)(1 << i)))
                {
                    SetBits(ref cxt.Dr7, i * 2, 1, 0);
                }
            }

            // Write out the new debug registers
            if (!Kernel32.SetThreadContext(ThreadHandle, cxt))
            {
                throw new BreakPointException("Failed to set thread context");
            }
        }
コード例 #2
0
 public ClothingInInventoryCon Slot(SlotFlags slotFlags, Blackboard context)
 {
     // Ideally we'd just use a variable but then if we were iterating through multiple AI at once it'd be
     // Stuffed so we need to store it on the AI's context.
     context.GetState <ClothingSlotFlagConState>().SetValue(slotFlags);
     return(this);
 }
コード例 #3
0
 public EquippedEventBase(EntityUid equipee, EntityUid equipment, SlotDefinition slotDefinition)
 {
     Equipee   = equipee;
     Equipment = equipment;
     Slot      = slotDefinition.Name;
     SlotFlags = slotDefinition.SlotFlags;
 }
コード例 #4
0
ファイル: Slot.cs プロジェクト: Aggror/Stride
 public Slot(SlotDirection direction, SlotKind kind, string name = null, SlotFlags flags = SlotFlags.None, string type = null, string value = null) : this()
 {
     Direction = direction;
     Kind      = kind;
     Name      = name;
     Flags     = flags;
     Type      = type;
     Value     = value;
 }
コード例 #5
0
ファイル: SlotDefinition.cs プロジェクト: Aggror/Stride
 protected SlotDefinition(SlotDirection direction, SlotKind kind, string name, string type, string value, SlotFlags flags)
 {
     Direction = direction;
     Kind      = kind;
     Name      = name;
     Type      = type;
     Value     = value;
     Flags     = flags;
 }
コード例 #6
0
 public EquipAttemptBase(EntityUid equipee, EntityUid equipTarget, EntityUid equipment,
                         SlotDefinition slotDefinition)
 {
     EquipTarget = equipTarget;
     Equipment   = equipment;
     Equipee     = equipee;
     SlotFlags   = slotDefinition.SlotFlags;
     Slot        = slotDefinition.Name;
 }
コード例 #7
0
        private List <string> slotstrings = new List <string>();    //serialization

        public override void ExposeData(EntitySerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataField(ref slotstrings, "Slots", new List <string>(0));

            foreach (var slotflagsloaded in slotstrings)
            {
                SlotFlags |= (SlotFlags)Enum.Parse(typeof(SlotFlags), slotflagsloaded.ToUpper());
            }
        }
コード例 #8
0
        protected Slot FindSlot(SlotDirection direction, SlotKind kind, SlotFlags flags)
        {
            foreach (var slot in Slots)
            {
                if (slot.Direction == direction && slot.Kind == kind && (slot.Flags & flags) == flags)
                {
                    return(slot);
                }
            }

            return(null);
        }
コード例 #9
0
        /// <summary>
        /// Gets the slots that have changed.
        /// </summary>
        /// <param name="slotInfo">The data of the last scan.</param>
        /// <param name="slotFlags">Flags for the slots to check.</param>
        /// <returns>A List of slots that changed.</returns>
        /// <remarks>
        /// <para>The returned slots are slots that have been swapped, removed, or added to the game.</para>
        /// <para>The data of the scan is saved in <paramref name="slotInfo"/>. It is compared to next time it is used with this method.
        /// A new <see cref="SlotInfo"/> object will return every slot.</para>
        /// </remarks>
        /// <seealso cref="SlotInfo"/>
        public List <int> GetUpdatedSlots(SlotInfo slotInfo, SlotFlags slotFlags = SlotFlags.All)
        {
            using (LockHandler.Passive)
            {
                object     listLock     = new object();
                List <int> changedSlots = new List <int>();

                var slots = GetSlots(slotFlags);

                for (int slot = 0; slot < SlotCount; slot++)
                //Parallel.For(0, SlotCount, (slot) =>
                {
                    SlotIdentity slotIdentity = slots.Contains(slot) ? GetSlotIdentity(slot) : null;

                    bool changed = true;

                    // Slot emptied
                    if (slotIdentity == null && slotInfo.SlotIdentities[slot] != null)
                    {
                        slotInfo.SlotIdentities[slot].Dispose();
                        slotInfo.SlotIdentities[slot] = null;
                    }
                    // Slot joined
                    else if (slotIdentity != null && slotInfo.SlotIdentities[slot] == null)
                    {
                        slotInfo.SlotIdentities[slot] = slotIdentity;
                    }
                    // Slot swapped
                    else if (slotIdentity != null && slotInfo.SlotIdentities[slot] != null && !Identity.Compare(slotInfo.SlotIdentities[slot], slotIdentity))
                    {
                        slotInfo.SlotIdentities[slot].Dispose();
                        slotInfo.SlotIdentities[slot] = slotIdentity;
                    }
                    // Slot did not change
                    else
                    {
                        if (slotIdentity != null)
                        {
                            slotIdentity.Dispose();
                        }
                        changed = false;
                    }

                    if (changed)
                    {
                        lock (listLock)
                            changedSlots.Add(slot);
                    }
                }

                return(changedSlots);
            }
        }
コード例 #10
0
        public SlotFlags SlotFlags = SlotFlags.PREVENTEQUIP; //Different from None, NONE allows equips if no slot flags are required

        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            // TODO: Writing.
            serializer.DataReadFunction("Slots", new List <string>(0), list =>
            {
                foreach (var slotflagsloaded in list)
                {
                    SlotFlags |= (SlotFlags)Enum.Parse(typeof(SlotFlags), slotflagsloaded.ToUpper());
                }
            });
        }
コード例 #11
0
        /// <summary>
        /// Tracks player slots.
        /// </summary>
        /// <param name="playerTracker"></param>
        /// <param name="slotFlags">Slots to track.</param>
        public void TrackPlayers(PlayerTracker playerTracker, SlotFlags slotFlags = SlotFlags.All)
        {
            if (playerTracker == null)
            {
                throw new ArgumentNullException(nameof(playerTracker));
            }

            using (LockHandler.Interactive)
            {
                List <int> changedSlots = GetUpdatedSlots(playerTracker.SlotInfo, slotFlags);

                var slots = GetSlots(slotFlags);

                foreach (int slot in changedSlots)
                {
                    if (slots.Contains(slot))
                    {
                        PlayerIdentity newIdentity = GetPlayerIdentity(slot);
                        if (newIdentity == null)
                        {
                            continue;
                        }

                        var pi = playerTracker._players.FirstOrDefault(p => Identity.Compare(newIdentity, p.PlayerIdentity));

                        // New player joined the game
                        if (pi == null)
                        {
                            playerTracker._players.Add(new PlayerTrackerSlot(newIdentity, slot));
                        }
                        // Player swapped slots
                        else
                        {
                            pi.Slot = slot;
                            newIdentity.Dispose();
                        }
                    }
                }

                // Remove players that left the game.
                for (int i = playerTracker._players.Count - 1; i >= 0; i--)
                {
                    if (!slots.Contains(playerTracker._players[i].Slot))
                    {
                        playerTracker._players[i].PlayerIdentity.Dispose();
                        playerTracker._players.RemoveAt(i);
                    }
                }
            }
        }
コード例 #12
0
        public Rv C_OpenSession(UInt32 slotID, SlotFlags flags, IntPtr pApplication, Notify notify, IntPtr phSession)
        {
            if (phSession == IntPtr.Zero)
            {
                return(Rv.ARGUMENTS_BAD);
            }

            IToken token     = GetToken(slotID);
            UInt32 sessionId = token.OpenSession().Result;

            Marshal.StructureToPtr(sessionId, phSession, false);

            return(Rv.OK);
        }
コード例 #13
0
        public ContainerSlotEnumerator(EntityUid uid, string prototypeId, IPrototypeManager prototypeManager, InventorySystem inventorySystem, SlotFlags flags = SlotFlags.All)
        {
            _uid             = uid;
            _inventorySystem = inventorySystem;
            _flags           = flags;

            if (prototypeManager.TryIndex <InventoryTemplatePrototype>(prototypeId, out var prototype))
            {
                _slots = prototype.Slots;
            }
            else
            {
                _slots = Array.Empty <SlotDefinition>();
            }
        }
コード例 #14
0
        public override void ExposeData(ObjectSerializer serializer)
        {
            base.ExposeData(serializer);

            serializer.DataField(ref _clothingEquippedPrefix, "ClothingPrefix", null);

            // TODO: Writing.
            serializer.DataReadFunction("Slots", new List <string>(0), list =>
            {
                foreach (var slotflagsloaded in list)
                {
                    SlotFlags |= (SlotFlags)Enum.Parse(typeof(SlotFlags), slotflagsloaded.ToUpper());
                }
            });

            serializer.DataField(ref _quickEquipEnabled, "QuickEquip", true);
            serializer.DataFieldCached(ref _heatResistance, "HeatResistance", 323);
        }
コード例 #15
0
 TriviaSlot(string text, SyntaxKind kind, SlotFlags flags)
     : base(text.Length, kind, flags)
 {
     Text = text;
 }
コード例 #16
0
ファイル: Slot.cs プロジェクト: IInspectable/Language.Gd
 protected Slot(int fullLength, SyntaxKind kind, SlotFlags slotFlags = SlotFlags.None)
 {
     _fullLength = fullLength;
     Kind        = kind;
     Flags       = slotFlags;
 }
コード例 #17
0
ファイル: Slot.cs プロジェクト: IInspectable/Language.Gd
 protected Slot(SyntaxKind kind, SlotFlags slotFlags = SlotFlags.None)
 {
     _fullLength = 0;
     Kind        = kind;
     Flags       = slotFlags;
 }
コード例 #18
0
ファイル: SlotDefinition.cs プロジェクト: Aggror/Stride
 public static SlotDefinition NewValueOutput(string name, SlotFlags flags = SlotFlags.None)
 {
     return(new SlotDefinition(SlotDirection.Output, SlotKind.Value, name, null, null, flags));
 }
コード例 #19
0
ファイル: Slot.cs プロジェクト: IInspectable/Language.Gd
 bool IsFlagPresent(SlotFlags flag)
 {
     return((Flags & flag) == flag);
 }
コード例 #20
0
ファイル: SlotDefinition.cs プロジェクト: Aggror/Stride
 public static SlotDefinition NewExecutionInput(string name, SlotFlags flags = SlotFlags.None)
 {
     return(new SlotDefinition(SlotDirection.Input, SlotKind.Execution, name, null, null, flags));
 }
コード例 #21
0
ファイル: SlotDefinition.cs プロジェクト: Aggror/Stride
 public static SlotDefinition NewValueInput(string name, string type, string value, SlotFlags flags = SlotFlags.None)
 {
     return(new SlotDefinition(SlotDirection.Input, SlotKind.Value, name, type, value, flags));
 }
コード例 #22
0
        /// <summary>
        /// Gets slots in the game.
        /// </summary>
        /// <param name="flags">Flags for obtaining slots.</param>
        /// <returns>Returns a list of slots following <paramref name="flags"/>.</returns>
        /// <example>
        /// The code below will write all blue players that are not AI to the console.
        /// <code>
        /// CustomGame cg = new CustomGame();
        ///
        /// List&lt;int&gt; bluePlayerSlots = cg.GetSlots(SlotFlags.Blue | SlotFlags.NoAI);
        ///
        /// Console.WriteLine(string.Join(", ", bluePlayerSlots));
        /// </code>
        /// The code below will write all AI queueing for red to the console.
        /// <code>
        /// CustomGame cg = new CustomGame();
        ///
        /// List&lt;int&gt; redQueueAISlots = cg.GetSlots(SlotFlags.NoPlayers | SlotFlags.RedQueue);
        ///
        /// Console.WriteLine(string.Join(", ", redQueueAISlots));
        /// </code>
        /// </example>
        /// <seealso cref="SlotFlags"/>
        public List <int> GetSlots(SlotFlags flags)
        {
            List <int> slots = new List <int>();

            // Add the blue slots
            if (flags.HasFlag(SlotFlags.BlueTeam))
            {
                slots.AddRange(BlueSlots);
            }

            // Add the red slots
            if (flags.HasFlag(SlotFlags.RedTeam))
            {
                slots.AddRange(RedSlots);
            }

            // Add the spectator slots
            if (flags.HasFlag(SlotFlags.Spectators))
            {
                slots.AddRange(SpectatorSlots);
            }

            // Add the queue slots
            if (flags.HasFlag(SlotFlags.NeutralQueue) || flags.HasFlag(SlotFlags.RedQueue) || flags.HasFlag(SlotFlags.BlueQueue))
            {
                slots.AddRange(QueueSlots.Where((slot) =>
                {
                    if (!IsSlotInQueue(slot))
                    {
                        return(false);
                    }

                    QueueTeam team = PlayerInfo.GetQueueTeam(slot);

                    if ((team == QueueTeam.Neutral && !flags.HasFlag(SlotFlags.NeutralQueue)) ||
                        (team == QueueTeam.Blue && !flags.HasFlag(SlotFlags.BlueQueue)) ||
                        (team == QueueTeam.Red && !flags.HasFlag(SlotFlags.RedQueue)))
                    {
                        return(false);
                    }

                    return(true);
                }));
            }

            if (flags.HasFlag(SlotFlags.NoPlayers) || flags.HasFlag(SlotFlags.NoAI))
            {
                List <int> aiSlots = AI.GetAISlots(flags.HasFlag(SlotFlags.AccurateGetAI));

                if (flags.HasFlag(SlotFlags.NoAI))
                {
                    slots = slots.Where(slot => aiSlots.Contains(slot) == false).ToList();
                }

                if (flags.HasFlag(SlotFlags.NoPlayers))
                {
                    slots = slots.Where(slot => aiSlots.Contains(slot)).ToList();
                }
            }

            return(slots);
        }
コード例 #23
0
 public void Add(string key, SlotFlags flags)
 {
     this[key] = flags;
 }
コード例 #24
0
 /// <summary>
 /// Gets the number of players in the game.
 /// </summary>
 /// <param name="flags">Flags for counting slots.</param>
 /// <param name="noUpdate"></param>
 /// <returns></returns>
 /// <seealso cref="GetSlots(SlotFlags, bool)"/>
 /// <seealso cref="SlotFlags"/>
 public int GetCount(SlotFlags flags, bool noUpdate = false)
 {
     return(GetSlots(flags, noUpdate).Count);
 }
コード例 #25
0
 public Rv C_WaitForSlotEvent(SlotFlags flags, ref UInt32 pSlot, ref IntPtr pReserved)
 {
     return(Rv.FUNCTION_NOT_SUPPORTED);
 }
コード例 #26
0
 public void Add(JSVariable key, SlotFlags flags)
 {
     this[key] = flags;
 }
コード例 #27
0
 public BarrierSlot(string name, SlotFlags flags)
 {
     Name  = name;
     Flags = flags;
 }
コード例 #28
0
 public virtual void Read(PackFileDeserializer des, BinaryReaderEx br)
 {
     m_flags  = (SlotFlags)br.ReadByte();
     m_stride = br.ReadByte();
 }
コード例 #29
0
ファイル: Scope.cs プロジェクト: yuva2achieve/SharpDevelop
 public bool IsSet(SlotFlags flag)
 {
     return((Flags & flag) != 0);
 }
コード例 #30
0
        /// <summary>
        /// Gets slots in the game.
        /// </summary>
        /// <param name="flags">Flags for obtaining slots.</param>
        /// <param name="noUpdate"></param>
        /// <returns>Returns a list of slots following <paramref name="flags"/>.</returns>
        /// <example>
        /// The code below will write all blue players that are not AI to the console.
        /// <code>
        /// CustomGame cg = new CustomGame();
        ///
        /// List&lt;int&gt; bluePlayerSlots = cg.GetSlots(SlotFlags.Blue | SlotFlags.NoAI);
        ///
        /// Console.WriteLine(string.Join(", ", bluePlayerSlots));
        /// </code>
        /// The code below will write all AI queueing for red to the console.
        /// <code>
        /// CustomGame cg = new CustomGame();
        ///
        /// List&lt;int&gt; redQueueAISlots = cg.GetSlots(SlotFlags.NoPlayers | SlotFlags.RedQueue);
        ///
        /// Console.WriteLine(string.Join(", ", redQueueAISlots));
        /// </code>
        /// </example>
        /// <seealso cref="GetCount(SlotFlags, bool)"/>
        /// <seealso cref="SlotFlags"/>
        public List <int> GetSlots(SlotFlags flags, bool noUpdate = false)
        {
            using (LockHandler.Passive)
            {
                List <int> slots = new List <int>();

                if (!noUpdate)
                {
                    UpdateScreen();
                }

                // Add the blue slots
                if (flags.HasFlag(SlotFlags.Blue))
                {
                    slots.AddRange(CheckRange(BlueMin, BlueMax, 0, true));
                }

                // Add the red slots
                if (flags.HasFlag(SlotFlags.Red))
                {
                    slots.AddRange(CheckRange(RedMin, RedMax, 0, true));
                }

                // Add the spectator slots
                if (flags.HasFlag(SlotFlags.Spectators))
                {
                    slots.AddRange(CheckRange(SpectatorMin, SpectatorMax, FindSpectatorOffset(true), true));
                }

                // Add the queue slots
                if (flags.HasFlag(SlotFlags.NeutralQueue) || flags.HasFlag(SlotFlags.RedQueue) || flags.HasFlag(SlotFlags.BlueQueue))
                {
                    slots.AddRange(CheckRange(QueueMin, QueueMax, 0, true).Where((slot) =>
                    {
                        QueueTeam team = PlayerInfo.GetQueueTeam(slot, true);

                        return(team == QueueTeam.Neutral && flags.HasFlag(SlotFlags.NeutralQueue) ||
                               team == QueueTeam.Blue && flags.HasFlag(SlotFlags.BlueQueue) ||
                               team == QueueTeam.Red && flags.HasFlag(SlotFlags.RedQueue));
                    }));
                }

                // Filter players/AI slots
                if (flags.HasFlag(SlotFlags.PlayersOnly) || flags.HasFlag(SlotFlags.AIOnly))
                {
                    List <int> aiSlots = AI.GetAISlots(false, true);

                    // Make the list AI only.
                    if (flags.HasFlag(SlotFlags.AIOnly))
                    {
                        slots = slots.Where(slot => aiSlots.Contains(slot)).ToList();
                    }
                    // Make the list players only.
                    if (flags.HasFlag(SlotFlags.PlayersOnly))
                    {
                        slots = slots.Where(slot => !aiSlots.Contains(slot)).ToList();
                    }
                }

                // Filter alive/dead slots
                if (flags.HasFlag(SlotFlags.DeadOnly) || flags.HasFlag(SlotFlags.AliveOnly))
                {
                    List <int> deadPlayers = PlayerInfo.GetDeadSlots(true);

                    // Make the list dead slots only.
                    if (flags.HasFlag(SlotFlags.DeadOnly))
                    {
                        slots = slots.Where(slot => deadPlayers.Contains(slot)).ToList();
                    }
                    // Make the list alive slots only.
                    if (flags.HasFlag(SlotFlags.AliveOnly))
                    {
                        slots = slots.Where(slot => !deadPlayers.Contains(slot)).ToList();
                    }
                }

                // Filter invited/ingame slots
                if (flags.HasFlag(SlotFlags.InvitedOnly) || flags.HasFlag(SlotFlags.IngameOnly))
                {
                    List <int> invited = GetInvitedSlots();

                    // Make the list invited slots only.
                    if (flags.HasFlag(SlotFlags.InvitedOnly))
                    {
                        slots = slots.Where(slot => invited.Contains(slot)).ToList();
                    }
                    // Make the list ingame slots only.
                    if (flags.HasFlag(SlotFlags.IngameOnly))
                    {
                        slots = slots.Where(slot => !invited.Contains(slot)).ToList();
                    }
                }

                return(slots);
            }
        }