collision detection – Godot: How do I create a temporary invincible state or invincibility frames?

My issue

I have been racking my head around how to achieve invincibility frames. Working in the Godot Engine I have considered a few methods for this:

  • Setting a Timer Node when damaged to trigger the invincibility
  • setting a knockback variable, converting it into an int which is then multiplied by the movement vector.

move_dir * int(self.knockback)

Each of these runs into the problem of how do I return the state back at a set and proper interval to prevent some sort of ping-pong effect when many enemies are present.

there likely is something better that I haven’t yet considered for this, but I just want to know what else is out there for this. Any algorithms or techniques will be welcome. I just want to help get the end of this.

animation – Unity Animator Controller restarting state every time I change a parameter

I am currently working on a ladder climbing animation. I have 4 animations:

  1. Walk
  2. Starting to climb ladder
  3. Climbing ladder
  4. Finished climbing the ladder

The way I envision the state machine is the model is walking then a bool is set so it starts to climb the ladder, then it transitions to the climbing animation that is looped. Then when another bool is set, is does the finished climbing animation.

However, what is happening now, is during the climbing animation, when I set the isDoneClimbingUp bool to transition into the finished climbing animation, the character starts the entire transition over. Meaning, it starts walking, then starts to climb, then finishes climbing.

Here is a picture of my animation controller:
enter image description here

What am I doing wrong?

Completer Flutter hook causes bad state error

For managing pull-to-refresh indication in Flutter with BLoC I created a custom Completer hook as an alternative to using a Stateful Widget, and in general, it works fine, however with hot-reload I run into Bad state: Future already completed

import 'dart:async';

import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

class _CompleterHook extends Hook<Completer> {
  @override
  HookState<Completer, Hook<Completer>> createState() => _CompleterHookState();
}

class _CompleterHookState extends HookState<Completer, _CompleterHook> {
  Completer _completer;

  @override
  void initHook() {
    _completer = Completer<void>();

    super.initHook();
  }

  @override
  Completer build(BuildContext context) => _completer;
}

Completer<void> useCompleterHook() {
  return Hook.use(_CompleterHook());
}

Not sure if there is perhaps something I missed, it’s literally only on the HR so completely a development annoyance, I would prefer not to learn to live with it though. Any ideas or suggestions on ways to fix that.

TIA

[ Politics ] Open Question : A vote for Biden is a vote for the Deep State, pedofilia, and mass unemployment?

[ Politics ] Open Question : A vote for Biden is a vote for the Deep State, pedofilia, and mass unemployment?

How do I programmatically send a mail after changing a workflow state?

How do I programmatically send a mail after changing a workflow state?

When a node is created, I send a mail. I want to send a mail on Workflow state operations.

function mails_node_insert(EntityInterface $entity) {
  if ($entity->getEntityTypeId() !== 'node' || ($entity->getEntityTypeId() === 'node' && $entity->bundle() !== 'article')) {
    return;
  }

  $node = Drupal::entityManager()->getStorage('node')->load($entity->id());

  if ($node->get("field_workflow")->value == "test_published") {
    $result = $node->get("body")->getString();
    if ($result != true) {
      drupal_set_message(t('Sorry , due to some error mail , we cant send a mail.'), 'error');
    }
    else {
      drupal_set_message(t('The mail has been sent successfully.'));
    }
  }
}

How to send a mail in Drupal 8 after changing a workflow state -programmatically?

How to send a mail in Drupal 8 after changing a workflow state with programming

On Node insert i send a mail like below, Now i wants to send a mail on Workflow state operations

function mails_node_insert(EntityInterface $entity) {

 if ($entity->getEntityTypeId() !== 'node' || ($entity->getEntityTypeId() === 'node' && $entity->bundle() !== 'article')) {
   return;
 }
 $node = Drupal::entityManager()->getStorage('node')->load($entity->id());

if ($node->get("field_workflow")->value == "test_published") // workflow state check on node insert
{
$send_mail = new DrupalCoreMailPluginMailPhpMail();
$from = 'test@xyz.com';
$to = 'test2@xyz.com';
$message('headers') = array(
        'content-type' => 'text/html',
        'MIME-Version' => '1.0',
       'reply-to' => $from,
       'from' => 'sender name <'.$from.'>'
);
$message('to') = $to;
$message('subject') = "Your article has been published";

$message('body') =$node->get("body")->getString();

$result=$send_mail->mail($message);

if ($result != true) {
   drupal_set_message(t('Sorry , due to some error mail , we cant send a mail.'), 'error');
 }
 else {
   drupal_set_message(t('The mail has been sent successfully.'));
 }
}
}

