Ejemplo n.º 1
0
        public void OnBeforeSerialize()
        {
            if (modifierDatas == null)
            {
                modifierDatas = new List <ModifierData>();
            }
            else
            {
                modifierDatas.Clear();
            }

            if (modifiers != null)
            {
                foreach (var modifier in modifiers)
                {
                    var modifierData = new ModifierData();
                    var objects      = modifier.GetObjects();

                    modifierData.typeName = modifier.GetType().FullName;
                    modifierData.jsonData = JsonUtility.ToJson(modifier);
                    modifierData.objects  = objects != null?objects.ToArray() : null;

                    modifierDatas.Add(modifierData);
                }
            }
        }
Ejemplo n.º 2
0
        public static void UpdateWithNull()
        {
            var data  = new ModifierData();
            var style = new CSharpPreferredModifierOrderStyle(data);

            Assert.That(() => style.Update(null !), Throws.TypeOf <ArgumentNullException>(), nameof(style.Update));
        }
Ejemplo n.º 3
0
        public override void Apply(Path p, ModifierData source)
        {
            if (p.vectorPath == null)
            {
                Debug.LogWarning("Can't process NULL path (has another modifier logged an error?)");
                return;
            }
            List <Vector3> list = null;

            switch (this.smoothType)
            {
            case SimpleSmoothModifier.SmoothType.Simple:
                list = this.SmoothSimple(p.vectorPath);
                break;

            case SimpleSmoothModifier.SmoothType.Bezier:
                list = this.SmoothBezier(p.vectorPath);
                break;

            case SimpleSmoothModifier.SmoothType.OffsetSimple:
                list = this.SmoothOffsetSimple(p.vectorPath);
                break;

            case SimpleSmoothModifier.SmoothType.CurvedNonuniform:
                list = this.CurvedNonuniform(p.vectorPath);
                break;
            }
            if (list != p.vectorPath)
            {
                ListPool <Vector3> .Release(p.vectorPath);

                p.vectorPath = list;
            }
        }
Ejemplo n.º 4
0
        public override void Apply(Path p, ModifierData source)
        {
            List <GraphNode> path       = p.path;
            List <Vector3>   vectorPath = p.vectorPath;

            if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count)
            {
                return;
            }

            List <Vector3> funnelPath = ListPool <Vector3> .Claim();

            // Claim temporary lists and try to find lists with a high capacity
            List <Vector3> left = ListPool <Vector3> .Claim(path.Count + 1);

            List <Vector3> right = ListPool <Vector3> .Claim(path.Count + 1);

            AstarProfiler.StartProfile("Construct Funnel");

            // Add start point
            left.Add(vectorPath[0]);
            right.Add(vectorPath[0]);

            // Loop through all nodes in the path (except the last one)
            for (int i = 0; i < path.Count - 1; i++)
            {
                // Get the portal between path[i] and path[i+1] and add it to the left and right lists
                bool portalWasAdded = path[i].GetPortal(path[i + 1], left, right, false);

                if (!portalWasAdded)
                {
                    // Fallback, just use the positions of the nodes
                    left.Add((Vector3)path[i].position);
                    right.Add((Vector3)path[i].position);

                    left.Add((Vector3)path[i + 1].position);
                    right.Add((Vector3)path[i + 1].position);
                }
            }

            // Add end point
            left.Add(vectorPath[vectorPath.Count - 1]);
            right.Add(vectorPath[vectorPath.Count - 1]);

            if (!RunFunnel(left, right, funnelPath))
            {
                // If funnel algorithm failed, degrade to simple line
                funnelPath.Add(vectorPath[0]);
                funnelPath.Add(vectorPath[vectorPath.Count - 1]);
            }

            // Release lists back to the pool
            ListPool <Vector3> .Release(p.vectorPath);

            p.vectorPath = funnelPath;

            ListPool <Vector3> .Release(left);

            ListPool <Vector3> .Release(right);
        }
Ejemplo n.º 5
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Type = {(Type == null ? "null" : Type.ToString())}");
     toStringOutput.Add($"Id = {(Id == null ? "null" : Id == string.Empty ? "" : Id)}");
     toStringOutput.Add($"UpdatedAt = {(UpdatedAt == null ? "null" : UpdatedAt == string.Empty ? "" : UpdatedAt)}");
     toStringOutput.Add($"Version = {(Version == null ? "null" : Version.ToString())}");
     toStringOutput.Add($"IsDeleted = {(IsDeleted == null ? "null" : IsDeleted.ToString())}");
     toStringOutput.Add($"CustomAttributeValues = {(CustomAttributeValues == null ? "null" : CustomAttributeValues.ToString())}");
     toStringOutput.Add($"CatalogV1Ids = {(CatalogV1Ids == null ? "null" : $"[{ string.Join(", ", CatalogV1Ids)} ]")}");
     toStringOutput.Add($"PresentAtAllLocations = {(PresentAtAllLocations == null ? "null" : PresentAtAllLocations.ToString())}");
     toStringOutput.Add($"PresentAtLocationIds = {(PresentAtLocationIds == null ? "null" : $"[{ string.Join(", ", PresentAtLocationIds)} ]")}");
     toStringOutput.Add($"AbsentAtLocationIds = {(AbsentAtLocationIds == null ? "null" : $"[{ string.Join(", ", AbsentAtLocationIds)} ]")}");
     toStringOutput.Add($"ImageId = {(ImageId == null ? "null" : ImageId == string.Empty ? "" : ImageId)}");
     toStringOutput.Add($"ItemData = {(ItemData == null ? "null" : ItemData.ToString())}");
     toStringOutput.Add($"CategoryData = {(CategoryData == null ? "null" : CategoryData.ToString())}");
     toStringOutput.Add($"ItemVariationData = {(ItemVariationData == null ? "null" : ItemVariationData.ToString())}");
     toStringOutput.Add($"TaxData = {(TaxData == null ? "null" : TaxData.ToString())}");
     toStringOutput.Add($"DiscountData = {(DiscountData == null ? "null" : DiscountData.ToString())}");
     toStringOutput.Add($"ModifierListData = {(ModifierListData == null ? "null" : ModifierListData.ToString())}");
     toStringOutput.Add($"ModifierData = {(ModifierData == null ? "null" : ModifierData.ToString())}");
     toStringOutput.Add($"TimePeriodData = {(TimePeriodData == null ? "null" : TimePeriodData.ToString())}");
     toStringOutput.Add($"ProductSetData = {(ProductSetData == null ? "null" : ProductSetData.ToString())}");
     toStringOutput.Add($"PricingRuleData = {(PricingRuleData == null ? "null" : PricingRuleData.ToString())}");
     toStringOutput.Add($"ImageData = {(ImageData == null ? "null" : ImageData.ToString())}");
     toStringOutput.Add($"MeasurementUnitData = {(MeasurementUnitData == null ? "null" : MeasurementUnitData.ToString())}");
     toStringOutput.Add($"SubscriptionPlanData = {(SubscriptionPlanData == null ? "null" : SubscriptionPlanData.ToString())}");
     toStringOutput.Add($"ItemOptionData = {(ItemOptionData == null ? "null" : ItemOptionData.ToString())}");
     toStringOutput.Add($"ItemOptionValueData = {(ItemOptionValueData == null ? "null" : ItemOptionValueData.ToString())}");
     toStringOutput.Add($"CustomAttributeDefinitionData = {(CustomAttributeDefinitionData == null ? "null" : CustomAttributeDefinitionData.ToString())}");
     toStringOutput.Add($"QuickAmountsSettingsData = {(QuickAmountsSettingsData == null ? "null" : QuickAmountsSettingsData.ToString())}");
 }
    public override void Apply(Path p, ModifierData source)
    {
        //This should never trigger unless some other modifier has messed stuff up
        if (p.vectorPath == null)
        {
            Debug.LogWarning("Can't process NULL path (has another modifier logged an error?)");
            return;
        }

        Vector3[] path = p.vectorPath;

        switch (smoothType)
        {
        case SmoothType.Simple:
            p.vectorPath = SmoothSimple(path); break;

        case SmoothType.Bezier:
            p.vectorPath = SmoothBezier(path); break;

        case SmoothType.OffsetSimple:
            p.vectorPath = SmoothOffsetSimple(path); break;

        case SmoothType.CurvedNonuniform:
            p.vectorPath = CurvedNonuniform(path); break;
        }
    }
