public async Task Apply(Configuration config) { Dictionary <SceneActor, TargetService.ActorTableActor>?lookup = null; if (config.IncludeActors && this.Actors != null) { lookup = await ActorSelector.GetActors(this.Actors); } if (TerritoryService.Instance.CurrentTerritoryId != this.TerritoryId) { this.RootPosition = Vector.Zero; if (lookup != null && lookup.Count > 0) { // Use the position of the first valid actor as the root position foreach ((SceneActor scene, TargetService.ActorTableActor actor) in lookup) { ActorViewModel?actorVm = actor.GetViewModel(); if (actorVm == null) { continue; } if (this.RootPosition == Vector.Zero && actorVm.ModelObject?.Transform != null) { this.RootPosition = actorVm.ModelObject.Transform.Position; } } } else { // No actors to fall back on means no positions config.IncludeActorPosition = false; config.IncludeCamera = false; } // TODO: Check to see if the desired weather is available for this map config.IncludeWeather = false; } if (config.IncludeTime && this.TimeOfDay != null && this.DayOfMonth != null) { TimeService.Instance.Freeze = true; TimeService.Instance.TimeOfDay = (int)this.TimeOfDay; TimeService.Instance.DayOfMonth = (int)this.DayOfMonth; } if (config.IncludeWeather && this.Weather != null) { TerritoryService.Instance.CurrentWeatherId = (ushort)this.Weather; } if (lookup != null && lookup.Count != 0) { if (await GposeService.LeaveGpose("You must not be in Gpose to apply actor appearances")) { foreach ((SceneActor scene, TargetService.ActorTableActor actor) in lookup) { ActorViewModel?actorVm = actor.GetViewModel(); if (actorVm == null) { continue; } await scene.ApplyOverworld(actorVm, config); } } if (await GposeService.EnterGpose("You must be in Gpose to apply actor poses")) { foreach ((SceneActor scene, TargetService.ActorTableActor actor) in lookup) { ActorViewModel?actorVm = actor.GetViewModel(); if (actorVm == null) { continue; } await scene.ApplyGpose(actorVm, this.RootPosition, config); } } } if (await GposeService.EnterGpose("You must be in Gpose to apply camera settings")) { if (config.IncludeCamera && CameraService.Instance.Camera != null) { if (this.UnlimitCamera != null) { CameraService.Instance.DelimitCamera = (bool)this.UnlimitCamera; } if (this.CameraAngle != null) { CameraService.Instance.Camera.Angle = (Vector2D)this.CameraAngle; } if (this.CameraYMin != null) { CameraService.Instance.Camera.YMin = (float)this.CameraYMin; } if (this.CameraYMax != null) { CameraService.Instance.Camera.YMax = (float)this.CameraYMax; } if (this.CameraPan != null) { CameraService.Instance.Camera.Pan = (Vector2D)this.CameraPan; } if (this.CameraRotation != null) { CameraService.Instance.Camera.Rotation = (float)this.CameraRotation; } if (this.CameraZoom != null) { CameraService.Instance.Camera.Zoom = (float)this.CameraZoom; } if (this.CameraMinZoom != null) { CameraService.Instance.Camera.MinZoom = (float)this.CameraMinZoom; } if (this.CameraMaxZoom != null) { CameraService.Instance.Camera.MaxZoom = (float)this.CameraMaxZoom; } if (this.CameraFieldOfView != null) { CameraService.Instance.Camera.FieldOfView = (float)this.CameraFieldOfView; } if (this.CameraPosition != null) { CameraService.Instance.CameraPosition = (Vector)this.CameraPosition; } } } }
public static async Task <Dictionary <SceneFile.SceneActor, TargetService.ActorTableActor> > GetActors(List <SceneFile.SceneActor> actors) { ActorSelector selector = new ActorSelector(actors); return(await ViewService.ShowDialog <ActorSelector, Dictionary <SceneFile.SceneActor, TargetService.ActorTableActor> >("Select Actors", selector)); }