public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool flag = base.ParseXmlAttribute(_attribute);

        if (!flag)
        {
            string name = _attribute.Name;
            if (name != null)
            {
                if (name == "item")
                {
                    this.CreateItem = _attribute.Value;
                    return(true);
                }

                if (name == "lootgroup")
                {
                    lootgroup = (int)StringParsers.ParseSInt64(_attribute.Value, 0, -1, NumberStyles.Any);
                    return(true);
                }
                if (name == "count")
                {
                    this.CreateItemCount = (int)StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
                    return(true);
                }
            }
        }
        return(flag);
    }
Exemple #2
0
    public static void RemoveRadiusEffect(String strItemClass, ref Block myBlock)
    {
        ItemClass itemClass = ItemClass.GetItemClass(strItemClass, false);

        if (itemClass.Properties.Values.ContainsKey("ActivatedBuff"))
        {
            String   strBuff = itemClass.Properties.Values["ActivatedBuff"];
            string[] array5  = strBuff.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

            // Grab the current radius effects
            List <BlockRadiusEffect> list2 = myBlock.RadiusEffects.OfType <BlockRadiusEffect>().ToList();
            foreach (string text4 in array5)
            {
                int num12 = text4.IndexOf('(');
                int num13 = text4.IndexOf(')');
                BlockRadiusEffect item = default(BlockRadiusEffect);
                if (num12 != -1 && num13 != -1 && num13 > num12 + 1)
                {
                    item.radius   = StringParsers.ParseFloat(text4.Substring(num12 + 1, num13 - num12 - 1), 0, -1, NumberStyles.Any);
                    item.variable = text4.Substring(0, num12);
                }
                else
                {
                    item.radius   = 1f;
                    item.variable = text4;
                }
                if (list2.Contains(item))
                {
                    list2.Remove(item);
                }
            }

            myBlock.RadiusEffects = list2.ToArray();
        }
    }
    public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool flag = base.ParseXmlAttribute(_attribute);

        if (!flag)
        {
            string name = _attribute.Name;
            if (name == "effect_name")
            {
                this.effect_name = _attribute.Value;
                return(true);
            }
            else if (name == "intensity")
            {
                this.intensity = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
                return(true);
            }
            else if (name == "rate0")
            {
                this.rate0 = float.Parse(_attribute.Value);
                return(true);
            }
            else if (name == "fade")
            {
                this.fade = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
                return(true);
            }
        }
        return(flag);
    }
    public override void Init()
    {
        base.Init();

        if (this.Properties.Values.ContainsKey("TakeDelay"))
        {
            this.fTakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
        }
    }
    public override void GiveReward(EntityPlayer player)
    {
        float value = StringParsers.ParseFloat(base.Value, 0, -1, System.Globalization.NumberStyles.Float);

        if (base.OwnerQuest.OwnerJournal.OwnerPlayer.Buffs.HasCustomVar(base.ID))
        {
            value += base.OwnerQuest.OwnerJournal.OwnerPlayer.Buffs.GetCustomVar(base.ID);
        }
        base.OwnerQuest.OwnerJournal.OwnerPlayer.Buffs.SetCustomVar(base.ID, value, true);
    }
        public static void Postfix(ref EntityAlive __instance)
        {
            // Check if this feature is enabled.
            if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                if (__instance is EntityPlayerLocal)
                {
                    return;
                }



                if (RandomSizeHelper.AllowedRandomSize(__instance))
                {
                    // This is the distributed random heigh multiplier. Add or adjust values as you see fit. By default, it's just a small adjustment.
                    float[] numbers = new float[9] {
                        0.7f, 0.8f, 0.9f, 0.9f, 1.0f, 1.0f, 1.0f, 1.1f, 1.2f
                    };
                    System.Random random = new System.Random();

                    int   randomIndex = random.Next(0, numbers.Length);
                    float flScale     = numbers[randomIndex];

                    AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: " + flScale);
                    __instance.Buffs.AddCustomVar("RandomSize", flScale);
                    // scale down the zombies, or upscale them
                    __instance.gameObject.transform.localScale = new Vector3(flScale, flScale, flScale);
                }

                // Check if there's random ranges
                EntityClass entityClass = __instance.EntityClass;
                if (entityClass.Properties.Values.ContainsKey("RandomSizes"))
                {
                    List <float> Ranges  = new List <float>();
                    float        flScale = 1f;
                    foreach (string text in entityClass.Properties.Values["RandomSizes"].Split(new char[] { ',' }))
                    {
                        Ranges.Add(StringParsers.ParseFloat(text));
                    }

                    System.Random random      = new System.Random();
                    int           randomIndex = random.Next(0, Ranges.Count);
                    flScale = Ranges[randomIndex];
                    AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: " + flScale);
                    __instance.Buffs.AddCustomVar("RandomSize", flScale);

                    // scale down the zombies, or upscale them
                    __instance.gameObject.transform.localScale = new Vector3(flScale, flScale, flScale);
                }
            }
        }
    public static float GetFloatValue(int EntityID, String strProperty)
    {
        float result = -1;

        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (myEntity)
        {
            EntityClass entityClass = EntityClass.list[myEntity.entityClass];
            if (entityClass.Properties.Values.ContainsKey(strProperty))
            {
                result = StringParsers.ParseFloat(entityClass.Properties.Values[strProperty], 0, -1, NumberStyles.Any);
            }
        }
        return(result);
    }
    public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool flag = base.ParseXmlAttribute(_attribute);

        if (!flag)
        {
            string name = _attribute.Name;
            if (name != null)
            {
                if (name == "faction")
                {
                    Faction = _attribute.Value;
                    return(true);
                }
                if (name == "value")
                {
                    value = StringParsers.ParseFloat(_attribute.Value);
                    return(true);
                }
            }
        }
        return(flag);
    }