Ejemplo n.º 7
0
        public override void Apply(Path p, ModifierData source)
        {
            //This should never trigger unless some other modifier has messed stuff up
            if (p.vectorPath == null)
            {
                Debug.LogWarning("Can't process NULL path (has another modifier logged an error?)");
                return;
            }

            List <Vector3> path = null;

            switch (smoothType)
            {
            case SmoothType.Simple:
                path = SmoothSimple(p.vectorPath); break;

            case SmoothType.Bezier:
                path = SmoothBezier(p.vectorPath); break;

            case SmoothType.OffsetSimple:
                path = SmoothOffsetSimple(p.vectorPath); break;

            case SmoothType.CurvedNonuniform:
                path = CurvedNonuniform(p.vectorPath); break;
            }

            if (path != p.vectorPath)
            {
                ListPool <Vector3> .Release(p.vectorPath);

                p.vectorPath = path;
            }
            //.vectorPath.Clear ();
            //p.vectorPath.AddRange (path);
        }
Ejemplo n.º 8
0
        /** Converts a path from \a input to \a output */
        public static ModifierData Convert(Path p, ModifierData input, ModifierData output)
        {
            //"Input" can not be converted to "output", log error
            if (!CanConvert(input, output))
            {
                Debug.LogError("Can't convert " + input + " to " + output);
                return(ModifierData.None);
            }

            //"Output" can take "input" with no change, return
            if (AnyBits(input, output))
            {
                return(input);
            }

            //If input is a node path, and output wants a vector array, convert the node array to a vector array
            if (AnyBits(input, ModifierData.Nodes) && AnyBits(output, ModifierData.Vector))
            {
                p.vectorPath = new Vector3[p.path.Length];
                for (int i = 0; i < p.vectorPath.Length; i++)
                {
                    p.vectorPath[i] = (Vector3)p.path[i].position;
                }

                //Return VectorPath and also StrictVectorPath if input has StrictNodePath set
                return(ModifierData.VectorPath | (AnyBits(input, ModifierData.StrictNodePath) ? ModifierData.StrictVectorPath : ModifierData.None));
            }

            Debug.LogError("This part should not be reached - Error in ModifierConverted\nInput: " + input + " (" + (int)input + ")\nOutput: " + output + " (" + (int)output + ")");
            return(ModifierData.None);
        }
Ejemplo n.º 9
0
    private static ModifierData ParseModifier(JsonData json, AbilityData abilityData)
    {
        var modifier = new ModifierData();

        //modifier.Name = json; json.key
        modifier.Duration      = GetFloatValue(json, "Duration");
        modifier.ThinkInterval = GetFloatValue(json, "ThinkInterval");
        modifier.IsDebuff      = GetBoolValue(json, "IsDebuff");
        modifier.IsBuff        = GetBoolValue(json, "IsBuff");
        modifier.Passive       = GetBoolValue(json, "Passive");
        modifier.IsHidden      = GetBoolValue(json, "IsHidden");
        modifier.IsPurgable    = GetBoolValue(json, "IsPurgable");
        // effect
        modifier.EffectName       = GetStringValue(json, "EffectName");
        modifier.EffectAttachType = GetEnumValue <ModifierEffectAttachType>(json, "EffectAttachType");
        // event
        modifier.ModifierEventMap = ParseModifierEvents(json, abilityData);
        // aura
        ParseModifierAura(json, abilityData, modifier);
        // ModifierProperties
        ParseModifierProperties(json, abilityData, modifier);
        // States
        ParseModifierStates(json, abilityData, modifier);

        return(modifier);
    }
Ejemplo n.º 10
0
    static void ApplyModifierToAttack(EntityData target, ModifierData modifier, EntityData attacker, ScenarioState gameState, Direction direction)
    {
        switch (modifier.modifierCategory)
        {
        // Cases account for modifiers that have some immediate impact (so far, all movement, of either attack target or attack source).
        // Default case handles modifiers that apply lasting buff/debuff.
        case ModifierCategory.Push:
            ApplyModifierToAttack_PushPull(target, modifier, attacker, gameState, ModifierCategory.Push);
            return;

        case ModifierCategory.Pull:
            ApplyModifierToAttack_PushPull(target, modifier, attacker, gameState, ModifierCategory.Pull);
            return;

        case ModifierCategory.Blowback:
            ApplyModifierToAttack_BlowbackFollowUp(modifier, attacker, gameState, direction, ModifierCategory.Blowback);
            return;

        case ModifierCategory.FollowUp:
            ApplyModifierToAttack_BlowbackFollowUp(modifier, attacker, gameState, direction, ModifierCategory.FollowUp);
            return;

        default:
            if (target.activeModifiers.Count >= Constants.MAX_MODIFIERS)
            {
                return;
            }
            target.activeModifiers.Add(Object.Instantiate(modifier));
            return;
        }
    }
Ejemplo n.º 11
0
        /** Returns All data types \a a can be converted to */
        public static ModifierData CanConvertTo(ModifierData a)
        {
            if (a == ModifierData.All)
            {
                return(ModifierData.All);
            }

            ModifierData result = a;

            if (AnyBits(a, ModifierData.Nodes))
            {
                result |= ModifierData.VectorPath;
            }

            if (AnyBits(a, ModifierData.StrictNodePath))
            {
                result |= ModifierData.StrictVectorPath;
            }

            if (AnyBits(a, ModifierData.StrictVectorPath))
            {
                result |= ModifierData.VectorPath;
            }
            return(result);
        }
        public static void VerifyEquality()
        {
            var data1 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            var data2 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.AsyncKeyword).ValueText }.ToImmutableList());
            var data3 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            var data4 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.AbstractKeyword).ValueText }.ToImmutableList());

            Assert.That(data1, Is.Not.EqualTo(data2));
            Assert.That(data1, Is.EqualTo(data3));
            Assert.That(data2, Is.Not.EqualTo(data3));
            Assert.That(data2, Is.Not.EqualTo(data4));

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.That(data1 == data1, Is.True);
#pragma warning restore CS1718 // Comparison made to same variable
            Assert.That(data1 == data2, Is.False);
            Assert.That(data1 == data3, Is.True);
            Assert.That(data2 == data3, Is.False);
            Assert.That((null as ModifierData) ! == data1, Is.False);
            Assert.That(data1 == (null as ModifierData) !, Is.False);

            Assert.That(data1 != data2, Is.True);
            Assert.That(data1 != data3, Is.False);
            Assert.That(data2 != data3, Is.True);
        }
Ejemplo n.º 13
0
 private static void ParseModifierAura(JsonData json, AbilityData abilityData, ModifierData modifier)
 {
     modifier.Aura = GetStringValue(json, "Aura");
     if (modifier.Aura != null)
     {
         modifier.Aura_Teams = GetEnumValue <MultipleTargetsTeam>(json, "Aura_Teams");
         if (modifier.Aura_Teams == default)
         {
             BattleLog.LogError("技能[{0}]的Modifier[{1}]中配置了光环类型,但是Aura_Teams未找到或者配置有错误", abilityData.configFileName, modifier.Name);
             return;
         }
         modifier.Aura_Types = GetEnumValue <MultipleTargetsType>(json, "Aura_Types");
         if (modifier.Aura_Teams == default)
         {
             BattleLog.LogError("技能[{0}]的Modifier[{1}]中配置了光环类型,但是Aura_Types未找到或者配置有错误", abilityData.configFileName, modifier.Name);
             return;
         }
         modifier.Aura_Radius = GetFloatValue(json, "Aura_Radius");
         if (modifier.Aura_Teams == default)
         {
             BattleLog.LogError("技能[{0}]的Modifier[{1}]中配置了光环类型,但是Aura_Radius未配置", abilityData.configFileName, modifier.Name);
             return;
         }
     }
 }
