// Successful hits a team
        public static bool HitTeam(GameEntityModel model, InclusionType teamInclusionType, int teamId, InclusionType typeInclusionType, int type)
        {
            GameEntityController controller = model.Controller() as GameEntityController;

            if (controller.lastHits.Count == 0)
            {
                return(false);
            }
            bool isValid = false;

            // Check team
            foreach (HitInformation hit in controller.lastHits)
            {
                if (InclusionCheck(teamInclusionType, WorldUtils.GetEntityTeam(hit.entityId), teamId, out isValid))
                {
                    break;
                }
            }
            if (!isValid)
            {
                return(false);
            }

            // Check type
            foreach (HitInformation hit in controller.lastHits)
            {
                if (InclusionCheck(typeInclusionType, (int)hit.hitData.type, type, out isValid))
                {
                    break;
                }
            }
            return(isValid);
        }
Exemplo n.º 2
0
        public static IMaybe <(Block, int)> GetBlock(string source, int index, bool advanceTabs,
                                                     InclusionType inclusion = InclusionType.Classes, bool compileAll = false)
        {
            if (advanceTabs)
            {
                AdvanceTabs();
            }

            var whenUnlessParser = new WhenUnlessParser();
            var statementParser  = new StatementParser {
                Inclusions = inclusion
            };
            var block      = new Block();
            var continuing = true;

            while (continuing && index < source.Length)
            {
                continuing = false;
                foreach (var parserResult in statementParser.Parsers
                         .Where(parser => parser.Scan(source, index))
                         .Select(parser => parser.Result))
                {
                    whenUnlessParser.OtherVerb = parserResult.Verb;
                    if (whenUnlessParser.Scan(source, parserResult.Position))
                    {
                        block.Add(whenUnlessParser.Verb);
                        index = whenUnlessParser.Position;
                    }
                    else
                    {
                        block.Add(parserResult.Verb);
                        index = parserResult.Position;
                    }
                    continuing = true;
                    break;
                }

                if (continuing && index < source.Length)
                {
                    var endParser = new EndParser();
                    if (endParser.Scan(source, index))
                    {
                        index = endParser.Position;
                    }
                }
            }

            if (compileAll)
            {
                Assert(index >= source.Length, "Compilation", $"Didn't understand {source.Skip(index)}");
            }

            if (advanceTabs)
            {
                RegressTabs();
            }

            return(when(block.Count > 0, () => (block, index)));
        }
Exemplo n.º 3
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Name = {(Name == null ? "null" : Name == string.Empty ? "" : Name)}");
     toStringOutput.Add($"CalculationPhase = {(CalculationPhase == null ? "null" : CalculationPhase.ToString())}");
     toStringOutput.Add($"InclusionType = {(InclusionType == null ? "null" : InclusionType.ToString())}");
     toStringOutput.Add($"Percentage = {(Percentage == null ? "null" : Percentage == string.Empty ? "" : Percentage)}");
     toStringOutput.Add($"AppliesToCustomAmounts = {(AppliesToCustomAmounts == null ? "null" : AppliesToCustomAmounts.ToString())}");
     toStringOutput.Add($"Enabled = {(Enabled == null ? "null" : Enabled.ToString())}");
 }
Exemplo n.º 4
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Errors = {(Errors == null ? "null" : $"[{ string.Join(", ", Errors)} ]")}");
     toStringOutput.Add($"Name = {(Name == null ? "null" : Name == string.Empty ? "" : Name)}");
     toStringOutput.Add($"AppliedMoney = {(AppliedMoney == null ? "null" : AppliedMoney.ToString())}");
     toStringOutput.Add($"Rate = {(Rate == null ? "null" : Rate == string.Empty ? "" : Rate)}");
     toStringOutput.Add($"InclusionType = {(InclusionType == null ? "null" : InclusionType.ToString())}");
     toStringOutput.Add($"FeeId = {(FeeId == null ? "null" : FeeId == string.Empty ? "" : FeeId)}");
 }
        private void AddInclusion(InclusionType type, int size)
        {
            var seed = GetSeedForInclusion();

            if (type == InclusionType.Circle)
            {
                GrowCircleInclusion(seed, size);
            }
            else if (type == InclusionType.Square)
            {
                GrowSquareInclusion(seed, size);
            }
        }
        // Generic entity-entity collision with team check
        public static bool IsCollidingWithTeam(GameEntityModel model, InclusionType teamInclusionType, int teamId)
        {
            GameEntityController controller = model.Controller() as GameEntityController;

            if (controller.lastCollisionEntityId == ModelReference.InvalidModelIndex)
            {
                return(false);
            }
            bool isValid;

            InclusionCheck(teamInclusionType, WorldUtils.GetEntityTeam(controller.lastCollisionEntityId), teamId, out isValid);
            return(isValid);
        }
