/// <summary> /// Loads the file from the specified stream. /// </summary> /// <param name="stream">The stream to read from.</param> public override void Load(Stream stream) { BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("us-ascii")); int sequenceCount = reader.ReadInt32(); for (int i = 0; i < sequenceCount; i++) { ParticleSequence sequence = new ParticleSequence { Name = reader.ReadIntString(), Lifetime = new MinMax <float>(reader.ReadSingle(), reader.ReadSingle()), EmitRate = new MinMax <float>(reader.ReadSingle(), reader.ReadSingle()), LoopCount = reader.ReadInt32(), SpawnDirection = new MinMax <Vector3>(reader.ReadVector3(), reader.ReadVector3()), EmitRadius = new MinMax <Vector3>(reader.ReadVector3(), reader.ReadVector3()), Gravity = new MinMax <Vector3>(reader.ReadVector3(), reader.ReadVector3()), TextureFileName = reader.ReadIntString(), ParticleCount = reader.ReadInt32(), Alignment = (AlignmentType)reader.ReadInt32(), UpdateCoordinate = (CoordinateType)reader.ReadInt32(), TextureWidth = reader.ReadInt32(), TextureHeight = reader.ReadInt32(), Implementation = (ImplementationType)reader.ReadInt32(), DestinationBlendMode = (Revise.Types.Utils.Blend)reader.ReadInt32(), SourceBlendMode = (Revise.Types.Utils.Blend)reader.ReadInt32(), BlendOperation = (Revise.Types.Utils.BlendOperation)reader.ReadInt32() }; int eventCount = reader.ReadInt32(); for (int j = 0; j < eventCount; j++) { ParticleEventType type = (ParticleEventType)reader.ReadInt32(); if (!Enum.IsDefined(typeof(ParticleEventType), type)) { throw new InvalidParticleEventTypeException((int)type); } Type classType = type.GetAttributeValue <ParticleEventTypeAttribute, Type>(x => x.Type); IParticleEvent @event = (IParticleEvent)Activator.CreateInstance(classType); @event.Read(reader); sequence.Events.Add(@event); } Sequences.Add(sequence); } }
private ParticleEventData(ParticleEventType eventType, GameObject gameObject) { EventType = eventType; GameObject = gameObject; }
public static ParticleEventData Create(ParticleEventType eventType, GameObject gameObject) => new ParticleEventData(eventType, gameObject);