| | 1 | | using DCL.Components.Video.Plugin; |
| | 2 | | using DCL.ECS7.ComponentWrapper; |
| | 3 | | using DCL.ECSComponents; |
| | 4 | | using DG.Tweening; |
| | 5 | | using System; |
| | 6 | | using System.Collections.Generic; |
| | 7 | | using UnityEngine; |
| | 8 | | using UnityEngine.UIElements; |
| | 9 | | using RaycastHit = DCL.ECSComponents.RaycastHit; |
| | 10 | |
|
| | 11 | | namespace DCL.ECS7.InternalComponents |
| | 12 | | { |
| | 13 | | public interface IInternalComponent |
| | 14 | | { |
| | 15 | | bool dirty { get; set; } |
| | 16 | | } |
| | 17 | |
|
| | 18 | | public struct InternalTexturizable : IInternalComponent |
| | 19 | | { |
| | 20 | | public bool dirty { get; set; } |
| | 21 | | public IList<Renderer> renderers; |
| | 22 | |
|
| | 23 | | public InternalTexturizable(List<Renderer> initialRenderers) |
| | 24 | | { |
| | 25 | | this.dirty = false; |
| | 26 | | this.renderers = initialRenderers; |
| | 27 | | } |
| | 28 | | } |
| | 29 | |
|
| | 30 | | public struct InternalMaterial : IInternalComponent |
| | 31 | | { |
| | 32 | | public bool dirty { get; set; } |
| | 33 | | public Material material; |
| | 34 | | public bool castShadows; |
| | 35 | |
|
| | 36 | | public InternalMaterial(Material material, bool castShadows) |
| | 37 | | { |
| | 38 | | this.dirty = false; |
| | 39 | | this.material = material; |
| | 40 | | this.castShadows = castShadows; |
| | 41 | | } |
| | 42 | | } |
| | 43 | |
|
| | 44 | | public struct InternalVideoMaterial : IInternalComponent |
| | 45 | | { |
| | 46 | | public readonly struct VideoTextureData |
| | 47 | | { |
| | 48 | | public readonly long videoId; |
| | 49 | | public readonly int textureType; |
| | 50 | |
|
| | 51 | | public VideoTextureData(long videoId, int textureType) |
| | 52 | | { |
| | 53 | | this.videoId = videoId; |
| | 54 | | this.textureType = textureType; |
| | 55 | | } |
| | 56 | | } |
| | 57 | |
|
| | 58 | | public bool dirty { get; set; } |
| | 59 | | public Material material; |
| | 60 | | public IList<VideoTextureData> videoTextureDatas; |
| | 61 | |
|
| | 62 | | public InternalVideoMaterial(Material material, IList<VideoTextureData> videoTextureDatas) |
| | 63 | | { |
| | 64 | | this.dirty = false; |
| | 65 | | this.material = material; |
| | 66 | | this.videoTextureDatas = videoTextureDatas; |
| | 67 | | } |
| | 68 | | } |
| | 69 | |
|
| | 70 | | public struct InternalVideoPlayer : IInternalComponent |
| | 71 | | { |
| | 72 | | public readonly struct MaterialAssigned |
| | 73 | | { |
| | 74 | | public readonly Material material; |
| | 75 | | public readonly int textureType; |
| | 76 | |
|
| | 77 | | public MaterialAssigned(Material material, int textureType) |
| | 78 | | { |
| | 79 | | this.material = material; |
| | 80 | | this.textureType = textureType; |
| | 81 | | } |
| | 82 | | } |
| | 83 | |
|
| | 84 | | public bool dirty { get; set; } |
| | 85 | | public bool removed; |
| | 86 | | public WebVideoPlayer videoPlayer; |
| | 87 | | public IList<MaterialAssigned> assignedMaterials; |
| | 88 | | } |
| | 89 | |
|
| | 90 | | public struct InternalColliders : IInternalComponent |
| | 91 | | { |
| | 92 | | public bool dirty { get; set; } |
| | 93 | | public KeyValueSet<Collider, uint> colliders; |
| | 94 | |
|
| | 95 | | public InternalColliders(KeyValueSet<Collider, uint> colliders) |
| | 96 | | { |
| | 97 | | this.dirty = false; |
| | 98 | | this.colliders = colliders; |
| | 99 | | } |
| | 100 | | } |
| | 101 | |
|
| | 102 | | public struct InternalRenderers : IInternalComponent |
| | 103 | | { |
| | 104 | | public bool dirty { get; set; } |
| | 105 | | public IList<Renderer> renderers; |
| | 106 | |
|
| | 107 | | public InternalRenderers(IList<Renderer> renderers) |
| | 108 | | { |
| | 109 | | this.dirty = false; |
| | 110 | | this.renderers = renderers; |
| | 111 | | } |
| | 112 | | } |
| | 113 | |
|
| | 114 | | public struct InternalAudioSource : IInternalComponent |
| | 115 | | { |
| | 116 | | public bool dirty { get; set; } |
| | 117 | | public AudioSource audioSource; |
| | 118 | | } |
| | 119 | |
|
| | 120 | | public struct InternalSceneBoundsCheck : IInternalComponent |
| | 121 | | { |
| | 122 | | public bool dirty { get; set; } |
| | 123 | | public Vector3 entityPosition; |
| | 124 | | public Bounds entityLocalMeshBounds; |
| | 125 | | public bool meshesDirty; |
| | 126 | | public IList<Renderer> renderers; |
| | 127 | | public KeyValueSet<Collider, uint> physicsColliders; |
| | 128 | | public KeyValueSet<Collider, uint> pointerColliders; |
| | 129 | | public Action<bool> OnSceneBoundsStateChange; |
| | 130 | |
|
| | 131 | | public InternalSceneBoundsCheck(Bounds entityLocalMeshBounds) |
| | 132 | | { |
| | 133 | | this.dirty = false; |
| | 134 | | this.entityPosition = Vector3.zero; |
| | 135 | | this.entityLocalMeshBounds = entityLocalMeshBounds; |
| | 136 | | this.meshesDirty = false; |
| | 137 | | this.renderers = null; |
| | 138 | | this.physicsColliders = null; |
| | 139 | | this.pointerColliders = null; |
| | 140 | | this.OnSceneBoundsStateChange = null; |
| | 141 | | } |
| | 142 | | } |
| | 143 | |
|
| | 144 | | public struct InternalVisibility : IInternalComponent |
| | 145 | | { |
| | 146 | | public bool dirty { get; set; } |
| | 147 | | public bool visible; |
| | 148 | |
|
| | 149 | | public InternalVisibility(bool visible) |
| | 150 | | { |
| | 151 | | this.dirty = false; |
| | 152 | | this.visible = visible; |
| | 153 | | } |
| | 154 | | } |
| | 155 | |
|
| | 156 | | public struct InternalInputEventResults : IInternalComponent |
| | 157 | | { |
| | 158 | | public struct EventData |
| | 159 | | { |
| | 160 | | public InputAction button; |
| | 161 | | public RaycastHit hit; |
| | 162 | | public PointerEventType type; |
| | 163 | | } |
| | 164 | |
|
| | 165 | | public bool dirty { get; set; } |
| | 166 | | public readonly IList<EventData> events; |
| | 167 | |
|
| | 168 | | public InternalInputEventResults(List<EventData> events) |
| | 169 | | { |
| | 170 | | this.dirty = false; |
| | 171 | | this.events = events; |
| | 172 | | } |
| | 173 | | } |
| | 174 | |
|
| | 175 | | public struct InternalUiContainer : IInternalComponent |
| | 176 | | { |
| | 177 | | public bool dirty { get; set; } |
| | 178 | | public readonly VisualElement rootElement; |
| | 179 | | public readonly HashSet<int> components; |
| | 180 | | public VisualElement parentElement; |
| | 181 | | public long parentId; |
| | 182 | | public long rightOf; |
| | 183 | | public bool shouldSort; |
| | 184 | |
|
| | 185 | | public InternalUiContainer(long entityId) |
| | 186 | | { |
| | 187 | | this.dirty = false; |
| | 188 | | this.components = new HashSet<int>(); |
| | 189 | | this.parentElement = null; |
| | 190 | | this.parentId = 0; |
| | 191 | | this.rightOf = 0; |
| | 192 | | this.shouldSort = false; |
| | 193 | |
|
| | 194 | | this.rootElement = new VisualElement(); |
| | 195 | | this.rootElement.pickingMode = PickingMode.Ignore; // ignore pointer by default |
| | 196 | | rootElement.name += $"(Id: {entityId})"; |
| | 197 | | } |
| | 198 | | } |
| | 199 | |
|
| | 200 | | public struct InternalPointerEvents : IInternalComponent |
| | 201 | | { |
| | 202 | | public readonly struct Entry |
| | 203 | | { |
| | 204 | | public readonly PointerEventType EventType; |
| | 205 | | public readonly Info EventInfo; |
| | 206 | |
|
| | 207 | | public Entry(PointerEventType eventType, Info eventInfo) |
| | 208 | | { |
| | 209 | | EventType = eventType; |
| | 210 | | EventInfo = eventInfo; |
| | 211 | | } |
| | 212 | | } |
| | 213 | |
|
| | 214 | | public readonly struct Info |
| | 215 | | { |
| | 216 | | public readonly InputAction Button; |
| | 217 | | public readonly string HoverText; |
| | 218 | | public readonly float MaxDistance; |
| | 219 | | public readonly bool ShowFeedback; |
| | 220 | |
|
| | 221 | | public Info(InputAction button, string hoverText, float maxDistance, bool showFeedback) |
| | 222 | | { |
| | 223 | | Button = button; |
| | 224 | | HoverText = hoverText; |
| | 225 | | MaxDistance = maxDistance; |
| | 226 | | ShowFeedback = showFeedback; |
| | 227 | | } |
| | 228 | | } |
| | 229 | |
|
| | 230 | | public bool dirty { get; set; } |
| | 231 | | public readonly List<Entry> PointerEvents; |
| | 232 | |
|
| | 233 | | public InternalPointerEvents(List<Entry> pointerEvents) |
| | 234 | | { |
| | 235 | | this.dirty = false; |
| | 236 | | this.PointerEvents = pointerEvents; |
| | 237 | | } |
| | 238 | | } |
| | 239 | |
|
| | 240 | | public struct InternalRegisteredUiPointerEvents : IInternalComponent |
| | 241 | | { |
| | 242 | | public bool dirty { get; set; } |
| | 243 | | public EventCallback<PointerDownEvent> OnPointerDownCallback; |
| | 244 | | public EventCallback<PointerUpEvent> OnPointerUpCallback; |
| | 245 | | public EventCallback<PointerEnterEvent> OnPointerEnterCallback; |
| | 246 | | public EventCallback<PointerLeaveEvent> OnPointerLeaveCallback; |
| | 247 | | } |
| | 248 | |
|
| | 249 | | public struct InternalRaycast : IInternalComponent |
| | 250 | | { |
| | 251 | | public bool dirty { get; set; } |
| | 252 | | public PBRaycast raycastModel; |
| | 253 | | } |
| | 254 | |
|
| | 255 | | public struct InternalGltfContainerLoadingState : IInternalComponent |
| | 256 | | { |
| | 257 | | public bool dirty { get; set; } |
| | 258 | | public LoadingState LoadingState; |
| | 259 | | public bool GltfContainerRemoved; |
| | 260 | | } |
| | 261 | |
|
| | 262 | | public struct InternalEngineInfo : IInternalComponent |
| | 263 | | { |
| | 264 | | public bool dirty { get; set; } |
| | 265 | | public uint SceneTick; |
| | 266 | | public float SceneInitialRunTime; |
| | 267 | | public int SceneInitialFrameCount; |
| | 268 | |
|
| | 269 | | public InternalEngineInfo(uint sceneTick, float sceneInitialRunTime) |
| | 270 | | { |
| | 271 | | this.dirty = false; |
| | 272 | | this.SceneTick = sceneTick; |
| | 273 | | this.SceneInitialRunTime = sceneInitialRunTime; |
| | 274 | | this.SceneInitialFrameCount = Time.frameCount; |
| | 275 | | } |
| | 276 | | } |
| | 277 | |
|
| | 278 | | public struct InternalUIInputResults : IInternalComponent |
| | 279 | | { |
| | 280 | | public readonly struct Result |
| | 281 | | { |
| | 282 | | public readonly IPooledWrappedComponent Message; |
| | 283 | | public readonly int ComponentId; |
| | 284 | |
|
| | 285 | | public Result(IPooledWrappedComponent message, int componentId) |
| | 286 | | { |
| 12 | 287 | | this.Message = message; |
| 12 | 288 | | this.ComponentId = componentId; |
| 12 | 289 | | } |
| | 290 | | } |
| | 291 | |
|
| 31 | 292 | | public bool dirty { get; set; } |
| | 293 | | public readonly Queue<Result> Results; |
| | 294 | |
|
| | 295 | | public InternalUIInputResults(Queue<Result> results) |
| | 296 | | { |
| 27 | 297 | | this.dirty = false; |
| 27 | 298 | | this.Results = results; |
| 27 | 299 | | } |
| | 300 | | } |
| | 301 | |
|
| | 302 | | public struct InternalAnimationPlayer : IInternalComponent |
| | 303 | | { |
| | 304 | | public bool dirty { get; set; } |
| | 305 | |
|
| | 306 | | public readonly struct State |
| | 307 | | { |
| | 308 | | public readonly string Clip; |
| | 309 | | public readonly bool Playing; |
| | 310 | | public readonly float Weight; |
| | 311 | | public readonly float Speed; |
| | 312 | | public readonly bool Loop; |
| | 313 | | public readonly bool ShouldReset; |
| | 314 | |
|
| | 315 | | public State(string clip, bool playing, float weight, float speed, bool loop, |
| | 316 | | bool shouldReset) |
| | 317 | | { |
| | 318 | | Clip = clip; |
| | 319 | | Playing = playing; |
| | 320 | | Weight = weight; |
| | 321 | | Speed = speed; |
| | 322 | | Loop = loop; |
| | 323 | | ShouldReset = shouldReset; |
| | 324 | | } |
| | 325 | | } |
| | 326 | |
|
| | 327 | | public readonly List<State> States; |
| | 328 | |
|
| | 329 | | public InternalAnimationPlayer(List<State> states) |
| | 330 | | { |
| | 331 | | States = states; |
| | 332 | | dirty = false; |
| | 333 | | } |
| | 334 | | } |
| | 335 | |
|
| | 336 | | public struct InternalAnimation : IInternalComponent |
| | 337 | | { |
| | 338 | | public bool dirty { get; set; } |
| | 339 | | public readonly Animation Animation; |
| | 340 | | public bool IsInitialized; |
| | 341 | |
|
| | 342 | | public InternalAnimation(Animation animation) |
| | 343 | | { |
| | 344 | | Animation = animation; |
| | 345 | | dirty = false; |
| | 346 | | IsInitialized = false; |
| | 347 | | } |
| | 348 | | } |
| | 349 | |
|
| | 350 | | public struct InternalTween : IInternalComponent |
| | 351 | | { |
| | 352 | | public bool dirty { get; set; } |
| | 353 | | public bool removed; |
| | 354 | | public bool playing; |
| | 355 | | public float currentTime; |
| | 356 | | public Transform transform; |
| | 357 | | public Tweener tweener; |
| | 358 | | public PBTween.ModeOneofCase tweenMode; |
| | 359 | | public PBTween lastModel; |
| | 360 | | } |
| | 361 | |
|
| | 362 | | public struct InternalAvatarModifierArea : IInternalComponent |
| | 363 | | { |
| | 364 | | public bool dirty { get; set; } |
| | 365 | | public bool removed; |
| | 366 | | public Vector3 area; |
| | 367 | | public HashSet<string> excludedIds; |
| | 368 | | public Action<GameObject> OnAvatarEnter; |
| | 369 | | public Action<GameObject> OnAvatarExit; |
| | 370 | | public HashSet<GameObject> avatarsInArea; |
| | 371 | | } |
| | 372 | | } |