//You must have an Update. //Always read in deltaTime, and only deltaTime (it's the time that's passed since the last frame) //Use deltaTime for things like changing velocity or changing position from velocity //This is where you do anything that you want to happen every frame. //There is a chance that your system won't need to do anything in update. Still have it. public override void Update(float deltaTime) { foreach (Entity e in getApplicableEntities()) { SmushComponent smushComp = ( SmushComponent )e.getComponent(GlobalVars.SMUSH_COMPONENT_NAME); if (!smushComp.getInitializedTimer()) { initializeTimer(e); } TimerComponent timeComp = ( TimerComponent )e.getComponent(GlobalVars.TIMER_COMPONENT_NAME); if (smushComp.isFrozen() && smushComp.isWaitingUpper()) { if (timeComp.getCompletedTimers().Contains(upperWaitTimer)) { timeComp.removeCompletedTimer(upperWaitTimer); } timeComp.addTimer(upperWaitTimer, smushComp.getUpperWaitTime()); } List <string> completedTimers = new List <string>(timeComp.getCompletedTimers()); foreach (string timer in completedTimers) { handleCompletedTimer(timer, e); timeComp.removeCompletedTimer(timer); } if (!smushComp.isWaitingUpper() && !smushComp.isWaitingLower()) { checkForDirectionChange(e); } } }
private void startUpperWait(VelocityComponent velComp, SmushComponent smushComp, TimerComponent timerComp, Entity e) { velComp.setVelocity(0, 0); if (!timerComp.hasTimer(upperWaitTimer)) { timerComp.addTimer(upperWaitTimer, smushComp.getUpperWaitTime()); } smushComp.setStateUpperWait(); }