private void Awake() { if (this.Obj == null) { this.Obj = (this._animal ?? (AnimalBase)((Component)this).GetComponent <AnimalBase>()) as INicknameObject; } if (this.Obj == null) { return; } this._outputter = !Singleton <MapUIContainer> .IsInstance() ? (AnimalNicknameOutput)null : MapUIContainer.NicknameUI; if (Object.op_Equality((Object)this._outputter, (Object)null)) { Object.DestroyImmediate((Object)this); } else { this.Obj.NicknameEnabled = true; this._outputter.AddElement(this.Obj); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnEnableAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => this.Obj.NicknameEnabled = true)); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDisableAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => this.Obj.NicknameEnabled = false)); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => { if (!Object.op_Inequality((Object)this._outputter, (Object)null)) { return; } this._outputter.RemoveElement(this.Obj); })); } }
public void AddElement(INicknameObject addElm) { if (addElm == null || this._elmList.Contains(addElm)) { return; } this._elmList.Add(addElm); this._hideList.Add(addElm); addElm.ChangeNickNameEvent = (Action)(() => this.Rename(addElm)); }
private AnimalNicknameUI GetUI(INicknameObject elm) { AnimalNicknameUI animalNicknameUi = this._uiPool.PopFront <AnimalNicknameUI>(); if (Object.op_Equality((Object)animalNicknameUi, (Object)null)) { animalNicknameUi = (AnimalNicknameUI)((GameObject)Object.Instantiate <GameObject>((M0)this._prefab, ((Component)this).get_transform())).GetComponent <AnimalNicknameUI>(); } animalNicknameUi.Nickname = elm.Nickname; animalNicknameUi.TargetObject = elm.NicknameRoot; animalNicknameUi.TargetCamera = this._camera; animalNicknameUi.PlayFadeIn(this._fadeTime); return(animalNicknameUi); }
private void Rename(INicknameObject elm) { ValueTuple <INicknameObject, AnimalNicknameUI> valueTuple; if (elm == null || !this._showTable.TryGetValue(elm.InstanceID, out valueTuple)) { return; } AnimalNicknameUI animalNicknameUi = (AnimalNicknameUI)valueTuple.Item2; if (!Object.op_Inequality((Object)animalNicknameUi, (Object)null)) { return; } animalNicknameUi.Nickname = elm.Nickname; }
public void RemoveElement(INicknameObject remelm) { if (remelm == null) { return; } this._showList.Remove(remelm); this._hideList.Remove(remelm); if (this._showTable.ContainsKey(remelm.InstanceID)) { this.ReturnUI((AnimalNicknameUI)this._showTable[remelm.InstanceID].Item2); this._showTable.Remove(remelm.InstanceID); } this._elmList.Remove(remelm); remelm.ChangeNickNameEvent = (Action)null; }
public bool ShowState(INicknameObject elm) { if (elm == null) { return(false); } Transform nicknameRoot = elm.NicknameRoot; if (Object.op_Equality((Object)nicknameRoot, (Object)null) || !elm.NicknameEnabled) { return(false); } Vector3 vector3 = Vector3.op_Subtraction(nicknameRoot.get_position(), this._player.Position); if ((double)((Vector3) ref vector3).get_sqrMagnitude() > (double)this._showDistance * (double)this._showDistance) { return(false); } Transform transform = ((Component)this._camera).get_transform(); return((double)Vector3.Angle(transform.get_forward(), Vector3.op_Subtraction(nicknameRoot.get_position(), transform.get_position())) * 2.0 <= (double)this._showAngle); }
public bool HideState(INicknameObject elm) { if (elm == null) { return(true); } Transform nicknameRoot = elm.NicknameRoot; if (Object.op_Equality((Object)nicknameRoot, (Object)null) || !elm.NicknameEnabled) { return(true); } double num = (double)this._hideDistance * (double)this._hideDistance; Vector3 vector3 = Vector3.op_Subtraction(nicknameRoot.get_position(), this._player.Position); double sqrMagnitude = (double)((Vector3) ref vector3).get_sqrMagnitude(); if (num < sqrMagnitude) { return(true); } Transform transform = ((Component)this._camera).get_transform(); return((double)this._hideAngle < (double)Vector3.Angle(transform.get_forward(), Vector3.op_Subtraction(nicknameRoot.get_position(), transform.get_position())) * 2.0); }
private void OnUpdate() { List <INicknameObject> toRelease1 = ListPool <INicknameObject> .Get(); List <INicknameObject> toRelease2 = ListPool <INicknameObject> .Get(); for (int index = 0; index < this._hideList.Count; ++index) { INicknameObject hide = this._hideList[index]; if (hide == null) { this._hideList.RemoveAt(index); --index; } else if (this.ShowState(hide)) { toRelease2.Add(hide); this._hideList.RemoveAt(index); --index; } } for (int index = 0; index < this._showList.Count; ++index) { INicknameObject show = this._showList[index]; if (show == null) { this._showList.RemoveAt(index); --index; } else if (this.HideState(show)) { toRelease1.Add(show); this._showList.RemoveAt(index); --index; } } for (int index = 0; index < toRelease2.Count; ++index) { INicknameObject elm = toRelease2[index]; AnimalNicknameUI ui = this.GetUI(elm); this._showTable[elm.InstanceID] = new ValueTuple <INicknameObject, AnimalNicknameUI>(elm, ui); } if (!((IReadOnlyList <INicknameObject>)toRelease2).IsNullOrEmpty <INicknameObject>()) { this._showList.AddRange((IEnumerable <INicknameObject>)toRelease2); } for (int index = 0; index < toRelease1.Count; ++index) { int instanceId = toRelease1[index].InstanceID; ValueTuple <INicknameObject, AnimalNicknameUI> valueTuple; if (this._showTable.TryGetValue(instanceId, out valueTuple)) { this.ReturnUI((AnimalNicknameUI)valueTuple.Item2); this._showTable.Remove(instanceId); } } if (!((IReadOnlyList <INicknameObject>)toRelease1).IsNullOrEmpty <INicknameObject>()) { this._hideList.AddRange((IEnumerable <INicknameObject>)toRelease1); } ListPool <INicknameObject> .Release(toRelease1); ListPool <INicknameObject> .Release(toRelease2); }