Пример #1
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                // Execute code directly.
                case "Code":
                    lua.DoString(parameter.GetValue<string>());
                    break;

                // Open the .lua file in SS14.Server\Scripts\
                case "File":
                    string fileName = Path.Combine("Scripts", parameter.GetValue<string>());
                    string fileContents = "";
                    if (scriptCache.ContainsKey(fileName))
                    {
                        // Console.WriteLine("Getting {0} from ScriptCache", fileName);
                        fileContents = scriptCache[fileName];
                    }
                    else
                    {
                        if (!File.Exists(fileName))
                            throw new FileNotFoundException("Unable to find Lua script file!", fileName);

                        fileContents = File.ReadAllText(fileName);
                        scriptCache.Add(fileName, fileContents);
                    }

                    lua.DoString(fileContents);
                    break;
            }
        }
Пример #2
0
        /// <summary>
        /// Set parameters :)
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            var tileSize = IoCManager.Resolve<IMapManager>().TileSize;

            //base.SetParameter(parameter);
            switch (parameter.MemberName)
            {
                case "SizeX":
                    var width = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left + (AABB.Width - width) / 2f, AABB.Top, width, AABB.Height);
                    break;
                case "SizeY":
                    var height = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left, AABB.Top + (AABB.Height - height) / 2f, AABB.Width, height);
                    break;
                case "OffsetX":
                    var x = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(x - AABB.Width / 2f, AABB.Top, AABB.Width, AABB.Height);
                    break;
                case "OffsetY":
                    var y = parameter.GetValue<float>() / tileSize;
                    AABB = new FloatRect(AABB.Left, y - AABB.Height / 2f, AABB.Width, AABB.Height);
                    break;
            }
        }
Пример #3
0
        /// <summary>
        /// Set parameters :)
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            var tileSize = IoCManager.Resolve <IMapManager>().TileSize;

            //base.SetParameter(parameter);
            switch (parameter.MemberName)
            {
            case "SizeX":
                var width = parameter.GetValue <float>() / tileSize;
                AABB = new FloatRect(AABB.Left + (AABB.Width - width) / 2f, AABB.Top, width, AABB.Height);
                break;

            case "SizeY":
                var height = parameter.GetValue <float>() / tileSize;
                AABB = new FloatRect(AABB.Left, AABB.Top + (AABB.Height - height) / 2f, AABB.Width, height);
                break;

            case "OffsetX":
                var x = parameter.GetValue <float>() / tileSize;
                AABB = new FloatRect(x - AABB.Width / 2f, AABB.Top, AABB.Width, AABB.Height);
                break;

            case "OffsetY":
                var y = parameter.GetValue <float>() / tileSize;
                AABB = new FloatRect(AABB.Left, y - AABB.Height / 2f, AABB.Width, AABB.Height);
                break;
            }
        }
 public override void SetParameter(ComponentParameter parameter)
 {
     base.SetParameter(parameter);
     switch (parameter.MemberName)
     {
         case "notWornSprite":
             SetNotWornSprite(parameter.GetValue<string>());
             break;
         case "carriedSprite":
             SetCarriedSprite(parameter.GetValue<string>());
             break;
     }
 }
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);
            switch (parameter.MemberName)
            {
                case "drawdepth":
                    DrawDepth = (DrawDepth)Enum.Parse(typeof(DrawDepth), parameter.GetValue<string>(), true);
                    break;

                case "sprite":
                    Name = parameter.GetValue<string>();
                    break;
            }
        }
Пример #6
0
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName) {
         case "DebugColor":
             DebugColor = ColorUtils.FromHex(parameter.GetValue<string>(), Color.Blue);
             break;
     }
 }
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
         case "lightoffsetx":
             _lightOffset.X = parameter.GetValue<float>();
             //float.Parse((string)parameter.Parameter, System.Globalization.CultureInfo.InvariantCulture);
             break;
         case "lightoffsety":
             _lightOffset.Y = parameter.GetValue<float>();
             //float.Parse((string)parameter.Parameter, System.Globalization.CultureInfo.InvariantCulture);
             break;
         case "lightradius":
             _lightRadius = parameter.GetValue<int>(); //int.Parse((string) parameter.Parameter);
             break;
         case "lightColorR":
             _lightColor.X = parameter.GetValue<int>(); //int.Parse((string) parameter.Parameter);
             break;
         case "lightColorG":
             _lightColor.Y = parameter.GetValue<int>(); //int.Parse((string)parameter.Parameter);
             break;
         case "lightColorB":
             _lightColor.Z = parameter.GetValue<int>(); //int.Parse((string)parameter.Parameter);
             break;
         case "mask":
             _mask = parameter.GetValue<string>(); // parameter.Parameter;
             break;
     }
 }
 public override void SetParameter(ComponentParameter parameter) {
     switch (parameter.MemberName) {
         case "DebugColor":
             var color = ColorTranslator.FromHtml(parameter.GetValue<string>());
             if (!color.IsEmpty)
                 DebugColor = color;
             break;
     }
 }
