/**
     * Checks whether the block requires power and parses the power sources.
     */

    protected void CheckRequiresPower()
    {
        if (!this.blockTransformerBlock.Block.Properties.Values.ContainsKey(propRequirePower))
        {
            this.requirePower = false;
            this.powerSources = new List <string>()
            {
                "electricwirerelay"
            };
            return;
        }

        string requirePowerValue = blockTransformerBlock.Block.Properties.Values[propRequirePower].ToString();
        bool   requirePower;

        this.requirePower = (StringParsers.TryParseBool(requirePowerValue, out requirePower) ? requirePower : false);

        this.powerSources = new List <string>();
        if (!this.blockTransformerBlock.Block.Properties.Values.ContainsKey(propPowerSources))
        {
            this.powerSources.Add("electricwirerelay");
        }
        else
        {
            this.powerSources = StringHelpers.WriteStringToList(this.blockTransformerBlock.Block.Properties.Values[propPowerSources]);
        }

        this.CheckBlocksDefined(this.powerSources);
    }
Ejemplo n.º 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();
        }
    }
Ejemplo n.º 3
0
    public static bool CheckFeatureStatus(string strClass, string strFeature)
    {
        BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock");

        if (ConfigurationFeatureBlock.type == 0)
        {
            // AdvLogging.DisplayLog("Configuration", "Feature: " + strFeature + " No Configuration Block");
            return(false);
        }



        bool result = false;

        if (ConfigurationFeatureBlock.Block.Properties.Classes.ContainsKey(strClass))
        {
            DynamicProperties dynamicProperties3 = ConfigurationFeatureBlock.Block.Properties.Classes[strClass];
            foreach (System.Collections.Generic.KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                if (string.Equals(keyValuePair.Key, strFeature, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    result = StringParsers.ParseBool(dynamicProperties3.Values[keyValuePair.Key]);
                }
            }
        }

        //  UnityEngine.Debug.Log(" Configuration:  " + strClass + " : " + strFeature + " : Result: " + result);
        //ConsoleCmdAIDirectorDebug.("Configuration", "Feature: " + strFeature + " Result: " + result);
        return(result);
    }
Ejemplo n.º 4
0
    public static bool CheckFeatureStatus(string strClass, string strFeature)
    {
        BlockValue ConfigurationFeatureBlock = Block.GetBlockValue("ConfigFeatureBlock");

        if (ConfigurationFeatureBlock.type == 0)
        {
            return(false);
        }

        bool result = false;

        if (ConfigurationFeatureBlock.Block.Properties.Classes.ContainsKey(strClass))
        {
            DynamicProperties dynamicProperties3 = ConfigurationFeatureBlock.Block.Properties.Classes[strClass];
            foreach (System.Collections.Generic.KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                if (string.Equals(keyValuePair.Key, strFeature, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    result = StringParsers.ParseBool(dynamicProperties3.Values[keyValuePair.Key]);
                }
            }
        }

        return(result);
    }
Ejemplo n.º 5
0
    // Over-ride for CopyProperties to allow it to read in StartingQuests.
    public override void CopyPropertiesFromEntityClass()
    {
        base.CopyPropertiesFromEntityClass();
        EntityClass entityClass = EntityClass.list[this.entityClass];

        flEyeHeight = EntityUtilities.GetFloatValue(entityId, "EyeHeight");

        // Read in a list of names then pick one at random.
        if (entityClass.Properties.Values.ContainsKey("Names"))
        {
            string   text  = entityClass.Properties.Values["Names"];
            string[] Names = text.Split(',');

            int index = UnityEngine.Random.Range(0, Names.Length);
            strMyName = Names[index];
        }

        if (entityClass.Properties.Values.ContainsKey("SleeperInstantAwake"))
        {
            isAlwaysAwake = true;
        }

        if (entityClass.Properties.Values.ContainsKey("Titles"))
        {
            string   text  = entityClass.Properties.Values["Titles"];
            string[] Names = text.Split(',');
            int      index = UnityEngine.Random.Range(0, Names.Length);
            strTitle = Names[index];
        }


        if (entityClass.Properties.Classes.ContainsKey("Boundary"))
        {
            DisplayLog(" Found Bandary Settings");
            String            strBoundaryBox     = "0,0,0";
            String            strCenter          = "0,0,0";
            DynamicProperties dynamicProperties3 = entityClass.Properties.Classes["Boundary"];
            foreach (KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                DisplayLog("Key: " + keyValuePair.Key);
                if (keyValuePair.Key == "BoundaryBox")
                {
                    DisplayLog(" Found a Boundary Box");
                    strBoundaryBox = dynamicProperties3.Values[keyValuePair.Key];
                    continue;
                }

                if (keyValuePair.Key == "Center")
                {
                    DisplayLog(" Found a Center");
                    strCenter = dynamicProperties3.Values[keyValuePair.Key];
                    continue;
                }
            }

            Vector3 Box    = StringParsers.ParseVector3(strBoundaryBox, 0, -1);
            Vector3 Center = StringParsers.ParseVector3(strCenter, 0, -1);
            ConfigureBounaryBox(Box, Center);
        }
    }
    /**
     * Checks whether block requires heat and parses the heat sources.
     */

    protected void CheckRequiresHeat()
    {
        this.requireHeat = false;
        this.heatSources = new List <string>()
        {
            "campfire"
        };

        string requireHeatValue;

        if (!this.PropExists(propRequireHeat, out requireHeatValue))
        {
            return;
        }

        if (!StringParsers.TryParseBool(requireHeatValue, out this.requireHeat))
        {
            throw new Exception("Could not parse require heat parameter as a boolean.");
        }

        this.heatSources = new List <string>();
        string heatSources;

        if (this.PropExists(propHeatSources, out heatSources))
        {
            this.heatSources = StringHelpers.WriteStringToList(heatSources);
            this.CheckBlocksDefined(this.heatSources);
        }
        this.heatSources.Add("campfire");
    }
    /**
     * Checks whether the block requires power and parses the power sources.
     */

    protected void CheckRequiresPower()
    {
        this.requirePower = false;
        this.powerSources = new List <string>()
        {
            "electricwirerelay"
        };

        string requirePowerValue;

        if (!this.PropExists(propRequirePower, out requirePowerValue))
        {
            return;
        }

        if (!StringParsers.TryParseBool(requirePowerValue, out this.requirePower))
        {
            throw new Exception("Require power could noot be parsed as a boolean value.");
        }

        this.powerSources = new List <string>();
        string powerSources;

        if (this.PropExists(propPowerSources, out powerSources))
        {
            this.powerSources = StringHelpers.WriteStringToList(powerSources);
            this.CheckBlocksDefined(this.powerSources);
            return;
        }
        this.powerSources.Add("electricwirerelay");
    }
    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);
    }
    /**
     * Checks whether block requires heat and parses the heat sources.
     */

    protected void CheckRequiresHeat()
    {
        if (!this.blockTransformerBlock.Block.Properties.Values.ContainsKey(propRequireHeat))
        {
            this.requireHeat = false;
            this.heatSources = new List <string>()
            {
                "campfire"
            };
            return;
        }

        string requireHeatValue = blockTransformerBlock.Block.Properties.Values[propRequireHeat].ToString();
        bool   requireHeat;

        this.requireHeat = (StringParsers.TryParseBool(requireHeatValue, out requireHeat) ? requireHeat : false);

        this.heatSources = new List <string>();
        if (!this.blockTransformerBlock.Block.Properties.Values.ContainsKey(propHeatSources))
        {
            this.heatSources.Add("canpfire");
        }
        else
        {
            this.heatSources = StringHelpers.WriteStringToList(this.blockTransformerBlock.Block.Properties.Values[propHeatSources]);
        }

        this.CheckBlocksDefined(this.heatSources);
    }
    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);
    }
    /**
     * Reads the data from a string.
     */

    public static TransformationJob Read(string _s, bool fromHash = false)
    {
        Match jobExists = TransformationQueue.queueEntryParse.Match(_s);

        if (!jobExists.Success)
        {
            throw new Exception("Could not read job string " + _s);
        }

        string timeString = jobExists.Groups[1].ToString();
        string dataString = jobExists.Groups[2].ToString();
        string boolString = jobExists.Groups[3].ToString();

        ulong transformTime;

        if (!StringParsers.TryParseUInt64(timeString, out transformTime))
        {
            throw new Exception("Could not parse time string " + timeString);
        }

        bool inProgress;

        if (!StringParsers.TryParseBool(boolString, out inProgress))
        {
            throw new Exception("Could not parse in progress string " + boolString);
        }

        TransformationData tData = TransformationData.Read(dataString, fromHash);

        return(new TransformationJob(transformTime, tData, inProgress));
    }
