package systems;

import com.badlogic.ashley.core.EntitySystem;

/**
 * Created by Thagus on 18/10/16.
 */
public class CallSystem extends EntitySystem {

}

@@ -47,111 +47,1732 @@
 ore.
-EntitySystem;%0A%0A/**%0A * Created by Thagus on 18/10/16.%0A */%0Apublic class CallSystem extends EntitySystem %7B
+*;%0Aimport com.badlogic.ashley.utils.ImmutableArray;%0Aimport components.UserCallComponent;%0A%0Aimport java.util.Random;%0A%0A/**%0A * Created by Thagus on 18/10/16.%0A */%0Apublic class CallSystem extends EntitySystem %7B%0A    private ImmutableArray%3CEntity%3E userEntities;%0A    private Random rnd;%0A    private PagingSystem pagingSystem;%0A%0A    private ComponentMapper%3CUserCallComponent%3E uccm = ComponentMapper.getFor(UserCallComponent.class);%0A%0A    public CallSystem(PagingSystem pagingSystem)%7B%0A        super();%0A        this.rnd = new Random();%0A        this.pagingSystem = pagingSystem;%0A    %7D%0A%0A    public void addedToEngine(Engine engine)%7B%0A        userEntities = engine.getEntitiesFor(Family.all(UserCallComponent.class).get());%0A    %7D%0A%0A    public void update(float delta)%7B%0A        final int numberOfUsers = userEntities.size();%0A%0A        for(Entity user : userEntities)%7B%0A            UserCallComponent userCallComponent = uccm.get(user);%0A%0A            if(userCallComponent.callCooldown%3C=0)%7B%0A                if(rnd.nextDouble()%3E0.8)%7B   //20%25 probability%0A                    //Select the receiving user%0A                    int receivingUser = rnd.nextInt(numberOfUsers);%0A%0A                    //Check if the receiving user is in the expected cell%0A                    if(pagingSystem.confirmPosition(userEntities.get(receivingUser)))%7B%0A                        //Create an actor to handle the call%0A%0A                        //Set the cooldown to a random number between 5 and 15%0A                        userCallComponent.callCooldown = rnd.nextFloat()*15 + 5;%0A                    %7D%0A                %7D%0A            %7D%0A            else %7B%0A                //Update the cooldown%0A                userCallComponent.callCooldown -= delta;%0A            %7D%0A        %7D%0A    %7D
 %0A%0A%7D%0A

Call system update basics