System.Collections.Generic.HashSet.Contains(UnitEntityData)

Here are the examples of the csharp api System.Collections.Generic.HashSet.Contains(UnitEntityData) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

19 Source : CombatController.cs
with MIT License
from hsinyuhcan

private void HandleCombatStart(bool isPartyCombatStateChanged)
        {
            Clear();

            _units.AddRange(Game.Instance.State.Units.Where(unit => unit.IsInCombat));
            _isUnitsChanged = true;

            // surprise round
            if (isPartyCombatStateChanged && SurpriseRound)
            {
                HashSet<UnitEnreplacedyData> playerUnits = new HashSet<UnitEnreplacedyData>(Game.Instance.Player.ControllableCharacters);
                int notAppearUnitsCount = 0;
                bool isInitiatedByPlayer = _units.Any(unit => playerUnits.Contains(unit) && unit.HasOffensiveCommand());

                // try to join units to the surprise round
                foreach (UnitEnreplacedyData unit in _units)
                {
                    if (unit.Descriptor.HasFact(BlueprintRoot.Instance.SystemMechanics.SummonedUnitAppearBuff))
                        // this unit is just summoned by a full round spell and technically it does not exist on combat start
                        notAppearUnitsCount++;
                    else if (unit.IsSummoned(out UnitEnreplacedyData caster) && _unitsToSurprise.Contains(caster))
                        // this summoned unit will act after its caster's turn
                        _unitsToSurprise.Add(unit);
                    else if (
                        // player
                        playerUnits.Contains(unit) ?
                        isInitiatedByPlayer && unit.IsUnseen() :
                        // enemy
                        unit.Group.IsEnemy(Game.Instance.Player.Group) ?
                        unit.HasOffensiveCommand(command => playerUnits.Contains(command.TargetUnit)) ||
                        (unit.IsUnseen() && !unit.IsVisibleForPlayer) :
                        // neutral
                        unit.IsUnseen())
                        // this unit will act on its initiative
                        _unitsToSurprise.Add(unit);
                }

                // determine whether the surprise round occurs 
                if (_unitsToSurprise.Count > 0)
                {
                    if (_unitsToSurprise.Count < _units.Count - notAppearUnitsCount)
                        _hreplacedurpriseRound = true;
                    else
                        _unitsToSurprise.Clear();
                }
            }

            RoundNumber = _hreplacedurpriseRound ? 0 : 1;
            TimeToNextRound = 6f;
            LogRound();

            Initialized = true;
        }

19 Source : CombatController.cs
with MIT License
from hsinyuhcan

private void HandleCombatStart(bool isPartyCombatStateChanged)
        {
            Clear();

            _units.AddRange(Game.Instance.State.Units.Where(unit => unit.IsInCombat));
            _isUnitsChanged = true;

            // surprise round
            if (isPartyCombatStateChanged && SurpriseRound)
            {
                HashSet<UnitEnreplacedyData> playerUnits = new HashSet<UnitEnreplacedyData>(Game.Instance.Player.ControllableCharacters);
                int notAppearUnitsCount = 0;
                bool isInitiatedByPlayer = _units.Any(unit => playerUnits.Contains(unit) && unit.HasOffensiveCommand());

                // try to join units to the surprise round
                foreach (UnitEnreplacedyData unit in _units)
                {
                    if (unit.Descriptor.HasFact(BlueprintRoot.Instance.SystemMechanics.SummonedUnitAppearBuff))
                        // this unit is just summoned by a full round spell and technically it does not exist on combat start
                        notAppearUnitsCount++;
                    else if (unit.IsSummoned(out UnitEnreplacedyData caster) && _unitsToSurprise.Contains(caster))
                        // this summoned unit will act after its caster's turn
                        _unitsToSurprise.Add(unit);
                    else if (
                        // player
                        playerUnits.Contains(unit) ?
                        isInitiatedByPlayer && unit.IsUnseen() :
                        // enemy
                        unit.Group.IsEnemy(Game.Instance.Player.Group) ?
                        unit.HasOffensiveCommand(command => playerUnits.Contains(command.TargetUnit)) ||
                        (unit.IsUnseen() && !unit.IsVisibleForPlayer) :
                        // neutral
                        unit.IsUnseen())
                        // this unit will act on its initiative
                        _unitsToSurprise.Add(unit);
                }

                // determine whether the surprise round occurs 
                if (_unitsToSurprise.Count > 0)
                {
                    if (_unitsToSurprise.Count < _units.Count - notAppearUnitsCount)
                        _hreplacedurpriseRound = true;
                    else
                        _unitsToSurprise.Clear();
                }
            }

            RoundNumber = _hreplacedurpriseRound ? 0 : 1;
            TimeToNextRound = 6f;
            LogRound();

            Initialized = true;
        }

19 Source : CombatController.cs
with MIT License
from hsinyuhcan

public void HandleUnitRollsInitiative(RuleInitiativeRoll rule)
        {
            UnitEnreplacedyData unit = rule.Initiator;
            UnitCombatState.Cooldowns cooldown = unit.CombatState.Cooldown;
            if (TimeSinceStart == 0f)
            {
                // it's the beginning of combat
                if (unit.IsSummoned(out UnitEnreplacedyData caster) && _units.Contains(caster))
                {
                    // this unit is summoned before the combat, it will act right after its caster
                    cooldown.Initiative = caster.CombatState.Cooldown.Initiative;
                }
                else if (_hreplacedurpriseRound && !_unitsToSurprise.Contains(unit))
                {
                    // this unit is surprised, it will be flat-footed for one more round
                    cooldown.Initiative += 6f;
                }

                _unitsToSurprise.Remove(unit);
            }
            else
            {
                // it's the middle of combat
                if (unit.IsSummoned(out UnitEnreplacedyData caster) && _units.Contains(caster))
                {
                    // summoned units can act instantly, it's delay is controlled by its buff
                    cooldown.Initiative = 0f;

                    // ensure its order is right after its caster
                    RemoveUnit(unit);
                    InsertUnit(unit, caster);
                }
                else
                {
                    if (_hreplacedurpriseRound && TimeSinceStart < 6f)
                    {
                        // units that join during surprise round will be regard as surprised
                        cooldown.Initiative = 6f;
                    }
                    else
                    {
                        // units that join during regular round have to wait for one round
                        cooldown.Initiative = 0f;
                        cooldown.StandardAction = 6f;
                    }
                }
            }
        }