Ejemplo n.º 12
0
    public override void Init()
    {
        base.Init();

        // SoundSource is the referenced SoundDataNode
        if (this.Properties.Values.ContainsKey("SoundDataNode"))
        {
            this.strSoundSource = this.Properties.Values["SoundDataNode"];
        }

        // Audio Source is the prefab name, without the asset bundle reference.
        // This is used to keep track of which audio source is actually playing, so we can turn it on and off.
        if (this.Properties.Values.ContainsKey("AudioSource"))
        {
            this.strAudioSource = this.Properties.Values["AudioSource"];
        }

        // The VideoSource can be an asset bundle or URL. If there is an embedded clip on the Video Player, it'll play that in preference to the URL, but
        // a video in the asset bundle will over-ride
        if (this.Properties.Values.ContainsKey("VideoSource"))
        {
            this.strVideoSource = this.Properties.Values["VideoSource"];
        }

        if (this.Properties.Values.ContainsKey("LootContainerSize"))
        {
            this.vLootContainerSize = StringParsers.ParseVector2i(this.Properties.Values["LootContainerSize"], ',');
        }
        else
        {
            this.vLootContainerSize = new Vector2i(2, 3);
        }
    }
Ejemplo n.º 13
0
    /**
     * Converts the XML into the drop info needed.
     */

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

        if (!flag)
        {
            string name = _attribute.Name;
            if (name == "block_name")
            {
                this.blockName = _attribute.Value;
                return(true);
            }

            if (name == "range")
            {
                this.range = StringHelpers.WriteStringToVector3i(_attribute.Value);
                if (range == Vector3i.zero)
                {
                    return(false);
                }
            }

            if (name == "require_materials")
            {
                bool requireMaterials;
                if (!StringParsers.TryParseBool(_attribute.Value, out requireMaterials))
                {
                    throw new Exception("Could not parse value as an boolean.");
                }
                this.requireMaterials = requireMaterials;
            }
        }
        return(flag);
    }