Ejemplo n.º 14
0
        private void addModifierButton_Click(object sender, EventArgs e)
        {
            this.SaveModifierData();

            this.modifierData = new ModifierData();
            this.modifierList.Add(this.modifierData);
            this.modifierListBox.SelectedIndex = this.modifierList.Count - 1;
        }
Ejemplo n.º 15
0
        public static void Create()
        {
            var data  = new ModifierData();
            var style = new CSharpPreferredModifierOrderStyle(data);

            Assert.That(style.Data, Is.SameAs(data), nameof(style.Data));
            Assert.That(style.GetSetting(), Is.EqualTo(string.Empty), nameof(style.GetSetting));
        }
Ejemplo n.º 16
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            ModifierData md = (ModifierData)this.modifierListBox.SelectedItem;

            this.ObjectId   = md.Id;
            this.ObjectName = md.ModifierName;
            this.Close();
        }
Ejemplo n.º 17
0
    public override void Apply(Path p, ModifierData source)
    {
        Node[] path = p.path;
        Vector3[] vectorPath = p.vectorPath;

        if (path == null || path.Length == 0 || vectorPath == null || vectorPath.Length != path.Length) {
            return;
        }

        //The graph index for the current nodes
        int currentGraphIndex = path[0].graphIndex;

        //First node which is in the graph currentGraphIndex
        int currentGraphStart = 0;

        List<Vector3> funnelPath = new List<Vector3> ();

        List<Vector3> left = new List<Vector3> ();
        List<Vector3> right = new List<Vector3> ();

        for (int i=0;i<path.Length;i++) {

            if (path[i].graphIndex != currentGraphIndex) {
                IFunnelGraph funnelGraph = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;

                if (funnelGraph == null) {
                    //Debug.Log ("Funnel Graph is null");
                    for (int j=currentGraphStart;j<=i;j++) {
                        funnelPath.Add ((Vector3)path[j].position);
                    }
                } else {
                    ConstructFunnel (funnelGraph, vectorPath,path,currentGraphStart,i-1,funnelPath,left,right);
                }

                currentGraphIndex = path[i].graphIndex;
                currentGraphStart = i;
            }
        }

        IFunnelGraph funnelGraph2 = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;

        if (funnelGraph2 == null) {
            for (int j=currentGraphStart;j<path.Length-1;j++) {
                funnelPath.Add ((Vector3)path[j].position);
            }
        } else {
            ConstructFunnel (funnelGraph2, vectorPath,path,currentGraphStart,path.Length-1,funnelPath,left,right);
        }

        p.vectorPath = funnelPath.ToArray ();

        #if DEBUG
        for (int i=0;i<p.vectorPath.Length-1;i++) {
            Debug.DrawLine (p.vectorPath[i]+Vector3.up,p.vectorPath[i+1]+Vector3.up,Color.magenta);
        }
        #endif
    }
        public static void VerifyHashCodes()
        {
            var data1 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            var data2 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.AsyncKeyword).ValueText }.ToImmutableList());
            var data3 = new ModifierData().Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());

            Assert.That(data1.GetHashCode(), Is.Not.EqualTo(data2.GetHashCode()));
            Assert.That(data1.GetHashCode(), Is.EqualTo(data3.GetHashCode()));
        }
Ejemplo n.º 19
0
 public D2Modifier(BattleUnit caster, ModifierData modifierData, BattleUnit target, AbilityData abilityData)
 {
     this.caster       = caster;
     this.target       = target;
     this.abilityData  = abilityData;
     this.modifierData = modifierData;
     requestTarget     = new RequestTarget();
     requestTarget.SetUnitTarget(target);
 }
Ejemplo n.º 20
0
        private void SetUpBindings()
        {
            // Immutable
            this.idBox.Text = this.traitData.Id;

            this.traitNameBox.DataBindings.Clear();
            this.traitDescriptionBox.DataBindings.Clear();
            this.traitTypeBox.DataBindings.Clear();
            this.traitRegionBox.DataBindings.Clear();
            this.traitCampaignBox.DataBindings.Clear();
            this.traitRaceBox.DataBindings.Clear();
            this.traitReligionBox.DataBindings.Clear();

            this.traitNameBox.DataBindings.Add("Text", this.traitData, "TraitName");
            this.traitDescriptionBox.DataBindings.Add("Text", this.traitData, "TraitDescription");
            this.traitTypeBox.DataBindings.Add("SelectedItem", this.traitData, "TraitType");
            this.traitRegionBox.DataBindings.Add("SelectedItem", this.traitData, "RegionName");
            this.traitCampaignBox.DataBindings.Add("SelectedItem", this.traitData, "CampaignName");
            this.traitRaceBox.DataBindings.Add("SelectedItem", this.traitData, "RaceName");
            this.traitReligionBox.DataBindings.Add("SelectedItem", this.traitData, "ReligionName");

            this.traitRegionBox.Enabled   = false;
            this.traitCampaignBox.Enabled = false;
            this.traitRaceBox.Enabled     = false;
            this.traitReligionBox.Enabled = false;
            switch (this.traitData.TraitType)
            {
            case TraitType.Regional:
                this.traitRegionBox.Enabled = true;
                break;

            case TraitType.Campaign:
                this.traitCampaignBox.Enabled = true;
                break;

            case TraitType.Race:
                this.traitRaceBox.Enabled = true;
                break;

            case TraitType.Religion:
                this.traitReligionBox.Enabled = true;
                break;

            default:
                break;
            }

            this.modifierList = new List <IdName>();
            foreach (string id in this.traitData.ModifierIdList)
            {
                ModifierData modifierData = this.loadedModifierList.Single(s => s.Id == id);
                this.modifierList.Add(new IdName(modifierData.Id, modifierData.ModifierName));
            }
            this.modifierListBox.DataSource = null;
            this.modifierListBox.DataSource = this.modifierList;
        }
        private static void TestUpdate(string keyword)
        {
            var data    = new ModifierData();
            var newData = data.Update(new[] { keyword }.ToImmutableList());

            var pair = new KeyValuePair <string, (uint weight, uint frequency)>(keyword, (1u, 1u));

            Shared.VerifyModifiers(newData.VisibilityModifiers, pair);
            Shared.VerifyModifiers(newData.OtherModifiers, pair);
        }
        public static void Create()
        {
            var data = new ModifierData();

            Assert.That(data.VisibilityModifiers.Count, Is.EqualTo(4));
            Assert.That(data.OtherModifiers.Count, Is.EqualTo(11));

            Shared.VerifyModifiers(data.VisibilityModifiers);
            Shared.VerifyModifiers(data.OtherModifiers);
        }
