private void DestroyComponents() { this.sceneObjectForComponents?.Destroy(); this.sceneObjectForComponents = null; this.blueprintRenderer = null; this.tilesBlueprint = null; ClientLandClaimAreaManager.RemoveBlueprintRenderer(); }
private static void InitGameplayMode(ICharacter currentCharacter) { ClientCurrentCharacterContainersHelper.Init(currentCharacter); ClientItemsManager.Init(currentCharacter); ClientDroppedItemsNotifier.Init(currentCharacter); var layoutRootChildren = Api.Client.UI.LayoutRootChildren; layoutRootChildren.Add(new HUDLayoutControl()); layoutRootChildren.Add(new ChatPanel()); ClientContainersExchangeManager.Reset(); CraftingQueueControl.Instance?.Refresh(); var input = Api.Client.Scene.CreateSceneObject("Input components"); input.AddComponent <ClientComponentHotbarHelper>(); input.AddComponent <ClientComponentWindowStructureSelectListToogle>(); input.AddComponent <ClientComponentObjectInteractionHelper>(); // ReSharper disable once CanExtractXamlLocalizableStringCSharp gameplayInputContext = ClientInputContext .Start("Menu toggles") .HandleButtonDown( GameButton.InventoryMenu, () => { if (Menu.IsOpened <ClientCurrentInteractionMenu>()) { // shortcut - close all currently opened menus and return Menu.CloseAll(); return; } Menu.Toggle <WindowInventory>(); }) .HandleButtonDown(GameButton.CraftingMenu, Menu.Toggle <WindowHandCrafting>) .HandleButtonDown(GameButton.MapMenu, Menu.Toggle <WindowWorldMap>) .HandleButtonDown(GameButton.SkillsMenu, Menu.Toggle <WindowSkills>) .HandleButtonDown(GameButton.TechnologiesMenu, Menu.Toggle <WindowTechnologies>) .HandleButtonDown(GameButton.SocialMenu, Menu.Toggle <WindowSocial>) .HandleButtonDown(GameButton.QuestsMenu, Menu.Toggle <WindowQuests>) .HandleButtonDown(GameButton.OpenChat, () => { if (WindowsManager.OpenedWindowsCount == 0) { ChatPanel.Instance.Open(); } }); sceneObjectInputComponents = input; ClientComponentWorldCameraZoomManager.Instance.ZoomBounds = ZoomBoundsGameplayMode; }
static ClientWorldObjectClaimTooltipManager() { SceneObjectCurrentTagInfo = Api.Client.Scene.CreateSceneObject(nameof(ClientWorldObjectClaimTooltipManager)); controlCurrentObjectDescription = new WorldObjectClaimTooltip(); componentCurrentObjectDescription = Api.Client.UI.AttachControl( SceneObjectCurrentTagInfo, controlCurrentObjectDescription, positionOffset: default,
protected virtual BaseClientComponentLightSource ClientCreateLightSource(IClientSceneObject sceneObject) { return(ClientLighting.CreateLightSourceSpot( sceneObject, color: this.LightColor, size: (float)this.LightSize, spritePivotPoint: this.LightWorldSpritePivotPoint, positionOffset: this.LightWorldOffset)); }
public ViewModelInventorySkeletonViewData( ICharacter character, IClientSceneObject sceneObjectCamera, IClientSceneObject sceneObjectSkeleton, ICamera2D camera, IRenderTarget2D renderTarget2D, string renderingTag, float textureWidth, float textureHeight) { this.character = character; this.equipmentContainer = (IClientItemsContainer)character .GetPublicState <ICharacterPublicStateWithEquipment>() .ContainerEquipment; this.equipmentContainer.StateHashChanged += this.EquipmentContainerStateHashChangedHandler; this.sceneObjectCamera = sceneObjectCamera; this.sceneObjectSkeleton = sceneObjectSkeleton; this.camera = camera; this.renderTarget2D = renderTarget2D; this.renderingTag = renderingTag; this.textureWidth = textureWidth; this.textureHeight = textureHeight; this.ImageBrush = InventorySkeletonViewHelper.Client.UI.CreateImageBrushForRenderTarget( renderTarget2D); this.ImageBrush.Stretch = Stretch.Uniform; // subscribe on change of the face // commented out - no need, the skeleton will be rebuilt completely //var publicState = PlayerCharacter.GetPublicState(character); //publicState.ClientSubscribe( // _ => _.FaceStyle, // _ => this.OnNeedRefreshEquipment(), // this); // subscribe on change of the equipment var clientState = PlayerCharacter.GetClientState(character); clientState.ClientSubscribe( _ => _.LastEquipmentContainerHash, _ => this.OnNeedRefreshEquipment(), this); var publicState = PlayerCharacter.GetPublicState(character); publicState.ClientSubscribe( _ => _.IsHeadEquipmentHiddenForSelfAndPartyMembers, _ => this.OnNeedRefreshEquipment(), this); this.RefreshEquipment(); }
public static void CreateCliffRenderer( IClientSceneObject sceneObject, ColumnRow textureRegion, TextureAtlasResource cliffAtlas) { RenderingService.CreateSpriteRenderer( sceneObject, cliffAtlas.Chunk(textureRegion.Column, textureRegion.Row), drawOrder: DrawOrder.GroundCliffs, positionOffset: (0, 0)); }
protected override BaseClientComponentLightSource ClientCreateLightSource( IItem item, ICharacter character, IClientSceneObject sceneObject) { var lightSource = base.ClientCreateLightSource(item, character, sceneObject); // restore circle shape by using x2 height lightSource.RenderingSize = new Size2F(lightSource.RenderingSize.X, lightSource.RenderingSize.Y * 2); return(lightSource); }
protected override BaseClientComponentLightSource ClientCreateLightSource(IClientSceneObject sceneObject) { var lightSource = base.ClientCreateLightSource(sceneObject); // add light flickering sceneObject.AddComponent <ClientComponentLightSourceEffectFlickering>() .Setup(lightSource, flickeringPercents: 5, flickeringChangePercentsPerSecond: 33); return(lightSource); }
public ClientBlueprintTilesRenderer(IClientSceneObject sceneObjectRoot) { this.sceneObjectRoot = sceneObjectRoot; if (renderingMaterial is null) { renderingMaterial = RenderingMaterial.Create(new EffectResource("SolidColor")); renderingMaterial.EffectParameters.Set(EffectParameters); } this.Reset(); }
public ClientBlueprintRenderer(IClientSceneObject sceneObjectRoot) { this.sceneObjectRoot = sceneObjectRoot; this.SpriteRenderer = Api.Client.Rendering.CreateSpriteRenderer( sceneObjectRoot, TextureResource.NoTexture); this.SpriteRenderer.RenderingMaterial = RenderingMaterial.Create(new EffectResource("ConstructionPlacement")); this.Reset(); }
private void DestroyComponents() { this.sceneObjectForComponents?.Destroy(); this.sceneObjectForComponents = null; if (this.blueprintRenderer == null) { return; } this.blueprintRenderer = null; this.tilesBlueprint = null; }
public ClientLandClaimAreaRenderer( Color zoneColor, DrawOrder drawOrder, int inflateSize = 0) { this.drawOrder = drawOrder; this.inflateSize = inflateSize; this.material = CreateRenderingMaterial(); this.material.EffectParameters.Set("Color", zoneColor); this.sceneObject = Api.Client.Scene.CreateSceneObject( nameof(ClientLandClaimAreaRenderer) + " with color=" + zoneColor); }
static ClientObjectDepositTooltipHelper() { SceneObject = Api.Client.Scene.CreateSceneObject(nameof(ClientObjectDepositTooltipHelper)); DepositTooltipControl = new DepositTooltipControl(); ComponentAttachedUIElement = Api.Client.UI.AttachControl( SceneObject, DepositTooltipControl, positionOffset: (0, 0), isFocusable: false); ComponentAttachedUIElement.IsEnabled = false; }
protected virtual IComponentSoundEmitter ClientCreateActiveStateSoundEmitterComponent( IStaticWorldObject worldObject, IClientSceneObject sceneObject) { return(Client.Audio.CreateSoundEmitter( sceneObject, soundResource: worldObject.ProtoStaticWorldObject .SharedGetObjectSoundPreset() .GetSound(ObjectSound.Active), is3D: true, radius: Client.Audio.CalculateObjectSoundRadius(worldObject), isLooped: true)); }
private void CreateWaterRendererBlendInternal( IClientSceneObject sceneObject, IProtoTileWater protoTileWater, ClientTileBlendHelper.BlendLayer blendLayer) { var renderer = Client.Rendering.CreateSpriteRenderer( sceneObject, protoTileWater.UnderwaterGroundTextureAtlas, drawOrder: DrawOrder.GroundBlend); renderer.RenderingMaterial = protoTileWater.ClientGetWaterBlendMaterial(blendLayer); renderer.SortByWorldPosition = false; renderer.Size = ScriptingConstants.TileSizeRenderingVirtualSize; }
public EditorToolZoneRenderer(ClientZoneProvider zoneProvider) { this.material = RenderingMaterial.Create(new EffectResource("SolidColor")); this.sceneObject = Api.Client.Scene.CreateSceneObject( "EditorToolZones / Zone renderer - " + zoneProvider.ProtoZone.ShortId); this.ZoneProvider = zoneProvider; this.ZoneProvider.ZoneModified += this.ZoneModifiedHandler; this.ZoneProvider.ZoneReset += this.ZoneResetHandler; ClientComponentUpdateHelper.UpdateCallback += this.Update; this.RebuildAllRenderers(); }
private void CreateWaterRendererInternal( IClientSceneObject sceneObject, IProtoTileWater protoTileWater) { var renderer = Client.Rendering.CreateSpriteRenderer( sceneObject, protoTileWater.UnderwaterGroundTextureAtlas, // currently we place water instead of ground for tile drawOrder: DrawOrder.Ground); renderer.RenderingMaterial = protoTileWater.ClientGetWaterPrimaryMaterial(); renderer.SortByWorldPosition = false; renderer.Size = ScriptingConstants.TileSizeRenderingVirtualSize; }
protected override BaseClientComponentLightSource ClientCreateLightSource( IItem item, ICharacter character, IClientSceneObject sceneObject) { var lightSource = base.ClientCreateLightSource(item, character, sceneObject); // add light flickering sceneObject.AddComponent <ClientComponentLightSourceEffectFlickering>() .Setup(lightSource, flickeringPercents: 10, flickeringChangePercentsPerSecond: 70); return(lightSource); }
public EditorActiveToolTileBrush( [NotNull] ApplyToolDelegate onSelected, Func <List <Vector2Ushort>, bool> validateCallback = null, Action onDispose = null, bool isRepeatOnMove = true, bool isReactOnRightMouseButton = false, [CanBeNull] Action onReleaseInput = null) { this.onDispose = onDispose; this.SceneObject = Api.Client.Scene.CreateSceneObject("ActiveEditorToolBrush", Vector2D.Zero); this.Component = this.SceneObject.AddComponent <ClientComponentEditorToolActiveTileBrush>(); this.Component.Setup(onSelected, validateCallback, isRepeatOnMove, inputReleasedCallback: onReleaseInput); this.Component.IsReactOnRightMouseButton = isReactOnRightMouseButton; }
public static BaseClientComponentLightSource CreateLightSourceSpot( IClientSceneObject sceneObject, IReadOnlyItemLightConfig itemLightConfig, Vector2D?positionOffset = null) { if (!itemLightConfig.IsLightEnabled) { return(null); } return(CreateLightSourceSpot( sceneObject, itemLightConfig.Color, size: (float)itemLightConfig.Size, positionOffset: positionOffset)); }
public EditorToolZoneRenderer(ClientZoneProvider zoneProvider) { this.material = RenderingMaterial.Create(new EffectResource("LandClaimArea")); this.material.EffectParameters.Set("SpriteTexture", new TextureResource("FX/EditorZoneTile")); this.sceneObject = Api.Client.Scene.CreateSceneObject( "EditorToolZones / Zone renderer - " + zoneProvider.ProtoZone.ShortId); this.ZoneProvider = zoneProvider; this.ZoneProvider.ZoneModified += this.ZoneModifiedHandler; this.ZoneProvider.ZoneReset += this.ZoneResetHandler; ClientUpdateHelper.UpdateCallback += this.Update; this.RebuildAllRenderers(); }
public static IComponentSpriteRenderer CreateOcclusionRenderer( IClientSceneObject sceneObject, ITextureResource textureResource, Vector2D?positionOffset = null, bool extractMaskFromColor = false) { var result = Rendering.CreateSpriteRenderer( sceneObject, textureResource, drawOrder: DrawOrder.Occlusion, positionOffset: positionOffset, renderingTag: RenderingTag); SetupComponent(result, extractMaskFromColor); return(result); }
public static BaseClientComponentLightSource CreateLightSourceSpot( IClientSceneObject sceneObject, IReadOnlyItemLightConfig itemLightConfig, Vector2D?overrideWorldOffset = null) { if (!itemLightConfig.IsLightEnabled) { return(null); } return(CreateLightSourceSpot( sceneObject, itemLightConfig.Color, size: itemLightConfig.Size, logicalSize: itemLightConfig.LogicalSize, positionOffset: overrideWorldOffset ?? itemLightConfig.WorldOffset)); }
protected override ITextureResource ClientSetupTileRendering(Tile tile, IClientSceneObject sceneObject) { var position = tile.Position; if (position.X % 2 == 0 && position.Y % 2 == 0) { // add light source ClientLighting.CreateLightSourceSpot( sceneObject, color: LightColors.Lava, size: (12, 12 * 1.5), positionOffset: (0.5, 0.5)); } return(base.ClientSetupTileRendering(tile, sceneObject)); }
public void Destroy() { if (this.sceneObject is null) { throw new Exception("Already destroyed"); } if (ReferenceEquals(Instance, this)) { Instance = null; } this.sceneObject.Destroy(); this.sceneObject = null; ClientUpdateHelper.UpdateCallback -= this.Update; }
public ClientBlueprintRenderer( IClientSceneObject sceneObjectRoot, bool isConstructionSite, Vector2D centerOffset) { this.sceneObjectRoot = sceneObjectRoot; this.IsConstructionSite = isConstructionSite; this.textBlockCannotBuildReasonOffset = centerOffset + (0, TextBlockCannotBuildReasonOffsetY); this.SpriteRenderer = Api.Client.Rendering.CreateSpriteRenderer( sceneObjectRoot, TextureResource.NoTexture); this.SpriteRenderer.RenderingMaterial = RenderingMaterial.Create(new EffectResource("ConstructionPlacement")); this.Reset(); }
private static void SetupBoundsForLandClaimsInScope( IClientSceneObject sceneObject, Vector2D sceneObjectPosition, Vector2Ushort originTilePosition, RectangleInt originBounds, IProtoObjectLandClaim originProtoObjectLandClaim) { var landClaims = Api.Client.World.GetStaticWorldObjectsOfProto <IProtoObjectLandClaim>(); foreach (var landClaim in landClaims) { var protoObjectLandClaim = (IProtoObjectLandClaim)landClaim.ProtoGameObject; var landClaimCenterPosition = LandClaimSystem .SharedCalculateLandClaimObjectCenterTilePosition( landClaim.TilePosition, protoObjectLandClaim); var landClaimBounds = LandClaimSystem.SharedCalculateLandClaimAreaBounds( landClaimCenterPosition, protoObjectLandClaim.LandClaimWithGraceAreaSize); var intersectionDepth = CalculateIntersectionDepth(originBounds, landClaimBounds); if (intersectionDepth < 0) { // no intersection continue; } intersectionDepth = (intersectionDepth + 1) / 2; intersectionDepth = Math.Min(intersectionDepth, originProtoObjectLandClaim.LandClaimGraceAreaPaddingSizeOneDirection + 1); var exceptBounds = originBounds.Inflate(-intersectionDepth); using var tempList = Api.Shared.WrapObjectInTempList(exceptBounds); AddBoundLabels(sceneObject, sceneObjectPosition, exceptBounds: tempList.AsList(), protoObjectLandClaim, positionOffset: landClaimCenterPosition.ToVector2D() - originTilePosition.ToVector2D()); } }
public ClientLandClaimGroupsRendererManager( Color zoneColor, DrawOrder drawOrder, bool isGraceAreaRenderer = false) { this.drawOrder = drawOrder; this.isGraceAreaRenderer = isGraceAreaRenderer; this.material = ClientLandClaimGroupRenderer.CreateRenderingMaterial(); this.material.EffectParameters.Set("Color", zoneColor); this.sceneObject = Api.Client.Scene.CreateSceneObject(nameof(ClientLandClaimGroupsRendererManager) + " " + zoneColor); this.callbackGetRendererFromCache = this.GetRendererFromCache; this.callbackReturnRendererToCache = this.ReturnRendererToCache; this.UpdateByTimer(); }
private void SetupComponents() { this.DestroyComponents(); this.sceneObjectForComponents = Client.Scene.CreateSceneObject( $"Scene object for {nameof(ClientComponentObjectPlacementHelper)} components"); this.sceneObjectForComponents .AddComponent <SceneObjectPositionSynchronizer>() .Setup(this.SceneObject); this.blueprintRenderer = new ClientBlueprintRenderer(this.sceneObjectForComponents); this.tilesBlueprint = new ClientBlueprintTilesRenderer(this.sceneObjectForComponents); this.tilesBlueprint.Setup(this.protoStaticWorldObject.Layout); if (this.isDrawConstructionGrid) { ClientConstructionGridRendererHelper.Setup(this.sceneObjectForComponents, this.protoStaticWorldObject); } }
public EditorActiveToolObjectBrush( IProtoStaticWorldObject protoStaticObject, [NotNull] Action <List <Vector2Ushort> > onSelected, Action onDispose = null) { this.protoStaticObject = protoStaticObject; this.onSelected = onSelected; this.onDispose = onDispose; this.sceneObject = Api.Client.Scene.CreateSceneObject("ActiveEditorToolBrush", Vector2D.Zero); this.sceneObject.AddComponent <ClientComponentObjectPlacementHelper>() .Setup( protoStaticObject, isCancelable: false, isRepeatCallbackIfHeld: true, isDrawConstructionGrid: false, isBlockingInput: false, validateCanPlaceCallback: this.ValidateCanBuild, placeSelectedCallback: this.PlaceSelectedHandler); }