Ejemplo n.º 14
0
        private bool ValidatePassport(string passport, int version)
        {
            var requiredFields = new HashSet <string>()
            {
                "byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"
            };
            var fields = StringParsers.SplitDelimitedStringIntoStringList(passport, new char[0]);

            foreach (var field in fields)
            {
                var fieldAndValue = field.Split(':');
                var fieldName     = fieldAndValue[0];
                var value         = fieldAndValue[1];

                if (ValidateField(fieldName, value, version))
                {
                    if (requiredFields.Contains(fieldName))
                    {
                        requiredFields.Remove(fieldName);
                    }
                }
            }

            return(requiredFields.Count() == 0);
        }
Ejemplo n.º 15
0
    public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool   based = base.ParseXmlAttribute(_attribute);
        string name  = _attribute.Name;
        bool   used  = true;

        if (name == "scale")
        {
            string val = _attribute.Value;
            if (val.Contains(','))
            {
                scale = StringParsers.ParseVector3(val);
            }
            else
            {
                float v = float.Parse(val);
                scale = v * Vectors.Float.One;
            }
        }
        else
        {
            used = false;
        }
        return(used || based);
    }
Ejemplo n.º 16
0
    public Vector3 dsi      = new Vector3(4f, 1f, 1f); // duration, speed, interleave
    // NB:
    // - depends on entity mass ...
    // - (ghost) (4f, 1f, 1f) is very small (4f, 1f, 0f) is way too strong
    //  - (4,2,1): very strong, but remains alive most of the time
    // todo: random duration / trigger on duration

    public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool   based = base.ParseXmlAttribute(_attribute);
        string name  = _attribute.Name;
        bool   used  = true;

        if (name == "checkothers")
        {
            this.CheckOthers = bool.Parse(_attribute.Value);
        }
        if (name == "dirrandom")
        {
            this.dirrandom = float.Parse(_attribute.Value);
        }
        if (name == "strength")
        {
            this.strength = float.Parse(_attribute.Value);
        }
        if (name == "dsi")
        {
            this.dsi = StringParsers.ParseVector3(_attribute.Value);
        }
        else
        {
            used = false;
        }
        return(used || based);
    }
