Exemple #1
0
        public static bool HasWire(this Tile tile, WireColor color = WireColor.None)
        {
            if (color == WireColor.None)
            return tile.wire() || tile.wire2() || tile.wire3();
              if (color == WireColor.Red)
            return tile.wire();
              if (color == WireColor.Blue)
            return tile.wire2();
              if (color == WireColor.Green)
            return tile.wire3();

              return false;
        }
 public RootBranchProcessData(DPoint senderLocation, DPoint firstWireLocation, SignalType signal, WireColor wireColor) {
   this.SenderLocation = senderLocation;
   this.FirstWireLocation = firstWireLocation;
   this.LastWireLocation = firstWireLocation;
   this.WireColor = wireColor;
   this.Direction = AdvancedCircuits.DirectionFromTileLocations(senderLocation, firstWireLocation);
   this.Signal = signal;
   this.SignaledComponentLocations = new List<DPoint>();
   this.BlockActivator = null;
   this.BlockActivatorLocation = DPoint.Empty;
   this.BlockActivatorDeactivatedBlockCounter = 0;
   this.BlockActivatorMode = BlockActivatorMode.Default;
 }
 public static string Name(this WireColor color)
 {
     return(Loc.GetString(color switch
     {
         WireColor.Red => "Red",
         WireColor.Blue => "Blue",
         WireColor.Green => "Green",
         WireColor.Orange => "Orange",
         WireColor.Brown => "Brown",
         WireColor.Gold => "Gold",
         WireColor.Gray => "Gray",
         WireColor.Cyan => "Cyan",
         WireColor.Navy => "Navy",
         WireColor.Purple => "Purple",
         WireColor.Pink => "Pink",
         WireColor.Fuchsia => "Fuchsia",
         _ => throw new InvalidOperationException()
     }));
        public static bool HasWire(this Tile tile, WireColor color = WireColor.None)
        {
            if (color == WireColor.None)
            {
                return(tile.wire() || tile.wire2() || tile.wire3());
            }
            if (color == WireColor.Red)
            {
                return(tile.wire());
            }
            if (color == WireColor.Blue)
            {
                return(tile.wire2());
            }
            if (color == WireColor.Green)
            {
                return(tile.wire3());
            }

            return(false);
        }
    private static string colorSvg(WireColor color)
    {
        switch (color)
        {
        case WireColor.Black: return("#34322D");

        case WireColor.Blue: return("#2B8DFF");

        case WireColor.Green: return("#1EE41F");

        case WireColor.Orange: return("#FFA600");

        case WireColor.Purple: return("#BB3AFF");

        case WireColor.Red: return("#FF3A3A");

        case WireColor.White: return("#E1E1E1");

        case WireColor.Yellow: return("#DADB35");
        }
        return("#f8f");
    }
Exemple #6
0
        public static bool HasWire(this ITile tile, WireColor color = WireColor.None)
        {
            if (color == WireColor.None)
            {
                return(tile.wire() || tile.wire2() || tile.wire3() /* || tile.wire4()*/);
            }
            if (color == WireColor.Red)
            {
                return(tile.wire());
            }
            if (color == WireColor.Blue)
            {
                return(tile.wire2());
            }
            if (color == WireColor.Green)
            {
                return(tile.wire3());
            }
            //if (color == WireColor.Yellow)
            //  return tile.wire4();

            return(false);
        }
Exemple #7
0
        public bool ShouldBeSnipped(WireColor color, int number, int to)
        {
            IList <int>[] array;
            switch (color)
            {
            case WireColor.black:
                array = this.blackWiresToSnip;
                goto IL_3B;

            case WireColor.blue:
                array = this.blueWiresToSnip;
                goto IL_3B;
            }
            array = this.redWiresToSnip;
IL_3B:
            bool result = false;

            if (number < array.Length && array[number].Contains(to))
            {
                result = true;
            }
            return(result);
        }
Exemple #8
0
    /**
     * This method spawns the edges corresponding to the DFA that was generated
     *
     * @param parent
     *
     * @param child
     *
     * @param color
     *
     * @param colorName
     */
    public DFAEdge SpawnEdge(DFANode parent, DFANode child, WireColor wireColor)
    {
        var newObj = Instantiate(this.dfaEdgePrefab, canvas.transform);
        var edge   = newObj.GetComponent <DFAEdge>();

        edge.parent = parent;
        edge.child  = child;
        edge.SetColor(wireColor);

        parent.edges.Add(edge);
        child.edges.Add(edge);

        var parentPos = parent.gameObject.transform.localPosition;
        var childPos  = child.gameObject.transform.localPosition;

        var edgeRectTrans = newObj.GetComponent <RectTransform>();

        edgeRectTrans.sizeDelta = new Vector2(Vector3.Distance(parentPos, childPos), 60);

        edge.transform.rotation      = Quaternion.Euler(90, 0, Vector3.SignedAngle(parentPos - childPos, parent.gameObject.transform.right, -parent.gameObject.transform.forward));
        edge.transform.localPosition = (parentPos + childPos) / 2;
        allEdges.Add(edge);
        return(edge);
    }
        protected override AbstractRuleSet CreateRules(bool useDefault)
        {
            WireRuleSet     wireRuleSet         = new WireRuleSet();
            QuerySet        serialNumberQueries = QuerySet.GetSerialNumberQueries();
            QuerySet        wireQueries         = QuerySet.GetWireQueries();
            QuerySet        portQueries         = QueryablePorts.GetPortQueries();
            List <QuerySet> list = new List <QuerySet>();

            for (int i = WireSetComponent.MIN_WIRES; i <= WireSetComponent.MAX_WIRES; i++)
            {
                List <Rule> list2 = new List <Rule>();
                list.Clear();
                list.Add(serialNumberQueries);
                list.Add(wireQueries);
                if (CommonReflectedTypeInfo.IsModdedSeed)
                {
                    list.Add(portQueries);
                }
                this.queryPropertyWeights.Clear();
                this.solutionWeights.Clear();
                int numRules = GetNumRules();
                for (int j = 0; j < numRules; j++)
                {
                    List <WireColor> listOfWireColors = RuleUtil.GetListOfWireColors();
                    Rule             rule             = new Rule();
                    int numQueriesForRule             = GetNumQueriesForRule();
                    List <WireColor> list3            = new List <WireColor>();
                    int num = i - 1;
                    for (int k = 0; k < numQueriesForRule; k++)
                    {
                        bool compoundQueriesAllowed = k > 0;
                        List <QueryableProperty> possibleQueryableProperties = this.CalculatePossibleQueryableProperties(list, num, compoundQueriesAllowed);
                        QueryableProperty        queryableProperty           = SelectQueryableProperty(possibleQueryableProperties);
                        Query query = new Query();
                        query.Property = queryableProperty;
                        if (queryableProperty is QueryableWireProperty)
                        {
                            QueryableWireProperty queryableWireProperty = (QueryableWireProperty)queryableProperty;
                            num -= queryableWireProperty.WiresInvolvedInQuery;
                            if (queryableWireProperty.UsesColor)
                            {
                                WireColor wireColor = listOfWireColors[this.rand.Next(0, listOfWireColors.Count)];
                                listOfWireColors.Remove(wireColor);
                                query.Args.Add("color", wireColor);
                                if (queryableWireProperty.ColorAvailableForSolution)
                                {
                                    list3.Add(wireColor);
                                }
                            }
                        }
                        rule.Queries.Add(query);
                    }
                    List <Solution> possibleSolutions = this.CalculatePossibleSolutions(i, rule);
                    Solution        solution          = SelectSolution(possibleSolutions);
                    rule.Solution = solution;
                    if (list3.Count > 0)
                    {
                        rule.SolutionArgs.Add("color", list3[this.rand.Next(0, list3.Count)]);
                    }
                    if (CommonReflectedTypeInfo.IsVanillaSeed || IsWireQueryValid(rule))
                    {
                        list2.Add(rule);
                    }
                    else
                    {
                        j--;    //Previous rule was never valid.
                    }
                }
                list2 = list2.OrderByDescending(x => x.Queries.Count).ToList();
                Rule  rule2  = new Rule();
                Query query2 = new Query();
                query2.Property = QueryableProperty.Otherwise;
                rule2.Queries.Add(query2);
                List <Solution> list4 = this.CalculatePossibleSolutions(i, rule2);
                if (CommonReflectedTypeInfo.IsModdedSeed)
                {
                    list4.Remove(list2.Last().Solution);    //Enforce no redundant rules.
                }
                rule2.Solution = list4[this.rand.Next(0, list4.Count)];
                list2.Add(rule2);
                wireRuleSet.RulesDictionary[i] = list2;
            }
            return(wireRuleSet);
        }
Exemple #10
0
 public WireData(WireLetter letter, WireColor color, int position)
 {
     Letter   = letter;
     Color    = color;
     Position = position;
 }
 public void TestColorValueExists([ValueSource(nameof(ColorValues))] WireColor color)
 {
     Assert.DoesNotThrow(() => color.ColorValue());
 }
Exemple #12
0
 public RootBranchProcessData(DPoint senderLocation, DPoint firstWireLocation, SignalType signal, WireColor wireColor)
 {
     this.SenderLocation                        = senderLocation;
     this.FirstWireLocation                     = firstWireLocation;
     this.LastWireLocation                      = firstWireLocation;
     this.WireColor                             = wireColor;
     this.Direction                             = AdvancedCircuits.DirectionFromTileLocations(senderLocation, firstWireLocation);
     this.Signal                                = signal;
     this.SignaledComponentLocations            = new List <DPoint>();
     this.BlockActivator                        = null;
     this.BlockActivatorLocation                = DPoint.Empty;
     this.BlockActivatorDeactivatedBlockCounter = 0;
     this.BlockActivatorMode                    = BlockActivatorMode.Default;
 }
 public bool IsObjectWired(ObjectMeasureData measureData, WireColor wireColor = WireColor.None)
 {
     DPoint dummy;
       return this.IsObjectWired(measureData, wireColor, out dummy);
 }
 public bool IsObjectWired(DPoint originTileLocation, DPoint size, WireColor wireColor = WireColor.None)
 {
     DPoint dummy;
       return this.IsObjectWired(originTileLocation, size, out dummy);
 }
        public bool IsObjectWired(ObjectMeasureData measureData, WireColor wireColor, out DPoint firstWireLocation)
        {
            foreach (DPoint tileLocation in this.EnumerateObjectTileLocations(measureData)) {
            Tile tile = TerrariaUtils.Tiles[tileLocation];
            if (tile.HasWire(wireColor)) {
              firstWireLocation = tileLocation;
              return true;
            }
              }

              firstWireLocation = DPoint.Empty;
              return false;
        }
Exemple #16
0
 public bool IsObjectWired(DPoint originTileLocation, DPoint size, WireColor wireColor = WireColor.None) {
   DPoint dummy;
   return this.IsObjectWired(originTileLocation, size, out dummy);
 }
Exemple #17
0
 public bool IsObjectWired(ObjectMeasureData measureData, WireColor wireColor = WireColor.None) {
   DPoint dummy;
   return this.IsObjectWired(measureData, wireColor, out dummy);
 }
Exemple #18
0
 public int GetColorCount(WireColor color)
 {
     return(wires.Count(x => x == color));
 }
Exemple #19
0
 public int GetLastIndexOfColor(WireColor color)
 {
     return(wires.LastIndexOf(color));
 }