Ejemplo n.º 23
0
        public override void Apply(Path p, ModifierData source)
        {
            List <GraphNode> path       = p.path;
            List <Vector3>   vectorPath = p.vectorPath;

            if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count)
            {
                return;
            }

            List <Vector3> funnelPath = ListPool <Vector3> .Claim();

            //Claim temporary lists and try to find lists with a high capacity
            List <Vector3> left = ListPool <Vector3> .Claim(path.Count + 1);

            List <Vector3> right = ListPool <Vector3> .Claim(path.Count + 1);

            AstarProfiler.StartProfile("Construct Funnel");

            left.Add(vectorPath[0]);
            right.Add(vectorPath[0]);

            for (int i = 0; i < path.Count - 1; i++)
            {
                bool a = path[i].GetPortal(path[i + 1], left, right, false);
                bool b = false;                //path[i+1].GetPortal (path[i], right, left, true);

                if (!a && !b)
                {
                    left.Add((Vector3)path[i].position);
                    right.Add((Vector3)path[i].position);

                    left.Add((Vector3)path[i + 1].position);
                    right.Add((Vector3)path[i + 1].position);
                }
            }

            left.Add(vectorPath[vectorPath.Count - 1]);
            right.Add(vectorPath[vectorPath.Count - 1]);

            if (!RunFunnel(left, right, funnelPath))
            {
                //If funnel algorithm failed, degrade to simple line
                funnelPath.Add(vectorPath[0]);
                funnelPath.Add(vectorPath[vectorPath.Count - 1]);
            }

            ListPool <Vector3> .Release(p.vectorPath);

            p.vectorPath = funnelPath;

            ListPool <Vector3> .Release(left);

            ListPool <Vector3> .Release(right);
        }
        public static void ExpressionBodiedData()
        {
            var data = new ModifierData();

            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.AsyncKeyword).ValueText }.ToImmutableList());
            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.AsyncKeyword).ValueText }.ToImmutableList());
            Assert.That(data.Consistency, Is.EqualTo(0.200000003f));
        }
Ejemplo n.º 25
0
    public void OnModifierClick(int slot)
    {
        modifierInfoDisplay.SetActive(true);

        ModifierData modifierToDisplay = depictedModifiers[slot];

        modifierName.text = modifierToDisplay.ID;
        modifierInfo.text = GetModifierInfoString(modifierToDisplay);

        GameStateManager.ActivateFullScreenTrigger((BaseEventData data) => OnClickAnywhereWhenPaneExpanded());
    }
Ejemplo n.º 26
0
        public static void CreateWithModifier()
        {
            var data = new ModifierData();

            data = data.Update(new[] { SyntaxFactory.Token(SyntaxKind.PublicKeyword).ValueText }.ToImmutableList());
            var style = new CSharpPreferredModifierOrderStyle(data);

            Assert.That(style.Data, Is.SameAs(data), nameof(style.Data));
            Assert.That(style.GetSetting(), Is.EqualTo(
                            $"{CSharpPreferredModifierOrderStyle.Setting} = public"), nameof(style.GetSetting));
        }
Ejemplo n.º 27
0
	public override void Apply (Path p, ModifierData source) {
		
		lock (lockObject) {
			toBeApplied = p.path;
			//AstarPath.active.RegisterCanUpdateGraphs (ApplyNow);
			if (!waitingForApply) {
				waitingForApply = true;
				AstarPath.OnPathPreSearch += ApplyNow;
			}
		}
	}
Ejemplo n.º 28
0
    /*public override void ApplyOriginal (Path p) {
     *
     *      if (exactStartPoint) {
     *              pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
     *
     *              if (!addPoints) {
     *                      p.startPoint = pStart;
     *              }
     *      }
     *
     *      if (exactEndPoint) {
     *              pEnd = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
     *
     *              if (!addPoints) {
     *                      p.endPoint = pEnd;
     *              }
     *      }
     * }*/

    public override void Apply(Path p, ModifierData source)
    {
        Vector3 pStart = Vector3.zero,
                pEnd   = Vector3.zero;

        if (exactStartPoint)
        {
            pStart = GetClampedPoint(p.path[0].position, p.originalStartPoint, p.path[0]);
        }
        else
        {
            pStart = p.path[0].position;
        }
        if (exactEndPoint)
        {
            pEnd = GetClampedPoint(p.path[p.path.Length - 1].position, p.originalEndPoint, p.path[p.path.Length - 1]);
        }
        else
        {
            pEnd = p.path[p.path.Length - 1].position;
        }

        if (!addPoints)
        {
            //p.vectorPath[0] = p.startPoint;
            //p.vectorPath[p.vectorPath.Length-1] = p.endPoint;
            //Debug.DrawLine (p.vectorPath[0],pStart,Color.green);
            //Debug.DrawLine (p.vectorPath[p.vectorPath.Length-1],pEnd,Color.green);
            p.vectorPath[0] = pStart;
            p.vectorPath[p.vectorPath.Length - 1] = pEnd;
        }
        else
        {
            Vector3[] newPath = new Vector3[p.vectorPath.Length + (exactStartPoint ? 1 : 0) + (exactEndPoint ? 1 : 0)];

            if (exactStartPoint)
            {
                newPath[0] = pStart;
            }

            if (exactEndPoint)
            {
                newPath[newPath.Length - 1] = pEnd;
            }

            int offset = exactStartPoint ? 1 : 0;
            for (int i = 0; i < p.vectorPath.Length; i++)
            {
                newPath[i + offset] = p.vectorPath[i];
            }
            p.vectorPath = newPath;
        }
    }
Ejemplo n.º 29
0
    public override void Apply(Path p, ModifierData source)
    {
        List <Vector3> vectorPath = p.vectorPath;
        List <Vector3> list       = this.Apply(vectorPath);

        if (list != vectorPath)
        {
            ListPool <Vector3> .Release(p.vectorPath);

            p.vectorPath = list;
        }
    }
Ejemplo n.º 30
0
    public ModifierData Copy()
    {
        ModifierData copy = ScriptableObject.CreateInstance(typeof(ModifierData)) as ModifierData;

        copy.ID               = ID;
        copy.sprite           = sprite;
        copy.modifierCategory = modifierCategory;
        copy.value            = value;
        copy.duration         = duration;

        return(copy);
    }
Ejemplo n.º 31
0
 public override void Apply(Path p, ModifierData source)
 {
     lock (lockObject) {
         toBeApplied = p.path;
         //AstarPath.active.RegisterCanUpdateGraphs (ApplyNow);
         if (!waitingForApply)
         {
             waitingForApply            = true;
             AstarPath.OnPathPreSearch += ApplyNow;
         }
     }
 }
Ejemplo n.º 32
0
		public override void Apply (Path p, ModifierData source) {
			List<GraphNode> path = p.path;
			List<Vector3> vectorPath = p.vectorPath;
			
			if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
				return;
			}
			
			List<Vector3> funnelPath = ListPool<Vector3>.Claim ();
			
			// Claim temporary lists and try to find lists with a high capacity
			List<Vector3> left = ListPool<Vector3>.Claim (path.Count+1);
			List<Vector3> right = ListPool<Vector3>.Claim (path.Count+1);
			
			AstarProfiler.StartProfile ("Construct Funnel");
			
			// Enqueue start point
			left.Add (vectorPath[0]);
			right.Add (vectorPath[0]);
			
			// Loop through all nodes in the path (except the last one)
			for (int i=0;i<path.Count-1;i++) {
				// Get the portal between path[i] and path[i+1] and add it to the left and right lists
				bool portalWasAdded = path[i].GetPortal (path[i+1], left, right, false);
				
				if (!portalWasAdded) {
					// Fallback, just use the positions of the nodes
					left.Add ((Vector3)path[i].position);
					right.Add ((Vector3)path[i].position);
					
					left.Add ((Vector3)path[i+1].position);
					right.Add ((Vector3)path[i+1].position);
				}
			}
			
			// Enqueue end point
			left.Add (vectorPath[vectorPath.Count-1]);
			right.Add (vectorPath[vectorPath.Count-1]);
			
			if (!RunFunnel (left,right,funnelPath)) {
				// If funnel algorithm failed, degrade to simple line
				funnelPath.Add (vectorPath[0]);
				funnelPath.Add (vectorPath[vectorPath.Count-1]);
			}
			
			// Release lists back to the pool
			ListPool<Vector3>.Release (p.vectorPath);
			p.vectorPath = funnelPath;
			
			ListPool<Vector3>.Release (left);
			ListPool<Vector3>.Release (right);
		}
		public override void Apply (Path p, ModifierData source) {
			
			if (this == null) return;
			
			lock (lockObject) {
				toBeApplied = p.path.ToArray();
				
				if (!waitingForApply) {
					waitingForApply = true;
					AstarPath.OnPathPreSearch += ApplyNow;
				}
			}
		}
