public ModViewModelAddArgs(ViewModel vm, IHeldItem item, bool isMesh, ItemModRepresentation modRep) { this.vm = vm; this.item = item; this.isMesh = isMesh; this.modRep = modRep; }
public ModViewModelRemoveArgs(ViewModel vm, IHeldItem item) : this(vm, item, null) { }
public ModViewModelRemoveArgs(ViewModel vm, IHeldItem item, ItemModRepresentation modRep) { this.vm = vm; this.item = item; this.modRep = modRep; }
public ModViewModelAddArgs(ViewModel vm, IHeldItem item, bool isMesh) : this(vm, item, isMesh, null) { }
private void SetViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item) { if (!this.awoke) { this.viewModel = vm; this.rep = rep; this.item = item; return; } if (this.viewModel != vm) { if (this.viewModel) { if (this.viewModel.itemRep) { try { this.viewModel.itemRep.UnBindViewModel(this.viewModel, this.viewModel.item); } catch (Exception exception) { Debug.LogException(exception, this.viewModel.itemRep); } } this.viewModel.UnBindTransforms(); this.viewModel.idMain = null; } this.viewModel = vm; if (vm) { if (!CameraFX.viewModelRootTransform) { Transform gameObject = (new GameObject("__View Model Root")).transform; CameraFX.viewModelRootTransform = (new GameObject("Eye Camera Difference")).transform; CameraFX.viewModelRootTransform.parent = gameObject; } vm.idMain = this.idMain; vm.transform.parent = CameraFX.viewModelRootTransform; if (rep) { rep.PrepareViewModel(vm, item); } vm.BindTransforms(CameraFX.viewModelRootTransform, base.transform.parent); if (rep) { rep.BindViewModel(vm, item); vm.itemRep = rep; vm.item = item; } } for (int i = (int)this._effects.Length - 1; i >= 0; i--) { if (this._effects[i]) { this.effects[i].OnViewModelChange(vm); } } } }
protected new void Awake() { this.camera = base.camera; this.adaptiveNearPlane = base.GetComponent<AdaptiveNearPlane>(); int num = 0; if (this._effects != null && (int)this._effects.Length != 0) { for (int i = 0; i < (int)this._effects.Length; i++) { if (!this._effects[i] || !(this._effects[i] is ICameraFX)) { Debug.LogWarning(string.Concat("effect at index ", i, " is missing, null or not a ICameraFX"), this); } else { int num1 = num; num = num1 + 1; this._effects[num1] = this._effects[i]; } } } Array.Resize<MonoBehaviour>(ref this._effects, num); Array.Resize<ICameraFX>(ref this.effects, num); if (num != 0) { for (int j = 0; j < num; j++) { this.effects[j] = (ICameraFX)this._effects[j]; } } else { Debug.LogWarning("There are no effects", this); } this.awoke = true; if (this.viewModel) { ViewModel viewModel = this.viewModel; this.viewModel = null; ItemRepresentation itemRepresentation = this.rep; this.rep = null; IHeldItem heldItem = this.item; this.item = null; this.SetViewModel(viewModel, itemRepresentation, heldItem); } base.Awake(); }
public static void ReplaceViewModel(ViewModel vm, ItemRepresentation rep, IHeldItem item, bool butDontDestroyOld) { CameraFX cameraFX = CameraFX.mainCameraFX; if (cameraFX && cameraFX.viewModel != vm) { ViewModel viewModel = cameraFX.viewModel; cameraFX.SetViewModel(vm, rep, item); if (!butDontDestroyOld && viewModel) { UnityEngine.Object.Destroy(viewModel.gameObject); } } }