public override TaskStatus OnUpdate() { if (this.targetEntity.Value == null) { return(TaskStatus.Failure); } BehaviorDesigner.Runtime.BehaviorTree component = this.targetEntity.Value.GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); for (int i = 0; i < this.SetVariableList.Count; i++) { switch (this.SetVariableList[i].variableType) { case SetVariable.VariableType.Bool: component.SetVariableValue(this.SetVariableList[i].variableName, this.SetVariableList[i].boolValue); break; case SetVariable.VariableType.Int: component.SetVariableValue(this.SetVariableList[i].variableName, this.SetVariableList[i].intValue); break; case SetVariable.VariableType.Float: component.SetVariableValue(this.SetVariableList[i].variableName, this.SetVariableList[i].floatValue); break; } } return(TaskStatus.Success); }
public MonsterAIPlugin(MonsterActor owner) { this._owner = owner; this._aiTree = this._owner.entity.GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); this._levelActor = Singleton <LevelManager> .Instance.levelActor; this._threatTable = new SortedList <uint, int>(); }
public void RefreshBehavior() { this.DisableBehavior(); UnityEngine.Object.DestroyImmediate(this._btree); this._btree = null; this.InitBTree(this._AIName); }
public override TaskStatus OnUpdate() { if (this._minionConfigLs != null) { List <BaseMonoMonster> allMonsters = Singleton <MonsterManager> .Instance.GetAllMonsters(); for (int i = 0; i < this._minionConfigLs.length; i++) { ConfigGroupAIMinion config = this._minionConfigLs.GetConfig <ConfigGroupAIMinion>(i); if (this._minions.ContainsKey(i)) { if (this._minions[i] != null) { continue; } this._minions.Remove(i); } for (int j = 0; j < allMonsters.Count; j++) { if ((allMonsters[j].MonsterName == config.MonsterName) && (allMonsters[j] != this.monster)) { BehaviorDesigner.Runtime.BehaviorTree component = allMonsters[j].GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); bool flag = true; SharedBool variable = component.GetVariable("Group_IsMinion") as SharedBool; if (!variable.Value) { flag = false; } SharedEntity entity = component.GetVariable("Group_LeaderEntity") as SharedEntity; if ((entity != null) && (entity.Value != null)) { flag = false; } SharedString str = component.GetVariable("GroupAIGrid") as SharedString; if ((str != null) && !string.IsNullOrEmpty(str.Value)) { flag = false; } if (flag && allMonsters[j].IsAIControllerActive()) { BTreeMonsterAIController activeAIController = (BTreeMonsterAIController)allMonsters[j].GetActiveAIController(); if (activeAIController.IsBehaviorRunning()) { activeAIController.SetActive(false); activeAIController.SetActive(true); component.SetVariableValue("Group_LeaderEntity", this.monster); AIData.SetSharedVariableCompat(component, config.AIParams); this._minions.Add(i, allMonsters[j]); break; } } } } } } return(TaskStatus.Success); }
private void InitPlay() { BaseMonoAvatar avatar = Singleton <AvatarManager> .Instance.TryGetLocalAvatar(); this._avatarTransform = avatar.transform; this._behaviorTree = avatar.GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); if (this.slowMode) { Time.timeScale = 0.25f; } if (!this.showEffect) { this._postFX = this._camera.GetComponent <PostFX>(); this._postFX.UseDistortion = false; } this._timer = 0f; this.isPlaying = true; }
public BTreeAvatarAIController(BaseMonoEntity avatar) : base(avatar) { this._avatar = (BaseMonoAvatar)avatar; string path = "AI/Avatar/AvatarAutoBattleBehavior_Alt"; this.autoBattleBehavior = Miscs.LoadResource <ExternalBehaviorTree>(path, BundleType.RESOURCE_FILE); this.autoMoveBehvior = Miscs.LoadResource <ExternalBehaviorTree>("AI/Avatar/AvatarAutoMoveBehavior", BundleType.RESOURCE_FILE); string supporterAI = "AvatarSupporterBehavior_Alt"; if (this._avatar.config.AIArguments.SupporterAI != string.Empty) { supporterAI = this._avatar.config.AIArguments.SupporterAI; } this.supporterBehavior = Miscs.LoadResource <ExternalBehaviorTree>("AI/Avatar/" + supporterAI, BundleType.RESOURCE_FILE); this._btree = this._avatar.gameObject.AddComponent <BehaviorDesigner.Runtime.BehaviorTree>(); this._btree.RestartWhenComplete = true; this._btree.StartWhenEnabled = false; this._btree.DisableBehavior(); this._btree.UpdateInterval = UpdateIntervalType.EveryFrame; }
private void InitBTree(string AIName) { this._btree = base._monster.gameObject.AddComponent <BehaviorDesigner.Runtime.BehaviorTree>(); this._btree.RestartWhenComplete = true; this._btree.StartWhenEnabled = false; if (!this._disableBehaviorWhenInit) { this._btree.DisableBehaviorWhenMonoDisabled = false; this._btree.TryEnableBehaviorWhenMonoEnabled = false; } ExternalBehaviorTree tree = Miscs.LoadResource <ExternalBehaviorTree>("AI/Monster/" + AIName, BundleType.RESOURCE_FILE); this._btree.ExternalBehavior = tree; if (this._disableBehaviorWhenInit) { this._btree.CheckForSerialization(); this._btree.DisableBehavior(); } else { this._btree.UpdateInterval = UpdateIntervalType.Manual; } }
private void SpawnSingleMirror(int ix) { if (base.actor is AvatarActor) { uint num = Singleton <AvatarManager> .Instance.CreateAvatarMirror((BaseMonoAvatar)base.entity, base.entity.XZPosition, base.entity.transform.forward, this.config.MirrorAIName, base.instancedAbility.Evaluate(this.config.HPRatioOfParent)); this._mirrorDatas[ix].mirrorRuntimeID = num; } else if (base.actor is MonsterActor) { uint num2 = Singleton <MonsterManager> .Instance.CreateMonsterMirror((BaseMonoMonster)base.entity, base.entity.XZPosition, base.entity.transform.forward, this.config.MirrorAIName, base.instancedAbility.Evaluate(this.config.HPRatioOfParent), false); this._mirrorDatas[ix].mirrorRuntimeID = num2; } BaseAbilityActor other = Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(this._mirrorDatas[ix].mirrorRuntimeID); if (this.config.MirrorAbilities != null) { foreach (string str in this.config.MirrorAbilities) { if (string.IsNullOrEmpty(this.config.MirrorAbilitiesOverrideName)) { other.abilityPlugin.AddAbility(AbilityData.GetAbilityConfig(str)); } else { other.abilityPlugin.AddAbility(AbilityData.GetAbilityConfig(str, this.config.MirrorAbilitiesOverrideName)); } } } BehaviorDesigner.Runtime.BehaviorTree component = other.entity.GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); if (component != null) { component.SetVariableValue("MirrorCreationIndex", ix); } base.actor.abilityPlugin.HandleActionTargetDispatch(this.config.MirrorCreateActions, base.instancedAbility, base.instancedModifier, other, null); }
public AvatarAIPlugin(AvatarActor owner) { this._owner = owner; this._aiTree = this._owner.avatar.GetComponent <BehaviorDesigner.Runtime.BehaviorTree>(); this._levelActor = Singleton <LevelManager> .Instance.levelActor; }