Пример #9
0
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
     case "DebugColor":
         DebugColor = ColorUtils.FromHex(parameter.GetValue <string>(), Color.Blue);
         break;
     }
 }
Пример #10
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "wearloc":
                    wearloc = (EquipmentSlot) Enum.Parse(typeof (EquipmentSlot), parameter.GetValue<string>());
                    break;
            }
        }
Пример #11
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "startState":
                    _state = (LightState) Enum.Parse(typeof (LightState), parameter.GetValue<string>(), true);
                    break;
                case "lightColorR":
                    _colorR = int.Parse(parameter.GetValue<string>());
                    break;
                case "lightColorG":
                    _colorG = int.Parse(parameter.GetValue<string>());
                    break;
                case "lightColorB":
                    _colorB = int.Parse(parameter.GetValue<string>());
                    break;
            }
        }
Пример #12
0
 /// <summary>
 /// Set parameters :)
 /// </summary>
 /// <param name="parameter"></param>
 public override void SetParameter(ComponentParameter parameter)
 {
     //base.SetParameter(parameter);
     switch (parameter.MemberName)
     {
         case "icon":
             var iconName = parameter.GetValue<string>();
             SetIcon(iconName);
             break;
     }
 }
Пример #13
0
        //private void GasEffect()
        //{
        //    ITile t = IoCManager.Resolve<IMapManager>().GetFloorAt(Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).Position);
        //    if (t == null)
        //        return;
        //    Vector2 gasVel = t.GasCell.GasVelocity;
        //    if (gasVel.Abs() > Mass) // Stop tiny wobbles
        //    {
        //        Owner.SendMessage(this, ComponentMessageType.PhysicsMove,
        //                          Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).Position.X +
        //                          gasVel.X,
        //                          Owner.GetComponent<TransformComponent>(ComponentFamily.Transform).Position.Y +
        //                          gasVel.Y);
        //    }
        //}
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "Mass":
                    Mass = parameter.GetValue<float>();
                    break;
            }
        }
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
         case "playersession": //TODO this shouldnt be a parameter.
             playerSession = parameter.GetValue<IPlayerSession>();
             break;
         default:
             base.SetParameter(parameter);
             break;
     }
 }
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "LoadThinkComponent":
                    IThinkComponent c = GetThinkComponent(parameter.GetValue<string>());
                    if (c == null)
                        break;
                    ThinkComponents.Add(c);
                    break;
            }
        }
Пример #16
0
 /// <summary>
 /// Set parameters :)
 /// </summary>
 /// <param name="parameter"></param>
 public override void SetParameter(ComponentParameter parameter)
 {
     //base.SetParameter(parameter);
     switch (parameter.MemberName)
     {
         case "drawdepth":
             SetDrawDepth((DrawDepth) Enum.Parse(typeof (DrawDepth), parameter.GetValue<string>(), true));
             break;
         case "basename":
             _basename = parameter.GetValue<string>();
             LoadSprites();
             break;
     }
 }
Пример #17
0
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
         case "healAmount":
             healAmount = parameter.GetValue<int>();
             break;
         case "damageType":
             if (parameter.ParameterType == typeof (string))
             {
                 //Try to parse it. Set to Bludgeoning damagetype if parsing fails
                 if (!Enum.TryParse(parameter.GetValue<string>(), true, out damType))
                     damType = DamageType.Bludgeoning;
             }
             else if (parameter.ParameterType == typeof (DamageType))
             {
                 damType = parameter.GetValue<DamageType>();
             }
             break;
         case "capacity":
             capacity = parameter.GetValue<int>();
             break;
     }
 }