Ejemplo n.º 17
0
        public string SolveFirstStar(StreamReader reader)
        {
            var  estimate     = int.Parse(reader.ReadLine());
            var  nextLine     = reader.ReadLine();
            var  buses        = StringParsers.SplitDelimitedStringIntoStringList(nextLine, ",".ToCharArray());
            long shortestWait = Int64.MaxValue;
            int  closestBus   = 0;

            foreach (var bus in buses)
            {
                if (bus == "x")
                {
                    continue;
                }
                var busInterval = int.Parse(bus);
                // Effectively computes -estimate % busInterval, picks the smallest positive unique solution
                var waitTime = (-estimate % busInterval + busInterval) % busInterval;
                if (waitTime < shortestWait)
                {
                    shortestWait = waitTime;
                    closestBus   = busInterval;
                }
            }

            return((shortestWait * closestBus).ToString());
        }
Ejemplo n.º 18
0
 public override void Init()
 {
     base.Init();
     if (this.Properties.Values.ContainsKey("RandomIndex"))
     {
         this.RandomIndex = StringParsers.ParseSInt32(this.Properties.Values["RandomIndex"], 0, -1, NumberStyles.Any);
     }
 }
Ejemplo n.º 19
0
    public override void Init()
    {
        base.Init();

        if (this.Properties.Values.ContainsKey("TakeDelay"))
        {
            this.fTakeDelay = StringParsers.ParseFloat(this.Properties.Values["TakeDelay"], 0, -1, NumberStyles.Any);
        }
    }
Ejemplo n.º 20
0
    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);
    }
Ejemplo n.º 21
0
    public override void Execute(List <string> _params, CommandSenderInfo _senderInfo)
    {
        /*
         * Direction not perfect, always moving up, jumping diagonally (issue of not waiting callback ?)
         *
         */
        Entity target = GameManager.Instance.World.GetLocalPlayers()[0];

        if (_params.Count > 0 && _params[0] == "sg")
        {
            Vector3  pos  = target.GetPosition();
            Vector3i ipos = Vectors.ToInt(pos);
            Printer.Print("pos: ", pos, "=>", ipos, "=>", Vectors.ToFloat(ipos));
            Printer.Print("pos: ", ipos, "=>", Vectors.ToFloat(ipos), "=>", Vectors.ToInt(Vectors.ToFloat(ipos)));
            target.SetPosition(pos); // _MoveSetPos only
            return;
            // also check conversion in Emplacement
        }


        int     check = 0;
        int     eid   = -1;
        Vector3 dir   = Vectors.Float.UnitY;

        if (_params.Count > 0)
        {
            eid = int.Parse(_params[0]);
        }
        if (_params.Count > 1)
        {
            check = int.Parse(_params[1]);
        }
        if (_params.Count > 2)
        {
            dir = StringParsers.ParseVector3(_params[2]);
        }

        if (eid > 0)
        {
            target = GameManager.Instance.World.GetEntity(eid);
        }
        if (target == null)
        {
            Printer.Print("Entity not there ", eid); return;
        }

        Printer.Print("ConsoleCmdEMover", eid, check, dir);
        EntityMover mover = new EntityMover(3, 0.2f); // .Config(1);

        mover.checkCollision = check == 1;
        mover.Apply(target, dir); // This is a routine... so check not executed ...
    }
Ejemplo n.º 22
0
 public override void Init()
 {
     base.Init();
     if (this.Properties.Values.ContainsKey("ParticleName"))
     {
         this.particleName = this.Properties.Values["ParticleName"];
         ConfigureParticles(this.particleName);
     }
     if (this.Properties.Values.ContainsKey("ParticleOffset"))
     {
         this.offset = StringParsers.ParseVector3(this.Properties.Values["ParticleOffset"], 0, -1);
     }
 }
Ejemplo n.º 23
0
 // don't open the loot container.
 public override bool OnBlockActivated(WorldBase _world, int _cIdx, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _player)
 {
     if (_blockValue.Block.Properties.Values.ContainsKey("IsContainer"))
     {
         bool IsContainer = StringParsers.ParseBool(_blockValue.Block.Properties.Values["IsContainer"], 0, -1, true);
         if (IsContainer)
         {
             base.OnBlockActivated(_world, _cIdx, _blockPos, _blockValue, _player);
             return(true);
         }
     }
     return(true);
 }
