Skip to content

Instantly share code, notes, and snippets.

@Lexxicon
Forked from oldmanauz/ExmpleSource.cpp
Created October 24, 2021 20:18

Revisions

  1. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -74,7 +74,7 @@ int main()
    ecs_tracing_color_enable(false);

    // Flecs system that runs every tick
    // .kind(flecs::PreFrame) makes the system run in the flecs::PreFrame pipeline
    // .kind(flecs::PreFrame) makes the system run in the flecs::PreFrame phase
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Tick Printer")
    .kind(flecs::PreFrame)
    @@ -85,7 +85,7 @@ int main()
    });

    // Flecs system that runs every tick
    // .kind(flecs::PostFrame) makes the system run in the flecs::PostFrame pipeline
    // .kind(flecs::PostFrame) makes the system run in the flecs::PostFrame phase
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Post Tick")
    .kind(flecs::PostFrame)
    @@ -96,8 +96,8 @@ int main()
    });

    // Flecs observer that logs creation of new entities
    // Triggered when an "IsA" relationship is ADDED to ANY [wildcard] entity
    // Triggered by creation of entities from prefabs (approx Line 282 onwards)
    // Triggered when an "IsA" relationship is ADDED to ANY (wildcard) entity
    // Triggered by creation of entities from prefabs (approx Line 348 --> "ecs.entity("Creep").scope([&]{" --> onwards)
    ecs.observer<>()
    .term(flecs::IsA).object(flecs::Wildcard)
    .event(flecs::OnAdd)
  2. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    **/

    // **TODO** code doesn't add <Cooldown> component to <Attack> component, it adds a seperate <Cooldown, Attack> pair. Update comments to reflect this understanding

    #include <vector>

    #include "flecs.h"
  3. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 54 additions and 52 deletions.
    106 changes: 54 additions & 52 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ int main()
    ecs_tracing_color_enable(false);

    // Flecs system that runs every tick
    // .kind(flecs::PreFrame) makes the system run in the default flecs::PreFrame pipeline **TODO** is PreFrame a default pipeline?
    // .kind(flecs::PreFrame) makes the system run in the flecs::PreFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Tick Printer")
    .kind(flecs::PreFrame)
    @@ -87,7 +87,7 @@ int main()
    });

    // Flecs system that runs every tick
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline **TODO** is PostFrame a default pipeline?
    // .kind(flecs::PostFrame) makes the system run in the flecs::PostFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Post Tick")
    .kind(flecs::PostFrame)
    @@ -97,11 +97,9 @@ int main()
    ecs_trace(TD_LOG_INFO, "--- End Tick ---");
    });

    // Flecs observer that is triggered when ANY entity has an "IsA" relationship set.
    // In this code is triggered by 'ecs.entity("Creep").scope([&]{' (approx Line 282 onwards)
    // when an entitiy is created from the prefab definitions.
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    // Flecs observer that logs creation of new entities
    // Triggered when an "IsA" relationship is ADDED to ANY [wildcard] entity
    // Triggered by creation of entities from prefabs (approx Line 282 onwards)
    ecs.observer<>()
    .term(flecs::IsA).object(flecs::Wildcard)
    .event(flecs::OnAdd)
    @@ -110,7 +108,8 @@ int main()
    ecs_trace(TD_LOG_INFO, "New Instance: %s [%s]", e.str().c_str(), e.type().str().c_str());
    });

    // Flecs observer that is triggered when an object has an <MaxHealth> component set BUT DOESN'T contain a <Health> component
    // Flecs observer sets an entities' health
    // Triggered when an object has an <MaxHealth> component ios SET AND the entity DOESN'T contain a <Health> component
    // Creating 'creep' entities triggers this observer, it sets their current health (in <Health> component) to their max health (in <MaxHealth> component)
    ecs.observer<MaxHealth>("Init Health")
    .term<Health>().oper(flecs::Not)
    @@ -121,35 +120,31 @@ int main()
    e.set<Health>({maxHealth.value});
    });

    // Flecs system that runs every tick
    // The system query collects all the entities that have a <Cooldown> paired with any component.
    // In this code, the <Cooldown> component is added to the <Attack> component in the line "e.set<Cooldown, Attack>({attack.cooldown});" in the "Send Attack" system
    // **TODO** is <Cooldown> paired with <Attack> or is <Cooldown> component added to <Attack> component???
    // This controls the cooldown between turret attacks
    // ".arg(1).object(flecs::Wildcard)" makes the system query only match with <Cooldown> components that HAVE been paired with another component
    // System monitors the attach cool downs.
    // Flecs system that updates cooldowns on entities
    // The system query collects entities with a <Cooldown , [WILDCARD]> pair
    // ".arg(1).object(flecs::Wildcard)" sets the WILDCARD in the pair
    // In this code sample, cooldowns are only added to turret attacks in the "Send Attack" system > "e.set<Cooldown, Attack>({attack.cooldown});"
    ecs.system<Cooldown>("Tick Cooldown")
    .arg(1).object(flecs::Wildcard) // <- Cooldown is actually a pair type with anything
    .iter([](flecs::iter& iter, Cooldown* cooldowns)
    {
    auto obj = iter.term_id(1).object(); // Gets the entity that is attached with the <Cooldown> component
    auto obj = iter.term_id(1).object(); // Gets the component that is paired with the <Cooldown> pair (In this code, an <Attack> component)
    for(auto i : iter)
    {
    cooldowns[i].remainingTime -= iter.delta_system_time();
    if(cooldowns[i].remainingTime <= 0)
    {
    ecs_trace(TD_LOG_INFO, "%s<%s> off cooldown", iter.entity(i).str().c_str(), obj.str().c_str());

    // Removes the component (in this code <Cooldown>) from the <Attack> component
    // Leaves the <Attack> attached to the entity
    // Removes the <Cooldown, *> pair from the entity when the <Cooldown>.remainingTime reaches 0
    iter.entity(i).remove<Cooldown>(obj);
    }
    }
    });

    // Flecs observer that is triggered when an object has an <Health> component set
    // This triggers when the <Health> component is modified: "it.entity(i).modified<Health>()" in the "Apply Damage" observer
    // Observer destorys an entity when it's health reaches 0
    // Flecs observer that destroys creeps when their health reaches 0
    // Triggered when an entity has a <Health> component set
    // This observer triggers when the <Health> component is modified by: "it.entity(i).modified<Health>()" in the "Apply Damage" observer
    ecs.observer<Health>()
    .event(flecs::OnSet)
    .each([](flecs::entity e, Health& hp)
    @@ -161,40 +156,45 @@ int main()
    }
    });

    // Flecs system prints the positions of entities with a <Position> component
    // Flecs system that prints the positions of entities with a <Position> component
    ecs.system<Position>()
    .each([](flecs::entity e, Position& p)
    {
    ecs_trace(TD_LOG_INFO, "%s located at [%f, %f]", e.str().c_str(), p.x, p.y);
    });

    // Flecs observer that is triggered when an object has <Health> component set AND <Damage> component set
    // Applys damage to an entity. Takes damage amount away from health.
    // Flecs observer that applies damage to creeps
    // Triggered when an entity has <Health> component set AND <Damage> component set
    // Creeps are the only entities that may contain a <Health> and <Damage> component
    // NOTE: This obsever will never match a <* , Damage> pair like the Turrets have set
    ecs.observer<Health, Damage>("Apply Damage")
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Health* healths, Damage* damages)
    {
    if(it.event_id() != it.world().component<Damage>()) // Only preceed if this event was triggered by a set<Damage>({}) DON'T do anything if set<Health>({});
    if(it.event_id() != it.world().component<Damage>()) // Only preceed if this event was triggered by <Damage> being set NOT <Health> being set
    {
    return;
    }
    for(auto i : it)
    {
    auto e = it.entity(i);
    auto maxHealth = e.get<MaxHealth>();
    auto maxHealth = e.get<MaxHealth>(); // Gettin the <MaxHealth> component from the entity
    healths[i].current -= damages[i].amount;
    it.entity(i).modified<Health>(); // Alert flecs that <Health> component is modified. Triggers observer: "ecs.observer<Health>()" above

    ecs_trace(TD_LOG_INFO, "Damaged %s for %f %f/%f", e.str().c_str(), damages[i].amount, healths[i].current, maxHealth->value);
    }
    });

    // Flecs observer that is triggered when an object has <Position> component set AND <KnockBack> component set
    // Flecs observer that Applies Knock Back attack
    // Triggered when an entity has <Position> component set AND <KnockBack> component set
    // Creeps are the only entities that may contain a <Position> and <KnockBack> component
    // NOTE: This obsever will never match a <* , KnockBack> pair like the Turrets have set
    ecs.observer<Position, KnockBack>("Apply Knock Back")
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Position* positions, KnockBack* knockBacks)
    {
    if(it.event_id() != it.world().component<KnockBack>()) // Only preceed if this event was triggered by a set<KnockBack>({}) DON'T do anything if set<Position>({});
    if(it.event_id() != it.world().component<KnockBack>()) // Only preceed if this event was triggered by <KnockBack> being set NOT <Position> being set
    {
    return;
    }
    @@ -203,16 +203,19 @@ int main()
    ecs_trace(TD_LOG_INFO, "Knocking %s for [%f,%f]", it.entity(i).str().c_str(), knockBacks[i].x, knockBacks[i].y);
    positions[i].x += knockBacks[i].x;
    positions[i].y += knockBacks[i].y;
    it.entity(i).modified<Position>(); // Alert flecs that <Position> component is modified. Not necessary in current code.
    it.entity(i).modified<Position>(); // Alert flecs that <Position> component is modified. Not necessary in current code, but might save some bug fixing later in life.
    }
    });

    // Flecs system sends attacks from turrets
    // The system query collects entites that have the <Attack> and <Target> components AND <Cooldown> component WITHOUT <Cooldown, Attack> pair
    // A turret can only attack if their attack is off cooldown. **TODO** This is expressed by <Attack> component NOT having an attached <Cooldown> component OR NOT HAVEING A <Cooldown,Attack> PAIR
    // The <Attack> component is added in the turret prefab below
    // When the <Attack> component is set, it creates 1 or 2 entities pairs of type <PayloadType, [KnockBack OR Damage]> in the <Attack>.payload variable
    // <PayloadType> is a tag.
    // The system query collects entites that HAVE an <Attack> AND <Target> components AND DONT HAVE a <Cooldown, Attack> pair
    // A turret can only attack if their attack is off cooldown. The presence of a <Cooldown,Attack> pair means the turret can't attack.
    //
    // In the turret prefab definition:
    // Turret contains an <Attack> component with variable "flecs::entity_view payload"
    // <Attack> component will add one or both of the following pairs (depnding on turret prefab type) to the <Attack> components "payload" variable:
    // <PayloadType, Damage> pair
    // <PayloadType, KnockBack> pair
    ecs.system<Attack, Target>("Send Attack")
    .term<Cooldown>().object<Attack>().oper(flecs::Not)
    .each([](flecs::entity e, Attack& attack, Target& target)
    @@ -228,42 +231,40 @@ int main()
    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();

    // Iterates through each "Type" that has been added to the <Attack>.payload entity. The TypeID will contain Pairs of <PayloadType, Damage> or <PayloadType, KnockBack>
    // Iterates through each pair that has been added to the <Attack>.payload entity. The TypeID will contain Pairs of <PayloadType, Damage> or <PayloadType, KnockBack>
    attack.payload.each([&](flecs::id TypeID)
    {
    // Checks if the "Type" (TypeID) is a Pair AND has a pair type of <PayloadType>
    // Checks if "TypeID" is a Pair WITH <PayloadType>
    // In this code, <Damage> or <KnockBack> components will be paired with <PayloadType>
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    // TypeID will be a pair of either: <PayloadType, Damage> or <PayloadType, KnockBack>
    auto payloadType = TypeID.object(); // Gets the 'object' from a pair. payloadType will be either <Damage> or <KnockBack>
    // "TypeID" will be a pair of either: <PayloadType, Damage> or <PayloadType, KnockBack>
    auto payloadType = TypeID.object(); // Gets the 'object' from a pair. "payloadType" will be either <Damage> or <KnockBack>
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());

    // Send an attack to the turret's target **TODO**
    // Send an attack to the turret's target
    // Adds a <Damage> or <KnockBack> component (with the turrets damage/knock back amount) to the turrets target entity
    //
    // Author's comment:
    // I then stage the target onto the current stage target.entity.mut(e) basically saying "Any writes to this entity will be queued in the queued that e is using.
    // Then I queue a write to the target from the payload onto the target: .set_ptr(payloadType, attack.payload.get(TypeID));

    //
    // target.entity is a reference to an entity in the <Target> component. It is the target creep of the turret. "target.entity" is type entity_view which is read only.
    // target.entity.mut(e) gets a pointer to entity which the turret is targeting stored in <Target>.entity so it can be modified.
    // ** TODO ** research stages: -> "target.entity.mut(e)" is doing: Any writes to this entity will be queued in the queued that e
    // "set_ptr" not currently documented.
    // "set_ptr(payloadType, attack.payload.get(TypeID));" sets a component of type "payloadType" (<Damage> or <Knockback>) in the target's entity (a creep)
    // **TODO** what is "attack.payload.get(TypeID)" doing? Aren't payloadType and attack.payload.get(TypeID) the same?
    // NOTE: ".set_ptr()" not currently documented.
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    }
    });
    ecs_log_pop();

    // Set a cooldown on the turret attack
    // Adds a <Cooldown, Attack> pair to the turret entity
    // The <Cooldown>.remainingTime is set from Turret entities' <Attack>.cooldown amount. (This is set in the turret prefab definition)
    e.set<Cooldown, Attack>({attack.cooldown});
    });

    // Creates 2 tags, one for each Team
    auto TeamOne = ecs.entity("PlayerTeam");
    auto TeamTwo = ecs.entity("Creeps");

    // Query builder that gets a collection of entities that contain <Position> component, <Health> component and <TeamTwo> tag
    // Query builder that gets a collection of entities that contain <Position> AND <Health> component AND <TeamTwo> tag
    // set(flecs::Self | flecs::SuperSet) matches <TeamTwo> in the base component of a prefab
    auto FindAllCreeps = ecs.query_builder<>()
    .term<Position>()
    @@ -273,8 +274,8 @@ int main()

    // Flecs system finds a target for a turret
    // The system query collects entites that have the <Attack> BUT NOT <Target> components AND <TeamOne> tag. Will get a list of turrets without a target.
    // A turret can only attack if their attack is off cooldown. This is expressed by <Cooldown> component NOT having an attached <Attack> component
    // ".each([FindAllCreeps](flecs::entity e)" copies the FindAllCreeps by value into the system.
    // A turret can only attack if their attack is off cooldown. The presence of a <Cooldown, Attack> pair means the turret's attack is on cooldown
    // ".each([FindAllCreeps](flecs::entity e)" copies the FindAllCreeps query by value into the system.
    ecs.system("Find New Targets")
    .term<Attack>()
    .term<Target>().oper(flecs::Not)
    @@ -285,7 +286,7 @@ int main()
    std::vector<flecs::entity> FoundCreeps;
    FindAllCreeps.each([&](flecs::entity Creep)
    {
    FoundCreeps.emplace_back(Creep); // Adds every entity found (creeps) to a vector
    FoundCreeps.emplace_back(Creep); // Adds every entity found (creeps) to a list
    });

    // Exit game if no creeps found
    @@ -295,7 +296,7 @@ int main()
    e.world().quit(); // Allows ecs.should_quit() to equal true
    }else
    {
    // Get a random creep of type flecs::entity
    // Get a random creep of type flecs::entity from the "FoundCreeps" list
    auto Picked = FoundCreeps[rand() % FoundCreeps.size()];

    ecs_trace(TD_LOG_INFO, "%s now targeting %s", e.str().c_str(), Picked.str().c_str());
    @@ -361,6 +362,7 @@ int main()
    ecs.entity().is_a(SlowSuperTurret);
    });
    ecs_trace(TD_LOG_INFO, "Begin");

    // Run flecs world at 1 FPS
    ecs.set_target_fps(1);
    while(!ecs.should_quit())
  4. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 13 additions and 11 deletions.
    24 changes: 13 additions & 11 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -228,23 +228,25 @@ int main()
    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();

    // **TODO**
    // Iterates through all the components added to the <PayloadType> tag. Set in the <Attack>.payload data during turret prefab initialisation.
    // PayloadType is either <Damage> or <KnockBack>
    // ".set<PayloadType, Damage>({5})" is added to <Attack> component when entity is created
    // Iterates through each "Type" that has been added to the <Attack>.payload entity. The TypeID will contain Pairs of <PayloadType, Damage> or <PayloadType, KnockBack>
    attack.payload.each([&](flecs::id TypeID)
    {
    // Checks if a component has a relationship with <PayloadType> component
    // In this code, will get a <Damage> or <KnockBack> component
    // Checks if the "Type" (TypeID) is a Pair AND has a pair type of <PayloadType>
    // In this code, <Damage> or <KnockBack> components will be paired with <PayloadType>
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    // TypeID will be a pair of either: <PayloadType, Damage> or <PayloadType, KnockBack>
    auto payloadType = TypeID.object(); // Gets the 'object' from a pair. payloadType will be either <Damage> or <KnockBack>
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());

    // Send an attack to the turret's target
    // target.entity is a reference to an entity in the <Target> component. It is the target creep of the turret
    // target.entity is type entity_view which is read only.
    // Send an attack to the turret's target **TODO**
    // I then stage the target onto the current stage target.entity.mut(e) basically saying "Any writes to this entity will be queued in the queued that e is using.
    // Then I queue a write to the target from the payload onto the target: .set_ptr(payloadType, attack.payload.get(TypeID));

    //
    // target.entity is a reference to an entity in the <Target> component. It is the target creep of the turret. "target.entity" is type entity_view which is read only.
    // target.entity.mut(e) gets a pointer to entity which the turret is targeting stored in <Target>.entity so it can be modified.
    // ** TODO ** research stages: -> "target.entity.mut(e)" is doing: Any writes to this entity will be queued in the queued that e
    // "set_ptr" not currently documented.
    // "set_ptr(payloadType, attack.payload.get(TypeID));" sets a component of type "payloadType" (<Damage> or <Knockback>) in the target's entity (a creep)
    // **TODO** what is "attack.payload.get(TypeID)" doing? Aren't payloadType and attack.payload.get(TypeID) the same?
    @@ -262,7 +264,7 @@ int main()
    auto TeamTwo = ecs.entity("Creeps");

    // Query builder that gets a collection of entities that contain <Position> component, <Health> component and <TeamTwo> tag
    // set(flecs::Self | flecs::SuperSet) matches <TeamTwo> in the base component of a prefab **TODO** confirm this is true
    // set(flecs::Self | flecs::SuperSet) matches <TeamTwo> in the base component of a prefab
    auto FindAllCreeps = ecs.query_builder<>()
    .term<Position>()
    .term<Health>()
  5. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 26 additions and 30 deletions.
    56 changes: 26 additions & 30 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,9 @@ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTIO
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    **/

    // **TODO** code doesn't add <Cooldown> component to <Attack> component, it adds a seperate <Cooldown, Attack> pair. Update comments to reflect this understanding

    #include <vector>

    #include "flecs.h"
    @@ -45,7 +48,6 @@ struct Attack
    {
    // flecs::entity_view is a `const` flecs::entity.
    // Functionally treat it is a ready only entity.
    // *TODO* > What are the benefits in flecs for using flecs::entity_view? (structures memory more efficiently? Allows faster iteration??)
    flecs::entity_view payload;
    float cooldown;
    };
    @@ -67,31 +69,28 @@ struct Target
    flecs::entity_view entity;
    };

    struct Team{}; // *TODO* IS THIS TAG USED ANYWHERE???? REMOVE!!!!!!


    int main()
    {
    // Initialise the flecs world
    flecs::world ecs;
    ecs_tracing_color_enable(false);

    // Flecs system that runs every tick
    // .kind(flecs::PreFrame) makes the system run in the default flecs::PreFrame pipeline
    // .kind(flecs::PreFrame) makes the system run in the default flecs::PreFrame pipeline **TODO** is PreFrame a default pipeline?
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Tick Printer")
    .kind(flecs::PreFrame) // **TODO** is PreFrame a current definition?? Not showing in: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pipeline
    .kind(flecs::PreFrame)
    .iter([](flecs::iter& iter)
    {
    ecs_trace(TD_LOG_INFO, "\n--- Tick[%d] time[%f] ---", iter.world().get_tick(), iter.world_time());
    ecs_log_push();
    });

    // Flecs system that runs every tick
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline **TODO** is PostFrame a default pipeline?
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Post Tick")
    .kind(flecs::PostFrame) // **TODO** is PostFrame a current definition?? Not showing in: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pipeline
    .kind(flecs::PostFrame)
    .iter([](flecs::iter& iter)
    {
    ecs_log_pop();
    @@ -122,9 +121,10 @@ int main()
    e.set<Health>({maxHealth.value});
    });

    // Flecs system that runs every tick **TODO** check terminology. Is this using the pair functionality from here: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pair or just straight adding a component to another component?
    // Flecs system that runs every tick
    // The system query collects all the entities that have a <Cooldown> paired with any component.
    // In this code, the <Attack> component is added to the <Cooldown> component in the line "e.set<Cooldown, Attack>({attack.cooldown});" in the "Send Attack" system
    // In this code, the <Cooldown> component is added to the <Attack> component in the line "e.set<Cooldown, Attack>({attack.cooldown});" in the "Send Attack" system
    // **TODO** is <Cooldown> paired with <Attack> or is <Cooldown> component added to <Attack> component???
    // This controls the cooldown between turret attacks
    // ".arg(1).object(flecs::Wildcard)" makes the system query only match with <Cooldown> components that HAVE been paired with another component
    // System monitors the attach cool downs.
    @@ -140,8 +140,8 @@ int main()
    {
    ecs_trace(TD_LOG_INFO, "%s<%s> off cooldown", iter.entity(i).str().c_str(), obj.str().c_str());

    // Removes the component (in this code <Attack>) from the <Cooldown> component
    // Leaves the <Cooldown> attached to the entity
    // Removes the component (in this code <Cooldown>) from the <Attack> component
    // Leaves the <Attack> attached to the entity
    iter.entity(i).remove<Cooldown>(obj);
    }
    }
    @@ -169,11 +169,6 @@ int main()
    });

    // Flecs observer that is triggered when an object has <Health> component set AND <Damage> component set
    // **TODO** Confirm behaviour below??
    // e.set<Health>({10}); // observer doesn't trigger
    // e.set<Damage>({10}); // observer does trigger
    // == new tick
    // e.set<Damage>({10}); // Does observer trigger here or need both <Health> && <Damage> set to retrigger??
    // Applys damage to an entity. Takes damage amount away from health.
    ecs.observer<Health, Damage>("Apply Damage")
    .event(flecs::OnSet)
    @@ -196,7 +191,6 @@ int main()

    // Flecs observer that is triggered when an object has <Position> component set AND <KnockBack> component set
    ecs.observer<Position, KnockBack>("Apply Knock Back")
    .arg(1) // **TODO** WHAT DOES THIS DO ??
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Position* positions, KnockBack* knockBacks)
    {
    @@ -209,17 +203,21 @@ int main()
    ecs_trace(TD_LOG_INFO, "Knocking %s for [%f,%f]", it.entity(i).str().c_str(), knockBacks[i].x, knockBacks[i].y);
    positions[i].x += knockBacks[i].x;
    positions[i].y += knockBacks[i].y;
    it.entity(i).modified<Position>(); // Alert flecs that <Position> component is modified. **TODO** Why is this necessary?
    it.entity(i).modified<Position>(); // Alert flecs that <Position> component is modified. Not necessary in current code.
    }
    });

    // Flecs system sends attacks from turrets
    // The system query collects entites that have the <Attack> and <Target> components AND <Cooldown> component WITHOUT an attached <Attack> component
    // A turret can only attack if their attack is off cooldown. This is expressed by <Cooldown> component NOT having an attached <Attack> component
    // The system query collects entites that have the <Attack> and <Target> components AND <Cooldown> component WITHOUT <Cooldown, Attack> pair
    // A turret can only attack if their attack is off cooldown. **TODO** This is expressed by <Attack> component NOT having an attached <Cooldown> component OR NOT HAVEING A <Cooldown,Attack> PAIR
    // The <Attack> component is added in the turret prefab below
    // When the <Attack> component is set, it creates 1 or 2 entities pairs of type <PayloadType, [KnockBack OR Damage]> in the <Attack>.payload variable
    // <PayloadType> is a tag.
    ecs.system<Attack, Target>("Send Attack")
    .term<Cooldown>().object<Attack>().oper(flecs::Not)
    .each([](flecs::entity e, Attack& attack, Target& target)
    {
    // Is the turrets target entity dead?
    if(!target.entity.is_alive())
    {
    ecs_trace(TD_LOG_INFO, "%s target is dead", e.str().c_str());
    @@ -231,8 +229,8 @@ int main()
    ecs_log_push();

    // **TODO**
    // Iterates through all the <PayloadType> components set in teh <Attack>.payload data ?????
    // payload is either <Damage> or <KnockBack>
    // Iterates through all the components added to the <PayloadType> tag. Set in the <Attack>.payload data during turret prefab initialisation.
    // PayloadType is either <Damage> or <KnockBack>
    // ".set<PayloadType, Damage>({5})" is added to <Attack> component when entity is created
    attack.payload.each([&](flecs::id TypeID)
    {
    @@ -247,8 +245,7 @@ int main()
    // target.entity is a reference to an entity in the <Target> component. It is the target creep of the turret
    // target.entity is type entity_view which is read only.
    // target.entity.mut(e) gets a pointer to entity which the turret is targeting stored in <Target>.entity so it can be modified.
    // **TODO** I don't understand the e variable in "mut(e)". Isn't e going to be a turret entity?
    // **TODO** Can't find "set_ptr" in manual??
    // "set_ptr" not currently documented.
    // "set_ptr(payloadType, attack.payload.get(TypeID));" sets a component of type "payloadType" (<Damage> or <Knockback>) in the target's entity (a creep)
    // **TODO** what is "attack.payload.get(TypeID)" doing? Aren't payloadType and attack.payload.get(TypeID) the same?
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    @@ -275,8 +272,7 @@ int main()
    // Flecs system finds a target for a turret
    // The system query collects entites that have the <Attack> BUT NOT <Target> components AND <TeamOne> tag. Will get a list of turrets without a target.
    // A turret can only attack if their attack is off cooldown. This is expressed by <Cooldown> component NOT having an attached <Attack> component
    // **TODO** confirm phrasing below
    // ".each([FindAllCreeps](flecs::entity e)" passes the <FindAllCreeps> query into the system.
    // ".each([FindAllCreeps](flecs::entity e)" copies the FindAllCreeps by value into the system.
    ecs.system("Find New Targets")
    .term<Attack>()
    .term<Target>().oper(flecs::Not)
    @@ -324,21 +320,21 @@ int main()
    auto BaseTurret = ecs.prefab("TurretBase")
    .add(TeamOne);
    // Defines FastDamageTurret as prefab based on BaseTurret.
    // Attacks with "Damage" payloads
    // Attacks with "Damage" payloads. For more explanation, see "Send Attack" function
    auto FastDamageTurret = ecs.prefab("FastDamageTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, Damage>({1}),
    1});
    // Defines MedTeleportTurret as prefab based on BaseTurret
    // Attacks with "KnockBack" payloads
    // Attacks with "KnockBack" payloads. For more explanation, see "Send Attack" function
    auto MedTeleportTurret = ecs.prefab("MedTeleportTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, KnockBack>({1, 0}),
    2});
    // Defines SlowSuperTurret as prefab based on BaseTurret
    // Attacks with "KnockBack" and "Damage" payloads
    // Attacks with "KnockBack" and "Damage" payloads. For more explanation, see "Send Attack" function
    auto SlowSuperTurret = ecs.prefab("SlowSuperTurret")
    .is_a(BaseTurret)
    .set<Attack>({
  6. @oldmanauz oldmanauz revised this gist Sep 28, 2021. 1 changed file with 110 additions and 21 deletions.
    131 changes: 110 additions & 21 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    const int TD_LOG_INFO = 0;

    // Define all the components
    struct Position
    {
    float x;
    @@ -42,7 +43,10 @@ struct Cooldown

    struct Attack
    {
    flecs::entity_view payload;
    // flecs::entity_view is a `const` flecs::entity.
    // Functionally treat it is a ready only entity.
    // *TODO* > What are the benefits in flecs for using flecs::entity_view? (structures memory more efficiently? Allows faster iteration??)
    flecs::entity_view payload;
    float cooldown;
    };

    @@ -63,28 +67,42 @@ struct Target
    flecs::entity_view entity;
    };

    struct Team{};
    struct Team{}; // *TODO* IS THIS TAG USED ANYWHERE???? REMOVE!!!!!!


    int main()
    {
    // Initialise the flecs world
    flecs::world ecs;
    ecs_tracing_color_enable(false);

    // Flecs system that runs every tick
    // .kind(flecs::PreFrame) makes the system run in the default flecs::PreFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Tick Printer")
    .kind(flecs::PreFrame)
    .kind(flecs::PreFrame) // **TODO** is PreFrame a current definition?? Not showing in: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pipeline
    .iter([](flecs::iter& iter)
    {
    ecs_trace(TD_LOG_INFO, "\n--- Tick[%d] time[%f] ---", iter.world().get_tick(), iter.world_time());
    ecs_log_push();
    });

    // Flecs system that runs every tick
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.system("Post Tick")
    .kind(flecs::PostFrame)
    .kind(flecs::PostFrame) // **TODO** is PostFrame a current definition?? Not showing in: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pipeline
    .iter([](flecs::iter& iter)
    {
    ecs_log_pop();
    ecs_trace(TD_LOG_INFO, "--- End Tick ---");
    });

    // Flecs observer that is triggered when ANY entity has an "IsA" relationship set.
    // In this code is triggered by 'ecs.entity("Creep").scope([&]{' (approx Line 282 onwards)
    // when an entitiy is created from the prefab definitions.
    // .kind(flecs::PostFrame) makes the system run in the default flecs::PostFrame pipeline
    // As no components are specified in the system query, it matches no entities the flecs::world. "iter.count() == 0"
    ecs.observer<>()
    .term(flecs::IsA).object(flecs::Wildcard)
    .event(flecs::OnAdd)
    @@ -93,6 +111,8 @@ int main()
    ecs_trace(TD_LOG_INFO, "New Instance: %s [%s]", e.str().c_str(), e.type().str().c_str());
    });

    // Flecs observer that is triggered when an object has an <MaxHealth> component set BUT DOESN'T contain a <Health> component
    // Creating 'creep' entities triggers this observer, it sets their current health (in <Health> component) to their max health (in <MaxHealth> component)
    ecs.observer<MaxHealth>("Init Health")
    .term<Health>().oper(flecs::Not)
    .event(flecs::OnSet)
    @@ -101,23 +121,35 @@ int main()
    ecs_trace(TD_LOG_INFO, "Init health for %s to %f", e.str().c_str(), maxHealth.value);
    e.set<Health>({maxHealth.value});
    });


    // Flecs system that runs every tick **TODO** check terminology. Is this using the pair functionality from here: https://github.com/SanderMertens/flecs/blob/master/docs/Quickstart.md#pair or just straight adding a component to another component?
    // The system query collects all the entities that have a <Cooldown> paired with any component.
    // In this code, the <Attack> component is added to the <Cooldown> component in the line "e.set<Cooldown, Attack>({attack.cooldown});" in the "Send Attack" system
    // This controls the cooldown between turret attacks
    // ".arg(1).object(flecs::Wildcard)" makes the system query only match with <Cooldown> components that HAVE been paired with another component
    // System monitors the attach cool downs.
    ecs.system<Cooldown>("Tick Cooldown")
    .arg(1).object(flecs::Wildcard) // <- Cooldown is actually a pair type with anything
    .iter([](flecs::iter& iter, Cooldown* cooldowns)
    {
    auto obj = iter.term_id(1).object();
    auto obj = iter.term_id(1).object(); // Gets the entity that is attached with the <Cooldown> component
    for(auto i : iter)
    {
    cooldowns[i].remainingTime -= iter.delta_system_time();
    if(cooldowns[i].remainingTime <= 0)
    if(cooldowns[i].remainingTime <= 0)
    {
    ecs_trace(TD_LOG_INFO, "%s<%s> off cooldown", iter.entity(i).str().c_str(), obj.str().c_str());
    iter.entity(i).remove<Cooldown>(obj);

    // Removes the component (in this code <Attack>) from the <Cooldown> component
    // Leaves the <Cooldown> attached to the entity
    iter.entity(i).remove<Cooldown>(obj);
    }
    }
    });


    // Flecs observer that is triggered when an object has an <Health> component set
    // This triggers when the <Health> component is modified: "it.entity(i).modified<Health>()" in the "Apply Damage" observer
    // Observer destorys an entity when it's health reaches 0
    ecs.observer<Health>()
    .event(flecs::OnSet)
    .each([](flecs::entity e, Health& hp)
    @@ -128,17 +160,26 @@ int main()
    e.destruct();
    }
    });

    // Flecs system prints the positions of entities with a <Position> component
    ecs.system<Position>()
    .each([](flecs::entity e, Position& p)
    {
    ecs_trace(TD_LOG_INFO, "%s located at [%f, %f]", e.str().c_str(), p.x, p.y);
    });

    // Flecs observer that is triggered when an object has <Health> component set AND <Damage> component set
    // **TODO** Confirm behaviour below??
    // e.set<Health>({10}); // observer doesn't trigger
    // e.set<Damage>({10}); // observer does trigger
    // == new tick
    // e.set<Damage>({10}); // Does observer trigger here or need both <Health> && <Damage> set to retrigger??
    // Applys damage to an entity. Takes damage amount away from health.
    ecs.observer<Health, Damage>("Apply Damage")
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Health* healths, Damage* damages)
    {
    if(it.event_id() != it.world().component<Damage>())
    if(it.event_id() != it.world().component<Damage>()) // Only preceed if this event was triggered by a set<Damage>({}) DON'T do anything if set<Health>({});
    {
    return;
    }
    @@ -147,18 +188,19 @@ int main()
    auto e = it.entity(i);
    auto maxHealth = e.get<MaxHealth>();
    healths[i].current -= damages[i].amount;
    it.entity(i).modified<Health>();
    it.entity(i).modified<Health>(); // Alert flecs that <Health> component is modified. Triggers observer: "ecs.observer<Health>()" above

    ecs_trace(TD_LOG_INFO, "Damaged %s for %f %f/%f", e.str().c_str(), damages[i].amount, healths[i].current, maxHealth->value);
    }
    });

    // Flecs observer that is triggered when an object has <Position> component set AND <KnockBack> component set
    ecs.observer<Position, KnockBack>("Apply Knock Back")
    .arg(1)
    .arg(1) // **TODO** WHAT DOES THIS DO ??
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Position* positions, KnockBack* knockBacks)
    {
    if(it.event_id() != it.world().component<KnockBack>())
    if(it.event_id() != it.world().component<KnockBack>()) // Only preceed if this event was triggered by a set<KnockBack>({}) DON'T do anything if set<Position>({});
    {
    return;
    }
    @@ -167,118 +209,165 @@ int main()
    ecs_trace(TD_LOG_INFO, "Knocking %s for [%f,%f]", it.entity(i).str().c_str(), knockBacks[i].x, knockBacks[i].y);
    positions[i].x += knockBacks[i].x;
    positions[i].y += knockBacks[i].y;
    it.entity(i).modified<Position>();
    it.entity(i).modified<Position>(); // Alert flecs that <Position> component is modified. **TODO** Why is this necessary?
    }
    });

    // Flecs system sends attacks from turrets
    // The system query collects entites that have the <Attack> and <Target> components AND <Cooldown> component WITHOUT an attached <Attack> component
    // A turret can only attack if their attack is off cooldown. This is expressed by <Cooldown> component NOT having an attached <Attack> component
    ecs.system<Attack, Target>("Send Attack")
    .term<Cooldown>().object<Attack>().oper(flecs::Not)
    .each([](flecs::entity e, Attack& attack, Target& target)
    {
    if(!target.entity.is_alive())
    {
    ecs_trace(TD_LOG_INFO, "%s target is dead", e.str().c_str());
    e.remove<Target>();
    e.remove<Target>(); // Removes <Target> component so turret is free to aquire new target
    return;
    }

    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();

    // **TODO**
    // Iterates through all the <PayloadType> components set in teh <Attack>.payload data ?????
    // payload is either <Damage> or <KnockBack>
    // ".set<PayloadType, Damage>({5})" is added to <Attack> component when entity is created
    attack.payload.each([&](flecs::id TypeID)
    {
    // Checks if a component has a relationship with <PayloadType> component
    // In this code, will get a <Damage> or <KnockBack> component
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());

    // Send an attack to the turret's target
    // target.entity is a reference to an entity in the <Target> component. It is the target creep of the turret
    // target.entity is type entity_view which is read only.
    // target.entity.mut(e) gets a pointer to entity which the turret is targeting stored in <Target>.entity so it can be modified.
    // **TODO** I don't understand the e variable in "mut(e)". Isn't e going to be a turret entity?
    // **TODO** Can't find "set_ptr" in manual??
    // "set_ptr(payloadType, attack.payload.get(TypeID));" sets a component of type "payloadType" (<Damage> or <Knockback>) in the target's entity (a creep)
    // **TODO** what is "attack.payload.get(TypeID)" doing? Aren't payloadType and attack.payload.get(TypeID) the same?
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    }
    });
    ecs_log_pop();

    // Set a cooldown on the turret attack
    e.set<Cooldown, Attack>({attack.cooldown});
    });

    // Creates 2 tags, one for each Team
    auto TeamOne = ecs.entity("PlayerTeam");
    auto TeamTwo = ecs.entity("Creeps");

    // Query builder that gets a collection of entities that contain <Position> component, <Health> component and <TeamTwo> tag
    // set(flecs::Self | flecs::SuperSet) matches <TeamTwo> in the base component of a prefab **TODO** confirm this is true
    auto FindAllCreeps = ecs.query_builder<>()
    .term<Position>()
    .term<Health>()
    .term(TeamTwo).set(flecs::Self | flecs::SuperSet)
    .build();

    // Flecs system finds a target for a turret
    // The system query collects entites that have the <Attack> BUT NOT <Target> components AND <TeamOne> tag. Will get a list of turrets without a target.
    // A turret can only attack if their attack is off cooldown. This is expressed by <Cooldown> component NOT having an attached <Attack> component
    // **TODO** confirm phrasing below
    // ".each([FindAllCreeps](flecs::entity e)" passes the <FindAllCreeps> query into the system.
    ecs.system("Find New Targets")
    .term<Attack>()
    .term<Target>().oper(flecs::Not)
    .term(TeamOne)
    .each([FindAllCreeps](flecs::entity e)
    {
    // Iterates all the entities found by the <FindAllCreeps> query
    std::vector<flecs::entity> FoundCreeps;
    FindAllCreeps.each([&](flecs::entity Creep)
    {
    FoundCreeps.emplace_back(Creep);
    FoundCreeps.emplace_back(Creep); // Adds every entity found (creeps) to a vector
    });

    // Exit game if no creeps found
    if(FoundCreeps.size() == 0)
    {
    ecs_trace(TD_LOG_INFO, "%s found no more creeps", e.str().c_str());
    e.world().quit();
    e.world().quit(); // Allows ecs.should_quit() to equal true
    }else
    {
    // Get a random creep of type flecs::entity
    auto Picked = FoundCreeps[rand() % FoundCreeps.size()];

    ecs_trace(TD_LOG_INFO, "%s now targeting %s", e.str().c_str(), Picked.str().c_str());

    // Sets turrets target
    e.set<Target>({Picked});
    }
    });

    // Defines BaseCreep as prefab
    auto BaseCreep = ecs.prefab("BaseCreep")
    .add(TeamTwo)
    .set_override<Position>({0, 0});


    // Defines WeakCreep as prefab based on BaseCreep
    auto WeakCreep = ecs.prefab("WeakCreep")
    .is_a(BaseCreep)
    .set<MaxHealth>({3});
    // Defines StrongCreep as prefab based on BaseCreep
    auto StrongCreep = ecs.prefab("StrongCreep")
    .is_a(BaseCreep)
    .set<MaxHealth>({20});

    // Defines BaseTurret as prefab
    auto BaseTurret = ecs.prefab("TurretBase")
    .add(TeamOne);

    // Defines FastDamageTurret as prefab based on BaseTurret.
    // Attacks with "Damage" payloads
    auto FastDamageTurret = ecs.prefab("FastDamageTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, Damage>({1}),
    1});
    // Defines MedTeleportTurret as prefab based on BaseTurret
    // Attacks with "KnockBack" payloads
    auto MedTeleportTurret = ecs.prefab("MedTeleportTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, KnockBack>({1, 0}),
    2});
    // Defines SlowSuperTurret as prefab based on BaseTurret
    // Attacks with "KnockBack" and "Damage" payloads
    auto SlowSuperTurret = ecs.prefab("SlowSuperTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, KnockBack>({0, 1})
    .set<PayloadType, Damage>({5}),
    3});

    // Creates 3 creeps from prefabs as children of entity "Creep"
    // This is done so the log is tidier.
    ecs.entity("Creep").scope([&]{
    ecs.entity().is_a(WeakCreep);
    ecs.entity().is_a(StrongCreep);
    ecs.entity().is_a(StrongCreep);
    });

    // Creates 4 turrets from prefabs as children of entity "Turret"
    // This is done so the log is tidier.
    ecs.entity("Turret").scope([&]{
    ecs.entity().is_a(FastDamageTurret);
    ecs.entity().is_a(FastDamageTurret);
    ecs.entity().is_a(MedTeleportTurret);
    ecs.entity().is_a(SlowSuperTurret);
    });
    ecs_trace(TD_LOG_INFO, "Begin");
    // Run flecs world at 1 FPS
    ecs.set_target_fps(1);
    while(!ecs.should_quit())
    {
    ecs.progress();
    ecs.progress(); // Update all the flecs systems
    }
    ecs_trace(TD_LOG_INFO, "Done");
    }
  7. Lexxicon revised this gist Sep 20, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ int main()
    .event(flecs::OnAdd)
    .each([](flecs::entity e)
    {
    ecs_trace(TD_LOG_INFO, "New Instance: %s [%s]", e.str().c_str(), e.type().str());
    ecs_trace(TD_LOG_INFO, "New Instance: %s [%s]", e.str().c_str(), e.type().str().c_str());
    });

    ecs.observer<MaxHealth>("Init Health")
  8. Lexxicon revised this gist Sep 20, 2021. 1 changed file with 282 additions and 282 deletions.
    564 changes: 282 additions & 282 deletions Output.log
    Original file line number Diff line number Diff line change
    @@ -1,283 +1,283 @@
    info: FlecsScratch.cpp:76: New Instance: Creep.436 [(ChildOf,Creep),(IsA,WeakCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.436 to 3.000000
    info: FlecsScratch.cpp:76: New Instance: Creep.437 [(ChildOf,Creep),(IsA,StrongCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.437 to 20.000000
    info: FlecsScratch.cpp:76: New Instance: Creep.438 [(ChildOf,Creep),(IsA,StrongCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.438 to 20.000000
    info: FlecsScratch.cpp:76: New Instance: Turret.440 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.441 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.442 [(ChildOf,Turret),(IsA,MedTeleportTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.443 [(ChildOf,Turret),(IsA,SlowSuperTurret)]
    info: FlecsScratch.cpp:260: Begin
    info: FlecsScratch.cpp:61:
    info: scratch.cpp:93: New Instance: Creep.436 [Position,(ChildOf,Creep),(IsA,WeakCreep)]
    info: scratch.cpp:101: Init health for Creep.436 to 3.000000
    info: scratch.cpp:93: New Instance: Creep.437 [Position,(ChildOf,Creep),(IsA,StrongCreep)]
    info: scratch.cpp:101: Init health for Creep.437 to 20.000000
    info: scratch.cpp:93: New Instance: Creep.438 [Position,(ChildOf,Creep),(IsA,StrongCreep)]
    info: scratch.cpp:101: Init health for Creep.438 to 20.000000
    info: scratch.cpp:93: New Instance: Turret.440 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: scratch.cpp:93: New Instance: Turret.441 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: scratch.cpp:93: New Instance: Turret.442 [(ChildOf,Turret),(IsA,MedTeleportTurret)]
    info: scratch.cpp:93: New Instance: Turret.443 [(ChildOf,Turret),(IsA,SlowSuperTurret)]
    info: scratch.cpp:277: Begin
    info: scratch.cpp:78:
    --- Tick[0] time[1.000000] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:211: Turret.440 now targeting Creep.438
    info: | FlecsScratch.cpp:211: Turret.441 now targeting Creep.438
    info: | FlecsScratch.cpp:211: Turret.442 now targeting Creep.437
    info: | FlecsScratch.cpp:211: Turret.443 now targeting Creep.437
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[1] time[2.037979] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 19.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 18.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 15.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[2] time[3.066594] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[3] time[4.124190] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 17.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 16.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[4] time[5.166672] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[5] time[6.178201] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 15.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 14.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 10.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[6] time[7.230884] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 2.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[7] time[8.258401] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 13.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 12.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[8] time[9.300746] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 2.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[9] time[10.343427] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 5.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 11.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 10.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[10] time[11.354971] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[11] time[12.397756] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 9.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 8.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[12] time[13.428698] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[13] time[14.468005] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 0.000000/20.000000
    info: FlecsScratch.cpp:110: Killing Creep.437
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 7.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 6.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[14] time[15.497147] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[15] time[16.554512] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 5.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 4.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[16] time[17.575466] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:163: Turret.442 target is dead
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[17] time[18.616386] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:163: Turret.443 target is dead
    info: | FlecsScratch.cpp:211: Turret.442 now targeting Creep.438
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 3.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 2.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[18] time[19.659281] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.438
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:211: Turret.443 now targeting Creep.436
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.438 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[19] time[20.699814] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [5.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [5.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.436
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 1.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 0.000000/20.000000
    info: FlecsScratch.cpp:110: Killing Creep.438
    info: FlecsScratch.cpp:135: Damaged Creep.436 for 5.000000 -2.000000/3.000000
    info: FlecsScratch.cpp:110: Killing Creep.436
    info: FlecsScratch.cpp:61:
    --- Tick[20] time[21.742548] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[21] time[22.786036] ---
    info: | FlecsScratch.cpp:163: Turret.442 target is dead
    info: | FlecsScratch.cpp:163: Turret.440 target is dead
    info: | FlecsScratch.cpp:163: Turret.441 target is dead
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[22] time[23.826353] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:205: Turret.442 found no more creeps
    info: | FlecsScratch.cpp:205: Turret.440 found no more creeps
    info: | FlecsScratch.cpp:205: Turret.441 found no more creeps
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:266: Done
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:228: Turret.440 now targeting Creep.438
    info: | scratch.cpp:228: Turret.441 now targeting Creep.438
    info: | scratch.cpp:228: Turret.442 now targeting Creep.437
    info: | scratch.cpp:228: Turret.443 now targeting Creep.437
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[1] time[2.031005] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.437
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:185: Sending payload from Turret.443 to Creep.437
    info: | | scratch.cpp:192: Damage
    info: | | scratch.cpp:192: KnockBack
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 19.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 18.000000/20.000000
    info: scratch.cpp:167: Knocking Creep.437 for [1.000000,0.000000]
    info: scratch.cpp:152: Damaged Creep.437 for 5.000000 15.000000/20.000000
    info: scratch.cpp:167: Knocking Creep.437 for [0.000000,1.000000]
    info: scratch.cpp:78:
    --- Tick[2] time[3.056674] ---
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [1.000000, 1.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[3] time[4.113907] ---
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [1.000000, 1.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 17.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 16.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[4] time[5.158010] ---
    info: | scratch.cpp:115: Turret.443<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [1.000000, 1.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.437
    info: | | scratch.cpp:192: KnockBack
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:167: Knocking Creep.437 for [1.000000,0.000000]
    info: scratch.cpp:78:
    --- Tick[5] time[6.169840] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [2.000000, 1.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.443 to Creep.437
    info: | | scratch.cpp:192: Damage
    info: | | scratch.cpp:192: KnockBack
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 15.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 14.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.437 for 5.000000 10.000000/20.000000
    info: scratch.cpp:167: Knocking Creep.437 for [0.000000,1.000000]
    info: scratch.cpp:78:
    --- Tick[6] time[7.211511] ---
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [2.000000, 2.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[7] time[8.267222] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [2.000000, 2.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.437
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:167: Knocking Creep.437 for [1.000000,0.000000]
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 13.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 12.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[8] time[9.311009] ---
    info: | scratch.cpp:115: Turret.443<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [3.000000, 2.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[9] time[10.356709] ---
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [3.000000, 2.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.443 to Creep.437
    info: | | scratch.cpp:192: Damage
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.437 for 5.000000 5.000000/20.000000
    info: scratch.cpp:167: Knocking Creep.437 for [0.000000,1.000000]
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 11.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 10.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[10] time[11.399392] ---
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [3.000000, 3.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.437
    info: | | scratch.cpp:192: KnockBack
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:167: Knocking Creep.437 for [1.000000,0.000000]
    info: scratch.cpp:78:
    --- Tick[11] time[12.414394] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [4.000000, 3.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 9.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 8.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[12] time[13.442084] ---
    info: | scratch.cpp:115: Turret.443<Attack> off cooldown
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [4.000000, 3.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[13] time[14.486403] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.437 located at [4.000000, 3.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.443 to Creep.437
    info: | | scratch.cpp:192: Damage
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.437
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.437 for 5.000000 0.000000/20.000000
    info: scratch.cpp:127: Killing Creep.437
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 7.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 6.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[14] time[15.516481] ---
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[15] time[16.546555] ---
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 5.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 4.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[16] time[17.591400] ---
    info: | scratch.cpp:115: Turret.443<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:180: Turret.442 target is dead
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[17] time[18.648335] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:180: Turret.443 target is dead
    info: | scratch.cpp:228: Turret.442 now targeting Creep.438
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 3.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 2.000000/20.000000
    info: scratch.cpp:78:
    --- Tick[18] time[19.663305] ---
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [0.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.442 to Creep.438
    info: | | scratch.cpp:192: KnockBack
    info: | scratch.cpp:228: Turret.443 now targeting Creep.436
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:167: Knocking Creep.438 for [1.000000,0.000000]
    info: scratch.cpp:78:
    --- Tick[19] time[20.704914] ---
    info: | scratch.cpp:134: Creep.436 located at [0.000000, 0.000000]
    info: | scratch.cpp:134: Creep.438 located at [1.000000, 0.000000]
    info: | scratch.cpp:185: Sending payload from Turret.440 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.441 to Creep.438
    info: | | scratch.cpp:192: Damage
    info: | scratch.cpp:185: Sending payload from Turret.443 to Creep.436
    info: | | scratch.cpp:192: Damage
    info: | | scratch.cpp:192: KnockBack
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 1.000000/20.000000
    info: scratch.cpp:152: Damaged Creep.438 for 1.000000 0.000000/20.000000
    info: scratch.cpp:127: Killing Creep.438
    info: scratch.cpp:152: Damaged Creep.436 for 5.000000 -2.000000/3.000000
    info: scratch.cpp:127: Killing Creep.436
    info: scratch.cpp:78:
    --- Tick[20] time[21.735649] ---
    info: | scratch.cpp:115: Turret.442<Attack> off cooldown
    info: | scratch.cpp:115: Turret.440<Attack> off cooldown
    info: | scratch.cpp:115: Turret.441<Attack> off cooldown
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[21] time[22.751541] ---
    info: | scratch.cpp:180: Turret.442 target is dead
    info: | scratch.cpp:180: Turret.440 target is dead
    info: | scratch.cpp:180: Turret.441 target is dead
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:78:
    --- Tick[22] time[23.796064] ---
    info: | scratch.cpp:115: Turret.443<Attack> off cooldown
    info: | scratch.cpp:222: Turret.442 found no more creeps
    info: | scratch.cpp:222: Turret.440 found no more creeps
    info: | scratch.cpp:222: Turret.441 found no more creeps
    info: scratch.cpp:86: --- End Tick ---
    info: scratch.cpp:283: Done
  9. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -154,7 +154,7 @@ int main()
    });

    ecs.observer<Position, KnockBack>("Apply Knock Back")
    .arg(1).set(flecs::Self | flecs::SuperSet)
    .arg(1)
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Position* positions, KnockBack* knockBacks)
    {
    @@ -201,7 +201,7 @@ int main()
    auto TeamTwo = ecs.entity("Creeps");

    auto FindAllCreeps = ecs.query_builder<>()
    .term<Position>().set(flecs::Self | flecs::SuperSet)
    .term<Position>()
    .term<Health>()
    .term(TeamTwo).set(flecs::Self | flecs::SuperSet)
    .build();
    @@ -232,7 +232,7 @@ int main()

    auto BaseCreep = ecs.prefab("BaseCreep")
    .add(TeamTwo)
    .set<Position>({0, 0});
    .set_override<Position>({0, 0});


    auto WeakCreep = ecs.prefab("WeakCreep")
  10. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -184,15 +184,15 @@ int main()

    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();
    attack.payload.each([&](flecs::id TypeID)
    {
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    }
    });
    attack.payload.each([&](flecs::id TypeID)
    {
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    }
    });
    ecs_log_pop();
    e.set<Cooldown, Attack>({attack.cooldown});
    });
  11. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 23 additions and 27 deletions.
    50 changes: 23 additions & 27 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,20 @@
    /**
    Copyright <2021> <Lexxicon Studios LLC.>
    Permission is hereby granted, free of charge, to any person obtaining a copy of this
    software and associated documentation files (the "Software"), to deal in the Software
    without restriction, including without limitation the rights to use, copy, modify,
    merge, publish, distribute, sublicense, and/or sell copies of the Software,
    and to permit persons to whom the Software is furnished to do so, subject to the
    following conditions:
    The above copyright notice and this permission notice shall be included in all copies
    or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    Permission is hereby granted, free of charge, to any person obtaining a copy of this
    software and associated documentation files (the "Software"), to deal in the Software
    without restriction, including without limitation the rights to use, copy, modify,
    merge, publish, distribute, sublicense, and/or sell copies of the Software,
    and to permit persons to whom the Software is furnished to do so, subject to the
    following conditions:
    The above copyright notice and this permission notice shall be included in all copies
    or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    **/

    #include <vector>

    #include "flecs.h"
    @@ -188,15 +184,15 @@ int main()

    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();
    attack.payload.each([&](flecs::id TypeID)
    {
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID.relation(), TypeID.object()));
    }
    });
    attack.payload.each([&](flecs::id TypeID)
    {
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID));
    }
    });
    ecs_log_pop();
    e.set<Cooldown, Attack>({attack.cooldown});
    });
  12. Lexxicon revised this gist Sep 18, 2021. No changes.
  13. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,8 @@ Copyright <2021> <Lexxicon Studios LLC.>
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    **/
    #include <vector>

    #include <vector>

    #include "flecs.h"

  14. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 16 additions and 4 deletions.
    20 changes: 16 additions & 4 deletions ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,23 @@
    /**
    Copyright <2021> <Lexxicon Studios LLC.>
    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
    Permission is hereby granted, free of charge, to any person obtaining a copy of this
    software and associated documentation files (the "Software"), to deal in the Software
    without restriction, including without limitation the rights to use, copy, modify,
    merge, publish, distribute, sublicense, and/or sell copies of the Software,
    and to permit persons to whom the Software is furnished to do so, subject to the
    following conditions:
    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
    The above copyright notice and this permission notice shall be included in all copies
    or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
    PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    **/
    #include <vector>

    #include "flecs.h"
  15. Lexxicon revised this gist Sep 18, 2021. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion ExmpleSource.cpp
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,12 @@
    #include <vector>
    Copyright <2021> <Lexxicon Studios LLC.>

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    #include <vector>

    #include "flecs.h"

  16. Lexxicon renamed this gist Sep 18, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  17. Lexxicon created this gist Sep 18, 2021.
    283 changes: 283 additions & 0 deletions Output.log
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,283 @@
    info: FlecsScratch.cpp:76: New Instance: Creep.436 [(ChildOf,Creep),(IsA,WeakCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.436 to 3.000000
    info: FlecsScratch.cpp:76: New Instance: Creep.437 [(ChildOf,Creep),(IsA,StrongCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.437 to 20.000000
    info: FlecsScratch.cpp:76: New Instance: Creep.438 [(ChildOf,Creep),(IsA,StrongCreep)]
    info: FlecsScratch.cpp:84: Init health for Creep.438 to 20.000000
    info: FlecsScratch.cpp:76: New Instance: Turret.440 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.441 [(ChildOf,Turret),(IsA,FastDamageTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.442 [(ChildOf,Turret),(IsA,MedTeleportTurret)]
    info: FlecsScratch.cpp:76: New Instance: Turret.443 [(ChildOf,Turret),(IsA,SlowSuperTurret)]
    info: FlecsScratch.cpp:260: Begin
    info: FlecsScratch.cpp:61:
    --- Tick[0] time[1.000000] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:211: Turret.440 now targeting Creep.438
    info: | FlecsScratch.cpp:211: Turret.441 now targeting Creep.438
    info: | FlecsScratch.cpp:211: Turret.442 now targeting Creep.437
    info: | FlecsScratch.cpp:211: Turret.443 now targeting Creep.437
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[1] time[2.037979] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [0.000000, 0.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 19.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 18.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 15.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[2] time[3.066594] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[3] time[4.124190] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 17.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 16.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[4] time[5.166672] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [1.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[5] time[6.178201] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 1.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 15.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 14.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 10.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[6] time[7.230884] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 2.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[7] time[8.258401] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [2.000000, 2.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 13.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 12.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[8] time[9.300746] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 2.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[9] time[10.343427] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 2.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 5.000000/20.000000
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [0.000000,1.000000]
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 11.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 10.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[10] time[11.354971] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [3.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.437 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[11] time[12.397756] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 9.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 8.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[12] time[13.428698] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[13] time[14.468005] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.437 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.437
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.437
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.437 for 5.000000 0.000000/20.000000
    info: FlecsScratch.cpp:110: Killing Creep.437
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 7.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 6.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[14] time[15.497147] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[15] time[16.554512] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 5.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 4.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[16] time[17.575466] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:163: Turret.442 target is dead
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[17] time[18.616386] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:163: Turret.443 target is dead
    info: | FlecsScratch.cpp:211: Turret.442 now targeting Creep.438
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 3.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 2.000000/20.000000
    info: FlecsScratch.cpp:61:
    --- Tick[18] time[19.659281] ---
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: | FlecsScratch.cpp:117: Creep.436 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [4.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.442 to Creep.438
    info: | | FlecsScratch.cpp:175: KnockBack
    info: | FlecsScratch.cpp:211: Turret.443 now targeting Creep.436
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:150: Knocking Creep.438 for [1.000000,0.000000]
    info: FlecsScratch.cpp:61:
    --- Tick[19] time[20.699814] ---
    info: | FlecsScratch.cpp:117: Creep.436 located at [5.000000, 3.000000]
    info: | FlecsScratch.cpp:117: Creep.438 located at [5.000000, 3.000000]
    info: | FlecsScratch.cpp:168: Sending payload from Turret.440 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.441 to Creep.438
    info: | | FlecsScratch.cpp:175: Damage
    info: | FlecsScratch.cpp:168: Sending payload from Turret.443 to Creep.436
    info: | | FlecsScratch.cpp:175: Damage
    info: | | FlecsScratch.cpp:175: KnockBack
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 1.000000/20.000000
    info: FlecsScratch.cpp:135: Damaged Creep.438 for 1.000000 0.000000/20.000000
    info: FlecsScratch.cpp:110: Killing Creep.438
    info: FlecsScratch.cpp:135: Damaged Creep.436 for 5.000000 -2.000000/3.000000
    info: FlecsScratch.cpp:110: Killing Creep.436
    info: FlecsScratch.cpp:61:
    --- Tick[20] time[21.742548] ---
    info: | FlecsScratch.cpp:98: Turret.442<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.440<Attack> off cooldown
    info: | FlecsScratch.cpp:98: Turret.441<Attack> off cooldown
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[21] time[22.786036] ---
    info: | FlecsScratch.cpp:163: Turret.442 target is dead
    info: | FlecsScratch.cpp:163: Turret.440 target is dead
    info: | FlecsScratch.cpp:163: Turret.441 target is dead
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:61:
    --- Tick[22] time[23.826353] ---
    info: | FlecsScratch.cpp:98: Turret.443<Attack> off cooldown
    info: | FlecsScratch.cpp:205: Turret.442 found no more creeps
    info: | FlecsScratch.cpp:205: Turret.440 found no more creeps
    info: | FlecsScratch.cpp:205: Turret.441 found no more creeps
    info: FlecsScratch.cpp:69: --- End Tick ---
    info: FlecsScratch.cpp:266: Done
    267 changes: 267 additions & 0 deletions Source.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,267 @@
    #include <vector>

    #include "flecs.h"

    const int TD_LOG_INFO = 0;

    struct Position
    {
    float x;
    float y;
    };

    struct Health
    {
    float current;
    };
    struct MaxHealth
    {
    float value;
    };
    struct Cooldown
    {
    float remainingTime;
    };

    struct Attack
    {
    flecs::entity_view payload;
    float cooldown;
    };

    struct PayloadType{};

    struct Damage
    {
    float amount;
    };
    struct KnockBack
    {
    float x;
    float y;
    };

    struct Target
    {
    flecs::entity_view entity;
    };

    struct Team{};


    int main()
    {
    flecs::world ecs;
    ecs_tracing_color_enable(false);

    ecs.system("Tick Printer")
    .kind(flecs::PreFrame)
    .iter([](flecs::iter& iter)
    {
    ecs_trace(TD_LOG_INFO, "\n--- Tick[%d] time[%f] ---", iter.world().get_tick(), iter.world_time());
    ecs_log_push();
    });
    ecs.system("Post Tick")
    .kind(flecs::PostFrame)
    .iter([](flecs::iter& iter)
    {
    ecs_log_pop();
    ecs_trace(TD_LOG_INFO, "--- End Tick ---");
    });
    ecs.observer<>()
    .term(flecs::IsA).object(flecs::Wildcard)
    .event(flecs::OnAdd)
    .each([](flecs::entity e)
    {
    ecs_trace(TD_LOG_INFO, "New Instance: %s [%s]", e.str().c_str(), e.type().str());
    });

    ecs.observer<MaxHealth>("Init Health")
    .term<Health>().oper(flecs::Not)
    .event(flecs::OnSet)
    .each([](flecs::entity e, MaxHealth& maxHealth)
    {
    ecs_trace(TD_LOG_INFO, "Init health for %s to %f", e.str().c_str(), maxHealth.value);
    e.set<Health>({maxHealth.value});
    });

    ecs.system<Cooldown>("Tick Cooldown")
    .arg(1).object(flecs::Wildcard) // <- Cooldown is actually a pair type with anything
    .iter([](flecs::iter& iter, Cooldown* cooldowns)
    {
    auto obj = iter.term_id(1).object();
    for(auto i : iter)
    {
    cooldowns[i].remainingTime -= iter.delta_system_time();
    if(cooldowns[i].remainingTime <= 0)
    {
    ecs_trace(TD_LOG_INFO, "%s<%s> off cooldown", iter.entity(i).str().c_str(), obj.str().c_str());
    iter.entity(i).remove<Cooldown>(obj);
    }
    }
    });

    ecs.observer<Health>()
    .event(flecs::OnSet)
    .each([](flecs::entity e, Health& hp)
    {
    if(hp.current <= 0)
    {
    ecs_trace(TD_LOG_INFO, "Killing %s", e.str().c_str());
    e.destruct();
    }
    });
    ecs.system<Position>()
    .each([](flecs::entity e, Position& p)
    {
    ecs_trace(TD_LOG_INFO, "%s located at [%f, %f]", e.str().c_str(), p.x, p.y);
    });

    ecs.observer<Health, Damage>("Apply Damage")
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Health* healths, Damage* damages)
    {
    if(it.event_id() != it.world().component<Damage>())
    {
    return;
    }
    for(auto i : it)
    {
    auto e = it.entity(i);
    auto maxHealth = e.get<MaxHealth>();
    healths[i].current -= damages[i].amount;
    it.entity(i).modified<Health>();

    ecs_trace(TD_LOG_INFO, "Damaged %s for %f %f/%f", e.str().c_str(), damages[i].amount, healths[i].current, maxHealth->value);
    }
    });

    ecs.observer<Position, KnockBack>("Apply Knock Back")
    .arg(1).set(flecs::Self | flecs::SuperSet)
    .event(flecs::OnSet)
    .iter([](flecs::iter it, Position* positions, KnockBack* knockBacks)
    {
    if(it.event_id() != it.world().component<KnockBack>())
    {
    return;
    }
    for(auto i : it)
    {
    ecs_trace(TD_LOG_INFO, "Knocking %s for [%f,%f]", it.entity(i).str().c_str(), knockBacks[i].x, knockBacks[i].y);
    positions[i].x += knockBacks[i].x;
    positions[i].y += knockBacks[i].y;
    it.entity(i).modified<Position>();
    }
    });

    ecs.system<Attack, Target>("Send Attack")
    .term<Cooldown>().object<Attack>().oper(flecs::Not)
    .each([](flecs::entity e, Attack& attack, Target& target)
    {
    if(!target.entity.is_alive())
    {
    ecs_trace(TD_LOG_INFO, "%s target is dead", e.str().c_str());
    e.remove<Target>();
    return;
    }

    ecs_trace(TD_LOG_INFO, "Sending payload from %s to %s", e.str().c_str(), target.entity.str().c_str());
    ecs_log_push();
    attack.payload.each([&](flecs::id TypeID)
    {
    if(TypeID.has_relation(TypeID.world().component<PayloadType>()))
    {
    auto payloadType = TypeID.object();
    ecs_trace(TD_LOG_INFO, "%s", payloadType.str().c_str());
    target.entity.mut(e).set_ptr(payloadType, attack.payload.get(TypeID.relation(), TypeID.object()));
    }
    });
    ecs_log_pop();
    e.set<Cooldown, Attack>({attack.cooldown});
    });

    auto TeamOne = ecs.entity("PlayerTeam");
    auto TeamTwo = ecs.entity("Creeps");

    auto FindAllCreeps = ecs.query_builder<>()
    .term<Position>().set(flecs::Self | flecs::SuperSet)
    .term<Health>()
    .term(TeamTwo).set(flecs::Self | flecs::SuperSet)
    .build();

    ecs.system("Find New Targets")
    .term<Attack>()
    .term<Target>().oper(flecs::Not)
    .term(TeamOne)
    .each([FindAllCreeps](flecs::entity e)
    {
    std::vector<flecs::entity> FoundCreeps;
    FindAllCreeps.each([&](flecs::entity Creep)
    {
    FoundCreeps.emplace_back(Creep);
    });
    if(FoundCreeps.size() == 0)
    {
    ecs_trace(TD_LOG_INFO, "%s found no more creeps", e.str().c_str());
    e.world().quit();
    }else
    {
    auto Picked = FoundCreeps[rand() % FoundCreeps.size()];

    ecs_trace(TD_LOG_INFO, "%s now targeting %s", e.str().c_str(), Picked.str().c_str());
    e.set<Target>({Picked});
    }
    });

    auto BaseCreep = ecs.prefab("BaseCreep")
    .add(TeamTwo)
    .set<Position>({0, 0});


    auto WeakCreep = ecs.prefab("WeakCreep")
    .is_a(BaseCreep)
    .set<MaxHealth>({3});
    auto StrongCreep = ecs.prefab("StrongCreep")
    .is_a(BaseCreep)
    .set<MaxHealth>({20});

    auto BaseTurret = ecs.prefab("TurretBase")
    .add(TeamOne);

    auto FastDamageTurret = ecs.prefab("FastDamageTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, Damage>({1}),
    1});
    auto MedTeleportTurret = ecs.prefab("MedTeleportTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, KnockBack>({1, 0}),
    2});
    auto SlowSuperTurret = ecs.prefab("SlowSuperTurret")
    .is_a(BaseTurret)
    .set<Attack>({
    ecs.entity().set<PayloadType, KnockBack>({0, 1})
    .set<PayloadType, Damage>({5}),
    3});

    ecs.entity("Creep").scope([&]{
    ecs.entity().is_a(WeakCreep);
    ecs.entity().is_a(StrongCreep);
    ecs.entity().is_a(StrongCreep);
    });

    ecs.entity("Turret").scope([&]{
    ecs.entity().is_a(FastDamageTurret);
    ecs.entity().is_a(FastDamageTurret);
    ecs.entity().is_a(MedTeleportTurret);
    ecs.entity().is_a(SlowSuperTurret);
    });
    ecs_trace(TD_LOG_INFO, "Begin");
    ecs.set_target_fps(1);
    while(!ecs.should_quit())
    {
    ecs.progress();
    }
    ecs_trace(TD_LOG_INFO, "Done");
    }