public ModelViewer(ITagContainer diContainer) { this.diContainer = diContainer; device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Model Viewer"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; modelMaterialEdit = new ModelMaterialEdit(Window, diContainer); diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.dff"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; imGuiRenderer = Window.Container.ImGuiRenderer; locationBuffer = new LocationBuffer(device); AddDisposable(locationBuffer); var localDiContainer = diContainer.ExtendedWith(locationBuffer); camera = new Camera(localDiContainer); AddDisposable(camera); controls = new OrbitControlsTag(Window, camera.Location, localDiContainer); AddDisposable(controls); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); triangleRenderer = new DebugTriangleLineRenderer(diContainer); triangleRenderer.Material.LinkTransformsTo(camera); triangleRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(triangleRenderer); planeRenderer = new DebugPlaneRenderer(diContainer); planeRenderer.Material.LinkTransformsTo(camera); planeRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(planeRenderer); editor.AddInfoSection("Statistics", HandleStatisticsContent); editor.AddInfoSection("Materials", HandleMaterialsContent); editor.AddInfoSection("Skeleton", HandleSkeletonContent); editor.AddInfoSection("Collision", HandleCollisionContent); }
public NPCScript(ITagContainer diContainer) : base(diContainer, CreateEntityContainer) { game = diContainer.GetTag <Game>(); scene = diContainer.GetTag <Scene>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); executeScriptSubscription = World.Subscribe <messages.ExecuteNPCScript>(HandleExecuteNPCScript); }
public Scheduler(ITagContainer diContainer) { this.diContainer = diContainer; options = diContainer.GetTag <Options>(); resourcePool = diContainer.GetTag <IResourcePool>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); sceneMetadataBuilder = new SceneMetadataBuilder(diContainer); bgTileRenderer = new BackgroundTileRenderer(options); for (int i = 0; i < options.Renderers; i++) { rendererQueue.Enqueue(new MapTileRenderer(diContainer)); } ProgressSteps = new[] { stepScenesFound, stepScenesLoaded, stepTilesEmpty, stepTilesRendered, stepTilesEncoded, stepTilesOptimized, stepTilesOutput, stepScenesMeta, stepMetaOutput, stepBgTilesRendered }; output = CreateOutput(options); var outputDisposable = output as IDisposable; if (outputDisposable != null) { AddDisposable(outputDisposable); } }
public Model(ITagContainer diContainer, zzio.scn.Model sceneModel, Behavior?sceneBehavior) { this.diContainer = diContainer; var textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); var textureBasePaths = new[] { new FilePath("resources/textures/models"), new FilePath("resources/textures/worlds") }; var camera = diContainer.GetTag <Camera>(); SceneModel = sceneModel; SceneBehaviour = sceneBehavior; locationRange = diContainer.GetTag <LocationBuffer>().Add(Location); Location.LocalPosition = sceneModel.pos; Location.LocalRotation = sceneModel.rot.ToZZRotation(); var clumpLoader = diContainer.GetTag <IAssetLoader <ClumpBuffers> >(); clumpBuffers = clumpLoader.Load(new FilePath("resources/models/models").Combine(sceneModel.filename + ".dff")); materials = clumpBuffers.SubMeshes.Select(subMesh => { var rwMaterial = subMesh.Material; var material = new ModelStandardMaterial(diContainer); (material.MainTexture.Texture, material.Sampler.Sampler) = textureLoader.LoadTexture(textureBasePaths, rwMaterial); material.LinkTransformsTo(camera); material.World.BufferRange = locationRange; material.Uniforms.Ref = ModelStandardMaterialUniforms.Default; material.Uniforms.Ref.vertexColorFactor = 0.0f; material.Uniforms.Ref.tint = rwMaterial.color.ToFColor() * sceneModel.color; return(material); }).ToArray(); }
public ModelLoader(ITagContainer diContainer) { this.diContainer = diContainer; scene = diContainer.GetTag <Scene>(); ecsWorld = diContainer.GetTag <DefaultEcs.World>(); sceneLoadSubscription = ecsWorld.Subscribe <messages.SceneLoaded>(HandleSceneLoaded); }
public ClumpMaterial(ITagContainer diContainer) { this.diContainer = diContainer; camera = diContainer.GetTag <Camera>(); textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); Manage(diContainer.GetTag <DefaultEcs.World>()); }
public PlayerTriggers(ITagContainer diContainer) { world = diContainer.GetTag <DefaultEcs.World>(); playerControls = diContainer.GetTag <PlayerControls>(); zzContainer = diContainer.GetTag <IZanzarahContainer>(); zzContainer.OnMouseDown += HandleMouseDown; var game = diContainer.GetTag <Game>(); cameraLocation = diContainer.GetTag <rendering.Camera>().Location; playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); npcMarker = world.CreateEntity(); npcMarker.Set(new Location()); npcMarker.Set(new components.behaviour.Rotate(Vector3.UnitY, 90f)); npcMarker.Set(ManagedResource <ClumpBuffers> .Create( new resources.ClumpInfo(resources.ClumpType.Model, "marker.dff"))); ModelLoader.LoadMaterialsFor(npcMarker, zzio.scn.FOModelRenderType.Solid, zzio.IColor.Green, new zzio.SurfaceProperties(1f, 1f, 1f)); var materials = npcMarker.Get <List <materials.BaseModelInstancedMaterial> >(); foreach (var material in materials) { material.Uniforms.Ref.vertexColorFactor = 1f; } }
public SceneMetadataBuilder(ITagContainer diContainer) { var options = diContainer.GetTag <Options>(); mappedDb = diContainer.GetTag <MappedDB>(); background = options.Background; }
private readonly Sampler fontSampler; // a linear, non-bleeding sampler public UITileSheet(ITagContainer diContainer) { this.diContainer = diContainer; ui = diContainer.GetTag <UI>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); resourceFactory = diContainer.GetTag <ResourceFactory>(); resourcePool = diContainer.GetTag <IResourcePool>(); Manage(diContainer.GetTag <DefaultEcs.World>()); linearSampler = resourceFactory.CreateSampler(new SamplerDescription( SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerFilter.MinLinear_MagLinear_MipLinear, comparisonKind: null, 0, 0, 0, 0, SamplerBorderColor.TransparentBlack)); fontSampler = resourceFactory.CreateSampler(new SamplerDescription( SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerAddressMode.Clamp, SamplerFilter.MinLinear_MagLinear_MipLinear, comparisonKind: null, 0, 0, 0, 0, SamplerBorderColor.TransparentBlack)); }
public UIPreloader(ITagContainer diContainer) { world = diContainer.GetTag <DefaultEcs.World>(); mappedDb = diContainer.GetTag <zzio.db.MappedDB>(); Btn000 = Preload(out var tsBtn000, "btn000", isFont: false); Btn001 = Preload(out var tsBtn001, "btn001", isFont: false); Btn002 = Preload(out var tsBtn002, "btn002", isFont: false); Sld000 = Preload(out var tsSld000, "sld000", isFont: false); Tit000 = Preload(out var tsTit000, "tit000", isFont: false); Cur000 = Preload(out var tsCur000, "cur000", isFont: false); Dnd000 = Preload(out var tsDnd000, "dnd000", isFont: false); Wiz000 = Preload(out var tsWiz000, "wiz000", isFont: false); Itm000 = Preload(out var tsItm000, "itm000", isFont: false); Spl000 = Preload(out var tsSpl000, "spl000", isFont: false); Lne000 = Preload(out var tsLne000, "lne000", isFont: false); Fnt000 = Preload(out var tsFnt000, "fnt000", isFont: true, lineHeight: 14f, charSpacing: 1f); Fnt001 = Preload(out var tsFnt001, "fnt001", isFont: true, charSpacing: 1f); Fnt002 = Preload(out var tsFnt002, "fnt002", isFont: true, lineHeight: 17f, charSpacing: 1f, lineOffset: 2f); Fnt003 = Preload(out var tsFnt003, "fnt003", isFont: true, lineHeight: 14f, charSpacing: 1f); Fnt004 = Preload(out var tsFnt004, "fnt004", isFont: true, lineHeight: 14f, charSpacing: 1f); Fsp000 = Preload(out var tsFsp000, "fsp000", isFont: true); Inf000 = Preload(out var tsInf000, "inf000", isFont: false); Log000 = Preload(out var tsLog000, "log000", isFont: false); Cls000 = Preload(out var tsCls000, "cls000", isFont: false); Cls001 = Preload(out var tsCls001, "cls001", isFont: false); Map000 = Preload(out var tsMap000, "map000", isFont: false); tsFnt000.Alternatives.Add(tsFnt001); tsFnt000.Alternatives.Add(tsFnt002); tsFnt000.Alternatives.Add(tsFsp000); tsFnt000.Alternatives.Add(tsItm000); tsFnt000.Alternatives.Add(tsCls000); tsFnt000.Alternatives.Add(tsFnt003); tsFnt000.Alternatives.Add(tsLog000); tsFnt000.Alternatives.Add(tsCls001); tsFnt000.Alternatives.Add(tsFnt004); tsFnt001.Alternatives.Add(tsFnt002); tsFnt001.Alternatives.Add(tsInf000); tsFnt001.Alternatives.Add(tsFnt000); tsFnt002.Alternatives.Add(tsFnt001); tsFnt002.Alternatives.Add(tsInf000); tsFnt002.Alternatives.Add(tsFsp000); tsFnt002.Alternatives.Add(tsItm000); tsFnt002.Alternatives.Add(tsCls000); tsFnt002.Alternatives.Add(tsCls001); tsFnt003.Alternatives.Add(tsFnt001); tsFnt003.Alternatives.Add(tsFnt002); tsFnt003.Alternatives.Add(tsFsp000); tsFnt003.Alternatives.Add(tsItm000); tsFnt003.Alternatives.Add(tsFnt000); tsFnt003.Alternatives.Add(tsFnt000); tsFnt003.Alternatives.Add(tsLog000); tsFnt003.Alternatives.Add(tsCls001); tsFnt003.Alternatives.Add(tsFnt004); }
public NPC(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { worldCollider = diContainer.GetTag <WorldCollider>(); scene = diContainer.GetTag <Scene>(); mappedDB = diContainer.GetTag <zzio.db.MappedDB>(); sceneLoadSubscription = World.Subscribe <messages.SceneLoaded>(HandleSceneLoaded); setNpcModifierSubscription = World.Subscribe <zzio.GSModSetNPCModifier>(HandleSetNpcModifier); }
public AnimalWaypointAI(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { game = diContainer.GetTag <Game>(); scene = diContainer.GetTag <Scene>(); worldCollider = diContainer.GetTag <WorldCollider>(); sceneLoadedSubscription = World.Subscribe <messages.SceneLoaded>(HandleSceneLoaded); addSubscription = World.SubscribeComponentAdded <components.AnimalWaypointAI>(HandleAddedComponent); }
public PuppetActorMovement(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { worldCollider = diContainer.GetTag <WorldCollider>(); scene = diContainer.GetTag <Scene>(); addedSubscription = World.SubscribeComponentAdded <components.PuppetActorMovement>(HandleComponentAdded); placeToGroundSubscription = World.Subscribe <messages.CreaturePlaceToGround>(HandlePlaceToGround); placeToTriggerSubscription = World.Subscribe <messages.CreaturePlaceToTrigger>(HandlePlaceToTrigger); }
public DialogLookAt(ITagContainer diContainer) { game = diContainer.GetTag <Game>(); var world = diContainer.GetTag <DefaultEcs.World>(); addedSubscription = world.SubscribeComponentAdded <components.DialogState>(HandleAddedComponent); removedSubscription = world.SubscribeComponentRemoved <components.DialogState>(HandleRemovedComponent); changedSubscription = world.SubscribeComponentChanged <components.DialogState>(HandleChangedComponent); }
public TriggerActivation(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { var game = diContainer.GetTag <Game>(); scene = diContainer.GetTag <Scene>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); sceneLoadedSubscription = World.Subscribe <messages.SceneLoaded>(HandleSceneLoaded); disableTriggerSubscription = World.Subscribe <zzio.GSModDisableTrigger>(HandleDisableTrigger); }
public PlantWiggle(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { var game = diContainer.GetTag <Game>(); gameTime = diContainer.GetTag <GameTime>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); cameraLocation = diContainer.GetTag <rendering.Camera>().Location; addComponentSubscription = World.SubscribeComponentAdded <components.PlantWiggle>(HandleComponentAdded); }
protected NPCMovementBase(ITagContainer diContainer, Func <object, DefaultEcs.World, DefaultEcs.EntitySet> factory, bool useBuffer) : base(diContainer.GetTag <DefaultEcs.World>(), factory, useBuffer: true) { var game = diContainer.GetTag <Game>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); scene = diContainer.GetTag <Scene>(); sceneLoadedSubscription = World.Subscribe <messages.SceneLoaded>(HandleSceneLoaded); }
public ActorRenderer(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { this.diContainer = diContainer; camera = diContainer.GetTag <Camera>(); textureLoader = diContainer.GetTag <IAssetLoader <Texture> >(); addSubscription = World.SubscribeComponentAdded <components.ActorPart>(HandleAddedComponent); removeSubscription = World.SubscribeComponentRemoved <ModelSkinnedMaterial[]>(HandleRemovedComponent); }
public UIBitmap(ITagContainer diContainer) { this.diContainer = diContainer; ui = diContainer.GetTag <UI>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); resourceFactory = diContainer.GetTag <ResourceFactory>(); resourcePool = diContainer.GetTag <IResourcePool>(); Manage(diContainer.GetTag <DefaultEcs.World>()); }
public NPCActivator(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: true) { World.SetMaxCapacity <components.ActiveNPC>(1); var game = diContainer.GetTag <Game>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); Set.EntityRemoved += HandleEntityRemoved; }
protected override void DisposeManaged() { base.DisposeManaged(); diContainer.GetTag <LocationBuffer>().Remove(locationRange); clumpBuffers.Dispose(); foreach (var material in materials) { material.Dispose(); } }
public PlayerControls(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>()) { diContainer.AddTag(this); World.SetMaxCapacity <components.PlayerControls>(1); lockMessageSubscription = World.Subscribe <messages.LockPlayerControl>(HandleLockPlayerControl); ui = diContainer.GetTag <UI>(); zzContainer = diContainer.GetTag <IZanzarahContainer>(); zzContainer.OnKeyDown += HandleKeyDown; zzContainer.OnKeyUp += HandleKeyUp; }
public ModelComponent(ITagContainer diContainer) { diContainer.AddTag(this); this.diContainer = diContainer; editor = diContainer.GetTag <SceneEditor>(); editor.selectableContainers.Add(this); editor.fbArea.OnRender += HandleRender; editor.OnLoadScene += HandleLoadScene; diContainer.GetTag <MenuBarWindowTag>().AddCheckbox("View/Models", () => ref isVisible, () => editor.fbArea.IsDirty = true); editor.editor.AddInfoSection("Models", HandleInfoSection, false); }
public BehaviourCityDoor(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: false) { game = diContainer.GetTag <Game>(); playerLocationLazy = new Lazy <Location>(() => game.PlayerEntity.Get <Location>()); addedSubscription = World.SubscribeComponentAdded <components.behaviour.CityDoor>(HandleComponentAdded); locks = World .GetEntities() .With <components.behaviour.Lock>() .AsSet(); }
public static IBuiltPipeline Get(ITagContainer diContainer, Func <IPipelineBuilder, IBuiltPipeline> create) { if (diContainer.HasTag <PipelineFor <T> >()) { return(diContainer.GetTag <PipelineFor <T> >().Pipeline); } var holder = new PipelineFor <T>( create(diContainer.GetTag <PipelineCollection>().GetPipeline())); diContainer.AddTag(holder); return(holder.Pipeline); }
public WorldComponent(ITagContainer diContainer) { diContainer.AddTag(this); this.diContainer = diContainer; var fbArea = diContainer.GetTag <FramebufferArea>(); fbArea.OnRender += HandleRender; renderer = new WorldRenderer(diContainer); diContainer.GetTag <MenuBarWindowTag>().AddCheckbox("View/World", () => ref isVisible, () => fbArea.IsDirty = true); editor = diContainer.GetTag <SceneEditor>(); editor.OnLoadScene += HandleLoadScene; }
public Batcher(ITagContainer diContainer) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: false) { ui = diContainer.GetTag <UI>(); graphicsDevice = diContainer.GetTag <GraphicsDevice>(); resourceFactory = diContainer.GetTag <ResourceFactory>(); instanceBuffer = null !; emptyTexture = resourceFactory.CreateTexture( new TextureDescription(1, 1, 1, 1, 1, PixelFormat.R8_G8_B8_A8_UNorm, TextureUsage.Sampled, TextureType.Texture2D)); untexturedMaterial = new UIMaterial(diContainer, isFont: false); untexturedMaterial.Texture.Texture = emptyTexture; untexturedMaterial.ScreenSize.Buffer = diContainer.GetTag <UI>().ProjectionBuffer; }
protected BaseScreen(ITagContainer diContainer, BlockFlags blockFlags) : base(diContainer.GetTag <DefaultEcs.World>(), CreateEntityContainer, useBuffer: false) { this.blockFlags = blockFlags; zzContainer = diContainer.GetTag <IZanzarahContainer>(); zanzarah = diContainer.GetTag <Zanzarah>(); ui = diContainer.GetTag <UI>(); preload = ui.GetTag <UIPreloader>(); uiWorld = ui.GetTag <DefaultEcs.World>(); World.SetMaxCapacity <TComponent>(1); openSubscription = World.Subscribe <TMessage>(HandleOpen); addedSubscription = World.SubscribeComponentAdded <TComponent>(HandleAdded); removedSubscription = World.SubscribeComponentRemoved <TComponent>(HandleRemoved); }
public Savegame(ITagContainer diContainer) { world = diContainer.GetTag <DefaultEcs.World>(); scene = diContainer.GetTag <Scene>(); savegame = diContainer.GetTag <zzio.Savegame>(); disableAttackTriggerDisposable = world.Subscribe <GSModDisableAttackTrigger>(HandleDisableAttackTrigger); removeItemDisposable = world.Subscribe <GSModRemoveItem>(HandleRemoveItem); changeNpcStateDisposable = world.Subscribe <GSModChangeNPCState>(HandleChangeNpcState); disableTriggerDisposable = world.Subscribe <GSModDisableTrigger>(HandleDisableTrigger); removeModelDisposable = world.Subscribe <GSModRemoveModel>(HandleRemoveModel); setTriggerDisposable = world.Subscribe <GSModSetTrigger>(HandleSetTrigger); setNpcModifierDisposable = world.Subscribe <GSModSetNPCModifier>(HandleSetNpcModifier); gsmodForSceneDisposable = world.Subscribe <messages.GSModForScene>(HandleGSModForScene); }
public ActorEditor(ITagContainer diContainer) { this.diContainer = diContainer; device = diContainer.GetTag <GraphicsDevice>(); resourcePool = diContainer.GetTag <IResourcePool>(); Window = diContainer.GetTag <WindowContainer>().NewWindow("Actor Editor"); Window.InitialBounds = new Rect(float.NaN, float.NaN, 1100.0f, 600.0f); Window.AddTag(this); editor = new TwoColumnEditorTag(Window, diContainer); var onceAction = new OnceAction(); Window.AddTag(onceAction); Window.OnContent += onceAction.Invoke; var menuBar = new MenuBarWindowTag(Window); menuBar.AddButton("Open", HandleMenuOpen); fbArea = Window.GetTag <FramebufferArea>(); fbArea.OnResize += HandleResize; fbArea.OnRender += HandleRender; diContainer.GetTag <OpenDocumentSet>().AddEditor(this); openFileModal = new OpenFileModal(diContainer); openFileModal.Filter = "*.aed"; openFileModal.IsFilterChangeable = false; openFileModal.OnOpenedResource += Load; locationBuffer = new LocationBuffer(device); AddDisposable(locationBuffer); localDiContainer = diContainer.ExtendedWith(locationBuffer); camera = new Camera(localDiContainer); AddDisposable(camera); controls = new OrbitControlsTag(Window, camera.Location, localDiContainer); AddDisposable(controls); localDiContainer.AddTag(camera); gridRenderer = new DebugGridRenderer(diContainer); gridRenderer.Material.LinkTransformsTo(camera); gridRenderer.Material.World.Ref = Matrix4x4.Identity; AddDisposable(gridRenderer); localDiContainer.AddTag <IStandardTransformMaterial>(gridRenderer.Material); editor.AddInfoSection("Info", HandleInfoContent); editor.AddInfoSection("Animation Playback", HandlePlaybackContent); editor.AddInfoSection("Body animations", () => HandlePartContent(false, () => body?.AnimationsContent() ?? false), false); editor.AddInfoSection("Wings animations", () => HandlePartContent(true, () => wings?.AnimationsContent() ?? false), false); editor.AddInfoSection("Body skeleton", () => HandlePartContent(false, () => body?.skeletonRenderer.Content() ?? false), false); editor.AddInfoSection("Wings skeleton", () => HandlePartContent(true, () => wings?.skeletonRenderer.Content() ?? false), false); editor.AddInfoSection("Head IK", HandleHeadIKContent, false); }