private void SetParticleSystem (ISceneChildEntity part, LSL_List rules) { if (rules.Length == 0) { part.RemoveParticleSystem(); } else { Primitive.ParticleSystem prules = getNewParticleSystemWithSLDefaultValues(); LSL_Vector tempv = new LSL_Vector(); float tempf = 0; for (int i = 0; i < rules.Length; i += 2) { LSL_Integer rule = rules.GetLSLIntegerItem(i); if (rule == (int)ScriptBaseClass.PSYS_PART_FLAGS) { prules.PartDataFlags = (Primitive.ParticleSystem.ParticleDataFlags)(uint)rules.GetLSLIntegerItem(i + 1); } else if (rule == (int)ScriptBaseClass.PSYS_PART_START_COLOR) { tempv = rules.GetVector3Item(i + 1); prules.PartStartColor.R = (float)tempv.x; prules.PartStartColor.G = (float)tempv.y; prules.PartStartColor.B = (float)tempv.z; } else if (rule == (int)ScriptBaseClass.PSYS_PART_START_ALPHA) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.PartStartColor.A = tempf; } else if (rule == (int)ScriptBaseClass.PSYS_PART_END_COLOR) { tempv = rules.GetVector3Item(i + 1); prules.PartEndColor.R = (float)tempv.x; prules.PartEndColor.G = (float)tempv.y; prules.PartEndColor.B = (float)tempv.z; } else if (rule == (int)ScriptBaseClass.PSYS_PART_END_ALPHA) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.PartEndColor.A = tempf; } else if (rule == (int)ScriptBaseClass.PSYS_PART_START_SCALE) { tempv = rules.GetVector3Item(i + 1); prules.PartStartScaleX = (float)tempv.x; prules.PartStartScaleY = (float)tempv.y; } else if (rule == (int)ScriptBaseClass.PSYS_PART_END_SCALE) { tempv = rules.GetVector3Item(i + 1); prules.PartEndScaleX = (float)tempv.x; prules.PartEndScaleY = (float)tempv.y; } else if (rule == (int)ScriptBaseClass.PSYS_PART_MAX_AGE) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.PartMaxAge = tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_ACCEL) { tempv = rules.GetVector3Item(i + 1); prules.PartAcceleration.X = (float)tempv.x; prules.PartAcceleration.Y = (float)tempv.y; prules.PartAcceleration.Z = (float)tempv.z; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_PATTERN) { int tmpi = (int)rules.GetLSLIntegerItem(i + 1); prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; } // PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The // PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The // client tells the difference between the two by looking at the 0x02 bit in // the PartFlags variable. else if (rule == (int)ScriptBaseClass.PSYS_SRC_INNERANGLE) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.InnerAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. } else if (rule == (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.OuterAngle = (float)tempf; prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. } else if (rule == (int)ScriptBaseClass.PSYS_SRC_TEXTURE) { prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1)); } else if (rule == (int)ScriptBaseClass.PSYS_SRC_BURST_RATE) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstRate = (float)tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_BURST_PART_COUNT) { prules.BurstPartCount = (byte)(int)rules.GetLSLIntegerItem(i + 1); } else if (rule == (int)ScriptBaseClass.PSYS_SRC_BURST_RADIUS) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstRadius = (float)tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MIN) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstSpeedMin = (float)tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_BURST_SPEED_MAX) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.BurstSpeedMax = (float)tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_MAX_AGE) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.MaxAge = (float)tempf; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_TARGET_KEY) { UUID key = UUID.Zero; if (UUID.TryParse(rules.Data[i + 1].ToString(), out key)) { prules.Target = key; } else { prules.Target = part.UUID; } } else if (rule == (int)ScriptBaseClass.PSYS_SRC_OMEGA) { // AL: This is an assumption, since it is the only thing that would match. tempv = rules.GetVector3Item(i + 1); prules.AngularVelocity.X = (float)tempv.x; prules.AngularVelocity.Y = (float)tempv.y; prules.AngularVelocity.Z = (float)tempv.z; } else if (rule == (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.InnerAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. } else if (rule == (int)ScriptBaseClass.PSYS_SRC_ANGLE_END) { tempf = (float)rules.GetLSLFloatItem(i + 1); prules.OuterAngle = (float)tempf; prules.PartFlags |= 0x02; // Set new angle format. } } prules.CRC = 1; part.AddNewParticleSystem(prules); } part.ScheduleUpdate(PrimUpdateFlags.Particles); }