Beispiel #1
0
        public SkyboxGeneratorContext(SkyboxAsset skybox, IDatabaseFileProviderService fileProviderService)
        {
            Skybox   = skybox ?? throw new ArgumentNullException(nameof(skybox));
            Services = new ServiceRegistry();
            Services.AddService(fileProviderService);
            Content = new ContentManager(Services);
            Services.AddService <IContentManager>(Content);
            Services.AddService(Content);

            GraphicsDevice        = GraphicsDevice.New();
            GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
            Services.AddService(GraphicsDeviceService);

            var graphicsContext = new GraphicsContext(GraphicsDevice);

            Services.AddService(graphicsContext);

            EffectSystem          = new EffectSystem(Services);
            EffectSystem.Compiler = EffectCompilerFactory.CreateEffectCompiler(Content.FileProvider, EffectSystem);

            Services.AddService(EffectSystem);
            EffectSystem.Initialize();
            ((IContentable)EffectSystem).LoadContent();
            ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;

            RenderContext     = RenderContext.GetShared(Services);
            RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext);
        }
Beispiel #2
0
        internal void OnInteract(Entity entity, MessageSession session, InteractMsg msg)
        {
            if (entity.Has <Fightable>())
            {
                var template = DataCenter.Instance.GetDatum <InteractTemplate>(msg.InteractId);
                if (template == null)
                {
                    Logger.Write("Request a invalid interact[{0}]", msg.InteractId);
                    return;
                }

                EffectSystem.Affect(entity, template);
            }
            else
            {
                PositionSystem.Global.Interact(entity, targets =>
                {
                    // default interaction - remove removables
                    foreach (var target in targets.Where(target => target.Has <Removable>() && target.Get <Removable>().Action))
                    {
                        // despawn target
                        PositionSystem.Global.Disappear(target);
                        EntityBinder.Instance.Remove(target);
                        EntityManager.Instance.Remove(target.Id);
                    }
                });
            }
        }
Beispiel #3
0
        public override void Load()
        {
            base.Load();

            skyboxEffect = EffectSystem.LoadEffect("SkyboxShader", GetDefaultCompilerParameters());
            parameters.Set(TexturingKeys.TextureCube0, skybox);
        }
Beispiel #4
0
        public override void Start()
        {
            base.Start();

            paradoxTexture = Asset.Load <Texture>("LogoParadox");
            customEffect   = EffectSystem.LoadEffect("Effect").WaitForResult();
            quad           = new PrimitiveQuad(GraphicsDevice, customEffect);

            // set fixed parameters once
            quad.Parameters.Set(EffectKeys.Center, new Vector2(0.5f, 0.5f));
            quad.Parameters.Set(EffectKeys.Frequency, 40);
            quad.Parameters.Set(EffectKeys.Spread, 0.5f);
            quad.Parameters.Set(EffectKeys.Amplitude, 0.015f);
            quad.Parameters.Set(EffectKeys.InvAspectRatio, GraphicsDevice.BackBuffer.Height / (float)GraphicsDevice.BackBuffer.Width);

            // NOTE: Linear-Wrap sampling is not available for non-square non-power-of-two textures on opengl es 2.0
            samplingState = SamplerState.New(GraphicsDevice, new SamplerStateDescription(TextureFilter.Linear, TextureAddressMode.Clamp));

            // Add Effect rendering to the end of the pipeline
            var scene      = SceneSystem.SceneInstance.Scene;
            var compositor = ((SceneGraphicsCompositorLayers)scene.Settings.GraphicsCompositor);

            renderer = new SceneDelegateRenderer(RenderQuad);
            compositor.Master.Renderers.Add(renderer);
        }
