-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
ParcelManager.cs
2408 lines (2153 loc) · 102 KB
/
ParcelManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2006-2016, openmetaverse.co
* Copyright (c) 2021-2022, Sjofn LLC
* All rights reserved.
*
* - Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* - Neither the name of the openmetaverse.co nor the names
* of its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Threading;
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using OpenMetaverse.Packets;
using OpenMetaverse.Interfaces;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Messages.Linden;
using System.Threading.Tasks;
using LibreMetaverse;
namespace OpenMetaverse
{
#region Enums
/// <summary>
/// Type of return to use when returning objects from a parcel
/// </summary>
public enum ObjectReturnType : uint
{
/// <summary></summary>
None = 0,
/// <summary>Return objects owned by parcel owner</summary>
Owner = 1 << 1,
/// <summary>Return objects set to group</summary>
Group = 1 << 2,
/// <summary>Return objects not owned by parcel owner or set to group</summary>
Other = 1 << 3,
/// <summary>Return a specific list of objects on parcel</summary>
List = 1 << 4,
/// <summary>Return objects that are marked for-sale</summary>
Sell = 1 << 5
}
/// <summary>
/// Blacklist/Whitelist flags used in parcels Access List
/// </summary>
public enum ParcelAccessFlags : uint
{
/// <summary>Agent is denied access</summary>
NoAccess = 0,
/// <summary>Agent is granted access</summary>
Access = 1
}
/// <summary>
/// The result of a request for parcel properties
/// </summary>
public enum ParcelResult : int
{
/// <summary>No matches were found for the request</summary>
NoData = -1,
/// <summary>Request matched a single parcel</summary>
Single = 0,
/// <summary>Request matched multiple parcels</summary>
Multiple = 1
}
/// <summary>
/// Flags used in the ParcelAccessListRequest packet to specify whether
/// we want the access list (whitelist), ban list (blacklist), or both
/// </summary>
[Flags]
public enum AccessList : uint
{
/// <summary>Request the access list</summary>
Access = 1 << 0,
/// <summary>Request the ban list</summary>
Ban = 1 << 1,
/// <summary>Request both White and Black lists</summary>
Both = Access | Ban
}
/// <summary>
/// Sequence ID in ParcelPropertiesReply packets (sent when avatar
/// tries to cross a parcel border)
/// </summary>
public enum ParcelPropertiesStatus : int
{
/// <summary>Parcel is currently selected</summary>
ParcelSelected = -10000,
/// <summary>Parcel restricted to a group the avatar is not a
/// member of</summary>
CollisionNotInGroup = -20000,
/// <summary>Avatar is banned from the parcel</summary>
CollisionBanned = -30000,
/// <summary>Parcel is restricted to an access list that the
/// avatar is not on</summary>
CollisionNotOnAccessList = -40000,
/// <summary>Response to hovering over a parcel</summary>
HoveredOverParcel = -50000
}
/// <summary>
/// The tool to use when modifying terrain levels
/// </summary>
public enum TerraformAction : byte
{
/// <summary>Level the terrain</summary>
Level = 0,
/// <summary>Raise the terrain</summary>
Raise = 1,
/// <summary>Lower the terrain</summary>
Lower = 2,
/// <summary>Smooth the terrain</summary>
Smooth = 3,
/// <summary>Add random noise to the terrain</summary>
Noise = 4,
/// <summary>Revert terrain to simulator default</summary>
Revert = 5
}
/// <summary>
/// The tool size to use when changing terrain levels
/// </summary>
public enum TerraformBrushSize : byte
{
/// <summary>Small</summary>
Small = 1,
/// <summary>Medium</summary>
Medium = 2,
/// <summary>Large</summary>
Large = 4
}
/// <summary>
/// Reasons agent is denied access to a parcel on the simulator
/// </summary>
public enum AccessDeniedReason : byte
{
/// <summary>Agent is not denied, access is granted</summary>
NotDenied = 0,
/// <summary>Agent is not a member of the group set for the parcel, or which owns the parcel</summary>
NotInGroup = 1,
/// <summary>Agent is not on the parcels specific allow list</summary>
NotOnAllowList = 2,
/// <summary>Agent is on the parcels ban list</summary>
BannedFromParcel = 3,
/// <summary>Unknown</summary>
NoAccess = 4,
/// <summary>Agent is not age verified and parcel settings deny access to non age verified avatars</summary>
NotAgeVerified = 5
}
/// <summary>
/// Parcel overlay type. This is used primarily for highlighting and
/// coloring which is why it is a single integer instead of a set of
/// flags
/// </summary>
/// <remarks>These values seem to be poorly thought out. The first three
/// bits represent a single value, not flags. For example Auction (0x05) is
/// not a combination of OwnedByOther (0x01) and ForSale(0x04). However,
/// the BorderWest and BorderSouth values are bit flags that get attached
/// to the value stored in the first three bits. Bits four, five, and six
/// are unused</remarks>
[Flags]
public enum ParcelOverlayType : byte
{
/// <summary>Public land</summary>
Public = 0,
/// <summary>Land is owned by another avatar</summary>
OwnedByOther = 1,
/// <summary>Land is owned by a group</summary>
OwnedByGroup = 2,
/// <summary>Land is owned by the current avatar</summary>
OwnedBySelf = 3,
/// <summary>Land is for sale</summary>
ForSale = 4,
/// <summary>Land is being auctioned</summary>
Auction = 5,
/// <summary>Land is private</summary>
Private = 32,
/// <summary>To the west of this area is a parcel border</summary>
BorderWest = 64,
/// <summary>To the south of this area is a parcel border</summary>
BorderSouth = 128
}
/// <summary>
/// Various parcel properties
/// </summary>
[Flags]
public enum ParcelFlags : uint
{
/// <summary>No flags set</summary>
None = 0,
/// <summary>Allow avatars to fly (a client-side only restriction)</summary>
AllowFly = 1 << 0,
/// <summary>Allow foreign scripts to run</summary>
AllowOtherScripts = 1 << 1,
/// <summary>This parcel is for sale</summary>
ForSale = 1 << 2,
/// <summary>Allow avatars to create a landmark on this parcel</summary>
AllowLandmark = 1 << 3,
/// <summary>Allows all avatars to edit the terrain on this parcel</summary>
AllowTerraform = 1 << 4,
/// <summary>Avatars have health and can take damage on this parcel.
/// If set, avatars can be killed and sent home here</summary>
AllowDamage = 1 << 5,
/// <summary>Foreign avatars can create objects here</summary>
CreateObjects = 1 << 6,
/// <summary>All objects on this parcel can be purchased</summary>
ForSaleObjects = 1 << 7,
/// <summary>Access is restricted to a group</summary>
UseAccessGroup = 1 << 8,
/// <summary>Access is restricted to a whitelist</summary>
UseAccessList = 1 << 9,
/// <summary>Ban blacklist is enabled</summary>
UseBanList = 1 << 10,
/// <summary>Unknown</summary>
UsePassList = 1 << 11,
/// <summary>List this parcel in the search directory</summary>
ShowDirectory = 1 << 12,
/// <summary>Allow personally owned parcels to be deeded to group</summary>
AllowDeedToGroup = 1 << 13,
/// <summary>If Deeded, owner contributes required tier to group parcel is deeded to</summary>
ContributeWithDeed = 1 << 14,
/// <summary>Restrict sounds originating on this parcel to the
/// parcel boundaries</summary>
SoundLocal = 1 << 15,
/// <summary>Objects on this parcel are sold when the land is
/// purchsaed</summary>
SellParcelObjects = 1 << 16,
/// <summary>Allow this parcel to be published on the web</summary>
AllowPublish = 1 << 17,
/// <summary>The information for this parcel is mature content</summary>
MaturePublish = 1 << 18,
/// <summary>The media URL is an HTML page</summary>
UrlWebPage = 1 << 19,
/// <summary>The media URL is a raw HTML string</summary>
UrlRawHtml = 1 << 20,
/// <summary>Restrict foreign object pushes</summary>
RestrictPushObject = 1 << 21,
/// <summary>Ban all non identified/transacted avatars</summary>
DenyAnonymous = 1 << 22,
// <summary>Ban all identified avatars [OBSOLETE]</summary>
//[Obsolete]
// This was obsoleted in 1.19.0 but appears to be recycled and is used on linden homes parcels
LindenHome = 1 << 23,
// <summary>Ban all transacted avatars [OBSOLETE]</summary>
//[Obsolete]
//DenyTransacted = 1 << 24,
/// <summary>Allow group-owned scripts to run</summary>
AllowGroupScripts = 1 << 25,
/// <summary>Allow object creation by group members or group
/// objects</summary>
CreateGroupObjects = 1 << 26,
/// <summary>Allow all objects to enter this parcel</summary>
AllowAPrimitiveEntry = 1 << 27,
/// <summary>Only allow group and owner objects to enter this parcel</summary>
AllowGroupObjectEntry = 1 << 28,
/// <summary>Voice Enabled on this parcel</summary>
AllowVoiceChat = 1 << 29,
/// <summary>Use Estate Voice channel for Voice on this parcel</summary>
UseEstateVoiceChan = 1 << 30,
/// <summary>Deny Age Unverified Users</summary>
DenyAgeUnverified = 1U << 31
}
/// <summary>
/// Parcel ownership status
/// </summary>
public enum ParcelStatus : sbyte
{
/// <summary>Placeholder</summary>
None = -1,
/// <summary>Parcel is leased (owned) by an avatar or group</summary>
Leased = 0,
/// <summary>Parcel is in process of being leased (purchased) by an avatar or group</summary>
LeasePending = 1,
/// <summary>Parcel has been abandoned back to Governor Linden</summary>
Abandoned = 2
}
/// <summary>
/// Category parcel is listed in under search
/// </summary>
public enum ParcelCategory : sbyte
{
/// <summary>No assigned category</summary>
None = 0,
/// <summary>Linden Infohub or public area</summary>
Linden,
/// <summary>Adult themed area</summary>
Adult,
/// <summary>Arts and Culture</summary>
Arts,
/// <summary>Business</summary>
Business,
/// <summary>Educational</summary>
Educational,
/// <summary>Gaming</summary>
Gaming,
/// <summary>Hangout or Club</summary>
Hangout,
/// <summary>Newcomer friendly</summary>
Newcomer,
/// <summary>Parks and Nature</summary>
Park,
/// <summary>Residential</summary>
Residential,
/// <summary>Shopping</summary>
Shopping,
/// <summary>Not Used?</summary>
Stage,
/// <summary>Other</summary>
Other,
/// <summary>Not an actual category, only used for queries</summary>
Any = -1
}
/// <summary>
/// Type of teleport landing for a parcel
/// </summary>
public enum LandingType : byte
{
/// <summary>Unset, simulator default</summary>
None = 0,
/// <summary>Specific landing point set for this parcel</summary>
LandingPoint = 1,
/// <summary>No landing point set, direct teleports enabled for
/// this parcel</summary>
Direct = 2
}
/// <summary>
/// Parcel Media Command used in ParcelMediaCommandMessage
/// </summary>
public enum ParcelMediaCommand : uint
{
/// <summary>Stop the media stream and go back to the first frame</summary>
Stop = 0,
/// <summary>Pause the media stream (stop playing but stay on current frame)</summary>
Pause,
/// <summary>Start the current media stream playing and stop when the end is reached</summary>
Play,
/// <summary>Start the current media stream playing,
/// loop to the beginning when the end is reached and continue to play</summary>
Loop,
/// <summary>Specifies the texture to replace with video</summary>
/// <remarks>If passing the key of a texture, it must be explicitly typecast as a key,
/// not just passed within double quotes.</remarks>
Texture,
/// <summary>Specifies the movie URL (254 characters max)</summary>
URL,
/// <summary>Specifies the time index at which to begin playing</summary>
Time,
/// <summary>Specifies a single agent to apply the media command to</summary>
Agent,
/// <summary>Unloads the stream. While the stop command sets the texture to the first frame of the movie,
/// unload resets it to the real texture that the movie was replacing.</summary>
Unload,
/// <summary>Turn on/off the auto align feature, similar to the auto align checkbox in the parcel media properties
/// (NOT to be confused with the "align" function in the textures view of the editor!) Takes TRUE or FALSE as parameter.</summary>
AutoAlign,
/// <summary>Allows a Web page or image to be placed on a prim (1.19.1 RC0 and later only).
/// Use "text/html" for HTML.</summary>
Type,
/// <summary>Resizes a Web page to fit on x, y pixels (1.19.1 RC0 and later only).</summary>
/// <remarks>This might still not be working</remarks>
Size,
/// <summary>Sets a description for the media being displayed (1.19.1 RC0 and later only).</summary>
Desc
}
#endregion Enums
#region Structs
/// <summary>
/// Some information about a parcel of land returned from a DirectoryManager search
/// </summary>
public struct ParcelInfo
{
/// <summary>Global Key of record</summary>
public UUID ID;
/// <summary>Parcel Owners <seealso cref="UUID"/></summary>
public UUID OwnerID;
/// <summary>Name field of parcel, limited to 128 characters</summary>
public string Name;
/// <summary>Description field of parcel, limited to 256 characters</summary>
public string Description;
/// <summary>Total Square meters of parcel</summary>
public int ActualArea;
/// <summary>Total area billable as Tier, for group owned land this will be 10% less than ActualArea</summary>
public int BillableArea;
/// <summary>True of parcel is in Mature simulator</summary>
public bool Mature;
/// <summary>Grid global X position of parcel</summary>
public float GlobalX;
/// <summary>Grid global Y position of parcel</summary>
public float GlobalY;
/// <summary>Grid global Z position of parcel (not used)</summary>
public float GlobalZ;
/// <summary>Name of simulator parcel is located in</summary>
public string SimName;
/// <summary>Texture <seealso cref="T:OpenMetaverse.UUID"/> of parcels display picture</summary>
public UUID SnapshotID;
/// <summary>Float representing calculated traffic based on time spent on parcel by avatars</summary>
public float Dwell;
/// <summary>Sale price of parcel (not used)</summary>
public int SalePrice;
/// <summary>Auction ID of parcel</summary>
public int AuctionID;
}
/// <summary>
/// Parcel Media Information
/// </summary>
public struct ParcelMedia
{
/// <summary>A byte, if 0x1 viewer should auto scale media to fit object</summary>
public bool MediaAutoScale;
/// <summary>A boolean, if true the viewer should loop the media</summary>
public bool MediaLoop;
/// <summary>The Asset UUID of the Texture which when applied to a
/// primitive will display the media</summary>
public UUID MediaID;
/// <summary>A URL which points to any Quicktime supported media type</summary>
public string MediaURL;
/// <summary>A description of the media</summary>
public string MediaDesc;
/// <summary>An Integer which represents the height of the media</summary>
public int MediaHeight;
/// <summary>An integer which represents the width of the media</summary>
public int MediaWidth;
/// <summary>A string which contains the mime type of the media</summary>
public string MediaType;
}
#endregion Structs
#region Parcel Class
/// <summary>
/// Parcel of land, a portion of virtual real estate in a simulator
/// </summary>
public class Parcel
{
/// <summary>The total number of contiguous 4x4 meter blocks your agent owns within this parcel</summary>
public int SelfCount;
/// <summary>The total number of contiguous 4x4 meter blocks contained in this parcel owned by a group or agent other than your own</summary>
public int OtherCount;
/// <summary>Deprecated, Value appears to always be 0</summary>
public int PublicCount;
/// <summary>Simulator-local ID of this parcel</summary>
public int LocalID;
/// <summary>UUID of the owner of this parcel</summary>
public UUID OwnerID;
/// <summary>Whether the land is deeded to a group or not</summary>
public bool IsGroupOwned;
/// <summary></summary>
public uint AuctionID;
/// <summary>Date land was claimed</summary>
public DateTime ClaimDate;
/// <summary>Appears to always be zero</summary>
public int ClaimPrice;
/// <summary>This field is no longer used</summary>
public int RentPrice;
/// <summary>Minimum corner of the axis-aligned bounding box for this
/// parcel</summary>
public Vector3 AABBMin;
/// <summary>Maximum corner of the axis-aligned bounding box for this
/// parcel</summary>
public Vector3 AABBMax;
/// <summary>Bitmap describing land layout in 4x4m squares across the
/// entire region</summary>
public byte[] Bitmap;
/// <summary>Total parcel land area</summary>
public int Area;
/// <summary></summary>
public ParcelStatus Status;
/// <summary>Maximum primitives across the entire simulator owned by the same agent or group that owns this parcel that can be used</summary>
public int SimWideMaxPrims;
/// <summary>Total primitives across the entire simulator calculated by combining the allowed prim counts for each parcel
/// owned by the agent or group that owns this parcel</summary>
public int SimWideTotalPrims;
/// <summary>Maximum number of primitives this parcel supports</summary>
public int MaxPrims;
/// <summary>Total number of primitives on this parcel</summary>
public int TotalPrims;
/// <summary>For group-owned parcels this indicates the total number of prims deeded to the group,
/// for parcels owned by an individual this inicates the number of prims owned by the individual</summary>
public int OwnerPrims;
/// <summary>Total number of primitives owned by the parcel group on
/// this parcel, or for parcels owned by an individual with a group set the
/// total number of prims set to that group.</summary>
public int GroupPrims;
/// <summary>Total number of prims owned by other avatars that are not set to group, or not the parcel owner</summary>
public int OtherPrims;
/// <summary>A bonus multiplier which allows parcel prim counts to go over times this amount, this does not affect
/// the max prims per simulator. e.g: 117 prim parcel limit x 1.5 bonus = 175 allowed</summary>
public float ParcelPrimBonus;
/// <summary>Autoreturn value in minutes for others' objects</summary>
public int OtherCleanTime;
/// <summary></summary>
public ParcelFlags Flags;
/// <summary>Sale price of the parcel, only useful if ForSale is set</summary>
/// <remarks>The SalePrice will remain the same after an ownership
/// transfer (sale), so it can be used to see the purchase price after
/// a sale if the new owner has not changed it</remarks>
public int SalePrice;
/// <summary>Parcel Name</summary>
public string Name;
/// <summary>Parcel Description</summary>
public string Desc;
/// <summary>URL For Music Stream</summary>
public string MusicURL;
/// <summary></summary>
public UUID GroupID;
/// <summary>Price for a temporary pass</summary>
public int PassPrice;
/// <summary>How long is pass valid for</summary>
public float PassHours;
/// <summary></summary>
public ParcelCategory Category;
/// <summary>Key of authorized buyer</summary>
public UUID AuthBuyerID;
/// <summary>Key of parcel snapshot</summary>
public UUID SnapshotID;
/// <summary>The landing point location</summary>
public Vector3 UserLocation;
/// <summary>The landing point LookAt</summary>
public Vector3 UserLookAt;
/// <summary>The type of landing enforced from the <see cref="LandingType"/> enum</summary>
public LandingType Landing;
/// <summary>Traffic count</summary>
public float Dwell;
/// <summary></summary>
public bool RegionDenyAnonymous;
/// <summary></summary>
public bool RegionPushOverride;
/// <summary>Access list of who is whitelisted on this
/// parcel</summary>
public List<ParcelManager.ParcelAccessEntry> AccessWhiteList;
/// <summary>Access list of who is blacklisted on this
/// parcel</summary>
public List<ParcelManager.ParcelAccessEntry> AccessBlackList;
/// <summary>TRUE of region denies access to age unverified users</summary>
public bool RegionDenyAgeUnverified;
/// <summary>true to obscure (hide) media url</summary>
public bool ObscureMedia;
/// <summary>true to obscure (hide) music url</summary>
public bool ObscureMusic;
/// <summary>A struct containing media details</summary>
public ParcelMedia Media;
/// <summary>Parcel privacy see avatars outside/inside parcel</summary>
public bool SeeAVs;
/// <summary>Parcel privacy play sounds attached to avatars outside/inside parcel</summary>
public bool AnyAVSounds;
/// <summary>Parcel privacy play sounds for group members</summary>
public bool GroupAVSounds;
/// <summary>
/// Displays a parcel object in string format
/// </summary>
/// <returns>string containing key=value pairs of a parcel object</returns>
public override string ToString()
{
Type parcelType = this.GetType();
FieldInfo[] fields = parcelType.GetFields();
return fields.Aggregate("", (current, field) => current + (field.Name + " = " + field.GetValue(this) + " "));
}
/// <summary>
/// Default constructor
/// </summary>
/// <param name="localID">Local ID of this parcel</param>
public Parcel(int localID)
{
LocalID = localID;
ClaimDate = Utils.Epoch;
Bitmap = Utils.EmptyBytes;
Name = string.Empty;
Desc = string.Empty;
MusicURL = string.Empty;
AccessWhiteList = new List<ParcelManager.ParcelAccessEntry>(0);
AccessBlackList = new List<ParcelManager.ParcelAccessEntry>(0);
Media = new ParcelMedia();
}
/// <summary>
/// Update the simulator with any local changes to this Parcel object
/// </summary>
/// <param name="client">Client message originates from</param>
/// <param name="simulator">Simulator to send updates to</param>
/// <param name="wantReply">Whether we want the simulator to confirm
/// the update with a reply packet or not</param>
public void Update(GridClient client, Simulator simulator, bool wantReply)
{
Uri cap = simulator.Caps.CapabilityURI("ParcelPropertiesUpdate");
if (cap != null)
{
ParcelPropertiesUpdateMessage payload = new ParcelPropertiesUpdateMessage
{
AuthBuyerID = AuthBuyerID,
Category = Category,
Desc = Desc,
GroupID = GroupID,
Landing = Landing,
LocalID = LocalID,
MediaAutoScale = Media.MediaAutoScale,
MediaDesc = Media.MediaDesc,
MediaHeight = Media.MediaHeight,
MediaID = Media.MediaID,
MediaLoop = Media.MediaLoop,
MediaType = Media.MediaType,
MediaURL = Media.MediaURL,
MediaWidth = Media.MediaWidth,
MusicURL = MusicURL,
Name = Name,
ObscureMedia = ObscureMedia,
ObscureMusic = ObscureMusic,
ParcelFlags = Flags,
PassHours = PassHours,
PassPrice = (uint) PassPrice,
SalePrice = (uint) SalePrice,
SnapshotID = SnapshotID,
UserLocation = UserLocation,
UserLookAt = UserLookAt,
SeeAVs = SeeAVs,
AnyAVSounds = AnyAVSounds,
GroupAVSounds = GroupAVSounds
};
Task req = client.HttpCapsClient.PostRequestAsync(cap, OSDFormat.Xml, payload.Serialize(),
CancellationToken.None, null);
}
else // lludp fallback
{
ParcelPropertiesUpdatePacket updatePacket = new ParcelPropertiesUpdatePacket
{
AgentData =
{
AgentID = simulator.Client.Self.AgentID,
SessionID = simulator.Client.Self.SessionID
},
ParcelData =
{
LocalID = LocalID,
AuthBuyerID = AuthBuyerID,
Category = (byte) Category,
Desc = Utils.StringToBytes(Desc),
GroupID = GroupID,
LandingType = (byte) Landing,
MediaAutoScale = (Media.MediaAutoScale) ? (byte) 0x1 : (byte) 0x0,
MediaID = Media.MediaID,
MediaURL = Utils.StringToBytes(Media.MediaURL),
MusicURL = Utils.StringToBytes(MusicURL),
Name = Utils.StringToBytes(Name)
}
};
if (wantReply)
{
updatePacket.ParcelData.Flags = 1;
}
updatePacket.ParcelData.ParcelFlags = (uint)Flags;
updatePacket.ParcelData.PassHours = PassHours;
updatePacket.ParcelData.PassPrice = PassPrice;
updatePacket.ParcelData.SalePrice = SalePrice;
updatePacket.ParcelData.SnapshotID = SnapshotID;
updatePacket.ParcelData.UserLocation = UserLocation;
updatePacket.ParcelData.UserLookAt = UserLookAt;
simulator.SendPacket(updatePacket);
}
UpdateOtherCleanTime(simulator);
}
/// <summary>
/// Set Autoreturn time
/// </summary>
/// <param name="simulator">Simulator to send the update to</param>
public void UpdateOtherCleanTime(Simulator simulator)
{
ParcelSetOtherCleanTimePacket request = new ParcelSetOtherCleanTimePacket
{
AgentData =
{
AgentID = simulator.Client.Self.AgentID,
SessionID = simulator.Client.Self.SessionID
},
ParcelData =
{
LocalID = LocalID,
OtherCleanTime = OtherCleanTime
}
};
simulator.SendPacket(request);
}
}
#endregion Parcel Class
/// <summary>
/// Parcel (subdivided simulator lots) subsystem
/// </summary>
public class ParcelManager
{
#region Structs
/// <summary>
/// Parcel Accesslist
/// </summary>
public struct ParcelAccessEntry
{
/// <summary>Agents <seealso cref="T:OpenMetaverse.UUID"/></summary>
public UUID AgentID;
/// <summary></summary>
public DateTime Time;
/// <summary>Flags for specific entry in white/black lists</summary>
public AccessList Flags;
}
/// <summary>
/// Owners of primitives on parcel
/// </summary>
public struct ParcelPrimOwners
{
/// <summary>Prim Owners <seealso cref="T:OpenMetaverse.UUID"/></summary>
public UUID OwnerID;
/// <summary>True of owner is group</summary>
public bool IsGroupOwned;
/// <summary>Total count of prims owned by OwnerID</summary>
public int Count;
/// <summary>true of OwnerID is currently online and is not a group</summary>
public bool OnlineStatus;
/// <summary>The date of the most recent prim left by OwnerID</summary>
public DateTime NewestPrim;
}
#endregion Structs
#region Delegates
/// <summary>
/// Called once parcel resource usage information has been collected
/// </summary>
/// <param name="success">Indicates if operation was successfull</param>
/// <param name="info">Parcel resource usage information</param>
public delegate void LandResourcesCallback(bool success, LandResourcesInfo info);
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelDwellReplyEventArgs> m_DwellReply;
/// <summary>Raises the ParcelDwellReply event</summary>
/// <param name="e">A ParcelDwellReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelDwellReply(ParcelDwellReplyEventArgs e)
{
EventHandler<ParcelDwellReplyEventArgs> handler = m_DwellReply;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_DwellReplyLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestDwell"/> request</summary>
public event EventHandler<ParcelDwellReplyEventArgs> ParcelDwellReply
{
add { lock (m_DwellReplyLock) { m_DwellReply += value; } }
remove { lock (m_DwellReplyLock) { m_DwellReply -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelInfoReplyEventArgs> m_ParcelInfo;
/// <summary>Raises the ParcelInfoReply event</summary>
/// <param name="e">A ParcelInfoReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelInfoReply(ParcelInfoReplyEventArgs e)
{
EventHandler<ParcelInfoReplyEventArgs> handler = m_ParcelInfo;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelInfoLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestParcelInfo"/> request</summary>
public event EventHandler<ParcelInfoReplyEventArgs> ParcelInfoReply
{
add { lock (m_ParcelInfoLock) { m_ParcelInfo += value; } }
remove { lock (m_ParcelInfoLock) { m_ParcelInfo -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelPropertiesEventArgs> m_ParcelProperties;
/// <summary>Raises the ParcelProperties event</summary>
/// <param name="e">A ParcelPropertiesEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelProperties(ParcelPropertiesEventArgs e)
{
EventHandler<ParcelPropertiesEventArgs> handler = m_ParcelProperties;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelPropertiesLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestParcelProperties"/> request</summary>
public event EventHandler<ParcelPropertiesEventArgs> ParcelProperties
{
add { lock (m_ParcelPropertiesLock) { m_ParcelProperties += value; } }
remove { lock (m_ParcelPropertiesLock) { m_ParcelProperties -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelAccessListReplyEventArgs> m_ParcelACL;
/// <summary>Raises the ParcelAccessListReply event</summary>
/// <param name="e">A ParcelAccessListReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelAccessListReply(ParcelAccessListReplyEventArgs e)
{
EventHandler<ParcelAccessListReplyEventArgs> handler = m_ParcelACL;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelACLLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestParcelAccessList"/> request</summary>
public event EventHandler<ParcelAccessListReplyEventArgs> ParcelAccessListReply
{
add { lock (m_ParcelACLLock) { m_ParcelACL += value; } }
remove { lock (m_ParcelACLLock) { m_ParcelACL -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelObjectOwnersReplyEventArgs> m_ParcelObjectOwnersReply;
/// <summary>Raises the ParcelObjectOwnersReply event</summary>
/// <param name="e">A ParcelObjectOwnersReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelObjectOwnersReply(ParcelObjectOwnersReplyEventArgs e)
{
EventHandler<ParcelObjectOwnersReplyEventArgs> handler = m_ParcelObjectOwnersReply;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelObjectOwnersLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestObjectOwners"/> request</summary>
public event EventHandler<ParcelObjectOwnersReplyEventArgs> ParcelObjectOwnersReply
{
add { lock (m_ParcelObjectOwnersLock) { m_ParcelObjectOwnersReply += value; } }
remove { lock (m_ParcelObjectOwnersLock) { m_ParcelObjectOwnersReply -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<SimParcelsDownloadedEventArgs> m_SimParcelsDownloaded;
/// <summary>Raises the SimParcelsDownloaded event</summary>
/// <param name="e">A SimParcelsDownloadedEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnSimParcelsDownloaded(SimParcelsDownloadedEventArgs e)
{
EventHandler<SimParcelsDownloadedEventArgs> handler = m_SimParcelsDownloaded;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_SimParcelsDownloadedLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestAllSimParcels"/> request</summary>
public event EventHandler<SimParcelsDownloadedEventArgs> SimParcelsDownloaded
{
add { lock (m_SimParcelsDownloadedLock) { m_SimParcelsDownloaded += value; } }
remove { lock (m_SimParcelsDownloadedLock) { m_SimParcelsDownloaded -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ForceSelectObjectsReplyEventArgs> m_ForceSelectObjects;
/// <summary>Raises the ForceSelectObjectsReply event</summary>
/// <param name="e">A ForceSelectObjectsReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnForceSelectObjectsReply(ForceSelectObjectsReplyEventArgs e)
{
EventHandler<ForceSelectObjectsReplyEventArgs> handler = m_ForceSelectObjects;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ForceSelectObjectsLock = new object();
/// <summary>Raised when the simulator responds to a <see cref="RequestForceSelectObjects"/> request</summary>
public event EventHandler<ForceSelectObjectsReplyEventArgs> ForceSelectObjectsReply
{
add { lock (m_ForceSelectObjectsLock) { m_ForceSelectObjects += value; } }
remove { lock (m_ForceSelectObjectsLock) { m_ForceSelectObjects -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelMediaUpdateReplyEventArgs> m_ParcelMediaUpdateReply;
/// <summary>Raises the ParcelMediaUpdateReply event</summary>
/// <param name="e">A ParcelMediaUpdateReplyEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelMediaUpdateReply(ParcelMediaUpdateReplyEventArgs e)
{
EventHandler<ParcelMediaUpdateReplyEventArgs> handler = m_ParcelMediaUpdateReply;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelMediaUpdateReplyLock = new object();
/// <summary>Raised when the simulator responds to a Parcel Update request</summary>
public event EventHandler<ParcelMediaUpdateReplyEventArgs> ParcelMediaUpdateReply
{
add { lock (m_ParcelMediaUpdateReplyLock) { m_ParcelMediaUpdateReply += value; } }
remove { lock (m_ParcelMediaUpdateReplyLock) { m_ParcelMediaUpdateReply -= value; } }
}
/// <summary>The event subscribers. null if no subcribers</summary>
private EventHandler<ParcelMediaCommandEventArgs> m_ParcelMediaCommand;
/// <summary>Raises the ParcelMediaCommand event</summary>
/// <param name="e">A ParcelMediaCommandEventArgs object containing the
/// data returned from the simulator</param>
protected virtual void OnParcelMediaCommand(ParcelMediaCommandEventArgs e)
{
EventHandler<ParcelMediaCommandEventArgs> handler = m_ParcelMediaCommand;
handler?.Invoke(this, e);
}
/// <summary>Thread sync lock object</summary>
private readonly object m_ParcelMediaCommandLock = new object();
/// <summary>Raised when the parcel your agent is located sends a ParcelMediaCommand</summary>
public event EventHandler<ParcelMediaCommandEventArgs> ParcelMediaCommand
{
add { lock (m_ParcelMediaCommandLock) { m_ParcelMediaCommand += value; } }
remove { lock (m_ParcelMediaCommandLock) { m_ParcelMediaCommand -= value; } }
}
#endregion Delegates
private GridClient Client;
private AutoResetEvent WaitForSimParcel;
#region Public Methods
/// <summary>
/// Default constructor
/// </summary>
/// <param name="client">A reference to the GridClient object</param>
public ParcelManager(GridClient client)
{
Client = client;
// Setup the callbacks
Client.Network.RegisterCallback(PacketType.ParcelInfoReply, ParcelInfoReplyHandler);
Client.Network.RegisterEventCallback("ParcelObjectOwnersReply", ParcelObjectOwnersReplyHandler);
// CAPS packet handler, to allow for Media Data not contained in the message template
Client.Network.RegisterEventCallback("ParcelProperties", ParcelPropertiesReplyHandler);
Client.Network.RegisterCallback(PacketType.ParcelDwellReply, ParcelDwellReplyHandler);
Client.Network.RegisterCallback(PacketType.ParcelAccessListReply, ParcelAccessListReplyHandler);
Client.Network.RegisterCallback(PacketType.ForceObjectSelect, SelectParcelObjectsReplyHandler);
Client.Network.RegisterCallback(PacketType.ParcelMediaUpdate, ParcelMediaUpdateHandler);
Client.Network.RegisterCallback(PacketType.ParcelOverlay, ParcelOverlayHandler);
Client.Network.RegisterCallback(PacketType.ParcelMediaCommandMessage, ParcelMediaCommandMessagePacketHandler);
}
/// <summary>
/// Request basic information for a single parcel
/// </summary>