public override void Run(ThnScriptInstance instance) { if (!Set) { return; } if (!instance.Objects.TryGetValue(Targets[0], out var obj)) { FLLog.Error("Thn", $"Entity {Targets[0]} does not exist"); return; } var ren = ((ParticleEffectRenderer)obj.Object.RenderComponent); if (Duration <= float.Epsilon) { ren.SParam = SParam; } else { instance.AddProcessor(new SParamAnimation() { Renderer = ren, Event = this, StartValue = ren.SParam }); } }
public override void Run(ThnScriptInstance instance) { if (SetFlags == AnimVars.Nothing) { return; //Nothing to change } var light = instance.Cutscene.Renderer.SystemLighting; //mode and fog on/off if ((SetFlags & AnimVars.FogOn) == AnimVars.FogOn) { if ((SetFlags & AnimVars.FogMode) == AnimVars.FogMode) { light.FogMode = FogOn ? FogMode : FogModes.None; } else if (!FogOn) { light.FogMode = FogModes.None; } } if (SetFlags == (AnimVars.FogMode | AnimVars.FogOn) || SetFlags == AnimVars.FogOn || SetFlags == AnimVars.FogMode) { return; //Nothing to animate } //anim if (Duration < float.Epsilon) { if ((SetFlags & AnimVars.FogColor) == AnimVars.FogColor) { light.FogColor = new Color4(FogColor.X, FogColor.Y, FogColor.Z, 1); } if ((SetFlags & AnimVars.FogDensity) == AnimVars.FogDensity) { light.FogDensity = FogDensity; } if ((SetFlags & AnimVars.FogStart) == AnimVars.FogStart) { light.FogRange.X = FogStart; } if ((SetFlags & AnimVars.FogEnd) == AnimVars.FogEnd) { light.FogRange.Y = FogEnd; } } else { instance.AddProcessor(new FogPropAnim() { Event = this, Lights = light, OrigFogColor = light.FogColor, OrigFogStart = light.FogRange.X, OrigFogEnd = light.FogRange.Y, OrigFogDensity = light.FogDensity }); } }
public override void Run(ThnScriptInstance instance) { if (!instance.Objects.TryGetValue(Targets[0], out var obj)) { FLLog.Error("Thn", "Entity " + Targets[0] + " does not exist"); return; } if (obj.Sound == null) { return; } var i = obj.Sound.CreateInstance(false); if (i != null) { instance.Sounds[Targets[0]] = i; i.Start((Flags & SoundFlags.Loop) == SoundFlags.Loop, StartTime); instance.AddProcessor(new SoundRoutine() { Sound = i, Duration = Duration, Name = Targets[0], SI = instance }); } else { FLLog.Error("Thn", "Sfx overflow"); } }
public override void Run(ThnScriptInstance instance) { var obj = instance.Objects[Targets[0]]; var path = instance.Objects[Targets[1]]; instance.AddProcessor(new PathAnimation() { Path = path, Object = obj, Event = this }); }
public override void Run(ThnScriptInstance instance) { if (SetFlags == AnimFlags.Nothing) { return; } if (!instance.Objects.TryGetValue(Targets[0], out var obj)) { FLLog.Error("Thn", $"Entity {Targets[0]} does not exist"); return; } if (obj.Camera == null) { FLLog.Error("Thn", $"Entity {Targets[0]} is not a camera"); return; } if (Duration > 0) { instance.AddProcessor(new CameraPropAnim() { Event = this, Camera = obj.Camera, OrigFovH = obj.Camera.FovH, OrigHVAspect = obj.Camera.AspectRatio, OrigNearPlane = obj.Camera.Znear, OrigFarPlane = obj.Camera.Zfar }); } else { if ((SetFlags & AnimFlags.FovH) == AnimFlags.FovH) { obj.Camera.FovH = FovH; } if ((SetFlags & AnimFlags.HVAspect) == AnimFlags.HVAspect) { obj.Camera.AspectRatio = HVAspect; } if ((SetFlags & AnimFlags.NearPlane) == AnimFlags.NearPlane) { obj.Camera.Znear = NearPlane; } if ((SetFlags & AnimFlags.FarPlane) == AnimFlags.FarPlane) { obj.Camera.Zfar = FarPlane; } } }
public override void Run(ThnScriptInstance instance) { if (!instance.Objects.TryGetValue(Targets[0], out var obj)) { FLLog.Error("Thn", "Entity " + Targets[0] + " does not exist"); return; } if (obj.Object == null) { FLLog.Error("Thn", "Entity " + Targets[0] + " null renderer"); return; } var r = (ParticleEffectRenderer)obj.Object.RenderComponent; r.Active = true; instance.AddProcessor(new StopPSys() { Duration = Duration, Fx = r }); }
public override void Run(ThnScriptInstance instance) { if (!instance.Objects.TryGetValue(Targets[0], out var obj)) { FLLog.Error("Thn", $"Entity {Targets[0]} does not exist"); return; } if (obj.Light == null) { FLLog.Error("Thn", $"Entity {Targets[0]} is not a light"); return; } if ((SetFlags & AnimVars.On) == AnimVars.On) { obj.Light.Active = On; } if (Duration > 0) { instance.AddProcessor(new LightPropAnim() { Orig = obj.Light.Light, Dst = obj.Light, Event = this }); } else { if ((SetFlags & AnimVars.Diffuse) == AnimVars.Diffuse) { obj.Light.Light.Color = Diffuse; } if ((SetFlags & AnimVars.Ambient) == AnimVars.Ambient) { obj.Light.Light.Ambient = Ambient; } } }
public override void Run(ThnScriptInstance instance) { if (Targets.Length == 0) { return; } bool hasPos = (SetFlags & AnimVars.Pos) == AnimVars.Pos; bool hasQuat = (SetFlags & AnimVars.Orient) == AnimVars.Orient || (SetFlags & AnimVars.QOrient) == AnimVars.QOrient; Quaternion quat = Q_Orient; if ((SetFlags & AnimVars.Orient) == AnimVars.Orient) { quat = Orient.ExtractRotation(); } ThnObject objA; if (!instance.Objects.TryGetValue(Targets[0], out objA)) { FLLog.Error("Thn", $"Object does not exist {Targets[0]}"); return; } AxisRotation trAxisRot = AxisRot; if ((SetFlags & AnimVars.AxisRot) == AnimVars.AxisRot) { trAxisRot.Axis = Vector3.TransformNormal(trAxisRot.Axis, objA.Rotate); } if (Targets.Length > 1) { if (!instance.Objects.TryGetValue(Targets[1], out var objB)) { FLLog.Error("Thn", $"Object does not exist {Targets[1]}"); return; } if (Duration < float.Epsilon) { objA.Translate = objB.Translate; objA.Rotate = objB.Rotate; } else { instance.AddProcessor(new FollowSpatialRoutine() { Event = this, HasPos = hasPos, HasQuat = hasQuat, This = objA, Follow = objB, OriginalRotate = objA.Rotate }); } } else { if (Duration < float.Epsilon) { if (hasPos) { objA.Translate = Pos; } if (hasQuat) { objA.Rotate = Matrix4x4.CreateFromQuaternion(quat); } if ((SetFlags & AnimVars.AxisRot) == AnimVars.AxisRot) { objA.Rotate = objA.Rotate * Matrix4x4.CreateFromAxisAngle(trAxisRot.Axis, trAxisRot.GetRads(1)); } } else { instance.AddProcessor(new StaticSpatialRoutine() { Event = this, HasPos = hasPos, HasQuat = hasQuat, EndPos = Pos, EndQuat = quat, This = objA, AxisRot = trAxisRot, OriginalRotate = objA.Rotate }); } } }
public override void Run(ThnScriptInstance instance) { ThnObject objA; ThnObject objB; if (!instance.Objects.TryGetValue(Targets[0], out objA)) { FLLog.Error("Thn", "Object doesn't exist " + Targets[0]); return; } if (!instance.Objects.TryGetValue(Targets[1], out objB)) { FLLog.Error("Thn", "Object doesn't exist " + Targets[1]); return; } //Attach GameObjects to eachother GameObject part = null; string tgt_part; if (TargetType == TargetTypes.Hardpoint && !string.IsNullOrEmpty(TargetPart)) { if (objB.Object == null) { FLLog.Error("Thn", "Could not get hardpoints on " + objB.Name); } else { part = new GameObject(); part.Parent = objB.Object; part.Attachment = objB.Object.GetHardpoint(TargetPart); } } if (TargetType == TargetTypes.Part && !string.IsNullOrEmpty(TargetPart)) { if (objB.Object == null || objB.Object.RigidModel == null || objB.Object.RigidModel.Parts == null) { FLLog.Error("Thn", "Could not get parts on " + objB.Name); } else { if (objB.Object.RigidModel.Parts.TryGetValue(TargetPart, out var tgtpart)) { var hp = new Hardpoint(null, tgtpart); part = new GameObject(); part.Parent = objB.Object; part.Attachment = hp; } } } Quaternion lastRotate = Quaternion.Identity; if ((Flags & AttachFlags.Orientation) == AttachFlags.Orientation && (Flags & AttachFlags.OrientationRelative) == AttachFlags.OrientationRelative) { if (part != null) { lastRotate = part.WorldTransform.ExtractRotation(); } else { lastRotate = objB.Rotate.ExtractRotation(); } } instance.AddProcessor(new AttachEntityProcessor() { Duration = Duration, Child = objA, Parent = objB, Part = part, Position = ((Flags & AttachFlags.Position) == AttachFlags.Position), Orientation = ((Flags & AttachFlags.Orientation) == AttachFlags.Orientation), OrientationRelative = ((Flags & AttachFlags.OrientationRelative) == AttachFlags.OrientationRelative), EntityRelative = ((Flags & AttachFlags.EntityRelative) == AttachFlags.EntityRelative), LookAt = ((Flags & AttachFlags.LookAt) == AttachFlags.LookAt), LastRotate = lastRotate, Offset = Offset }); }