Ejemplo n.º 1
0
        public static UnitSelector CreateNew <T>(T plugin, ILevelManager level)
            where T : UnitInstancePlugin, IUser
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }

            var newInstance = new UnitSelector(plugin, level);

            plugin.Entity.AddComponent(newInstance);
            return(newInstance);
        }
Ejemplo n.º 2
0
            public override void StartLoading()
            {
                var user = plugin as IUser;

                if (user == null)
                {
                    throw new
                          ArgumentException($"provided plugin does not implement the {nameof(IUser)} interface", nameof(plugin));
                }

                if (storedData.ComponentCase != StDefaultComponent.ComponentOneofCase.UnitSelector)
                {
                    throw new ArgumentException("Invalid component type data passed to loader", nameof(storedData));
                }

                var storedUnitSelector = storedData.UnitSelector;

                UnitSelector = new UnitSelector(user, level)
                {
                    Enabled = storedUnitSelector.Enabled
                };
            }