Beispiel #5
0
        public EffectNodeFactory()
        {
            mainContext = VLServiceRegistry.Default.GetService <SynchronizationContext>();
            var game = VLServiceRegistry.Default.GetService <Game>();

            ServiceRegistry  = game?.Services;
            ContentManger    = game?.Content;
            EffectSystem     = game?.EffectSystem;
            DeviceManager    = game?.GraphicsDeviceManager;
            ScriptSystem     = game?.Script;
            nodeDescriptions = new ObservableCollection <IVLNodeDescription>(GetNodeDescriptions());
            NodeDescriptions = new ReadOnlyObservableCollection <IVLNodeDescription>(nodeDescriptions);

            if (EffectSystem != null)
            {
                // Ensure the effect system tracks the same files as we do
                var fieldInfo = typeof(EffectSystem).GetField("directoryWatcher", BindingFlags.NonPublic | BindingFlags.Instance);
                directoryWatcher = fieldInfo.GetValue(EffectSystem) as DirectoryWatcher;
            }
            else
            {
                directoryWatcher = new DirectoryWatcher(xkslFileFilter);
            }
            directoryWatcher.Modified += DirectoryWatcher_Modified;
        }
Beispiel #6
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            customEffect = EffectSystem.LoadEffect("CustomEffect");
            quad         = new PrimitiveQuad(GraphicsDevice, customEffect);
        }
Beispiel #7
0
        public SkyboxGeneratorContext(SkyboxAsset skybox)
        {
            if (skybox == null)
            {
                throw new ArgumentNullException(nameof(skybox));
            }

            Skybox   = skybox;
            Services = new ServiceRegistry();
            Content  = new ContentManager(Services);

            GraphicsDevice        = GraphicsDevice.New();
            GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);

            var graphicsContext = new GraphicsContext(GraphicsDevice);

            Services.AddService(typeof(GraphicsContext), graphicsContext);

            EffectSystem = new EffectSystem(Services);
            EffectSystem.Initialize();
            ((IContentable)EffectSystem).LoadContent();
            ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;

            RenderContext     = RenderContext.GetShared(Services);
            RenderDrawContext = new RenderDrawContext(Services, RenderContext, graphicsContext);
        }
Beispiel #8
0
        protected override void Destroy()
        {
            EffectSystem.Dispose();
            GraphicsDevice.Dispose();

            base.Destroy();
        }
Beispiel #9
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     FInit();
 }
Beispiel #10
0
        /// <summary>
        /// Loads the effect.
        /// </summary>
        /// <param name="contentManager">The EffectSystem instance</param>
        /// <param name="file">The file.</param>
        /// <returns></returns>
        public override EffectBase LoadEffect(object contentManager, string file)
        {
            file = file.Replace("\\", "/");
            EffectSystem effectSystem = contentManager as EffectSystem;
            Effect       effect       = effectSystem.LoadEffect(file).WaitForResult();

            return(Engine.Instance.Renderer.CreateEffect(effect));
        }
Beispiel #11
0
        public static IEffectCompiler CreateEffectCompiler(
            IVirtualFileProvider fileProvider,
            EffectSystem effectSystem = null,
            string packageName        = null,
            EffectCompilationMode effectCompilationMode = EffectCompilationMode.Local,
            bool recordEffectRequested = false,
            TaskSchedulerSelector taskSchedulerSelector = null,
            DatabaseFileProvider database = null)
        {
            EffectCompilerBase compiler = null;

            if ((effectCompilationMode & EffectCompilationMode.Local) != 0)
            {
                // Local allowed and available, let's use that
                compiler = new EffectCompiler(fileProvider)
                {
                    SourceDirectories = { EffectCompilerBase.DefaultSourceShaderFolder },
                };
            }

            // Select database - needed for caching
            var selectedDatabase = database ?? fileProvider as DatabaseFileProvider;

            // Nothing to do remotely
            bool needRemoteCompiler = (compiler == null && (effectCompilationMode & EffectCompilationMode.Remote) != 0);

            if (needRemoteCompiler || recordEffectRequested)
            {
                // Create the object that handles the connection
                var shaderCompilerTarget = new RemoteEffectCompilerClient(packageName);

                if (recordEffectRequested)
                {
                    // Let's notify effect compiler server for each new effect requested
                    effectSystem.EffectUsed += shaderCompilerTarget.NotifyEffectUsed;
                }

                // Use remote only if nothing else was found before (i.e. a local compiler)
                if (needRemoteCompiler)
                {
                    // Create a remote compiler
                    compiler = new RemoteEffectCompiler(fileProvider, selectedDatabase, shaderCompilerTarget);
                }
                else
                {
                    // Otherwise, EffectSystem takes ownership of shaderCompilerTarget
                    shaderCompilerTarget.DisposeBy(effectSystem);
                }
            }

            // Local not possible or allowed, and remote not allowed either => switch back to null compiler
            if (compiler == null)
            {
                compiler = new NullEffectCompiler(fileProvider, selectedDatabase);
            }

            return(new EffectCompilerCache(compiler, selectedDatabase, taskSchedulerSelector));
        }