Пример #18
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "TweakAABB":
                    TweakAABB = parameter.GetValue<Vector4D>();
                    break;
            }
        }
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "MaxHealth":
                    maxHealth = parameter.GetValue<int>();
                    currentHealth = maxHealth;
                    break;
                case "CurrentHealth":
                    currentHealth = parameter.GetValue<int>();
                    break;
            }
        }
Пример #20
0
        /// <summary>
        /// Parameter Setting
        /// Settable params:
        /// TweakAABB - Vector4D
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "TweakAABB":
                    TweakAABB = parameter.GetValue<Vector4D>();
                    break;
                case "TweakAABBtop":
                    tweakAABB.X = parameter.GetValue<float>();
                    break;
                case "TweakAABBright":
                    tweakAABB.Y = parameter.GetValue<float>();
                    break;
                case "TweakAABBbottom":
                    tweakAABB.Z = parameter.GetValue<float>();
                    break;
                case "TweakAABBleft":
                    tweakAABB.W = parameter.GetValue<float>();
                    break;
            }
        }
 public override void SetParameter(ComponentParameter parameter)
 {
     switch (parameter.MemberName)
     {
         case "damageAmount":
             damageAmount = parameter.GetValue<int>();
             break;
         case "damageType":
             if (parameter.ParameterType == typeof (string))
             {
                 //Try to parse it. Set to Bludgeoning damagetype if parsing fails
                 if (!Enum.TryParse(parameter.GetValue<string>(), true, out damType))
                     damType = DamageType.Bludgeoning;
             }
             else if (parameter.ParameterType == typeof (DamageType))
             {
                 damType = parameter.GetValue<DamageType>();
             }
             break;
         case "startActive":
             active = parameter.GetValue<bool>();
             break;
         case "toggleable":
             toggleable = parameter.GetValue<bool>();
             if (!toggleable)
                 active = true;
             break;
         case "inactiveSprite":
             inactiveSprite = parameter.GetValue<string>();
             break;
         case "activeSprite":
             activeSprite = parameter.GetValue<string>();
             break;
     }
 }
Пример #22
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "AddEffect":
                    AddEffect(parameter.GetValue<string>(), 10);
                    break;
                default:
                    base.SetParameter(parameter);
                    break;
            }
        }
        /// <summary>
        /// Parameter Setting
        /// Settable params:
        /// TweakAABB - Vector4
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "TweakAABB":
                    TweakAABB = parameter.GetValue<Vector4f>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBtop":
                    tweakAABB.X = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBright":
                    tweakAABB.Y = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBbottom":
                    tweakAABB.Z = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBleft":
                    tweakAABB.W = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "DebugColor":
                    DebugColor = ColorUtils.FromHex(parameter.GetValue<string>(), Color.Red);
                    break;
            }
        }
Пример #24
0
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "OpenSprite":
                    openSprite = parameter.GetValue<string>();
                    break;
                case "ClosedSprite":
                    closedSprite = parameter.GetValue<string>();
                    break;
                case "OpenOnBump":
                    openonbump = parameter.GetValue<bool>();
                    break;
                case "AutoCloseInterval":
                    var autocloseinterval = parameter.GetValue<int>();
                    if (autocloseinterval == 0)
                        autoclose = false;
                    else
                    {
                        autoclose = true;
                        openLength = autocloseinterval;
                    }
                    break;
                default:
                    base.SetParameter(parameter);
                    break;
            }
        }
        /// <summary>
        /// Parameter Setting
        /// Settable params:
        /// TweakAABB - Vector4
        /// </summary>
        /// <param name="parameter"></param>
        public override void SetParameter(ComponentParameter parameter)
        {
            base.SetParameter(parameter);

            switch (parameter.MemberName)
            {
                case "TweakAABB":
                    TweakAABB = parameter.GetValue<Vector4>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBtop":
                    tweakAABB.X = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBright":
                    tweakAABB.Y = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBbottom":
                    tweakAABB.Z = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "TweakAABBleft":
                    tweakAABB.W = parameter.GetValue<float>() / IoCManager.Resolve<IMapManager>().TileSize;
                    break;
                case "DebugColor":
                    var color = ColorTranslator.FromHtml(parameter.GetValue<string>());
                    if (!color.IsEmpty)
                        DebugColor = color;
                    break;
            }
        }