Ejemplo n.º 34
0
    public override void Apply(Path p, ModifierData source)
    {
        List <Vector3> vs = p.vectorPath;

        List <Vector3> res = Apply(vs);

        if (res != vs)
        {
            Pathfinding.Util.ListPool <Vector3> .Release(p.vectorPath);

            p.vectorPath = res;
        }
    }
Ejemplo n.º 35
0
		public override void Apply (Path p, ModifierData source) {
			var path = p.path;
			var vectorPath = p.vectorPath;
			
			if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
				return;
			}
			
			var funnelPath = ListPool<Vector3>.Claim ();
			
			//Claim temporary lists and try to find lists with a high capacity
			var left = ListPool<Vector3>.Claim (path.Count+1);
			var right = ListPool<Vector3>.Claim (path.Count+1);
			
			AstarProfiler.StartProfile ("Construct Funnel");
			
			left.Add (vectorPath[0]);
			right.Add (vectorPath[0]);
			
			for (var i=0;i<path.Count-1;i++) {
				var a = path[i].GetPortal (path[i+1], left, right, false);
				var b = false;//path[i+1].GetPortal (path[i], right, left, true);
				
				if (!a && !b) {
					left.Add ((Vector3)path[i].position);
					right.Add ((Vector3)path[i].position);
					
					left.Add ((Vector3)path[i+1].position);
					right.Add ((Vector3)path[i+1].position);
				}
			}
			
			left.Add (vectorPath[vectorPath.Count-1]);
			right.Add (vectorPath[vectorPath.Count-1]);
			
			if (!RunFunnel (left,right,funnelPath)) {
				//If funnel algorithm failed, degrade to simple line
				funnelPath.Add (vectorPath[0]);
				funnelPath.Add (vectorPath[vectorPath.Count-1]);
			}
			
			ListPool<Vector3>.Release (p.vectorPath);
			p.vectorPath = funnelPath;
			
			ListPool<Vector3>.Release (left);
			ListPool<Vector3>.Release (right);
		}
Ejemplo n.º 36
0
 public override void Apply(Path p, ModifierData source)
 {
     if (this == null)
     {
         return;
     }
     object obj = this.lockObject;
     lock (obj)
     {
         this.toBeApplied = p.path.ToArray();
         if (!this.waitingForApply)
         {
             this.waitingForApply = true;
             AstarPath.OnPathPreSearch = (OnPathDelegate)Delegate.Combine(AstarPath.OnPathPreSearch, new OnPathDelegate(this.ApplyNow));
         }
     }
 }
	public override void Apply (Path p, ModifierData source) {
		
		//This should never trigger unless some other modifier has messed stuff up
		if (p.vectorPath == null) {
			Debug.LogWarning ("Can't process NULL path (has another modifier logged an error?)");
			return;
		}
		
		Vector3[] path = p.vectorPath;
		
		switch (smoothType) {
			case SmoothType.Simple:
				p.vectorPath = SmoothSimple (path); break;
			case SmoothType.Bezier:
				p.vectorPath = SmoothBezier (path); break;
			case SmoothType.OffsetSimple:
				p.vectorPath = SmoothOffsetSimple (path); break;
			case SmoothType.CurvedNonuniform:
				p.vectorPath = CurvedNonuniform (path); break;
		}
	}
Ejemplo n.º 38
0
 public static ModifierData CanConvertTo(ModifierData a)
 {
     if (a == ModifierData.All)
     {
         return ModifierData.All;
     }
     ModifierData modifierData = a;
     if (ModifierConverter.AnyBits(a, ModifierData.Nodes))
     {
         modifierData |= ModifierData.VectorPath;
     }
     if (ModifierConverter.AnyBits(a, ModifierData.StrictNodePath))
     {
         modifierData |= ModifierData.StrictVectorPath;
     }
     if (ModifierConverter.AnyBits(a, ModifierData.StrictVectorPath))
     {
         modifierData |= ModifierData.VectorPath;
     }
     return modifierData;
 }
Ejemplo n.º 39
0
 public static ModifierData Convert(Path p, ModifierData input, ModifierData output)
 {
     if (!ModifierConverter.CanConvert(input, output))
     {
         Debug.LogError(string.Concat(new object[]
         {
             "Can't convert ",
             input,
             " to ",
             output
         }));
         return ModifierData.None;
     }
     if (ModifierConverter.AnyBits(input, output))
     {
         return input;
     }
     if (ModifierConverter.AnyBits(input, ModifierData.Nodes) && ModifierConverter.AnyBits(output, ModifierData.Vector))
     {
         p.vectorPath.Clear();
         for (int i = 0; i < p.vectorPath.Count; i++)
         {
             p.vectorPath.Add((Vector3)p.path[i].position);
         }
         return ModifierData.VectorPath | ((!ModifierConverter.AnyBits(input, ModifierData.StrictNodePath)) ? ModifierData.None : ModifierData.StrictVectorPath);
     }
     Debug.LogError(string.Concat(new object[]
     {
         "This part should not be reached - Error in ModifierConverted\nInput: ",
         input,
         " (",
         (int)input,
         ")\nOutput: ",
         output,
         " (",
         (int)output,
         ")"
     }));
     return ModifierData.None;
 }
Ejemplo n.º 40
0
		/** Main Post-Processing function */
		public abstract void Apply (Path p, ModifierData source);
Ejemplo n.º 41
0
	/*public override void ApplyOriginal (Path p) {
		
		if (exactStartPoint) {
			pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
			
			if (!addPoints) {
				p.startPoint = pStart;
			}
		}
		
		if (exactEndPoint) {
			pEnd = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
			
			if (!addPoints) {
				p.endPoint = pEnd;
			}
		}
	}*/
	
	public override void Apply (Path _p, ModifierData source) {
		
		ABPath p = _p as ABPath;
		
		//Only for ABPaths
		if (p == null) return;
		
		if (p.vectorPath.Count == 0) {
			return;
		} else if (p.vectorPath.Count < 2 && !addPoints) {
			//Vector3[] arr = new Vector3[2];
			//arr[0] = p.vectorPath[0];
			//arr[1] = p.vectorPath[0];
			//p.vectorPath = arr;
			p.vectorPath.Add (p.vectorPath[0]);
		}
		
		//Debug.DrawRay (p.originalEndPoint,Vector3.up,Color.red);
		//Debug.DrawRay (p.startPoint,Vector3.up,Color.red);
		//Debug.DrawRay (p.endPoint,Vector3.up,Color.green);
		
		Vector3 pStart = Vector3.zero,
		pEnd = Vector3.zero;
		
		if (exactStartPoint == Exactness.Original) {
			pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
		} else if (exactStartPoint == Exactness.ClosestOnNode) {
			pStart = GetClampedPoint ((Vector3)p.path[0].position, p.startPoint, p.path[0]);
		} else if (exactStartPoint == Exactness.Interpolate) {
			pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
			pStart = Mathfx.NearestPointStrict ((Vector3)p.path[0].position,(Vector3)p.path[1>=p.path.Count?0:1].position,pStart);
		} else {
			pStart = (Vector3)p.path[0].position;
		}
		
		if (exactEndPoint == Exactness.Original) {
			pEnd   = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);
		} else if (exactEndPoint == Exactness.ClosestOnNode) {
			pEnd = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.endPoint, p.path[p.path.Count-1]);
		} else if (exactEndPoint == Exactness.Interpolate) {
			pEnd   = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);
			
			pEnd = Mathfx.NearestPointStrict ((Vector3)p.path[p.path.Count-1].position,(Vector3)p.path[p.path.Count-2<0?0:p.path.Count-2].position,pEnd);
		} else {
			pEnd = (Vector3)p.path[p.path.Count-1].position;
		}
		
		if (!addPoints) {
			//p.vectorPath[0] = p.startPoint;
			//p.vectorPath[p.vectorPath.Length-1] = p.endPoint;
			//Debug.DrawLine (p.vectorPath[0],pStart,Color.green);
			//Debug.DrawLine (p.vectorPath[p.vectorPath.Length-1],pEnd,Color.green);
			p.vectorPath[0] = pStart;
			p.vectorPath[p.vectorPath.Count-1] = pEnd;
			
			
		} else {
			
			//Vector3[] newPath = new Vector3[p.vectorPath.Length+(exactStartPoint != Exactness.SnapToNode ? 1 : 0) + (exactEndPoint  != Exactness.SnapToNode ? 1 : 0)];
			
			if (exactStartPoint != Exactness.SnapToNode) {
				//newPath[0] = pStart;
				p.vectorPath.Insert (0,pStart);
			}
			
			if (exactEndPoint != Exactness.SnapToNode) {
				//newPath[newPath.Length-1] = pEnd;
				p.vectorPath.Add (pEnd);
			}
			
			/*int offset = exactStartPoint != Exactness.SnapToNode ? 1 : 0;
			for (int i=0;i<p.vectorPath.Length;i++) {
				newPath[i+offset] = p.vectorPath[i];
			}
			p.vectorPath = newPath;*/
		}
		
	}