Beispiel #12
0
        protected override void Initialize()
        {
            base.Initialize();

            //now we probably are capable of detecting the gpu/cpu/etc so we confirm rendering settings
            if (AutoLoadDefaultSettings)
            {
                ConfirmRenderingSettings();
            }

            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            Input = InputManagerFactory.NewInputManager(Services, Context);
            GameSystems.Add(Input);

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            GameSystems.Add(ProfilerSystem);

            EffectSystem = new EffectSystem(Services);

            // If requested in game settings, compile effects remotely and/or notify new shader requests
            if (Settings != null)
            {
                EffectSystem.Compiler = EffectSystem.CreateEffectCompiler(EffectSystem, Settings.PackageId, Settings.EffectCompilation, Settings.RecordUsedEffects);
            }

            GameSystems.Add(EffectSystem);

            GameSystems.Add(SceneSystem);

            // TODO: data-driven?
            Content.Serializer.RegisterSerializer(new ImageSerializer());
            Content.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine));
            Content.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine));

            // enable multi-touch by default
            Input.MultiTouchEnabled = true;

            OnGameStarted(this);
        }
Beispiel #13
0
 // Start is called before the first frame update. Initializing the weather state, gametime, and time speed.
 void Start()
 {
     soundSystem   = FindObjectOfType <SoundSystem>();
     effectSystem  = FindObjectOfType <EffectSystem>();
     thunderSystem = FindObjectOfType <ThunderSystem>();
     clipSystem    = FindObjectOfType <ClipSystem>();
     setWeatherGameTime(Weather.SUNNY, 12);
     timeSpeed = 1;
 }
Beispiel #14
0
        public ShadowMapRenderer(IServiceRegistry services, RenderPipeline recursivePipeline) : base(services, recursivePipeline)
        {
            // Build blur effects for VSM
            var compilerParameters = GetDefaultCompilerParameters();

            vsmHorizontalBlur = EffectSystem.LoadEffect("HorizontalVsmBlur", compilerParameters);
            vsmVerticalBlur   = EffectSystem.LoadEffect("VerticalVsmBlur", compilerParameters);
            blurParameters    = new ParameterCollection();
        }
Beispiel #15
0
 public void Dispose()
 {
     // destroy all game systems
     thumbnailGraphicsCompositors.ForEach(x => x.Dispose());
     sceneSystem.Dispose();
     fontSystem.Dispose();
     EffectSystem.Dispose();
     GraphicsDevice.Dispose();
 }
Beispiel #16
0
        private Effect GetOrCreateSelectedSpriteEffect()
        {
            if (selectedSpriteEffect == null)
            {
                selectedSpriteEffect = EffectSystem.LoadEffect("SelectedSprite").WaitForResult();
            }

            return(selectedSpriteEffect);
        }
Beispiel #17
0
        private Effect GetOrCreatePickingSpriteEffect()
        {
            if (pickingSpriteEffect == null)
            {
                pickingSpriteEffect = EffectSystem.LoadEffect("SpritePicking").WaitForResult();
            }

            return(pickingSpriteEffect);
        }
