该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

48 行
1.7 KiB

using System.Collections;
using System.Collections.Generic;
using Unity.Entities;
using Unity.Jobs;
using UnityEngine;
// TODO (mogensh) when to update these. Does it even make sense to update all conditions in tree ?
public class AnimConditionDead
{
public struct State : IComponentData
{
public static State Default => new State();
public int Bar;
}
[UpdateInGroup(typeof(AnimConditionUpdate))]
[DisableAutoCreation]
[AlwaysSynchronizeSystem]
class Update : JobComponentSystem
{
protected override JobHandle OnUpdate(JobHandle inputDeps)
{
var AbilityStateActiveFromEntity = GetComponentDataFromEntity<Ability.AbilityStateActive>(true);
var OwnedAbilityBufferFromEntity = GetBufferFromEntity<AbilityOwner.OwnedAbility>(true);
Entities
.WithReadOnly(AbilityStateActiveFromEntity)
.WithoutBurst() // Captures managed data
.ForEach((Entity entity, ref DecisionTreeNode.State condition, ref State state) =>
{
condition.isTrue = false;
if (!EntityManager.Exists(condition.owner))
return;
var abilityEntity =
Ability.FindAbility(OwnedAbilityBufferFromEntity, condition.owner, AbilityDead.Tag);
if (abilityEntity == Entity.Null)
return;
condition.isTrue = AbilityStateActiveFromEntity.HasComponent(abilityEntity);
// GameDebug.Log(World,null,"Condition:{0}",condition.isTrue);
}).Run();
return default;
}
}
}