Ejemplo n.º 42
0
		/** Returns All data types \a a can be converted to */
		public static ModifierData CanConvertTo (ModifierData a) {
			
			if (a == ModifierData.All) {
				return ModifierData.All;
			}
			
			var result = a;
			
			if (AnyBits (a,ModifierData.Nodes)) {
				result |= ModifierData.VectorPath;
			}
			
			if (AnyBits (a,ModifierData.StrictNodePath)) {
				result |= ModifierData.StrictVectorPath;
			}
			
			if (AnyBits (a,ModifierData.StrictVectorPath)) {
				result |= ModifierData.VectorPath;
			}
			return result;
		}
Ejemplo n.º 43
0
		/** Converts a path from \a input to \a output */
		public static ModifierData Convert (Path p, ModifierData input, ModifierData output) {
			
			//"Input" can not be converted to "output", log error
			if (!CanConvert (input,output)) {
				Debug.LogError ("Can't convert "+input+" to "+output);
				return ModifierData.None;
			}
			
			//"Output" can take "input" with no change, return
			if (AnyBits (input,output)) {
				return input;
			}
			
			//If input is a node path, and output wants a vector array, convert the node array to a vector array
			if (AnyBits (input,ModifierData.Nodes) && AnyBits (output, ModifierData.Vector)) {
				p.vectorPath.Clear();
				for (var i=0;i<p.vectorPath.Count;i++) {
					p.vectorPath.Add ((Vector3)p.path[i].position);
				}
				
				//Return VectorPath and also StrictVectorPath if input has StrictNodePath set
				return ModifierData.VectorPath | (AnyBits (input, ModifierData.StrictNodePath) ? ModifierData.StrictVectorPath : ModifierData.None);
			}
			
			Debug.LogError ("This part should not be reached - Error in ModifierConverted\nInput: "+input+" ("+(int)input+")\nOutput: "+output+" ("+(int)output+")");
			return ModifierData.None;
		}
		public override void Apply (Path _p, ModifierData source) {
			var p = _p as ABPath;

			//Only for ABPaths
			if (p == null) return;

			if (p.vectorPath.Count == 0) {
				return;
			}

			if (p.vectorPath.Count == 1 && !addPoints) {
				// Duplicate first point
				p.vectorPath.Add (p.vectorPath[0]);
			}

			Vector3 pStart = Vector3.zero;
			Vector3 pEnd = Vector3.zero;

			switch(exactStartPoint) {
			case Exactness.Original:
				pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
				break;
			case Exactness.ClosestOnNode:
				pStart = GetClampedPoint ((Vector3)p.path[0].position, p.startPoint, p.path[0]);
				break;
			case Exactness.SnapToNode:
				pStart = (Vector3)p.path[0].position;
				break;
			case Exactness.Interpolate:
				pStart = GetClampedPoint ((Vector3)p.path[0].position, p.originalStartPoint, p.path[0]);
				pStart = AstarMath.NearestPointStrict ((Vector3)p.path[0].position,(Vector3)p.path[1>=p.path.Count?0:1].position,pStart);
				break;
			}

			switch(exactEndPoint) {
			case Exactness.Original:
				pEnd   = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);
				break;
			case Exactness.ClosestOnNode:
				pEnd = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.endPoint, p.path[p.path.Count-1]);
				break;
			case Exactness.SnapToNode:
				pEnd = (Vector3)p.path[p.path.Count-1].position;
				break;
			case Exactness.Interpolate:
				pEnd   = GetClampedPoint ((Vector3)p.path[p.path.Count-1].position, p.originalEndPoint, p.path[p.path.Count-1]);

				pEnd = AstarMath.NearestPointStrict ((Vector3)p.path[p.path.Count-1].position,(Vector3)p.path[p.path.Count-2<0?0:p.path.Count-2].position,pEnd);
				break;
			}

			if (!addPoints) {
				p.vectorPath[0] = pStart;
				p.vectorPath[p.vectorPath.Count-1] = pEnd;
			} else {
				if (exactStartPoint != Exactness.SnapToNode) {
					p.vectorPath.Insert (0,pStart);
				}

				if (exactEndPoint != Exactness.SnapToNode) {
					p.vectorPath.Add (pEnd);
				}
			}

		}
Ejemplo n.º 45
0
 public static bool CanConvert(ModifierData input, ModifierData output)
 {
     ModifierData b = ModifierConverter.CanConvertTo(input);
     return ModifierConverter.AnyBits(output, b);
 }
Ejemplo n.º 46
0
		/** Returns If \a a has all bits that \a b has set to true, also set to true */
		public static bool AllBits (ModifierData a, ModifierData b) {
			return (a & b) == b;
		}
Ejemplo n.º 47
0
		/** Returns If \a a and \a b has any bits in common */
		public static bool AnyBits (ModifierData a, ModifierData b) {
			return (a & b) != 0;
		}
    public override void Apply(Path p, ModifierData source)
    {
        List<Node> path = p.path;
        List<Vector3> vectorPath = p.vectorPath;

        if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count) {
            return;
        }

        //The graph index for the current nodes
        int currentGraphIndex = path[0].graphIndex;

        //First node which is in the graph currentGraphIndex
        int currentGraphStart = 0;

        List<Vector3> funnelPath = ListPool<Vector3>.Claim ();

        List<Vector3> left = ListPool<Vector3>.Claim ();
        List<Vector3> right = ListPool<Vector3>.Claim ();

        AstarProfiler.StartProfile ("Construct Funnel");

        for (int i=0;i<path.Count;i++) {

            if (path[i].graphIndex != currentGraphIndex) {
                IFunnelGraph funnelGraph = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;

                if (funnelGraph == null) {
                    //Debug.Log ("Funnel Graph is null");
                    for (int j=currentGraphStart;j<=i;j++) {
                        funnelPath.Add ((Vector3)path[j].position);
                    }
                } else {
                    AstarProfiler.StartProfile ("Construct Funnel Real");
                    ConstructFunnel (funnelGraph, vectorPath,path,currentGraphStart,i-1,funnelPath,left,right);
                    AstarProfiler.EndProfile ();
                }

                currentGraphIndex = path[i].graphIndex;
                currentGraphStart = i;
            }
        }

        IFunnelGraph funnelGraph2 = AstarData.GetGraph (path[currentGraphStart]) as IFunnelGraph;

        if (funnelGraph2 == null) {
            for (int j=currentGraphStart;j<path.Count-1;j++) {
                funnelPath.Add ((Vector3)path[j].position);
            }
        } else {
            AstarProfiler.StartProfile ("Construct Funnel Real");
            ConstructFunnel (funnelGraph2, vectorPath,path,currentGraphStart,path.Count-1,funnelPath,left,right);
            AstarProfiler.EndProfile ();
        }

        AstarProfiler.EndProfile ();

        ListPool<Vector3>.Release (p.vectorPath);
        p.vectorPath = funnelPath;

        ListPool<Vector3>.Release (left);
        ListPool<Vector3>.Release (right);
    }