Beispiel #18
0
        public SceneRenderer(GameSettingsAsset gameSettings)
        {
            if (gameSettings == null)
            {
                throw new ArgumentNullException(nameof(gameSettings));
            }

            // Initialize services
            Services       = new ServiceRegistry();
            ContentManager = new ContentManager(Services);
            Services.AddService(typeof(IContentManager), ContentManager);
            Services.AddService(typeof(ContentManager), ContentManager);

            var renderingSettings = gameSettings.GetOrCreate <RenderingSettings>();

            GraphicsDevice = GraphicsDevice.New(DeviceCreationFlags.Debug, new[] { renderingSettings.DefaultGraphicsProfile });

            var graphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);

            Services.AddService(typeof(IGraphicsDeviceService), graphicsDeviceService);
            EffectSystem = new EffectSystem(Services);
            Services.AddService(typeof(EffectSystem), EffectSystem);

            GraphicsContext = new GraphicsContext(GraphicsDevice);
            Services.AddService(typeof(GraphicsContext), GraphicsContext);

            SceneSystem = new SceneSystem(Services);
            Services.AddService(typeof(SceneSystem), SceneSystem);

            // Create game systems
            GameSystems = new GameSystemCollection(Services);
            Services.AddService(typeof(IGameSystemCollection), GameSystems);

            var gameFontSystem = new GameFontSystem(Services);

            Services.AddService(typeof(FontSystem), gameFontSystem.FontSystem);
            Services.AddService(typeof(IFontFactory), gameFontSystem.FontSystem);
            GameSystems.Add(gameFontSystem);

            var uiSystem = new UISystem(Services);

            Services.AddService(typeof(UISystem), uiSystem);
            GameSystems.Add(uiSystem);

            GameSystems.Add(EffectSystem);
            GameSystems.Add(SceneSystem);
            GameSystems.Initialize();

            // Fake presenter
            // TODO GRAPHICS REFACTOR: This is needed be for render stage setup
            GraphicsDevice.Presenter = new RenderTargetGraphicsPresenter(GraphicsDevice,
                                                                         Texture.New2D(GraphicsDevice, renderingSettings.DefaultBackBufferWidth, renderingSettings.DefaultBackBufferHeight,
                                                                                       renderingSettings.ColorSpace == ColorSpace.Linear ? PixelFormat.R8G8B8A8_UNorm_SRgb : PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget),
                                                                         PixelFormat.D24_UNorm_S8_UInt);

            GraphicsContext.CommandList.SetRenderTarget(GraphicsDevice.Presenter.DepthStencilBuffer, GraphicsDevice.Presenter.BackBuffer);
        }
Beispiel #19
0
        protected override void Initialize()
        {
            // ---------------------------------------------------------
            // Add common GameSystems - Adding order is important
            // (Unless overriden by gameSystem.UpdateOrder)
            // ---------------------------------------------------------

            // Add the input manager
            // Add it first so that it can obtained by the UI system
            Input = new InputManager(Services);
            Services.AddService(Input);
            GameSystems.Add(Input);

            // Initialize the systems
            base.Initialize();

            // Add the scheduler system
            // - Must be after Input, so that scripts are able to get latest input
            // - Must be before Entities/Camera/Audio/UI, so that scripts can apply
            // changes in the same frame they will be applied
            GameSystems.Add(Script);

            // Add the Font system
            GameSystems.Add(gameFontSystem);

            //Add the sprite animation System
            GameSystems.Add(SpriteAnimation);

            GameSystems.Add(DebugTextSystem);
            GameSystems.Add(ProfilingSystem);

            EffectSystem = new EffectSystem(Services);
            Services.AddService(EffectSystem);

            // If requested in game settings, compile effects remotely and/or notify new shader requests
            if (Settings != null)
            {
                EffectSystem.Compiler = EffectSystem.CreateEffectCompiler(EffectSystem, Settings.PackageId, Settings.EffectCompilation, Settings.RecordUsedEffects);
            }

            GameSystems.Add(EffectSystem);

            GameSystems.Add(Streaming);
            GameSystems.Add(SceneSystem);

            // Add the Audio System
            GameSystems.Add(Audio);

            // Add the VR System
            GameSystems.Add(VRDeviceSystem);

            // TODO: data-driven?
            Content.Serializer.RegisterSerializer(new ImageSerializer());

            OnGameStarted(this);
        }
