예제 #1
0
 public GOAP_Worldstate(WorldStateKey key, int value, IActionTarget target = null)
 {
     this.key    = key;
     this.value  = value;
     this.target = target;
     type        = DetermineType();
     forgetTime  = DetermineForgetTime();
 }
예제 #2
0
    public IActionTarget FindClosestAvailable(IActionTarget[] transforms, Vector3 position)
    {
        IActionTarget closest     = null;
        float         minDistance = Mathf.Infinity;

        foreach (IActionTarget t in transforms)
        {
            if (t == null || !t.IsAvailable())
            {
                continue;
            }
            float distance = Vector3.Distance(t.GetPosition(), position);
            if (distance < minDistance)
            {
                closest     = t;
                minDistance = distance;
            }
        }
        return(closest);
    }
예제 #3
0
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            var pvt = serviceProvider.GetService <IProvideValueTarget>();
            //var s1 = (IRootObjectProvider)serviceProvider.GetService(typeof(IRootObjectProvider));
            var s2 = serviceProvider.GetService <IXamlTypeResolver>();
            var s3 = serviceProvider.GetService <IXamlSchemaContextProvider>();

            var sdf = s3.SchemaContext;

            IActionTarget result = pvt.TargetProperty switch
            {
                EventInfo ee
                => new EventAction(pvt.TargetObject, Path, ee.EventHandlerType),
                DependencyProperty dp when dp.PropertyType == typeof(ICommand)
                => new CommandAction(pvt.TargetObject, Path),
                MethodInfo mm
                => new EventAction(pvt.TargetObject, Path, mm.GetParameters().ElementAt(1).ParameterType),
                _ => throw new NotSupportedException($"Not support xaml attribute: {pvt.TargetProperty}")
            };

            return(result.ProvideValue(serviceProvider));
        }
    }
예제 #4
0
 public GOAP_Worldstate(WorldStateKey key, bool value, IActionTarget target = null) : this(key, value == true ? 1 : 0, target)
 {
 }
예제 #5
0
        public void AddSatisfyWorldState(WorldStateKey key, int value, IActionTarget target = null)
        {
            GOAP_Worldstate state = new GOAP_Worldstate(key, value, target);

            SatisfyWorldstates.Add(state);
        }
예제 #6
0
 public void AddSatisfyWorldState(WorldStateKey key, bool value, IActionTarget target = null)
 {
     AddSatisfyWorldState(key, value ? 1 : 0, target);
 }
예제 #7
0
    protected void AddRequiredWorldState(WorldStateKey key, int value, IActionTarget target = null)
    {
        GOAP_Worldstate state = new GOAP_Worldstate(key, value, target);

        RequiredWorldstates.Add(state);
    }
예제 #8
0
 protected void AddRequiredWorldState(WorldStateKey key, bool value, IActionTarget target = null)
 {
     AddRequiredWorldState(key, value ? 1 : 0, target);
 }