Ejemplo n.º 24
0
        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);
                }
            }
        }
    private void BtnOk_OnPressed(XUiController _sender, OnPressEventArgs _onPressEventArgs)
    {
        string text = this.txtPassword.Text;
        float  code = 0f;

        StringParsers.TryParseFloat(text, out code);
        myEntity.Buffs.AddCustomVar("PathingCode", code);

        SphereCache.RemovePaths(myEntity.entityId);
        EntityUtilities.GetNewPositon(myEntity.entityId);
        EntityUtilities.SetCurrentOrder(myEntity.entityId, EntityUtilities.Orders.Wander);
        GameManager.ShowTooltip(base.xui.playerUI.entityPlayer, "Pathing Code Set");
        base.xui.playerUI.windowManager.Close(base.WindowGroup.ID);
    }
    public override void CopyPropertiesFromEntityClass()
    {
        this.npcID = "animalFarm";

        base.CopyPropertiesFromEntityClass();
        EntityClass entityClass = EntityClass.list[this.entityClass];

        if (entityClass.Properties.Values.ContainsKey("BoundaryBox"))
        {
            Vector3 dim = StringParsers.ParseVector3(entityClass.Properties.Values["BoundaryBox"], 0, -1);
            ConfigureBounaryBox(dim);
        }
        InvokeRepeating("CheckAnimalEvent", 1f, 60f);
    }
Ejemplo n.º 27
0
    public void SetupAutoPathingBlocks()
    {
        if (this.Buffs.HasCustomVar("PathingCode"))
        {
            return;
        }

        // Check if pathing blocks are defined.
        List <string> Blocks = EntityUtilities.ConfigureEntityClass(this.entityId, "PathingBlocks");

        if (Blocks.Count == 0)
        {
            Blocks = new List <string>()
            {
                "PathingCube"
            }
        }
        ;

        //Scan for the blocks in the area
        List <Vector3> PathingVectors = ModGeneralUtilities.ScanForTileEntityInChunksListHelper(this.position, Blocks, this.entityId);

        if (PathingVectors == null || PathingVectors.Count == 0)
        {
            return;
        }

        // Find the nearest block, and if its a sign, read its code.
        Vector3        target         = ModGeneralUtilities.FindNearestBlock(this.position, PathingVectors);
        TileEntitySign tileEntitySign = GameManager.Instance.World.GetTileEntity(0, new Vector3i(target)) as TileEntitySign;

        if (tileEntitySign == null)
        {
            return;
        }

        // Since signs can have multiple codes, splite with a ,, parse each one.
        String text = tileEntitySign.GetText();
        float  code = 0f; // Defined here as DMT compiler doesn't like inlining it.

        foreach (String temp in text.Split(','))
        {
            if (StringParsers.TryParseFloat(temp, out code))
            {
                this.Buffs.AddCustomVar("PathingCode", code);
                return;
            }
        }
    }
    /**
     * Checks whether the user is needed to be accessing the block in order for processing to occur.
     */

    protected void CheckRequireUserAccess()
    {
        this.requireUserAccess = false;
        string requireUserAccess;

        if (!this.PropExists(this.propRequireUserAccess, out requireUserAccess))
        {
            return;
        }

        if (!StringParsers.TryParseBool(requireUserAccess, out this.requireUserAccess))
        {
            throw new Exception("Could not parse value as boolean.");
        }
    }
Ejemplo n.º 29
0
    public override bool ParseXmlAttribute(XmlAttribute _attribute)
    {
        bool   based = base.ParseXmlAttribute(_attribute);
        string name  = _attribute.Name;
        bool   used  = true;

        if (name == "particle")
        {
            this.particle = _attribute.Value;
            if (this.particle.StartsWith("p_"))
            {
                this.particle = this.particle.Substring(2);
            }
        }
        else if (name == "offset")
        {
            this.offset = StringParsers.ParseVector3(_attribute.Value);
        }
        else if (name == "rcol")
        {
            this.rcol = StringParsers.ParseVector3(_attribute.Value);
        }
        else if (name == "rpos")
        {
            this.rpos = StringParsers.ParseVector3(_attribute.Value);
        }
        else if (name == "sound")
        {
            this.sound = _attribute.Value;
        }
        else if (name == "color")
        {
            this.color = ParseColor(_attribute.Value);
        }
        else if (name == "rep")
        {
            this.rep = int.Parse(_attribute.Value);
        }
        else if (name == "dt")
        {
            this.dt = int.Parse(_attribute.Value);
        }
        else
        {
            used = false;
        }
        return(used || based);
    }
Ejemplo n.º 30
0
    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);
    }