Beispiel #20
0
        internal void OnTick(Entity entity, TickMessage tick)
        {
            // 로그아웃 한 상태에서 Tickable이 남아있는 유저는 Tick을 수행하지 않도록 한다.
            if (entity.Has <Player>() && !entity.Get <Player>().Logged)
            {
                entity.Detach <Tickable>();
                return;
            }

            if (entity.Has <Fightable>())
            {
                var fightable = entity.Get <Fightable>();
                if (fightable.IsAlive)
                {
                    if (++fightable.RecoveryCurrentTick >= fightable.RecoveryTickCount)
                    {
                        var recovery = DataCenter.Instance.GetDatum <InteractTemplate>((int)InteractTemplate.Ids.Recovery);
                        EffectSystem.Affect(entity, recovery);

                        fightable.RecoveryCurrentTick = 0;
                    }
                }
            }

            if (entity.Has <Eatable>())
            {
            }

            if (entity.Has <EntityGenerate>())
            {
                var entityGenerate = entity.Get <EntityGenerate>();
                if (entityGenerate.IsGeneratable)
                {
                    if (entityGenerate.Resource >= entityGenerate.NeededResourceToGen)
                    {
                        // generate!


                        entityGenerate.Resource -= entityGenerate.NeededResourceToGen;
                    }

                    entityGenerate.Resource += entityGenerate.IncResource;
                }
            }

            // 다음 Tick을 요청한다.
            if (entity.Has <Tickable>())
            {
                var nextMsg = new TickMessage {
                    Id = entity.Id
                };
                nextMsg.ExecuteDelayed(entity, entity.Get <Tickable>().Interval);
            }
        }
Beispiel #21
0
        public override void Load()
        {
            var desc = new BlendStateDescription(Blend.One, Blend.SourceAlpha);

            desc.RenderTargets[0].AlphaSourceBlend      = Blend.Zero;
            desc.RenderTargets[0].AlphaDestinationBlend = Blend.One;
            blendState = BlendState.New(GraphicsDevice, desc);

            effect          = EffectSystem.LoadEffect("AtmosphereLighting");
            Pass.StartPass += Render;
        }
Beispiel #22
0
 public SkyboxGeneratorContext()
 {
     Services              = new ServiceRegistry();
     Assets                = new AssetManager(Services);
     GraphicsDevice        = GraphicsDevice.New();
     GraphicsDeviceService = new GraphicsDeviceServiceLocal(Services, GraphicsDevice);
     EffectSystem          = new EffectSystem(Services);
     EffectSystem.Initialize();
     ((IContentable)EffectSystem).LoadContent();
     ((EffectCompilerCache)EffectSystem.Compiler).CompileEffectAsynchronously = false;
     DrawEffectContext = RenderContext.GetShared(Services);
 }
Beispiel #23
0
            public EffectInstance GetOrCreateAlphaCutoffSpriteEffect(EffectSystem effectSystem)
            {
                if (alphaCutoffEffect != null)
                {
                    return(alphaCutoffEffect);
                }

                alphaCutoffEffect = new EffectInstance(effectSystem.LoadEffect("SpriteAlphaCutoffEffect").WaitForResult());
                alphaCutoffEffect.Parameters.Set(SpriteBaseKeys.ColorIsSRgb, isSrgb);

                return(alphaCutoffEffect);
            }