Exemple #9
0
        public static bool Postfix(bool ___result, TileEntity __instance, World world)
        {
            BlockValue block          = GameManager.Instance.World.GetBlock(__instance.ToWorldPos());
            Block      block2         = Block.list[block.type];
            bool       isAlwaysActive = false;

            if (block2.Properties.Values.ContainsKey("AlwaysActive"))
            {
                isAlwaysActive = StringParsers.ParseBool(block2.Properties.Values["AlwaysActive"], 0, -1, true);
                if (isAlwaysActive)
                {
                    ___result = true;
                    AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": TileEntity is Active.");
                    bool blCanTrigger = false;

                    int Bounds = 6;
                    if (block2.Properties.Values.ContainsKey("ActivationDistance"))
                    {
                        Bounds = StringParsers.ParseSInt32(block2.Properties.Values["ActivationDistance"].ToString());
                    }

                    // Scan for the player in the radius as defined by the Activation distance of the block
                    List <Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(null, new Bounds(__instance.ToWorldPos().ToVector3(), (Vector3.one * 20)));
                    if (entitiesInBounds.Count > 0)
                    {
                        AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": TileEntity has Entities in Bound of " + Bounds);
                        for (int i = 0; i < entitiesInBounds.Count; i++)
                        {
                            EntityPlayer player = entitiesInBounds[i] as EntityPlayer;
                            if (player)
                            {
                                float distance = (player.position - __instance.ToWorldPos().ToVector3()).sqrMagnitude;
                                if (distance > block2.GetActivationDistanceSq())
                                {
                                    continue;
                                }

                                AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Player: " + player.EntityName + " is in bounds");

                                if (block2.Properties.Values.ContainsKey("ActivationBuffs"))
                                {
                                    foreach (String strbuff in block2.Properties.Values["ActivationBuffs"].Split(','))
                                    {
                                        AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Checking ActivationBuffs: " + strbuff);
                                        String strBuffName = strbuff;
                                        float  CheckValue  = -1f;

                                        // Check if there's a ( ) at the end of the buff; this will be used as a cvar hook.
                                        int start = strbuff.IndexOf('(');
                                        int end   = strbuff.IndexOf(')');
                                        if (start != -1 && end != -1 && end > start + 1)
                                        {
                                            CheckValue  = StringParsers.ParseFloat(strbuff.Substring(start + 1, end - start - 1), 0, -1, NumberStyles.Any);
                                            strBuffName = strbuff.Substring(0, start);
                                            AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Actviation Buff is a cvar: " + strBuffName + ". Requires value: " + CheckValue);
                                        }

                                        // If the player has a buff by this name, trigger it.
                                        if (player.Buffs.HasBuff(strBuffName))
                                        {
                                            AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Buff has been found: " + strBuffName);
                                            blCanTrigger = true;
                                        }

                                        // If the player has a cvar, then do some extra checks
                                        if (player.Buffs.HasCustomVar(strBuffName))
                                        {
                                            AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Cvar has been found: " + strBuffName);
                                            // If there's no cvar value specified, just allow it.
                                            if (CheckValue == -1)
                                            {
                                                AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Cvar found, and does not require a specific value.");
                                                blCanTrigger = true;
                                            }
                                            // If a cvar is set, then check to see if it matches
                                            if (CheckValue > -1)
                                            {
                                                AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Cvar found, and requires a value of " + CheckValue + " Player has: " + player.Buffs.GetCustomVar(strBuffName));
                                                if (player.Buffs.GetCustomVar(strBuffName) == CheckValue)
                                                {
                                                    blCanTrigger = true;
                                                }
                                            }

                                            // If any of these conditions match, trigger the Activate block
                                            if (blCanTrigger)
                                            {
                                                AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ":  Checks successfully passed for player: " + player.EntityName);
                                                break;
                                            }
                                            else
                                            {
                                                AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": Checks were NOT success for player: " + player.EntityName);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    blCanTrigger = true;
                                }

                                if (blCanTrigger)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (blCanTrigger)
                    {
                        AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": TileEntity can call ActivateBlock. Calling it...");
                        Block.list[block.type].ActivateBlock(world, __instance.GetClrIdx(), __instance.ToWorldPos(), block, true, true);
                    }
                    else
                    {
                        AdvLogging.DisplayLog(AdvFeatureClass, block2.GetBlockName() + ": TileEntity is Active but is not Activating.");
                        Block.list[block.type].ActivateBlock(world, __instance.GetClrIdx(), __instance.ToWorldPos(), block, false, true);
                    }
                    return(true);
                }
            }
            return(false);
        }
    public override void PerformAction()
    {
        float value = StringParsers.ParseFloat(base.Value, 0, -1, System.Globalization.NumberStyles.Float);

        base.OwnerQuest.OwnerJournal.OwnerPlayer.Buffs.SetCustomVar(base.ID, value, true);
    }
Exemple #11
0
    public override void Init()
    {
        base.Init();

        _takeDelay = !Properties.Values.ContainsKey("TakeDelay") ? 2f : StringParsers.ParseFloat(Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
    }