public void Initialize(AloneButterflyHabitatPoint habitatPoint, GameObject prefabObj) { if (Object.op_Equality((Object)habitatPoint, (Object)null)) { return; } this._habitatPoint = habitatPoint; ObservableExtensions.Subscribe <long>(Observable.TakeUntilDestroy <long>(Observable.TakeUntilDestroy <long>((IObservable <M0>)Observable.Timer(TimeSpan.FromSeconds((double)Random.Range(0.0f, this._habitatPoint.MaxDelayTime))), (Component)habitatPoint), (Component)this), (Action <M0>)(_ => { this._bodyObject = (GameObject)Object.Instantiate <GameObject>((M0)prefabObj, ((Component)this).get_transform()); Transform transform = this._bodyObject.get_transform(); Vector3 zero = Vector3.get_zero(); this._bodyObject.get_transform().set_localEulerAngles(zero); Vector3 vector3 = zero; transform.set_localPosition(vector3); this._bodyObject.SetActive(true); AnimalDefinePack animalDefinePack = Singleton <Resources> .Instance.AnimalDefinePack; float speed = !Object.op_Inequality((Object)animalDefinePack, (Object)null) ? 1f : animalDefinePack.AnimatorInfo.ButterflyAnimationSpeed; this._animation = (Animation)((Component)this).GetComponentInChildren <Animation>(true); this.SetAnimationSpeed(speed); this.Position = this.GetRandomMoveAreaPoint(); ObservableExtensions.Subscribe <long>(Observable.Where <long>(Observable.TakeUntilDestroy <long>(Observable.TakeUntilDestroy <long>((IObservable <M0>)Observable.EveryUpdate(), (Component)this._habitatPoint), (Component)this), (Func <M0, bool>)(__ => ((Behaviour)this).get_isActiveAndEnabled())), (Action <M0>)(__ => { this.AddWaypoint(); this.OnUpdate(); })); })); }
protected override void OnRepop() { if ((double)Time.get_timeScale() == 0.0) { return; } float deltaTime = Time.get_deltaTime(); Vector3 forward = this.Forward; Vector3 vector3_1 = Vector3.op_Subtraction(this.targetPosition, this.Position); forward.y = (__Null)(double)(vector3_1.y = (__Null)0.0f); float num1 = Vector3.SignedAngle(forward, vector3_1, Vector3.get_up()); if (!Mathf.Approximately(num1, 0.0f)) { float num2 = Mathf.Abs(num1); Quaternion rotation = this.Rotation; float num3 = this.addAngle * deltaTime; if ((double)num2 < (double)num3) { num3 = num2; } float num4 = num3 * Mathf.Sign(num1); this.Rotation = Quaternion.op_Multiply(rotation, Quaternion.Euler(0.0f, num4, 0.0f)); } Vector3 vector3_2 = Vector3.op_Subtraction(this.destination.Value, this.Position); this.speed = Mathf.Clamp(this.speed + this.Agent.get_acceleration() * deltaTime, 0.0f, this.WalkSpeed); Vector3 vector3_3 = Vector3.op_Multiply(Vector3.op_Multiply(((Vector3) ref vector3_2).get_normalized(), this.speed), deltaTime); if ((double)((Vector3) ref vector3_2).get_sqrMagnitude() <= (double)((Vector3) ref vector3_3).get_magnitude()) { this.AnimationEndUpdate = true; this.Position = this.destination.Value; float num2 = 10f; if (Singleton <Resources> .IsInstance()) { AnimalDefinePack animalDefinePack = Singleton <Resources> .Instance.AnimalDefinePack; if (animalDefinePack?.SystemInfo != null) { num2 = animalDefinePack.SystemInfo.PopPointCoolTimeRange.RandomRange(); } } this.SetState(AnimalState.Locomotion, (Action)null); this.SearchActor.SetSearchEnabled(true, false); }
protected override void EnterDepop() { this.AutoChangeAnimation = false; StuffItemInfo _itemInfo = this.ItemInfo; StuffItem _addItem = (StuffItem)null; if (_itemInfo != null) { _addItem = new StuffItem(_itemInfo.CategoryID, _itemInfo.ID, 1); } PlayerActor playerActor = !Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player; if ((!Object.op_Inequality((Object)playerActor, (Object)null) ? (List <StuffItem>)null : playerActor.PlayerData?.ItemList) != null && _addItem != null) { playerActor.PlayerData.ItemList.AddItem(_addItem); } if (Singleton <Resources> .IsInstance()) { AnimalDefinePack animalDefinePack = Singleton <Resources> .Instance.AnimalDefinePack; if (Object.op_Inequality((Object)animalDefinePack, (Object)null)) { AudioSource audioSource = this.Play3DSound(animalDefinePack.SoundID.MechaStartup); if (Object.op_Inequality((Object)audioSource, (Object)null)) { audioSource.Stop(); ((Component)audioSource).get_transform().SetPositionAndRotation(this.Position, this.Rotation); audioSource.Play(); } } } this.PlayInAnim(AnimationCategoryID.Etc, 1, (System.Action)(() => { this.AutoChangeAnimation = true; if (_itemInfo != null && _addItem != null) { MapUIContainer.AddSystemItemLog(_itemInfo, _addItem.Count, true); } else { MapUIContainer.AddNotify(MapUIContainer.ItemGetEmptyText); } this.SetState(AnimalState.Destroyed, (System.Action)null); })); }
protected override void InitializeCommandLabels() { if (!Singleton <Resources> .IsInstance()) { return; } if (((IReadOnlyList <CommandLabel.CommandInfo>) this.giveFoodLabels).IsNullOrEmpty <CommandLabel.CommandInfo>()) { Resources instance = Singleton <Resources> .Instance; CommonDefine.CommonIconGroup icon = instance.CommonDefine.Icon; StuffItemInfo stuffItemInfo = !Singleton <Resources> .IsInstance() ? (StuffItemInfo)null : Singleton <Resources> .Instance.GameInfo.GetItem(this.foodItemID.categoryID, this.foodItemID.itemID); int guideCancelId = icon.GuideCancelID; Sprite sprite; instance.itemIconTables.InputIconTable.TryGetValue(guideCancelId, out sprite); string _foodItemName = stuffItemInfo?.Name ?? "エサ"; Dictionary <int, List <string> > commandLabelTextTable = instance.Map.EventPointCommandLabelTextTable; List <string> source; commandLabelTextTable.TryGetValue(19, out source); List <string> _textList1; commandLabelTextTable.TryGetValue(20, out _textList1); int _langIdx = !Singleton <GameSystem> .IsInstance() ? 0 : Singleton <GameSystem> .Instance.languageInt; this.giveFoodLabels = new CommandLabel.CommandInfo[1] { new CommandLabel.CommandInfo() { Text = string.Format(source.GetElement <string>(_langIdx) ?? "{0}をあげる", (object)_foodItemName), Transform = this.LabelPoint, IsHold = false, Icon = sprite, TargetSpriteInfo = icon?.CharaSpriteInfo, Condition = (Func <PlayerActor, bool>)(_player => this.HaveFoodItem()), ErrorText = (Func <PlayerActor, string>)(_player => string.Format(_textList1.GetElement <string>(_langIdx) ?? "{0}を持っていません。", (object)_foodItemName)), Event = (Action)(() => { this.ChangeEmptyLabels(); List <StuffItem> self = !Singleton <Manager.Map> .IsInstance() ? (List <StuffItem>)null : Singleton <Manager.Map> .Instance.Player?.PlayerData?.ItemList; if (!((IReadOnlyList <StuffItem>)self).IsNullOrEmpty <StuffItem>()) { self.RemoveItem(new StuffItem(this.foodItemID.categoryID, this.foodItemID.itemID, 1)); } if (this.CurrentState != AnimalState.Sleep) { this.SetState(AnimalState.LovelyIdle, (Action)(() => this.ChangeGetAnimalLabels())); } else { this.ChangeGetAnimalLabels(); } float num = 120f; if (Singleton <Resources> .IsInstance()) { AnimalDefinePack animalDefinePack = Singleton <Resources> .Instance.AnimalDefinePack; if (animalDefinePack?.GroundWildInfo != null) { num = animalDefinePack.GroundWildInfo.LovelyTime; } } if (this.lovelyModeDisposable != null) { this.lovelyModeDisposable.Dispose(); } this.lovelyModeDisposable = ObservableExtensions.Subscribe <long>(Observable.Do <long>(Observable.TakeUntilDestroy <long>((IObservable <M0>)Observable.Timer(TimeSpan.FromSeconds((double)num)), ((Component)this).get_gameObject()), (Action <M0>)(_ => this.lovelyModeDisposable = (IDisposable)null)), (Action <M0>)(_ => { if (this.IsLovely) { this.ChangeEmptyLabels(); } switch (this.CurrentState) { case AnimalState.LovelyIdle: this.SetState(AnimalState.Locomotion, (Action)(() => this.ChangeAnimalLabel())); break; case AnimalState.LovelyFollow: this.SetState(AnimalState.Idle, (Action)(() => this.ChangeAnimalLabel())); break; default: this.ChangeAnimalLabel(); break; } })); }) } }; } string _getItemName = (!Singleton <Resources> .IsInstance() ? (StuffItemInfo)null : Singleton <Resources> .Instance.GameInfo.GetItem(this.getItemID.categoryID, this.getItemID.itemID))?.Name ?? "捕獲アイテム"; if (!((IReadOnlyList <CommandLabel.CommandInfo>) this.getAnimalLabels).IsNullOrEmpty <CommandLabel.CommandInfo>()) { return; } Resources instance1 = Singleton <Resources> .Instance; CommonDefine.CommonIconGroup icon1 = instance1.CommonDefine.Icon; int guideCancelId1 = icon1.GuideCancelID; Sprite sprite1; instance1.itemIconTables.InputIconTable.TryGetValue(guideCancelId1, out sprite1); Dictionary <int, List <string> > commandLabelTextTable1 = instance1.Map.EventPointCommandLabelTextTable; List <string> source1; commandLabelTextTable1.TryGetValue(21, out source1); List <string> _textList1_1; commandLabelTextTable1.TryGetValue(20, out _textList1_1); int _langIdx1 = !Singleton <GameSystem> .IsInstance() ? 0 : Singleton <GameSystem> .Instance.languageInt; this.getAnimalLabels = new CommandLabel.CommandInfo[1] { new CommandLabel.CommandInfo() { Text = string.Format(source1.GetElement <string>(_langIdx1) ?? "{0}を捕まえる", (object)this.Name), Transform = this.LabelPoint, IsHold = false, Icon = sprite1, Condition = (Func <PlayerActor, bool>)(_player => this.HaveGetItem()), ErrorText = (Func <PlayerActor, string>)(_player => string.Format(_textList1_1.GetElement <string>(_langIdx1) ?? "{0}を持っていません。", (object)_getItemName)), TargetSpriteInfo = icon1?.CharaSpriteInfo, Event = (Action)(() => { this.ChangeEmptyLabels(); this.SetState(AnimalState.WithPlayer, (Action)null); PlayerActor playerActor = !Singleton <Manager.Map> .IsInstance() ? (PlayerActor)null : Singleton <Manager.Map> .Instance.Player; if (!Object.op_Inequality((Object)playerActor, (Object)null)) { return; } playerActor.Animal = (AnimalBase)this; playerActor.PlayerController.ChangeState("CatchAnimal"); }) } }; }