private void ExecuteOrder(IntelligenceComponent intelligence, IntelligenceOrder order, IntelligenceNode node) { InputComponent input = null; if (intelligence.Bindings.TryGetValue(typeof(InputComponent), out var binding)) { input = binding as InputComponent; } if (input.Blocked) { return; } intelligence.State = order.Type; if (order.Type == OrderType.AttackPrimary || order.Type == OrderType.AttackSecondary) { input.CursorPoint = node.Pos; intelligence.TargetPos = node.Pos; if (order.Type == OrderType.AttackPrimary) { input.PrimaryAttack = true; } if (order.Type == OrderType.AttackSecondary) { input.SecondaryAttack = true; } } if (order.Type == OrderType.Follow || order.Type == OrderType.Move) { input.MovementDirection = VectorDirection(intelligence.Pos, node.Pos); if (order.Type == OrderType.Follow) { intelligence.TargetPos = node.Pos; } if (order.Type == OrderType.Move) { intelligence.TargetPos = new Vector2Ref(node.Pos); } } intelligence.UpdateCooldownMilliseconds = order.UpdateCooldownMilliseconds; }
private void ResetOrderInputs(IntelligenceComponent intelligence, IntelligenceOrder order) { InputComponent input = null; if (intelligence.Bindings.TryGetValue(typeof(InputComponent), out var binding)) { input = binding as InputComponent; } if (order.Type == OrderType.AttackPrimary) { input.PrimaryAttack = false; } if (order.Type == OrderType.AttackSecondary) { input.SecondaryAttack = false; } if (order.Type == OrderType.Follow || order.Type == OrderType.Move) { input.MovementDirection = Vector2.Zero; } }