public void SetActiveWithInterp(GlobalCamera cam, int duration, bool easePos, bool easeRot) { if (_activeCamera == null || cam == null) { return; } if (_oldInterp != null) { _oldInterp.Active = false; _oldInterp.Dispose(); _oldInterp = null; } if (cam.CamObj == null) { cam.CamObj = World.CreateCamera(cam.Position.ToVector(), cam.Rotation.ToVector(), cam.Fov); if (cam.EntityAttached != 0) { if (cam.BoneAttached != 0) { cam.CamObj.AttachTo(new Ped(cam.EntityAttached), cam.BoneAttached, cam.AttachOffset.ToVector()); } else { cam.CamObj.AttachTo(new Prop(cam.EntityAttached), cam.AttachOffset.ToVector()); } } if (cam.EntityPointing != 0) { if (cam.BonePointing != 0) { cam.CamObj.PointAt(new Ped(cam.EntityPointing), cam.BonePointing, cam.PointOffset.ToVector()); } else { cam.CamObj.PointAt(new Prop(cam.EntityPointing), cam.PointOffset.ToVector()); } } else if (cam.VectorPointing != null) { cam.CamObj.PointAt(cam.VectorPointing.ToVector()); } if (!string.IsNullOrEmpty(cam.Shake)) { Function.Call(Hash.SHAKE_CAM, cam.CamObj.Handle, cam.Shake, cam.ShakeAmp); } } _activeCamera.CamObj.InterpTo(cam.CamObj, duration, easePos, easeRot); cam.Active = true; _activeCamera.Active = false; _oldInterp = _activeCamera; _activeCamera = cam; }
public void Delete(GlobalCamera cam) { if (cam.Active) { SetActive(null); } _cameras.Remove(cam); }
public GlobalCamera Create(CherryMPShared.Vector3 position, CherryMPShared.Vector3 rotation) { var gCam = new GlobalCamera(); gCam.Position = position; gCam.Rotation = rotation; gCam.Fov = GameplayCamera.FieldOfView; _cameras.Add(gCam); return(gCam); }
public void Reset() { for (int i = 0; i < _cameras.Count; i++) { _cameras[i].Dispose(); } SetActive(null); _oldInterp = null; _activeCamera = null; _cameras.Clear(); }
public void SetActive(GlobalCamera cam) { if (_activeCamera != null) { _activeCamera.Active = false; _activeCamera.Dispose(); _activeCamera = null; } if (_oldInterp != null) { _oldInterp.Active = false; _oldInterp.Dispose(); _oldInterp = null; } if (cam == null) { World.RenderingCamera = null; _activeCamera = null; return; } if (cam.CamObj == null) { cam.CamObj = World.CreateCamera(cam.Position.ToVector(), cam.Rotation.ToVector(), cam.Fov); if (cam.EntityAttached != 0) { if (cam.BoneAttached != 0) { cam.CamObj.AttachTo(new Ped(cam.EntityAttached), cam.BoneAttached, cam.AttachOffset.ToVector()); } else { cam.CamObj.AttachTo(new Prop(cam.EntityAttached), cam.AttachOffset.ToVector()); } } if (cam.EntityPointing != 0) { if (cam.BonePointing != 0) { cam.CamObj.PointAt(new Ped(cam.EntityPointing), cam.BonePointing, cam.PointOffset.ToVector()); } else { cam.CamObj.PointAt(new Prop(cam.EntityPointing), cam.PointOffset.ToVector()); } } else if (cam.VectorPointing != null) { cam.CamObj.PointAt(cam.VectorPointing.ToVector()); } if (!string.IsNullOrEmpty(cam.Shake)) { Function.Call(Hash.SHAKE_CAM, cam.CamObj.Handle, cam.Shake, cam.ShakeAmp); } World.RenderingCamera = cam.CamObj; } else { World.RenderingCamera = cam.CamObj; } cam.Active = true; _activeCamera = cam; }