Exemplo n.º 7
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CatalogTax other &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((CalculationPhase == null && other.CalculationPhase == null) || (CalculationPhase?.Equals(other.CalculationPhase) == true)) &&
                   ((InclusionType == null && other.InclusionType == null) || (InclusionType?.Equals(other.InclusionType) == true)) &&
                   ((Percentage == null && other.Percentage == null) || (Percentage?.Equals(other.Percentage) == true)) &&
                   ((AppliesToCustomAmounts == null && other.AppliesToCustomAmounts == null) || (AppliesToCustomAmounts?.Equals(other.AppliesToCustomAmounts) == true)) &&
                   ((Enabled == null && other.Enabled == null) || (Enabled?.Equals(other.Enabled) == true)));
        }
Exemplo n.º 8
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is V1PaymentTax other &&
                   ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)) &&
                   ((Name == null && other.Name == null) || (Name?.Equals(other.Name) == true)) &&
                   ((AppliedMoney == null && other.AppliedMoney == null) || (AppliedMoney?.Equals(other.AppliedMoney) == true)) &&
                   ((Rate == null && other.Rate == null) || (Rate?.Equals(other.Rate) == true)) &&
                   ((InclusionType == null && other.InclusionType == null) || (InclusionType?.Equals(other.InclusionType) == true)) &&
                   ((FeeId == null && other.FeeId == null) || (FeeId?.Equals(other.FeeId) == true)));
        }
        // Return true if cycle must stop, output variable does the comparison and must be used as result
        private static bool InclusionCheck(InclusionType inclusionType, int original, int other, out bool inclusion)
        {
            switch (inclusionType)
            {
            case InclusionType.none: {
                inclusion = true;
                return(true);
            }

            case InclusionType.contains: {
                inclusion = original == other;
                if (inclusion)
                {
                    return(true);
                }
            } break;

            case InclusionType.except: {
                inclusion = original != other;
                if (!inclusion)
                {
                    return(true);
                }
            } break;

            case InclusionType.only: {
                inclusion = original == other;
                if (!inclusion)
                {
                    return(true);
                }
            } break;

            default: {
                inclusion = false;
                break;
            }
            }
            return(false);
        }
Exemplo n.º 10
0
        public override int GetHashCode()
        {
            int hashCode = 29476180;

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (CalculationPhase != null)
            {
                hashCode += CalculationPhase.GetHashCode();
            }

            if (InclusionType != null)
            {
                hashCode += InclusionType.GetHashCode();
            }

            if (Percentage != null)
            {
                hashCode += Percentage.GetHashCode();
            }

            if (AppliesToCustomAmounts != null)
            {
                hashCode += AppliesToCustomAmounts.GetHashCode();
            }

            if (Enabled != null)
            {
                hashCode += Enabled.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 11
0
        public override int GetHashCode()
        {
            int hashCode = 2123751229;

            if (Errors != null)
            {
                hashCode += Errors.GetHashCode();
            }

            if (Name != null)
            {
                hashCode += Name.GetHashCode();
            }

            if (AppliedMoney != null)
            {
                hashCode += AppliedMoney.GetHashCode();
            }

            if (Rate != null)
            {
                hashCode += Rate.GetHashCode();
            }

            if (InclusionType != null)
            {
                hashCode += InclusionType.GetHashCode();
            }

            if (FeeId != null)
            {
                hashCode += FeeId.GetHashCode();
            }

            return(hashCode);
        }
Exemplo n.º 12
0
 public InclusionTypeData(InclusionType type, string name)
 {
     Type = type;
     Name = name;
 }
Exemplo n.º 13
0
        private static IReadOnlyCollection <string> GetPaths(IEnumerable <SearchPath> searchPaths, InclusionType inclusionType)
        {
            var paths = searchPaths
                        .Where(searchPath => searchPath.PathInclusionType == inclusionType)
                        .Select(searchPath => searchPath.Path)
                        .ToList();

            paths.RemoveAll(path1 => paths.Any(path2 => !ReferenceEquals(path1, path2) && path1.StartsWith(path2, StringComparison.OrdinalIgnoreCase)));

            return(paths);
        }