Ejemplo n.º 49
0
		/** Returns If \a input can be converted to \a output */
		public static bool CanConvert (ModifierData input, ModifierData output) {
			var convert = CanConvertTo (input);
			return AnyBits (output,convert);
		}
Ejemplo n.º 50
0
        public override void Apply (Path p, ModifierData source) {
            List<Vector3> vs = p.vectorPath;
		
            List<Vector3> res = Apply (vs);
		
            if (res != vs) {
                ListPool<Vector3>.Release(p.vectorPath);
                p.vectorPath = res;
            }
        }
Ejemplo n.º 51
0
		public override void Apply (Path p, ModifierData source) {
			//System.DateTime startTime = System.DateTime.UtcNow;
			
			if (iterations <= 0) {
				return;
			}
			
			if (nodes == null) {
				nodes = new List<Vector3> (p.vectorPath.Count);
			} else {
				nodes.Clear ();
			}
			
			nodes.AddRange (p.vectorPath);
			// = new List<Vector3> (p.vectorPath);
			
			for (int it=0;it<iterations;it++) {
				
				if (subdivideEveryIter && it != 0) {
					
					if (nodes.Capacity < nodes.Count*3) {
						nodes.Capacity = nodes.Count*3;
					}
					
					int preLength = nodes.Count;
					
					for (int j=0;j<preLength-1;j++) {
						nodes.Add (Vector3.zero);
						nodes.Add (Vector3.zero);
					}
					
					for (int j=preLength-1;j > 0;j--) {
						
						Vector3 p1 = nodes[j];
						Vector3 p2 = nodes[j+1];
						
						nodes[j*3] = nodes[j];
						
						if (j != preLength-1) {
							nodes[j*3+1] = Vector3.Lerp (p1,p2,0.33F);
							nodes[j*3+2] = Vector3.Lerp (p1,p2,0.66F);
						}
					}
				}
				
				int i = 0;
				while (i < nodes.Count-2) {
					
					Vector3 start = nodes[i];
					Vector3 end = nodes[i+2];
					
					/*if (i == 0 && exactStartAndEnd) {
						if (overrideClampedExacts) {
							start = p.originalStartPoint;
						} else {
							start = p.startPoint;
						}
					}
					
					if (i == nodes.Count-3 && exactStartAndEnd) {
						if (overrideClampedExacts) {
							end = p.originalEndPoint;
						} else {
							end = p.endPoint;
						}
					}*/
					
					//if (ValidateLine (nodes[i],nodes[i+2],start,end)) {
					
					System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch ();
					watch.Start ();
					
					if (ValidateLine (null,null,start,end)) {
						//Debug.Log ("+++ Simplified "+i+" +++");
						//Debug.DrawLine (start+raycastOffset,end+raycastOffset,new Color (1,0,0.5F));
						nodes.RemoveAt (i+1);
						//i++;
					} else {
						//Debug.DrawLine (start,end,Color.red);
						i++;
					}
					
					watch.Stop ();
					//Debug.Log ("Validate Line Took "+(watch.ElapsedTicks * 0.0001) +" Magnitude: "+(start-end).magnitude);
				}
				
			}
			
			//ValidateLine (null,null,nodes[0],nodes[nodes.Count-1]);
			
			p.vectorPath.Clear ();
			p.vectorPath.AddRange (nodes);
			
			//System.DateTime endTime2 = System.DateTime.UtcNow;
			//float theTime2 = (endTime2-startTime).Ticks*0.0001F;
			
			//Debug.Log ("Raycast Modifier : Time "+theTime2.ToString ("0.00"));
			/*p.vectorPath = new Vector3[p.path.Length];
			for (int i=0;i<p.path.Length;i++) {
				
				Vector3 point = p.path[i].position;
					
				if (i == 0 && exactStartAndEnd) {
					if (overrideClampedExacts) {
						point = p.originalStartPoint;
					} else {
						point = p.startPoint;
					}
				} else if (i == p.path.Length-1 && exactStartAndEnd) {
					if (overrideClampedExacts) {
						point = p.originalEndPoint;
					} else {
						point = p.endPoint;
					}
				}
					
				p.vectorPath[i] = point;
			}*/
		}
Ejemplo n.º 52
0
	/*public override void ApplyOriginal (Path p) {
		
		if (exactStartPoint) {
			pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
			
			if (!addPoints) {
				p.startPoint = pStart;
			}
		}
		
		if (exactEndPoint) {
			pEnd = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
			
			if (!addPoints) {
				p.endPoint = pEnd;
			}
		}
	}*/
	
	public override void Apply (Path p, ModifierData source) {
		
		if (p.vectorPath.Length == 0) {
			return;
		} else if (p.vectorPath.Length < 2 && !addPoints) {
			Vector3[] arr = new Vector3[2];
			arr[0] = p.vectorPath[0];
			arr[1] = p.vectorPath[0];
			p.vectorPath = arr;
		}
		
		Vector3 pStart = Vector3.zero,
		pEnd = Vector3.zero;
		
		if (exactStartPoint == Exactness.Exact) {
			pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
		} else if (exactStartPoint == Exactness.Interpolate) {
			pStart = GetClampedPoint (p.path[0].position, p.originalStartPoint, p.path[0]);
			pStart = Mathfx.NearestPointStrict (p.path[0].position,p.path[1>=p.path.Length?0:1].position,pStart);
		} else {
			pStart = p.path[0].position;
		}
		
		if (exactEndPoint == Exactness.Exact) {
			pEnd   = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
		} else if (exactEndPoint == Exactness.Interpolate) {
			pEnd   = GetClampedPoint (p.path[p.path.Length-1].position, p.originalEndPoint, p.path[p.path.Length-1]);
			
			pEnd = Mathfx.NearestPointStrict (p.path[p.path.Length-1].position,p.path[p.path.Length-2<0?0:p.path.Length-2].position,pEnd);
		} else {
			pEnd = p.path[p.path.Length-1].position;
		}
		
		if (!addPoints) {
			//p.vectorPath[0] = p.startPoint;
			//p.vectorPath[p.vectorPath.Length-1] = p.endPoint;
			//Debug.DrawLine (p.vectorPath[0],pStart,Color.green);
			//Debug.DrawLine (p.vectorPath[p.vectorPath.Length-1],pEnd,Color.green);
			p.vectorPath[0] = pStart;
			p.vectorPath[p.vectorPath.Length-1] = pEnd;
			
			
		} else {
			
			Vector3[] newPath = new Vector3[p.vectorPath.Length+(exactStartPoint != Exactness.Snapped ? 1 : 0) + (exactEndPoint  != Exactness.Snapped ? 1 : 0)];
			
			if (exactEndPoint != Exactness.Snapped) {
				newPath[0] = pStart;
			}
			
			if (exactEndPoint != Exactness.Snapped) {
				newPath[newPath.Length-1] = pEnd;
			}
			
			int offset = exactStartPoint != Exactness.Snapped ? 1 : 0;
			for (int i=0;i<p.vectorPath.Length;i++) {
				newPath[i+offset] = p.vectorPath[i];
			}
			p.vectorPath = newPath;
		}
	}
		public override void Apply (Path p, ModifierData source) {
			
			//This should never trigger unless some other modifier has messed stuff up
			if (p.vectorPath == null) {
				Debug.LogWarning ("Can't process NULL path (has another modifier logged an error?)");
				return;
			}
			
			List<Vector3> path = null;
			
			switch (smoothType) {
				case SmoothType.Simple:
					path = SmoothSimple (p.vectorPath); break;
				case SmoothType.Bezier:
					path = SmoothBezier (p.vectorPath); break;
				case SmoothType.OffsetSimple:
					path = SmoothOffsetSimple (p.vectorPath); break;
				case SmoothType.CurvedNonuniform:
					path = CurvedNonuniform (p.vectorPath); break;
			}
			
			if (path != p.vectorPath) {
				ListPool<Vector3>.Release (p.vectorPath);
				p.vectorPath = path;
			}
			//.vectorPath.Clear ();
			//p.vectorPath.AddRange (path);
		}