[ Politics ] Open Question : Masks are tools of the oppressive socialist deep globalist state ?

[ Politics ] Open Question : Masks are tools of the oppressive socialist deep globalist state ?

unable to copy WooCommerce checkout state field values from billing to shipping, or vice versa

I’m trying to modify the WooCommerce checkout display so that:

  1. Both field columns are open and expanded
  2. There is a checkbox under shipping address, which upon clicking, copies data over from the billing fields to the shipping fields.

I’ve got that part set up, but though the state data is copied over from one area to another, upon trying to place order, the error message of “Shipping State is a required field.
No shipping method has been selected.” is displayed.

I’m presuming that the data upon manually using the state select field is being recorded somewhere other than the DOM, which is why it’s not working?

Here’s my jQuery code that’s doing the copying:

<script type="text/javascript">
$("#ship-to-billing-address-checkbox").on("click", function(){
    // if (this.checked) {
        $("(name='shipping_first_name')").val($("(name='billing_first_name')").val());
        $("(name='shipping_last_name')").val($("(name='billing_last_name')").val());
        $("(name='shipping_address_1')").val($("(name='billing_address_1')").val());
        $("(name='shipping_address_2')").val($("(name='billing_address_2')").val());
        $("(name='shipping_city')").val($("(name='billing_city')").val());
        $("(id='select2-shipping_state-container')").text($("(id='select2-billing_state-container')").text());
        $("(name='shipping_postcode')").val($("(name='billing_postcode')").val());
        $("(name='shipping_country')").val($("(name='billing_country')").val());
});

If you want to see it in action, go to https://stage.chilwellness.com/checkout/?add-to-cart=12105. Enter your info in billing, click the checkbox, then you’ll see that though the state field seems entered, the label is still the color red, indicating that it’s needing data still.

java – State design pattern for vending machine

I have to write a java program for a vending machine which:

  1. Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter.
  2. Allow user to select products Coke(25), Pepsi(35), Soda(45)
  3. Allow user to take refund by canceling the request.
  4. Return selected product and remaining change if any
  5. Allow reset operation for vending machine supplier.

I searched different design patterns and i saw that the best design pattern to write this kind of programs is the State Pattern. So i want your help to find the states because this is the first time that im going to use this pattern. I think that the states must be the following:

  1. Cancel Request(refund)
  2. Return product and Remaining change
  3. Reset Operation

Are those all the states that i must use or i must add something else?

optimization – Why a query takes too long in statistics thread state in AWS Aurora MySQL?

The following query execution too long in statistics state and I couldn’t figure out why.

DB engine – 5.7.mysql_aurora.2.07.2

DB Size – db.r5.4xlarge

Sample Query Profile output

+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000023 |
| checking query cache for query | 0.000155 |
| checking permissions           | 0.000009 |
| checking permissions           | 0.000002 |
| checking permissions           | 0.000003 |
| checking permissions           | 0.000002 |
| checking permissions           | 0.000009 |
| Opening tables                 | 0.000035 |
| init                           | 0.000102 |
| System lock                    | 0.000035 |
| optimizing                     | 0.000004 |
| optimizing                     | 0.000003 |
| optimizing                     | 0.000011 |
| statistics                     | 0.224528 |
| preparing                      | 0.000030 |
| Sorting result                 | 0.000017 |
| statistics                     | 0.000041 |
| preparing                      | 0.000013 |
| Creating tmp table             | 0.000023 |
| optimizing                     | 0.000013 |
| statistics                     | 0.064207 |
| preparing                      | 0.000035 |
| Sorting result                 | 0.000025 |
| statistics                     | 0.000098 |
| preparing                      | 0.000018 |
| executing                      | 0.000011 |
| Sending data                   | 0.000007 |
| executing                      | 0.000003 |
| Sending data                   | 0.000251 |
| executing                      | 0.000007 |
| Sending data                   | 0.000003 |
| executing                      | 0.000002 |
| Sending data                   | 0.000526 |
| end                            | 0.000007 |
| query end                      | 0.000013 |
| removing tmp table             | 0.000007 |
| query end                      | 0.000004 |
| closing tables                 | 0.000003 |
| removing tmp table             | 0.000004 |
| closing tables                 | 0.000002 |
| removing tmp table             | 0.000005 |
| closing tables                 | 0.000002 |
| removing tmp table             | 0.000004 |
| closing tables                 | 0.000010 |
| freeing items                  | 0.000050 |
| storing result in query cache  | 0.000007 |
| cleaned up                     | 0.000004 |
| cleaning up                    | 0.000017 |
+--------------------------------+----------+

