Annotation of /trunk/ModularRex/RexFramework/RexObjectProperties.cs
Parent Directory
|
Revision Log
Revision 42 - (view) (download)
| 1 : | mikkopa | 28 | using System; |
| 2 : | mikkopa | 39 | using System.Collections; |
| 3 : | mikkopa | 28 | using System.Collections.Generic; |
| 4 : | using System.Reflection; | ||
| 5 : | using System.Text; | ||
| 6 : | using System.Xml; | ||
| 7 : | using System.Xml.Schema; | ||
| 8 : | using System.Xml.Serialization; | ||
| 9 : | using log4net; | ||
| 10 : | using OpenMetaverse; | ||
| 11 : | |||
| 12 : | namespace ModularRex.RexFramework | ||
| 13 : | { | ||
| 14 : | public delegate void OnRexObjectPropertiesUpdateDelegate(UUID id, RexObjectProperties prop, bool dbSave); | ||
| 15 : | |||
| 16 : | public delegate void OnRexObjectPropertiesDataUpdateDelegate(UUID id, string data, bool dbSave); | ||
| 17 : | |||
| 18 : | mikkopa | 42 | public delegate void OnChangePythonClassDelegate(UUID id); |
| 19 : | |||
| 20 : | mikkopa | 28 | public class RexObjectProperties |
| 21 : | { | ||
| 22 : | private static readonly ILog m_log = | ||
| 23 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 24 : | |||
| 25 : | mikkopa | 39 | #region Properties |
| 26 : | mikkopa | 28 | |
| 27 : | mikkopa | 39 | private UUID parentObjectID = UUID.Zero; |
| 28 : | public UUID ParentObjectID | ||
| 29 : | { | ||
| 30 : | get { return parentObjectID; } | ||
| 31 : | set { parentObjectID = value; } | ||
| 32 : | mikkopa | 28 | } |
| 33 : | |||
| 34 : | mikkopa | 39 | private byte m_RexDrawType = 1; |
| 35 : | mikkopa | 28 | public byte RexDrawType |
| 36 : | { | ||
| 37 : | get { return m_RexDrawType; } | ||
| 38 : | set | ||
| 39 : | { | ||
| 40 : | m_RexDrawType = value; | ||
| 41 : | SchedulePropertiesUpdate(true); | ||
| 42 : | } | ||
| 43 : | } | ||
| 44 : | |||
| 45 : | private bool m_RexIsVisible = true; | ||
| 46 : | public bool RexIsVisible | ||
| 47 : | { | ||
| 48 : | get { return m_RexIsVisible; } | ||
| 49 : | set | ||
| 50 : | { | ||
| 51 : | m_RexIsVisible = value; | ||
| 52 : | SchedulePropertiesUpdate(true); | ||
| 53 : | } | ||
| 54 : | } | ||
| 55 : | |||
| 56 : | mikkopa | 39 | private bool m_RexCastShadows = false; |
| 57 : | mikkopa | 28 | public bool RexCastShadows |
| 58 : | { | ||
| 59 : | get { return m_RexCastShadows; } | ||
| 60 : | set | ||
| 61 : | { | ||
| 62 : | m_RexCastShadows = value; | ||
| 63 : | SchedulePropertiesUpdate(true); | ||
| 64 : | } | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | mikkopa | 39 | private bool m_RexLightCreatesShadows = false; |
| 68 : | mikkopa | 28 | public bool RexLightCreatesShadows |
| 69 : | { | ||
| 70 : | get { return m_RexLightCreatesShadows; } | ||
| 71 : | set | ||
| 72 : | { | ||
| 73 : | m_RexLightCreatesShadows = value; | ||
| 74 : | SchedulePropertiesUpdate(true); | ||
| 75 : | } | ||
| 76 : | } | ||
| 77 : | |||
| 78 : | mikkopa | 39 | private bool m_RexDescriptionTexture = false; |
| 79 : | mikkopa | 28 | public bool RexDescriptionTexture |
| 80 : | { | ||
| 81 : | get { return m_RexDescriptionTexture; } | ||
| 82 : | set | ||
| 83 : | { | ||
| 84 : | m_RexDescriptionTexture = value; | ||
| 85 : | SchedulePropertiesUpdate(true); | ||
| 86 : | } | ||
| 87 : | } | ||
| 88 : | |||
| 89 : | mikkopa | 39 | private bool m_RexScaleToPrim = false; |
| 90 : | mikkopa | 28 | public bool RexScaleToPrim |
| 91 : | { | ||
| 92 : | get { return m_RexScaleToPrim; } | ||
| 93 : | set | ||
| 94 : | { | ||
| 95 : | m_RexScaleToPrim = value; | ||
| 96 : | SchedulePropertiesUpdate(true); | ||
| 97 : | } | ||
| 98 : | } | ||
| 99 : | |||
| 100 : | mikkopa | 39 | private float m_RexDrawDistance = 0; |
| 101 : | mikkopa | 28 | public float RexDrawDistance |
| 102 : | { | ||
| 103 : | get { return m_RexDrawDistance; } | ||
| 104 : | set | ||
| 105 : | { | ||
| 106 : | m_RexDrawDistance = value; | ||
| 107 : | SchedulePropertiesUpdate(true); | ||
| 108 : | } | ||
| 109 : | } | ||
| 110 : | |||
| 111 : | private float m_RexLOD = 1.0F; | ||
| 112 : | public float RexLOD | ||
| 113 : | { | ||
| 114 : | get { return m_RexLOD; } | ||
| 115 : | set | ||
| 116 : | { | ||
| 117 : | m_RexLOD = value; | ||
| 118 : | SchedulePropertiesUpdate(true); | ||
| 119 : | } | ||
| 120 : | } | ||
| 121 : | |||
| 122 : | private UUID m_RexMeshUUID = UUID.Zero; | ||
| 123 : | public UUID RexMeshUUID | ||
| 124 : | { | ||
| 125 : | get { return m_RexMeshUUID; } | ||
| 126 : | set | ||
| 127 : | { | ||
| 128 : | m_RexMeshUUID = value; | ||
| 129 : | SchedulePropertiesUpdate(true); | ||
| 130 : | } | ||
| 131 : | } | ||
| 132 : | |||
| 133 : | private UUID m_RexCollisionMeshUUID = UUID.Zero; | ||
| 134 : | public UUID RexCollisionMeshUUID | ||
| 135 : | { | ||
| 136 : | get { return m_RexCollisionMeshUUID; } | ||
| 137 : | set | ||
| 138 : | { | ||
| 139 : | m_RexCollisionMeshUUID = value; | ||
| 140 : | SchedulePropertiesUpdate(true); | ||
| 141 : | } | ||
| 142 : | } | ||
| 143 : | |||
| 144 : | private UUID m_RexParticleScriptUUID = UUID.Zero; | ||
| 145 : | public UUID RexParticleScriptUUID | ||
| 146 : | { | ||
| 147 : | get { return m_RexParticleScriptUUID; } | ||
| 148 : | set | ||
| 149 : | { | ||
| 150 : | m_RexParticleScriptUUID = value; | ||
| 151 : | SchedulePropertiesUpdate(true); | ||
| 152 : | } | ||
| 153 : | } | ||
| 154 : | |||
| 155 : | private UUID m_RexAnimationPackageUUID = UUID.Zero; | ||
| 156 : | public UUID RexAnimationPackageUUID | ||
| 157 : | { | ||
| 158 : | get { return m_RexAnimationPackageUUID; } | ||
| 159 : | set | ||
| 160 : | { | ||
| 161 : | m_RexAnimationPackageUUID = value; | ||
| 162 : | SchedulePropertiesUpdate(true); | ||
| 163 : | } | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | private string m_RexAnimationName = String.Empty; | ||
| 167 : | public string RexAnimationName | ||
| 168 : | { | ||
| 169 : | get { return m_RexAnimationName; } | ||
| 170 : | set | ||
| 171 : | { | ||
| 172 : | m_RexAnimationName = value; | ||
| 173 : | SchedulePropertiesUpdate(true); | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | private float m_RexAnimationRate = 1.0F; | ||
| 178 : | public float RexAnimationRate | ||
| 179 : | { | ||
| 180 : | get { return m_RexAnimationRate; } | ||
| 181 : | set | ||
| 182 : | { | ||
| 183 : | m_RexAnimationRate = value; | ||
| 184 : | SchedulePropertiesUpdate(true); | ||
| 185 : | } | ||
| 186 : | } | ||
| 187 : | |||
| 188 : | mikkopa | 39 | |
| 189 : | #region Material Stuff | ||
| 190 : | |||
| 191 : | mikkopa | 28 | public RexMaterialsDictionary RexMaterials = new RexMaterialsDictionary(); |
| 192 : | public RexMaterialsDictionary GetRexMaterials() | ||
| 193 : | { | ||
| 194 : | return (RexMaterialsDictionary)RexMaterials.Clone(); | ||
| 195 : | } | ||
| 196 : | |||
| 197 : | mikkopa | 39 | /// <summary> |
| 198 : | /// This is only to be used from NHibernate. Use RexMaterials instead in other cases. | ||
| 199 : | /// </summary> | ||
| 200 : | public IList<RexMaterialsDictionaryItem> RexMaterialDictionaryItems | ||
| 201 : | { | ||
| 202 : | get | ||
| 203 : | { | ||
| 204 : | IList<RexMaterialsDictionaryItem> tempRexMaterialDictionaryItems = new List<RexMaterialsDictionaryItem>(); | ||
| 205 : | foreach (KeyValuePair<uint, UUID> entry in RexMaterials) | ||
| 206 : | { | ||
| 207 : | tempRexMaterialDictionaryItems.Add(new RexMaterialsDictionaryItem(entry)); | ||
| 208 : | } | ||
| 209 : | return tempRexMaterialDictionaryItems; | ||
| 210 : | } | ||
| 211 : | set | ||
| 212 : | { | ||
| 213 : | //rexMaterialDictionary = new Dictionary<uint, UUID>(); | ||
| 214 : | if (value != null) | ||
| 215 : | { | ||
| 216 : | foreach (RexMaterialsDictionaryItem e in value) | ||
| 217 : | { | ||
| 218 : | //rexMaterialDictionary.Add(e.Num, e.AssetID); | ||
| 219 : | RexMaterials.Add(e.Num, e.AssetID); | ||
| 220 : | } | ||
| 221 : | } | ||
| 222 : | } | ||
| 223 : | } | ||
| 224 : | |||
| 225 : | #endregion | ||
| 226 : | |||
| 227 : | mikkopa | 28 | private string m_RexClassName = String.Empty; |
| 228 : | public string RexClassName | ||
| 229 : | { | ||
| 230 : | get { return m_RexClassName; } | ||
| 231 : | set | ||
| 232 : | { | ||
| 233 : | m_RexClassName = value; | ||
| 234 : | mikkopa | 42 | TriggerOnChangePythonClass(parentObjectID); |
| 235 : | mikkopa | 28 | SchedulePropertiesUpdate(true); |
| 236 : | } | ||
| 237 : | } | ||
| 238 : | |||
| 239 : | private UUID m_RexSoundUUID = UUID.Zero; | ||
| 240 : | public UUID RexSoundUUID | ||
| 241 : | { | ||
| 242 : | get { return m_RexSoundUUID; } | ||
| 243 : | set | ||
| 244 : | { | ||
| 245 : | m_RexSoundUUID = value; | ||
| 246 : | SchedulePropertiesUpdate(true); | ||
| 247 : | } | ||
| 248 : | } | ||
| 249 : | |||
| 250 : | mikkopa | 39 | private float m_RexSoundVolume = 0; |
| 251 : | mikkopa | 28 | public float RexSoundVolume |
| 252 : | { | ||
| 253 : | get { return m_RexSoundVolume; } | ||
| 254 : | set | ||
| 255 : | { | ||
| 256 : | m_RexSoundVolume = value; | ||
| 257 : | SchedulePropertiesUpdate(true); | ||
| 258 : | } | ||
| 259 : | } | ||
| 260 : | |||
| 261 : | mikkopa | 39 | private float m_RexSoundRadius = 0; |
| 262 : | mikkopa | 28 | public float RexSoundRadius |
| 263 : | { | ||
| 264 : | get { return m_RexSoundRadius; } | ||
| 265 : | set | ||
| 266 : | { | ||
| 267 : | m_RexSoundRadius = value; | ||
| 268 : | SchedulePropertiesUpdate(true); | ||
| 269 : | } | ||
| 270 : | } | ||
| 271 : | |||
| 272 : | private string m_rexData = String.Empty; | ||
| 273 : | public string RexData | ||
| 274 : | { | ||
| 275 : | get { return m_rexData; } | ||
| 276 : | set | ||
| 277 : | { | ||
| 278 : | if (value.Length > 3000) | ||
| 279 : | m_rexData = value.Substring(0, 3000); | ||
| 280 : | else | ||
| 281 : | m_rexData = value; | ||
| 282 : | |||
| 283 : | ScheduleDataUpdate(true); | ||
| 284 : | } | ||
| 285 : | } | ||
| 286 : | |||
| 287 : | mikkopa | 39 | private int m_RexSelectPriority = 0; |
| 288 : | mikkopa | 28 | public int RexSelectPriority |
| 289 : | { | ||
| 290 : | get { return m_RexSelectPriority; } | ||
| 291 : | set | ||
| 292 : | { | ||
| 293 : | m_RexSelectPriority = value; | ||
| 294 : | SchedulePropertiesUpdate(true); | ||
| 295 : | } | ||
| 296 : | } | ||
| 297 : | #endregion | ||
| 298 : | |||
| 299 : | #region Events | ||
| 300 : | |||
| 301 : | public event OnRexObjectPropertiesDataUpdateDelegate OnDataUpdate; | ||
| 302 : | public event OnRexObjectPropertiesUpdateDelegate OnPropertiesUpdate; | ||
| 303 : | mikkopa | 42 | public event OnChangePythonClassDelegate OnPythonClassChange; |
| 304 : | mikkopa | 28 | |
| 305 : | mikkopa | 42 | public void TriggerOnChangePythonClass(UUID id) |
| 306 : | { | ||
| 307 : | if (OnPythonClassChange != null) | ||
| 308 : | OnPythonClassChange(id); | ||
| 309 : | } | ||
| 310 : | |||
| 311 : | mikkopa | 28 | #endregion |
| 312 : | |||
| 313 : | /// <summary> | ||
| 314 : | /// Initialises a new RexObjectProperties class from | ||
| 315 : | /// the specified binary array. Unpacks the array | ||
| 316 : | /// according to the viewer-specified format into | ||
| 317 : | /// the properties. | ||
| 318 : | /// </summary> | ||
| 319 : | /// <param name="data"></param> | ||
| 320 : | public RexObjectProperties(byte[] data) | ||
| 321 : | { | ||
| 322 : | SetRexPrimDataFromBytes(data); | ||
| 323 : | } | ||
| 324 : | |||
| 325 : | mikkopa | 39 | public RexObjectProperties() { } |
| 326 : | |||
| 327 : | mikkopa | 28 | #region Old RexServer ToByte/FromByte methods |
| 328 : | public byte[] GetRexPrimDataToBytes() | ||
| 329 : | { | ||
| 330 : | try | ||
| 331 : | { | ||
| 332 : | // Display | ||
| 333 : | int size = sizeof(byte) + // drawtype | ||
| 334 : | sizeof(bool) + sizeof(bool) + sizeof(bool) + sizeof(bool) + sizeof(bool) + // visible,castshadows,lightcreatesshadows,desctex,scaletoprim | ||
| 335 : | sizeof(float) + sizeof(float) + // drawdist,lod | ||
| 336 : | 16 + 16 + 16 + 16 + // meshuuid,colmeshuuid,particleuuid,animpackuuid | ||
| 337 : | sizeof(int); // selectpriority | ||
| 338 : | |||
| 339 : | // Animname,animrate | ||
| 340 : | size += (m_RexAnimationName.Length + 1 + sizeof(float)); | ||
| 341 : | |||
| 342 : | // Materialdata | ||
| 343 : | size += sizeof(byte); // Number of materials | ||
| 344 : | RexMaterialsDictionary materials = GetRexMaterials(); | ||
| 345 : | size += (materials.Values.Count * (sizeof(byte) + 16 + sizeof(byte))); // materialassettype,matuuid,matindex | ||
| 346 : | |||
| 347 : | // Misc | ||
| 348 : | size = size + m_RexClassName.Length + 1 + // classname & endbyte | ||
| 349 : | 16 + sizeof(float) + sizeof(float); // sounduuid,sndvolume,sndradius | ||
| 350 : | |||
| 351 : | // Build byte array | ||
| 352 : | byte[] buffer = new byte[size]; | ||
| 353 : | int idx = 0; | ||
| 354 : | |||
| 355 : | buffer[idx++] = m_RexDrawType; | ||
| 356 : | BitConverter.GetBytes(m_RexIsVisible).CopyTo(buffer, idx); | ||
| 357 : | idx += sizeof(bool); | ||
| 358 : | BitConverter.GetBytes(m_RexCastShadows).CopyTo(buffer, idx); | ||
| 359 : | idx += sizeof(bool); | ||
| 360 : | BitConverter.GetBytes(m_RexLightCreatesShadows).CopyTo(buffer, idx); | ||
| 361 : | idx += sizeof(bool); | ||
| 362 : | BitConverter.GetBytes(m_RexDescriptionTexture).CopyTo(buffer, idx); | ||
| 363 : | idx += sizeof(bool); | ||
| 364 : | BitConverter.GetBytes(m_RexScaleToPrim).CopyTo(buffer, idx); | ||
| 365 : | idx += sizeof(bool); | ||
| 366 : | |||
| 367 : | BitConverter.GetBytes(m_RexDrawDistance).CopyTo(buffer, idx); | ||
| 368 : | idx += sizeof(float); | ||
| 369 : | BitConverter.GetBytes(m_RexLOD).CopyTo(buffer, idx); | ||
| 370 : | idx += sizeof(float); | ||
| 371 : | |||
| 372 : | m_RexMeshUUID.GetBytes().CopyTo(buffer, idx); | ||
| 373 : | idx += 16; | ||
| 374 : | m_RexCollisionMeshUUID.GetBytes().CopyTo(buffer, idx); | ||
| 375 : | idx += 16; | ||
| 376 : | m_RexParticleScriptUUID.GetBytes().CopyTo(buffer, idx); | ||
| 377 : | idx += 16; | ||
| 378 : | |||
| 379 : | m_RexAnimationPackageUUID.GetBytes().CopyTo(buffer, idx); | ||
| 380 : | idx += 16; | ||
| 381 : | Encoding.ASCII.GetBytes(m_RexAnimationName).CopyTo(buffer, idx); | ||
| 382 : | idx += (m_RexAnimationName.Length); | ||
| 383 : | buffer[idx++] = 0; | ||
| 384 : | BitConverter.GetBytes(m_RexAnimationRate).CopyTo(buffer, idx); | ||
| 385 : | idx += sizeof(float); | ||
| 386 : | |||
| 387 : | buffer[idx++] = (byte)materials.Values.Count; | ||
| 388 : | foreach (KeyValuePair<uint, UUID> kvp in materials) | ||
| 389 : | { | ||
| 390 : | // Removed - do we really need to know this? | ||
| 391 : | // Adds a dependency for a single scene method | ||
| 392 : | // which may break in future. Dont see why | ||
| 393 : | // the client needs it either. | ||
| 394 : | |||
| 395 : | /* | ||
| 396 : | AssetBase tempmodel = m_parentGroup.Scene.AssetCache.FetchAsset(kvp.Value); // materialassettype | ||
| 397 : | if (tempmodel != null) | ||
| 398 : | { | ||
| 399 : | byte temptype = (byte)(tempmodel.Type); | ||
| 400 : | buffer[idx++] = temptype; | ||
| 401 : | } | ||
| 402 : | else | ||
| 403 : | */ | ||
| 404 : | buffer[idx++] = 0; | ||
| 405 : | |||
| 406 : | kvp.Value.GetBytes().CopyTo(buffer, idx); // matuuid | ||
| 407 : | idx += 16; | ||
| 408 : | |||
| 409 : | byte tempindex = (byte)kvp.Key; // matindex | ||
| 410 : | buffer[idx++] = tempindex; | ||
| 411 : | } | ||
| 412 : | |||
| 413 : | Encoding.ASCII.GetBytes(m_RexClassName).CopyTo(buffer, idx); | ||
| 414 : | idx += (m_RexClassName.Length); | ||
| 415 : | buffer[idx++] = 0; | ||
| 416 : | |||
| 417 : | m_RexSoundUUID.GetBytes().CopyTo(buffer, idx); | ||
| 418 : | idx += 16; | ||
| 419 : | BitConverter.GetBytes(m_RexSoundVolume).CopyTo(buffer, idx); | ||
| 420 : | idx += sizeof(float); | ||
| 421 : | BitConverter.GetBytes(m_RexSoundRadius).CopyTo(buffer, idx); | ||
| 422 : | idx += sizeof(float); | ||
| 423 : | |||
| 424 : | BitConverter.GetBytes(m_RexSelectPriority).CopyTo(buffer, idx); | ||
| 425 : | // ReSharper disable RedundantAssignment | ||
| 426 : | idx += sizeof(int); | ||
| 427 : | // ReSharper restore RedundantAssignment | ||
| 428 : | |||
| 429 : | return buffer; | ||
| 430 : | } | ||
| 431 : | catch (Exception e) | ||
| 432 : | { | ||
| 433 : | m_log.Error(e.ToString()); | ||
| 434 : | return null; | ||
| 435 : | } | ||
| 436 : | } | ||
| 437 : | |||
| 438 : | public void SetRexPrimDataFromBytes(byte[] bytes) | ||
| 439 : | { | ||
| 440 : | try | ||
| 441 : | { | ||
| 442 : | int idx = 0; | ||
| 443 : | RexDrawType = bytes[idx++]; | ||
| 444 : | |||
| 445 : | RexIsVisible = BitConverter.ToBoolean(bytes, idx); | ||
| 446 : | idx += sizeof(bool); | ||
| 447 : | RexCastShadows = BitConverter.ToBoolean(bytes, idx); | ||
| 448 : | idx += sizeof(bool); | ||
| 449 : | RexLightCreatesShadows = BitConverter.ToBoolean(bytes, idx); | ||
| 450 : | idx += sizeof(bool); | ||
| 451 : | RexDescriptionTexture = BitConverter.ToBoolean(bytes, idx); | ||
| 452 : | idx += sizeof(bool); | ||
| 453 : | RexScaleToPrim = BitConverter.ToBoolean(bytes, idx); | ||
| 454 : | idx += sizeof(bool); | ||
| 455 : | |||
| 456 : | RexDrawDistance = BitConverter.ToSingle(bytes, idx); | ||
| 457 : | idx += sizeof(float); | ||
| 458 : | RexLOD = BitConverter.ToSingle(bytes, idx); | ||
| 459 : | idx += sizeof(float); | ||
| 460 : | |||
| 461 : | RexMeshUUID = new UUID(bytes, idx); | ||
| 462 : | idx += 16; | ||
| 463 : | RexCollisionMeshUUID = new UUID(bytes, idx); | ||
| 464 : | idx += 16; | ||
| 465 : | RexParticleScriptUUID = new UUID(bytes, idx); | ||
| 466 : | idx += 16; | ||
| 467 : | |||
| 468 : | // animation | ||
| 469 : | RexAnimationPackageUUID = new UUID(bytes, idx); | ||
| 470 : | idx += 16; | ||
| 471 : | StringBuilder bufferanimname = new StringBuilder(); | ||
| 472 : | while ((idx < bytes.Length) && (bytes[idx] != 0)) | ||
| 473 : | { | ||
| 474 : | char c = (char)bytes[idx++]; | ||
| 475 : | bufferanimname.Append(c); | ||
| 476 : | } | ||
| 477 : | RexAnimationName = bufferanimname.ToString(); | ||
| 478 : | idx++; | ||
| 479 : | RexAnimationRate = BitConverter.ToSingle(bytes, idx); | ||
| 480 : | idx += sizeof(float); | ||
| 481 : | |||
| 482 : | // materials, before setting materials clear them | ||
| 483 : | RexMaterials.ClearMaterials(); | ||
| 484 : | byte matcount = bytes[idx++]; | ||
| 485 : | for (int i = 0; i < matcount; i++) | ||
| 486 : | { | ||
| 487 : | idx++; // skip type | ||
| 488 : | UUID matuuid = new UUID(bytes, idx); | ||
| 489 : | idx += 16; | ||
| 490 : | byte matindex = bytes[idx++]; | ||
| 491 : | RexMaterials.AddMaterial(Convert.ToUInt32(matindex), matuuid); | ||
| 492 : | } | ||
| 493 : | |||
| 494 : | // misc | ||
| 495 : | StringBuilder buffer = new StringBuilder(); | ||
| 496 : | while ((idx < bytes.Length) && (bytes[idx] != 0)) | ||
| 497 : | { | ||
| 498 : | char c = (char)bytes[idx++]; | ||
| 499 : | buffer.Append(c); | ||
| 500 : | } | ||
| 501 : | RexClassName = buffer.ToString(); | ||
| 502 : | idx++; | ||
| 503 : | |||
| 504 : | RexSoundUUID = new UUID(bytes, idx); | ||
| 505 : | idx += 16; | ||
| 506 : | RexSoundVolume = BitConverter.ToSingle(bytes, idx); | ||
| 507 : | idx += sizeof(float); | ||
| 508 : | RexSoundRadius = BitConverter.ToSingle(bytes, idx); | ||
| 509 : | idx += sizeof(float); | ||
| 510 : | |||
| 511 : | if (bytes.Length >= (idx + sizeof(int))) | ||
| 512 : | { | ||
| 513 : | RexSelectPriority = BitConverter.ToInt32(bytes, idx); | ||
| 514 : | // ReSharper disable RedundantAssignment | ||
| 515 : | idx += sizeof(int); | ||
| 516 : | // ReSharper restore RedundantAssignment | ||
| 517 : | } | ||
| 518 : | |||
| 519 : | SchedulePropertiesUpdate(true); | ||
| 520 : | } | ||
| 521 : | catch (Exception e) | ||
| 522 : | { | ||
| 523 : | m_log.Error(e.ToString()); | ||
| 524 : | } | ||
| 525 : | } | ||
| 526 : | #endregion | ||
| 527 : | |||
| 528 : | #region Debug | ||
| 529 : | public void PrintRexPrimdata() | ||
| 530 : | { | ||
| 531 : | try | ||
| 532 : | { | ||
| 533 : | m_log.Warn("RexDrawType:" + RexDrawType); | ||
| 534 : | m_log.Warn("RexIsVisible:" + RexIsVisible); | ||
| 535 : | m_log.Warn("RexCastShadows:" + RexCastShadows); | ||
| 536 : | m_log.Warn("RexLightCreatesShadows:" + RexLightCreatesShadows); | ||
| 537 : | m_log.Warn("RexDescriptionTexture:" + RexDescriptionTexture); | ||
| 538 : | m_log.Warn("RexScaleToPrim:" + RexScaleToPrim); | ||
| 539 : | m_log.Warn("RexDrawDistance:" + RexDrawDistance); | ||
| 540 : | m_log.Warn("RexLOD" + RexLOD); | ||
| 541 : | m_log.Warn("RexMeshUUID:" + RexMeshUUID); | ||
| 542 : | m_log.Warn("RexCollisionMeshUUID:" + RexCollisionMeshUUID); | ||
| 543 : | m_log.Warn("RexParticleScriptUUID:" + RexParticleScriptUUID); | ||
| 544 : | m_log.Warn("RexAnimationPackageUUID:" + RexAnimationPackageUUID); | ||
| 545 : | m_log.Warn("RexAnimationName:" + RexAnimationName); | ||
| 546 : | m_log.Warn("RexAnimationRate:" + RexAnimationRate); | ||
| 547 : | m_log.Warn("RexMaterials:" + RexMaterials); | ||
| 548 : | m_log.Warn("RexClassName:" + RexClassName); | ||
| 549 : | m_log.Warn("RexSoundUUID:" + RexSoundUUID); | ||
| 550 : | m_log.Warn("RexSoundVolume:" + RexSoundVolume); | ||
| 551 : | m_log.Warn("RexSoundRadius:" + RexSoundRadius); | ||
| 552 : | m_log.Warn("RexSelectPriority:" + RexSelectPriority); | ||
| 553 : | } | ||
| 554 : | catch (Exception e) | ||
| 555 : | { | ||
| 556 : | m_log.Error(e.ToString()); | ||
| 557 : | } | ||
| 558 : | } | ||
| 559 : | #endregion | ||
| 560 : | |||
| 561 : | /// <summary> | ||
| 562 : | /// TODO | ||
| 563 : | /// </summary> | ||
| 564 : | /// <param name="saveToDB"></param> | ||
| 565 : | public void SchedulePropertiesUpdate(bool saveToDB) | ||
| 566 : | { | ||
| 567 : | if(OnPropertiesUpdate != null) | ||
| 568 : | { | ||
| 569 : | OnPropertiesUpdate(ParentObjectID, this, saveToDB); | ||
| 570 : | } | ||
| 571 : | } | ||
| 572 : | |||
| 573 : | /// <summary> | ||
| 574 : | /// TODO | ||
| 575 : | /// </summary> | ||
| 576 : | /// <param name="saveToDB"></param> | ||
| 577 : | public void ScheduleDataUpdate(bool saveToDB) | ||
| 578 : | { | ||
| 579 : | if(OnDataUpdate != null) | ||
| 580 : | { | ||
| 581 : | OnDataUpdate(ParentObjectID, RexData, saveToDB); | ||
| 582 : | } | ||
| 583 : | } | ||
| 584 : | |||
| 585 : | |||
| 586 : | } | ||
| 587 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