Ejemplo n.º 54
0
		public override void Apply (Path p, ModifierData source) {
			//System.DateTime startTime = System.DateTime.UtcNow;
			
			if (iterations <= 0) {
				return;
			}
			
			if (nodes == null) {
				nodes = new List<Vector3> (p.vectorPath.Count);
			} else {
				nodes.Clear ();
			}
			
			nodes.AddRange (p.vectorPath);
			// = new List<Vector3> (p.vectorPath);
			
			for (int it=0;it<iterations;it++) {
				
				if (subdivideEveryIter && it != 0) {
					
					if (nodes.Capacity < nodes.Count*3) {
						nodes.Capacity = nodes.Count*3;
					}
					
					int preLength = nodes.Count;
					
					for (int j=0;j<preLength-1;j++) {
						nodes.Add (Vector3.zero);
						nodes.Add (Vector3.zero);
					}
					
					for (int j=preLength-1;j > 0;j--) {
						
						Vector3 p1 = nodes[j];
						Vector3 p2 = nodes[j+1];
						
						nodes[j*3] = nodes[j];
						
						if (j != preLength-1) {
							nodes[j*3+1] = Vector3.Lerp (p1,p2,0.33F);
							nodes[j*3+2] = Vector3.Lerp (p1,p2,0.66F);
						}
					}
				}
				
				int i = 0;
				while (i < nodes.Count-2) {
					
					Vector3 start = nodes[i];
					Vector3 end = nodes[i+2];
					
					var watch = System.Diagnostics.Stopwatch.StartNew();
					
					if (ValidateLine (null,null,start,end)) {
						nodes.RemoveAt (i+1);
					} else {
						i++;
					}
					
					watch.Stop ();
				}
				
			}
			
			p.vectorPath.Clear ();
			p.vectorPath.AddRange (nodes);
		}
Ejemplo n.º 55
0
 public override void Apply(Path p, ModifierData source)
 {
     List<GraphNode> path = p.path;
     List<Vector3> vectorPath = p.vectorPath;
     if (path == null || path.Count == 0 || vectorPath == null || vectorPath.Count != path.Count)
     {
         return;
     }
     List<Vector3> list = ListPool<Vector3>.Claim();
     List<Vector3> list2 = ListPool<Vector3>.Claim(path.Count + 1);
     List<Vector3> list3 = ListPool<Vector3>.Claim(path.Count + 1);
     list2.Add(vectorPath[0]);
     list3.Add(vectorPath[0]);
     for (int i = 0; i < path.Count - 1; i++)
     {
         if (!path[i].GetPortal(path[i + 1], list2, list3, false))
         {
             list2.Add((Vector3)path[i].position);
             list3.Add((Vector3)path[i].position);
             list2.Add((Vector3)path[i + 1].position);
             list3.Add((Vector3)path[i + 1].position);
         }
     }
     list2.Add(vectorPath[vectorPath.Count - 1]);
     list3.Add(vectorPath[vectorPath.Count - 1]);
     if (!FunnelModifier.RunFunnel(list2, list3, list))
     {
         list.Add(vectorPath[0]);
         list.Add(vectorPath[vectorPath.Count - 1]);
     }
     ListPool<Vector3>.Release(p.vectorPath);
     p.vectorPath = list;
     ListPool<Vector3>.Release(list2);
     ListPool<Vector3>.Release(list3);
 }
Ejemplo n.º 56
0
 public override void Apply(Path _p, ModifierData source)
 {
     ABPath aBPath = _p as ABPath;
     if (aBPath == null)
     {
         return;
     }
     if (aBPath.vectorPath.Count == 0)
     {
         return;
     }
     if (aBPath.vectorPath.Count == 1 && !this.addPoints)
     {
         aBPath.vectorPath.Add(aBPath.vectorPath[0]);
     }
     Vector3 vector = Vector3.zero;
     Vector3 vector2 = Vector3.zero;
     switch (this.exactStartPoint)
     {
     case StartEndModifier.Exactness.SnapToNode:
         vector = (Vector3)aBPath.path[0].position;
         break;
     case StartEndModifier.Exactness.Original:
         vector = this.GetClampedPoint((Vector3)aBPath.path[0].position, aBPath.originalStartPoint, aBPath.path[0]);
         break;
     case StartEndModifier.Exactness.Interpolate:
         vector = this.GetClampedPoint((Vector3)aBPath.path[0].position, aBPath.originalStartPoint, aBPath.path[0]);
         vector = AstarMath.NearestPointStrict((Vector3)aBPath.path[0].position, (Vector3)aBPath.path[(1 < aBPath.path.Count) ? 1 : 0].position, vector);
         break;
     case StartEndModifier.Exactness.ClosestOnNode:
         vector = this.GetClampedPoint((Vector3)aBPath.path[0].position, aBPath.startPoint, aBPath.path[0]);
         break;
     }
     switch (this.exactEndPoint)
     {
     case StartEndModifier.Exactness.SnapToNode:
         vector2 = (Vector3)aBPath.path[aBPath.path.Count - 1].position;
         break;
     case StartEndModifier.Exactness.Original:
         vector2 = this.GetClampedPoint((Vector3)aBPath.path[aBPath.path.Count - 1].position, aBPath.originalEndPoint, aBPath.path[aBPath.path.Count - 1]);
         break;
     case StartEndModifier.Exactness.Interpolate:
         vector2 = this.GetClampedPoint((Vector3)aBPath.path[aBPath.path.Count - 1].position, aBPath.originalEndPoint, aBPath.path[aBPath.path.Count - 1]);
         vector2 = AstarMath.NearestPointStrict((Vector3)aBPath.path[aBPath.path.Count - 1].position, (Vector3)aBPath.path[(aBPath.path.Count - 2 >= 0) ? (aBPath.path.Count - 2) : 0].position, vector2);
         break;
     case StartEndModifier.Exactness.ClosestOnNode:
         vector2 = this.GetClampedPoint((Vector3)aBPath.path[aBPath.path.Count - 1].position, aBPath.endPoint, aBPath.path[aBPath.path.Count - 1]);
         break;
     }
     if (!this.addPoints)
     {
         aBPath.vectorPath[0] = vector;
         aBPath.vectorPath[aBPath.vectorPath.Count - 1] = vector2;
     }
     else
     {
         if (this.exactStartPoint != StartEndModifier.Exactness.SnapToNode)
         {
             aBPath.vectorPath.Insert(0, vector);
         }
         if (this.exactEndPoint != StartEndModifier.Exactness.SnapToNode)
         {
             aBPath.vectorPath.Add(vector2);
         }
     }
 }