public static int GetStateHash() { int hash = 23; for (int i = ProjectileBucket.PeakCount - 1; i >= 0; i--) { if (ProjectileBucket.arrayAllocation[i]) { LSProjectile proj = ProjectileManager.ProjectileBucket[i]; hash ^= proj.GetStateHash(); } } return(hash); }
private static void CacheProjectile(LSProjectile projectile) { ProjectilePool[projectile.MyProjCode].Add(projectile); /*if (projectile.ID == PeakCount - 1) * { * PeakCount--; * for (int i = projectile.ID - 1; i >= 0; i--) * { * if (ProjectileActive[i] == false) * { * PeakCount--; * } * else { * break; * } * } * }*/ }
public static LSProjectile Create(string projCode, RTSAgent source, Vector3d offset, AllegianceType targetAllegiance, Func <RTSAgent, bool> agentConditional, Action <RTSAgent> hitEffect) { Vector2d relativePos = offset.ToVector2d(); Vector2d worldPos = relativePos.Rotated(source.Body.Rotation) + source.Body.Position; Vector3d pos = new Vector3d(worldPos.x, worldPos.y, offset.z + source.Body.HeightPos); AgentController sourceController = source.Controller; LSProjectile proj = Create( projCode, pos, agentConditional, (bite) => { return((sourceController.GetAllegiance(bite) & targetAllegiance) != 0); } , hitEffect); return(proj); }
public static void EndProjectile(LSProjectile projectile) { if (projectile.Deterministic) { int id = projectile.ID; if (!ProjectileBucket.SafeRemoveAt(id, projectile)) { Debug.Log("BOO! This is a terrible bug."); } } else { if (!NDProjectileBucket.SafeRemoveAt(projectile.ID, projectile)) { Debug.Log("BOO! This is a terrible bug."); } } CacheProjectile(projectile); projectile.Deactivate(); }
private static LSProjectile RawCreate(string projCode) { if (ProjectilePool.ContainsKey(projCode) == false) { Debug.Log(projCode + " fired by " + Attack.LastFire + " Caused boom"); return(null); } FastStack <LSProjectile> pool = ProjectilePool[projCode]; LSProjectile curProj = null; if (pool.Count > 0) { curProj = pool.Pop(); } else { curProj = NewProjectile(projCode); } return(curProj); }
public LSProjectile PrepareProjectile(string projectileCode, Vector3d projOffset, LSAgent target) { LastFire = this; LSProjectile currentProjectile = ProjectileManager.Create( projectileCode, this.Agent, projOffset, this.TargetAllegiance, (other) => { Health healther = other.GetAbility <Health>(); return(healther.IsNotNull() && healther.HealthAmount > 0); }, CachedOnHit); switch (currentProjectile.TargetingBehavior) { case TargetingType.Homing: currentProjectile.InitializeHoming(target); break; case TargetingType.Timed: currentProjectile.InitializeTimed(Agent.Body.Forward); break; case TargetingType.Positional: currentProjectile.InitializePositional(target.Body.Position.ToVector3d(target.Body.HeightPos)); break; case TargetingType.Directional: //TODO throw new System.Exception("Not implemented yet."); //break; } OnPrepareProjectile(currentProjectile); return(currentProjectile); }
public void FireProjectile(LSProjectile projectile) { ProjectileManager.Fire(projectile); }
protected virtual void OnPrepareProjectile(LSProjectile projectile) { }