Beispiel #24
0
        protected override void Initialize()
        {
            base.Initialize();

            if (Context.InitializeDatabase)
            {
                InitializeAssetDatabase();
            }

            EffectSystem = new EffectSystem(Services);
            GameSystems.Add(EffectSystem);

            // Add RenderSystem
            RenderSystem = new RenderSystem(Services);
            GameSystems.Add(RenderSystem);

            using (var profile = Profiler.Begin(GameProfilingKeys.EntityProcessorInitialize))
            {
                // TODO: Do we need to make this list data-driven?
                Entities.Processors.Add(new HierarchicalProcessor());
                Entities.Processors.Add(new AnimationProcessor());
                Entities.Processors.Add(new ModelNodeLinkProcessor());
                Entities.Processors.Add(new TransformationProcessor());
                Entities.Processors.Add(new MeshProcessor());
                Entities.Processors.Add(new AudioListenerProcessor());
                Entities.Processors.Add(new AudioEmitterProcessor());
                Entities.Processors.Add(new SpriteProcessor());
            }

            // TODO: data-driven?
            Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture>(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture1D>(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture2D>(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.Texture3D>(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuTextureSerializer2 <Graphics.TextureCube>(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuSamplerStateSerializer2(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuBlendStateSerializer(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuRasterizerStateSerializer(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new GpuDepthStencilStateSerializer(GraphicsDevice));
            Asset.Serializer.RegisterSerializer(new ImageSerializer());
            Asset.Serializer.RegisterSerializer(new SoundEffectSerializer(Audio.AudioEngine));
            Asset.Serializer.RegisterSerializer(new SoundMusicSerializer(Audio.AudioEngine));

            // determine the virtual resolution so that ratio is maintained
            const int screenDesiredHeight = 1080;
            var       screenRatio         = GraphicsDevice.BackBuffer.Width / (float)GraphicsDevice.BackBuffer.Height;

            VirtualResolution = new Vector3((int)(screenRatio * screenDesiredHeight), screenDesiredHeight, screenDesiredHeight);

            // enable multi-touch by default
            Input.MultiTouchEnabled = true;
        }
Beispiel #25
0
        public CombatState(Lua Lua, EffectSystem eSys, NameSystem nSys, PlayerSystem pSys, EntityManager eMan,CombatSystem cSys,GameMap gMap, StateMachine sMach)
        {
            lua = Lua;
            effectSystem = eSys;
            combatSystem = cSys;
            nameSystem = nSys;
            playerSystem = pSys;
            entityManager = eMan;
            gameMap = gMap;
            stateSystem = sMach;

            RegisterLuaFunctions();
        }
Beispiel #26
0
 public void EnterWorld(int mapID)
 {
     Ect      = new EffectSystem();
     Fly      = new FlywordSystem();
     Hud      = new HUDSystem();
     Act      = new ActSystem();
     Nts      = new NodeTreeSystem();
     Plt      = new PlotSystem();
     Cut      = new VideoSystem();
     WorldMap = new GameObject("FTWorldMap").AddComponent <FTWorldMap>();
     WorldMap.MapLoadFinish = OnLoadMapFinished;
     WorldMap.EnterWorld(mapID);
 }
Beispiel #27
0
        private void CreateDeviceObjects()
        {
            var commandList = Game.GraphicsContext.CommandList;

            var shader = new EffectInstance(EffectSystem.LoadEffect("MultiMeshShader").WaitForResult());

            shader.UpdateEffect(GraphicsDevice);
            streamShader = shader;

            var outputDesc = new RenderOutputDescription(GraphicsDevice.Presenter.BackBuffer.Format);

            outputDesc.CaptureState(commandList);

            var pipeline = new PipelineStateDescription()
            {
                /* TODO: do we need all these? */
                BlendState        = BlendStates.Default,
                RasterizerState   = RasterizerStateDescription.Default,
                DepthStencilState = DepthStencilStates.None,
                Output            = outputDesc,

                PrimitiveType  = PrimitiveType.TriangleList,
                InputElements  = VertexType.Layout.CreateInputElements(),
                EffectBytecode = shader.Effect.Bytecode,
                RootSignature  = shader.RootSignature,
            };

            var newPipelineState = PipelineState.New(GraphicsDevice, ref pipeline);

            pipelineState = newPipelineState;

            var streamBuffer = Xenko.Graphics.Buffer.New <VertexType>(
                GraphicsDevice,
                INITIAL_INSTANCE_COUNT,
                BufferFlags.VertexBuffer | BufferFlags.StreamOutput
                );

            streamOutBufferBinding = new VertexBufferBinding(streamBuffer, VertexType.Layout, streamBuffer.ElementCount);

            transformBuffer = Xenko.Graphics.Buffer.Structured.New <Matrix>(
                GraphicsDevice,
                INITIAL_INSTANCE_COUNT,
                isUnorderedAccess: true
                );

            colorBuffer = Xenko.Graphics.Buffer.Structured.New <Color4>(
                GraphicsDevice,
                INITIAL_INSTANCE_COUNT,
                isUnorderedAccess: true
                );
        }
Beispiel #28
0
    private void DetonateTrap(int actorID, int itemID)
    {
        var trap = this.EntityManager.GetComponent <TrapComponent>(itemID);

        if (trap == null)
        {
            return;
        }

        trap.Effect.Location = trap.FormParent.Position_Center; // Location is unset until detonation because a trap on a chest can move

        EffectSystem.CreateEffectEntity(this.EntityManager, trap.Effect);

        RemoveTrap(itemID, trap);
    }
 public EntityMaintenanceSystem(EffectSystem eSys, EntityManager eMan, EquipmentSystem eqSys, ExperienceSystem xSys, GearSystem gSys, ItemInventorySystem invSys, ItemSystem iSys, NameSystem nSys, PlayerSystem pSys, ProfessionSystem profSys, StatsSystem sSys, StatModifierSystem smSys)
 {
     effectSystem = eSys;
     entityManager = eMan;
     equipmentSystem = eqSys;
     experienceSystem = xSys;
     gearSystem = gSys;
     inventorySystem=invSys;
     itemSystem = iSys;
     nameSystem = nSys;
     playerSystem = pSys;
     professionSystem = profSys;
     statsSystem = sSys;
     modifierSystem = smSys;
 }
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            cubemapSpriteEffect = EffectSystem.LoadEffect("CubemapSprite").WaitForResult();

            drawEffectContext = RenderContext.GetShared(Services);
            lamberFilter      = new LambertianPrefilteringSH(drawEffectContext);
            renderSHEffect    = new SphericalHarmonicsRendererEffect();
            renderSHEffect.Initialize(drawEffectContext);

            spriteBatch      = new SpriteBatch(GraphicsDevice);
            inputCubemap     = Asset.Load <Texture>("CubeMap");
            outputCubemap    = Texture.NewCube(GraphicsDevice, 256, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.RenderTarget | TextureFlags.ShaderResource).DisposeBy(this);
            displayedCubemap = outputCubemap;
        }
Beispiel #31
0
        public CombatSystem(Lua Lua, ActionSystem actSys, ActionInventorySystem actInvSys, AISystem aiSys, DropSystem dSys, EffectSystem eSys, EntityMaintenanceSystem eMainSys, ExperienceSystem xSys, ItemInventorySystem iSys, NameSystem nSys, PlayerSystem pSys, StatsSystem sSys)
        {
            actionSystem = actSys;
            aInventorySystem = actInvSys;
            aiSystem = aiSys;
            dropSystem = dSys;
            effectSystem = eSys;
            entityMaintenanceSystem = eMainSys;
            experienceSystem = xSys;
            inventorySystem = iSys;
            nameSystem = nSys;
            playerSystem = pSys;
            statsSystem = sSys;

            lua = Lua;
            RegisterLuaFunctions();
        }
Beispiel #32
0
        /// <inheritdoc/>
        public override void Load()
        {
            base.Load();

            // Create necessary objects
            if (IBLRenderTarget == null)
            {
                IBLRenderTarget = Texture.New2D(GraphicsDevice, readOnlyDepthBuffer.Width, readOnlyDepthBuffer.Height, PixelFormat.R16G16B16A16_Float, TextureFlags.ShaderResource | TextureFlags.RenderTarget);
            }

            cubemapMesh = GeometricPrimitive.Cube.New(GraphicsDevice);

            var blendStateDescr = new BlendStateDescription()
            {
                RenderTargets = new[]
                {
                    new BlendStateRenderTargetDescription()
                    {
                        BlendEnable           = true,
                        ColorSourceBlend      = Blend.SourceAlpha,
                        ColorDestinationBlend = Blend.One,
                        ColorBlendFunction    = BlendFunction.Add,
                        AlphaSourceBlend      = Blend.One,
                        AlphaDestinationBlend = Blend.One,
                        AlphaBlendFunction    = BlendFunction.Add,
                        ColorWriteChannels    = ColorWriteChannels.All
                    }
                }
            };

            IBLBlendState = BlendState.New(GraphicsDevice, blendStateDescr);

            // depth state to test z-fail of backfaces
            IBLDepthStencilState = DepthStencilState.New(GraphicsDevice, new DepthStencilStateDescription(true, false)
            {
                StencilEnable       = false,
                DepthBufferFunction = CompareFunction.GreaterEqual,
            });

            // effect
            IBLEffect = EffectSystem.LoadEffect(specularEffectName);

            parameters = new ParameterCollection();
            parameters.Set(RenderTargetKeys.DepthStencilSource, readOnlyDepthBuffer);
        }
Beispiel #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XenkoRenderer"/> class.
        /// </summary>
        /// <param name="graphicsDeviceManager">The graphics device manager.</param>
        public XenkoRenderer(GraphicsDeviceManager graphicsDeviceManager, EffectSystem effectSystem)
            : base()
        {
            manager           = graphicsDeviceManager;
            this.effectSystem = effectSystem;
            spriteBatch       = new SpriteBatch(manager.GraphicsDevice);
            clipRectanges     = new Stack <Rectangle>();
            activeEffects     = new Stack <EffectInstance>();

            scissorRasterizerStateDescription = RasterizerStates.CullNone;
            scissorRasterizerStateDescription.ScissorTestEnable = true; // enables the scissor test

            geometryRasterizerStateDescription = RasterizerStates.CullNone;
            //geometryRasterizerStateDescription.FillMode = FillMode.Wireframe;
            geometryPipelineState = new MutablePipelineState(manager.GraphicsDevice);
            geometryPipelineState.State.DepthStencilState = DepthStencilStates.None;

            clipArray = new Rectangle[1];
        }
Beispiel #34
0
 public EntityManager(StateMachine sMach, DropSystem dSys, PlayerSystem pS, StatsSystem sS, ItemSystem iS, StatModifierSystem mS, EffectSystem efS, EquipmentSystem eqS, AISystem aiS, GearSystem gS, ExperienceSystem xS, ItemInventorySystem invS, NameSystem nS, ProfessionSystem profS, ActionSystem actS, ActionInventorySystem aInvS, CombatSystem cSys, EntityMaintenanceSystem eMS)
 {
     stateSystem = sMach;
     dropSystem = dSys;
     entMaintenanceSystem = eMS;
     aInventorySystem = aInvS;
     combatSystem = cSys;
     playerSystem = pS;
     statsSystem = sS;
     itemSystem = iS;
     modifierSystem = mS;
     effectSystem = efS;
     equipmentSystem = eqS;
     aiSystem = aiS;
     gearSystem = gS;
     experienceSystem = xS;
     inventorySystem = invS;
     nameSystem = nS;
     professionSystem = profS;
     actionSystem = actS;
 }
 public EffectInstance GetOrCreatePickingSpriteEffect(EffectSystem effectSystem)
 {
     return pickingEffect ?? (pickingEffect = new EffectInstance(effectSystem.LoadEffect("SpritePicking").WaitForResult()));
 }
Beispiel #36
0
        private void InitializeSystems()
        {
            Console.WriteLine("Initializing Game Systems");

            professionSystem = new ProfessionSystem();
            effectSystem=new EffectSystem(lua);
            equipmentSystem = new EquipmentSystem();
            experienceSystem = new ExperienceSystem();         
            itemSystem = new ItemSystem();
            inventorySystem = new ItemInventorySystem();
            modifierSystem = new StatModifierSystem();
            nameSystem = new NameSystem(lua);
            playerSystem = new PlayerSystem(nameSystem, stateSystem);
            gearSystem = new GearSystem();
            statsSystem = new StatsSystem();
            aInventorySystem = new ActionInventorySystem(lua, statsSystem);
            actionSystem = new ActionSystem(lua);
            aiSystem = new AISystem();
            dropSystem = new DropSystem(dropMap);
        }