Query

select xo.ITEM, xo.VALUE
from (
         select pi.ITEM, pi.ITEM_GROUP, pi.VALUE
         from TABLE_2 pi
                  inner join (select max(ps.EXPORTED_DATE) as max_expo, ps.ITEM
                              from TABLE_2 ps
                                       inner join (
                                  select max(pp.EFFECTIVE_DATE) max_eff_TABLE_2, pp.ITEM
                                  from TABLE_2 pp
                                  where pp.EFFECTIVE_DATE <= '2020/07/17'
                                    and ITEM in
                                        ('20', '30', '40', '50', '110', '120', '320', '520', '720', '820', '920', '321',
                                         '275', '221')
                                  group by ITEM
                              ) a on ps.EFFECTIVE_DATE = a.max_eff_TABLE_2 and ps.ITEM = a.ITEM
                              group by a.ITEM) rr on rr.ITEM = pi.ITEM and rr.max_expo = pi.EXPORTED_DATE) xo

         inner join (
    select ea.ITEM, ea.CUSTOMER_ID, ea.ITEM_GROUP
    from TABLE_1 ea
             inner join (
        select MAX(e.EFFECTIVE_DATE) eat_max_eff, e.ITEM, e.CUSTOMER_ID
        from TABLE_1 e
        where e.CUSTOMER_ID = '20'
          and ITEM in ('20', '30', '40', '50', '110', '120', '320', '520', '720', '820', '920', '321', '275', '221')
          and EFFECTIVE_DATE <= '2020/07/17'
        group by e.ITEM
    ) aa
    where ea.ITEM = (aa.ITEM)
      and ea.CUSTOMER_ID = aa.CUSTOMER_ID
      and ea.EFFECTIVE_DATE = aa.eat_max_eff) lo
                    on lo.ITEM_GROUP = xo.ITEM_GROUP and lo.ITEM = xo.ITEM;

Indexes

Table 1

mysql> SHOW INDEX FROM T1;
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name     | Seq_in_index | Column_name    | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| T1    |          0 | PRIMARY      |            1 | CUSTOMER_ID    | A         |     3297549 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          0 | PRIMARY      |            2 | ITEM           | A         |   687374784 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          0 | PRIMARY      |            3 | EFFECTIVE_DATE | A         |  1314196480 |     NULL | NULL   |      | BTREE      |         |               |
| T1    |          1 | t1_ix_item   |            1 | ITEM           | A         |     2151649 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+--------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

Table 2


mysql> SHOW INDEX FROM TABLE_2;
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| Table | Non_unique | Key_name              | Seq_in_index | Column_name    | Collation | Cardinality | Sub_T2rt | T2cked | Null | Index_type | Comment | Index_comment |
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
| T2    |          0 | PRIMARY               |            1 | ITEM           | A         |           1 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            2 | ITEM_GROUP     | A         |       14265 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            3 | EFFECTIVE_DATE | A         |    63663076 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          0 | PRIMARY               |            4 | EXPORTED_DATE  | A         |    62464764 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_expo       |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_expo       |            2 | EXPORTED_DATE  | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_date   |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_date   |            2 | EFFECTIVE_DATE | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            1 | ITEM           | A         |      115823 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            2 | EFFECTIVE_DATE | A         |    13766454 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_ix_item_eff_ig     |            3 | ITEM_GROUP     | A         |    68216912 |     NULL | NULL   |      | BTREE      |         |               |
| T2    |          1 | t2_idx_effective_date |            1 | EFFECTIVE_DATE | A         |       79406 |     NULL | NULL   |      | BTREE      |         |               |
+-------+------------+-----------------------+--------------+----------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

According to this: statistics State in MySQL Processlist

I checked the innodb_buffer_pool_size.

mysql> SHOW VARIABLES LIKE "innodb_buffer_pool_size";
+-------------------------+-------------+
| Variable_name           | Value       |
+-------------------------+-------------+
| innodb_buffer_pool_size | 96223625216 |
+-------------------------+-------------+

In EXPLAIN output rows are minimal (Depends on the Item count in the query. If Item count is 10, the number of rows were 20). Even though the row counts are minimal why the query takes too long in statistics state?