public override void Update(float elapsed) { for (int i = this.AlwaysUpdate.Count - 1; i >= 0; i--) { Component e = this.AlwaysUpdate[i]; if (!e.Ghost) { e.Update(elapsed); if (e.Destroyed) { this.RemoveComponent(e); } } } EntityRenderer r = this.renderer as EntityRenderer; if (r != null) { foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true)) { if (!e.Ghost && e.UpdateBehaviour == Entity.UpdateBehaviours.UpdateWhenVisible) { e.Update(elapsed); if (e.Destroyed) { this.RemoveComponent(e); } } } } // DO NOT CALL BASE UPDATE! WE ARE OVERRIDING THIS BEHAVIOUR!! //base.Update(elapsed); }
private void Init() { //TODO - just a test - WORKS! //_installedMods.Add(new TestMod()); GlSetup(); _itemRegistry = new ItemRegistry(); _blockRegistry = new BlockRegistry(); _recipeRegistry = new RecipeRegistry(); LoadMods(); GameRegistry(); WorldRenderer = new WorldRenderer(); EntityRenderer = new EntityRenderer(); GuiRenderer = new GuiRenderer(); FontRenderer = new FontRenderer(); SettingsManager.Load(); //load settings Camera.SetTargetFov(SettingsManager.GetFloat("fov")); _sensitivity = SettingsManager.GetFloat("sensitivity"); WorldRenderer.RenderDistance = SettingsManager.GetInt("renderdistance"); OpenGuiScreen(new GuiScreenMainMenu()); }
public Player(MasterRenderer renderer, World world, SimpleCamera camera, Vector3 position, Team team) : base(position, 11, 5, 2.5f) { this.masterRenderer = renderer; this.World = world; this.camera = camera; Team = team; if (!GlobalNetwork.IsServer) { debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); base.Renderer.VoxelObject = new DebugVOCube(world.GetTeamColor(team).ToColor4(), 1); flashlight = new Light(Vector3.Zero, LightType.Spot, 2, Color.White, new Vector3(1, 0, 0.002f)) { Radius = MathHelper.ToRadians(45), Visible = false }; renderer.Lights.Add(flashlight); } HitFeedbackPositions = new List <Vector3>(); Viewbob = GlobalNetwork.IsClient ? new ItemViewbob(this) : null; ItemManager = new ItemManager(renderer, this, world, Viewbob); }
public static List <EntityRenderer> LoadRenderers(List <string> filepaths) { CompilerResults compilationResults = null; List <EntityRenderer> validRenders = new List <EntityRenderer>(); CodeDomProvider codeProvider = GetCodeDomProvider(); try { CompilerParameters parms = GetParameters("Renders.dll"); compilationResults = codeProvider.CompileAssemblyFromFile(parms, filepaths.ToArray()); Assembly assembly = compilationResults.CompiledAssembly; foreach (var type in assembly.ExportedTypes) { var rawResult = assembly.CreateInstance(type.ToString()); if (rawResult is EntityRenderer) { EntityRenderer result = (EntityRenderer)rawResult; if (result != null) { validRenders.Add(result); } } } codeProvider.Dispose(); return(validRenders); } catch (Exception ex) { InterpretException(ex, compilationResults, codeProvider); codeProvider.Dispose(); return(validRenders); } }
public EditorScreen(MainWindow window, MasterRenderer renderer) { this.Window = window; this.renderer = renderer; this.entReneder = renderer.GetRenderer3D <EntityRenderer>(); UI = new EditorUI(renderer, this); debug = new DashCMDScreen("modeldebug", "", true, (s) => { s.WriteLine("Mouse POS {0} {1}", Input.ClampedCursorX, Input.ClampedCursorY); s.WriteLine("Camera POS {0}", Camera.Active.Position); s.WriteLine("VoxelEditorObject POS {0}", (Model != null ? Model.CenterPosition : Vector3.Zero)); s.WriteLine(""); s.WriteLine("Current File {0}", CurrentFile); s.WriteLine("Fog: {0}; Enabled? {1}", renderer.GFXSettings.FogQuality, renderer.FogEnabled); s.WriteLine("FXAA: {0}", renderer.GFXSettings.ApplyFXAA); s.WriteLine("Shadows: {0}", renderer.GFXSettings.RenderShadows); s.WriteLine("PCF Samples: {0}", renderer.GFXSettings.ShadowPCFSamples); s.WriteLine("Wireframe: {0}", renderer.GlobalWireframe); }) { SleepTime = 40, }; DashCMD.AddScreen(debug); DashCMD.ExecuteCommand("screen modeldebug"); Camera.Active.Speeds[0] = .5f; LoadNewModel(); }
protected override void DrawAdditionalContent( ) { foreach (Mob mob in mobs) { EntityRenderer.Draw(mob, map.MobPosition); } }
// These are special public void DrawOthers(DevicePanel d) { int x = entity.Position.X.High; int y = entity.Position.Y.High; int Transparency = (Editor.Instance.EditLayer == null) ? 0xff : 0x32; if (entity.Object.Name.Name.Contains("Setup")) { EntityRenderer renderer = EntityRenderers.Where(t => t.GetObjectName() == "ZoneSetup").FirstOrDefault(); if (renderer != null) { renderer.Draw(d, entity, this, x, y, Transparency); } } else if (entity.Object.Name.Name.Contains("Intro") || entity.Object.Name.Name.Contains("Outro")) { EntityRenderer renderer = EntityRenderers.Where(t => t.GetObjectName() == "Outro_Intro_Object").FirstOrDefault(); if (renderer != null) { renderer.Draw(d, entity, this, x, y, Transparency); } } else { EntityRenderer renderer = EntityRenderers.Where(t => t.GetObjectName() == entity.Object.Name.Name).FirstOrDefault(); if (renderer != null) { renderer.Draw(d, entity, this, x, y, Transparency); } } }
/// <summary> /// Initialize any components required by this state. /// </summary> public override void Initialize() { ServiceManager.Game.FormManager.ClearWindow(); Options options = ServiceManager.Game.Options; RendererAssetPool.DrawShadows = GraphicOptions.ShadowMaps; mouseCursor = new MouseCursor(options.KeySettings.Pointer); mouseCursor.EnableCustomCursor(); renderer = ServiceManager.Game.Renderer; fps = new FrameCounter(); Chat = new ChatArea(); Projectiles = new ProjectileManager(); Tiles = new TexturedTileGroupManager(); Utilities = new UtilityManager(); cd = new Countdown(); Lazers = new LazerBeamManager(this); Scene.Add(Lazers, 0); Players = new PlayerManager(); currentGameMode = ServiceManager.Theater.GetCurrentGameMode(); Flags = new FlagManager(); Bases = new BaseManager(); EnvironmentEffects = new EnvironmentEffectManager(); buffbar = new BuffBar(); Scores = new ScoreBoard(currentGameMode, Players); input = new ChatInput(new Vector2(5, ServiceManager.Game.GraphicsDevice.Viewport.Height), 300);//300 is a magic number...Create a chat width variable. input.Visible = false; hud = HUD.GetHudForPlayer(Players.GetLocalPlayer()); localPlayer = Players.GetLocalPlayer(); Scene.MainEntity = localPlayer; sky = ServiceManager.Resources.GetTexture2D("textures\\misc\\background\\sky"); tips = new GameTips(new GameContext(CurrentGameMode, localPlayer)); helpOverlay = new HelpOverlay(); }
public ModelToTexture(Model _tank, Model _turret) { model1 = _tank; model2 = _turret; renderer = new EntityRenderer(ServiceManager.Game.GraphicsDeviceManager, ServiceManager.Game.Content); bak = Renderer.GraphicOptions.BackgroundColor; //Set up the camera for the shot Camera cam = renderer.ActiveScene.CurrentCamera; renderer.ActiveScene.CreateCamera(new Vector3(100, 100, 20), Vector3.Zero, cam.Projection, "Side View"); renderer.ActiveScene.AccessCamera("Side View").CameraUp = Vector3.UnitZ; renderer.ActiveScene.SwitchCamera("Side View"); LoadContent(); renderTarget = new RenderTarget2D(ServiceManager.Game.GraphicsDevice, ServiceManager.Game.GraphicsDeviceManager.PreferredBackBufferWidth, ServiceManager.Game.GraphicsDeviceManager.PreferredBackBufferHeight, 1, SurfaceFormat.Color, ServiceManager.Game.GraphicsDevice.PresentationParameters.MultiSampleType, ServiceManager.Game.GraphicsDevice.PresentationParameters.MultiSampleQuality); }
public ClientWorld(MasterRenderer renderer) { Renderer = renderer; debugRenderer = Renderer.GetRenderer3D <DebugRenderer>(); entRenderer = Renderer.GetRenderer3D <EntityRenderer>(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { cBuilder = new ContentBuilder(); Content.RootDirectory = cBuilder.OutputDirectory; renderer = new EntityRenderer(graphics, Content); this.IsMouseVisible = true; base.Initialize(); }
public MasterRenderer() { GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); createProjectionMatrix(); renderer = new EntityRenderer(shader,projectionMatrix); terrainRenderer = new TerrainRenderer(terrainShader, projectionMatrix); }
// -------------------------------------------------------------------- public EntityRendererInspectorControl(EntityRenderer renderer) { InitializeComponent(); mRenderer = renderer; entityAssetField.AssetChanged += new EventHandler(OnEntitySelected); //materialAssetField.AssetChanged += new EventHandler(OnMaterialSelected); }
private static void RenderEntities(GameEngine engine, GraphicsRenderer renderer, GameTime gameTime, List <CoreAbstractEntity> entities, ClientMapTile onTile, float tileDrawX, float tileDrawY) { foreach (CoreAbstractEntity entity in entities) { EntityRenderer entityRenderer = EntityRenderers.Get(entity); entityRenderer.Render(engine, renderer, gameTime, entity, onTile, tileDrawX, tileDrawY); } }
public void AddEntity(Entity entity) { var entityRenderer = new EntityRenderer(_content, _expiringSpatialHash, entity, _tileSize.ToPoint()); _expiringSpatialHash.AddNode(entity.Position.ToPoint(), entity); RenderList.Add(entityRenderer); EntityRenderersDict[entity] = entityRenderer; _spatialHashMover.Add(entity); }
public void ExecuteInOutFilter(IFilter filter, Action <Entity> callbackIn, Action <Entity> callbackOut, FilterTarget target) { switch (target) { case FilterTarget.All: for (int i = 0; i < this.Components.Count; i++) { if (this.Components[i] is Entity) { if (filter.Contains(this.Components[i] as Entity)) { callbackIn(this.Components[i] as Entity); } else { callbackOut(this.Components[i] as Entity); } } } break; case FilterTarget.AlwaysUpdate: for (int i = 0; i < this.AlwaysUpdate.Count; i++) { if (this.AlwaysUpdate[i] is Entity) { if (filter.Contains(this.AlwaysUpdate[i] as Entity)) { callbackIn(this.AlwaysUpdate[i] as Entity); } else { callbackOut(this.AlwaysUpdate[i] as Entity); } } } break; case FilterTarget.OnScreen: EntityRenderer r = this.renderer as EntityRenderer; if (r != null) { foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true)) { if (filter.Contains(e)) { callbackIn(e); } else { callbackOut(e); } } } break; } }
protected new void Start() { base.Start(); size = GetComponent <BoxCollider>().size.x; Rend = GetComponent <EntityRenderer>(); boss = GameObject.Find("BlackBishop(Clone)").GetComponent <BossBlackBishop>(); Position = boss.addRocket(this); StartCoroutine("Wait"); }
public VoxelTranslationHandles(MasterRenderer renderer) { xAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Blue); xAxisVo.MeshRotation = new Vector3(0, 0, -90); yAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Red); zAxisVo = new VoxelTranslationHandle(6, cubeSize, Color.Green); zAxisVo.MeshRotation = new Vector3(90, 0, 0); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); debugRenderer = renderer.GetRenderer3D <DebugRenderer>(); }
// -------------------------------------------------------------------- public void SetEntity(int guid) { Entity e = OnyxInstance.Resources.GetEntity(guid); mProxy.EntityRef = e; EntityRenderer renderer = mProxy.GetComponent <EntityRenderer>(); float scale = 1.25f / renderer.Bounds.Size.Max(); mProxy.Transform.LocalScale = Vector3.One * scale; }
/// <summary> /// Create a new renderer for the given entity /// </summary> /// <param name="entity">Entity for which the renderer will be created</param> private void CreateEntity(IMap map, Entity entity, bool isPlayer) { GameObject instance = Instantiate(entityPrefab, Vector3.zero, Quaternion.identity); EntityActor actor = instance.AddComponent( isPlayer ? typeof(PlayerActor) : typeof(AIActor) ) as EntityActor; actor.Init(map, entity); instance.transform.parent = transform; EntityRenderer renderer = instance.GetComponent <EntityRenderer>(); renderer.Init(entity); }
public Terrain(MasterRenderer renderer) { if (!GlobalNetwork.IsServer) { entRenderer = renderer.GetRenderer3D <EntityRenderer>(); chunkRenderer = renderer.GetRenderer3D <ChunkRenderer>(); MeshReadyChunks = new ConcurrentQueue <Chunk>(); } Chunks = new ConcurrentDictionary <IndexPosition, Chunk>(); AllChanges = new List <BlockChange>(); TrackChanges = GlobalNetwork.IsServer; }
public void Draw(EntityRenderer entRenderer, ItemViewbob viewbob) { // Render item in hand if (SelectedItem != null) { if (SelectedItem.Type.HasFlag(ItemType.Gun)) { Gun gun = (Gun)SelectedItem; // Render muzzle flash ((ClientMuzzleFlash)muzzleFlash).Render(gun, entRenderer, viewbob); } SelectedItem.Draw(viewbob); } }
public void Render(Gun gun, EntityRenderer entRenderer, ItemViewbob viewbob) { if (muzzleFlashTime > 0) { Matrix4 flashMatrix; if (ownerPlayer.IsRenderingThirdperson) { flashMatrix = Matrix4.CreateTranslation(gun.MuzzleFlashOffset) * Matrix4.CreateScale(gun.ThirdpersonScale) * Matrix4.CreateTranslation(0, 1.5f, -0.25f) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt)) * Matrix4.CreateTranslation(gun.ModelOffset + viewbob.CurrentViewBob + new Vector3(-1.35f, 0, -viewbob.CurrentKickback + -2)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) - MathHelper.Pi) * Matrix4.CreateTranslation(ownerPlayer.Transform.Position + new Vector3(0, ownerPlayer.Size.Y / 2f - 1.5f, 0)); } else { flashMatrix = Matrix4.CreateTranslation(gun.MuzzleFlashOffset) * Matrix4.CreateRotationX(MathHelper.ToRadians(viewbob.CurrentSway.X)) * Matrix4.CreateRotationY(MathHelper.ToRadians(viewbob.CurrentSway.Y)) * Matrix4.CreateRotationZ(MathHelper.ToRadians(viewbob.CurrentTilt + viewbob.CurrentSway.Y * 0.5f)) * Matrix4.CreateTranslation(gun.ModelOffset + viewbob.CurrentViewBob + new Vector3(0, 0, -viewbob.CurrentKickback)) * Matrix4.CreateRotationX(MathHelper.ToRadians(camera.Pitch)) * Matrix4.CreateRotationY(MathHelper.ToRadians(-camera.Yaw) - MathHelper.Pi) * Matrix4.CreateTranslation(camera.OffsetPosition); } light.Position = flashMatrix.ExtractTranslation(); light.LightPower = (muzzleFlashTime / MUZZLE_FLASH_COOLDOWN) * MUZZLE_FLASH_LIGHT_POWER; flashCube.RenderFront = !ownerPlayer.IsRenderingThirdperson; entRenderer.Batch(flashCube, flashMatrix); } else { light.Visible = false; } }
protected new void Start() { base.Start(); Rend = GetComponent <EntityRenderer>(); size = GetComponent <BoxCollider>().size.x; RectTransform TopPos = GameObject.Find("Canvas/TopBackground").GetComponent <RectTransform>(); RectTransform BottomPos = GameObject.Find("Canvas/ButtonBackground").GetComponent <RectTransform>(); StopPosition = TopPos.position.y + BottomPos.position.y / 9 - boxCollider.size.y * 0.9f; if (Gm.WaveManager.EnemyMax < 6) { Gm.WaveManager.EnemyMax = 6; } LifeMax = Life; UpdateSpawnPosition(); Gm.cm.BossMode = true; }
public TerrainEditor(EditorScreen screen) { this.screen = screen; editor = screen.WorldEditor; renderer = screen.Window.Renderer; terrainPhys = new TerrainPhysicsExtension(); entRenderer = renderer.GetRenderer3D <EntityRenderer>(); colorPicker = screen.UI.ColorWindow.ColorPicker; blockCursorCube = new DebugCube(Color4.White, Block.CUBE_SIZE); SelectionBox = new EditorSelectionBox(); undoStack = new Stack <TerrainOperationBatch>(); redoStack = new Stack <TerrainOperationBatch>(); operationBatch = new TerrainOperationBatch(); rayIntersection = new TerrainRaycastResult(new Ray(Vector3.Zero, Vector3.UnitZ)); }
private void ShowEntity(Entity e) { _selectionWindow.Hide(); if (e != null) { if (_renderer != null) { _renderer.Shutdown(); } else { _renderer = new EntityRenderer(e, World); _renderer.Next.Click += new EventHandler(Next_Click); _renderer.Previous.Click += new EventHandler(Previous_Click); } _renderer.Update(e); } }
/// <summary> /// Unload any content (textures, fonts, etc) used by this state. Called when the state is removed. /// </summary> public override void UnloadContent() { /*try * { * ServiceManager.Game.GraphicsDevice.Reset(); * ServiceManager.Game.GraphicsDevice.VertexDeclaration = null; * ServiceManager.Game.GraphicsDevice.Vertices[0].SetSource(null, 0, 0); * } * catch (Exception ex) * { * // If the graphics device was disposed already, it throws an exception. * Console.Error.WriteLine(ex); * }*/ if (mouseCursor != null) { mouseCursor.DisableCustomCursor(); mouseCursor = null; } EnvironmentEffects = null; Bases = null; buffbar = null; cd = null; hud = null; renderer = null; fps = null; map = null; visibleTiles = null; Scores = null; Players = null; Projectiles = null; Chat = null; buffer = null; miniMap.Dispose(); miniMap = null; if (OnGameFinished != null) { EventArgs args = new EventArgs(); OnGameFinished.Invoke(this, args); } }
private void Init() { GlSetup(); itemRegistry = new ItemRegistry(); blockRegistry = new BlockRegistry(); WorldRenderer = new WorldRenderer(); EntityRenderer = new EntityRenderer(); GuiRenderer = new GuiRenderer(); FontRenderer = new FontRenderer(); SettingsManager.Load(); LoadMods(); RegisterItemsAndBlocks(); OpenGuiScreen(new GuiScreenMainMenu()); }
protected new void Start() { base.Start(); r = gameObject.GetComponent <EntityRenderer>(); Speed = 0; // RectTransform Width = GameObject.Find("Canvas/BackgroundImage").GetComponent<RectTransform>(); RectTransform Canvas = GameObject.Find("Canvas").GetComponent <RectTransform>(); totalSize = Screen.width * Canvas.localScale.x; updateRotateConst(); float d = 0; for (int i = 0; i *verticalSpeed < 180; i++) { d += Mathf.Sin(Mathf.Deg2Rad * i * verticalSpeed); } boss = GameObject.Find("BlackPawn(Clone)").GetComponent <BossBlackPawn>(); stopPosition = boss.stopPosition + d / 2 * rotateConst; boss.addMinion(this); }
public Spade(ItemManager itemManager, MasterRenderer renderer) : base(renderer, itemManager, ItemType.Spade) { ModelOffset = new Vector3(-3f, -5f, 3f); LoadModel("Models/spade.aosm"); if (GlobalNetwork.IsClient) { entRenderer = renderer.GetRenderer3D <EntityRenderer>(); if (cursorCube == null) { cursorCube = new DebugCube(Color4.Black, Block.CUBE_SIZE); cursorCube.RenderAsWireframe = true; cursorCube.ApplyNoLighting = true; cursorCube.OnlyRenderFor = RenderPass.Normal; } if (!itemManager.IsReplicated) { AudioBuffer hitBlockAudioBuffer = AssetManager.LoadSound("Weapons/Spade/hit-block.wav"); if (hitBlockAudioBuffer != null) { hitBlockAudioSource = new AudioSource(hitBlockAudioBuffer); hitBlockAudioSource.IsSourceRelative = true; hitBlockAudioSource.Gain = 0.2f; } AudioBuffer missAudioBuffer = AssetManager.LoadSound("Weapons/Spade/miss.wav"); if (missAudioBuffer != null) { missAudioSource = new AudioSource(missAudioBuffer); missAudioSource.IsSourceRelative = true; missAudioSource.Gain = 0.5f; } } } }
private IEnumerator Run() { yield return(WaitForEndOfJob(new RandomizeJob(maxSize, positions))); EntityRenderer r = GetComponent <EntityRenderer>(); for (;;) { if (Input.GetMouseButton(1)) { yield return(WaitForEndOfJob(new SphereJob(maxSize, 0.01f, positions))); } else { yield return(null); } if (Input.GetMouseButton(0)) { r.SetBuffer(this); } } }
private void OnEnable () { renderer = (EntityRenderer)target; layerNames = GetSortingLayerNames (); }