AI operating reactors & railguns, misc AI improvements
This commit is contained in:
@@ -151,13 +151,17 @@ namespace Barotrauma
|
||||
|
||||
if (size.X < 100.0f) continue;
|
||||
|
||||
var smokeParticle = GameMain.ParticleManager.CreateParticle("smoke",
|
||||
if (Rand.Int(5) == 1)
|
||||
{
|
||||
var smokeParticle = GameMain.ParticleManager.CreateParticle("smoke",
|
||||
spawnPos, speed, 0.0f, hull);
|
||||
|
||||
if (smokeParticle != null)
|
||||
{
|
||||
smokeParticle.Size *= MathHelper.Clamp(size.X / 100.0f * Math.Max(hull.Oxygen / hull.FullVolume, 0.4f), 0.5f, 4.0f);
|
||||
if (smokeParticle != null)
|
||||
{
|
||||
smokeParticle.Size *= MathHelper.Clamp(size.X / 100.0f * Math.Max(hull.Oxygen / hull.FullVolume, 0.4f), 0.5f, 4.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DamageCharacters(deltaTime);
|
||||
@@ -166,7 +170,7 @@ namespace Barotrauma
|
||||
if (hull.Volume > 0.0f) HullWaterExtinquish(deltaTime);
|
||||
|
||||
lightSource.Range = Math.Max(size.X, size.Y) * Rand.Range(8.0f, 10.0f)/2.0f;
|
||||
lightSource.Color = new Color(1.0f, 0.9f, 0.6f) * Rand.Range(0.8f, 1.0f);
|
||||
lightSource.Color = new Color(1.0f, 0.45f, 0.3f) * Rand.Range(0.8f, 1.0f);
|
||||
|
||||
hull.Oxygen -= size.X*deltaTime*OxygenConsumption;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Barotrauma
|
||||
if (type.HasHireableCharacters)
|
||||
{
|
||||
hireManager = new HireManager();
|
||||
hireManager.GenerateCharacters(Character.HumanConfigFile, 10);
|
||||
hireManager.GenerateCharacters(this, 10);
|
||||
}
|
||||
|
||||
Connections = new List<LocationConnection>();
|
||||
|
||||
@@ -24,11 +24,9 @@ namespace Barotrauma
|
||||
|
||||
private Sprite backGround;
|
||||
|
||||
public bool HasHireableCharacters
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
//<name, commonness>
|
||||
private List<Tuple<JobPrefab, float>> hireableJobs;
|
||||
private float totalHireableWeight;
|
||||
|
||||
public string Name
|
||||
{
|
||||
@@ -40,6 +38,11 @@ namespace Barotrauma
|
||||
get { return nameFormats; }
|
||||
}
|
||||
|
||||
public bool HasHireableCharacters
|
||||
{
|
||||
get { return hireableJobs.Any(); }
|
||||
}
|
||||
|
||||
public Sprite Sprite
|
||||
{
|
||||
get { return symbolSprite; }
|
||||
@@ -57,21 +60,51 @@ namespace Barotrauma
|
||||
commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||
totalWeight += commonness;
|
||||
|
||||
HasHireableCharacters = ToolBox.GetAttributeBool(element, "hireablecharacters", false);
|
||||
|
||||
nameFormats = new List<string>();
|
||||
foreach (XAttribute nameFormat in element.Element("nameformats").Attributes())
|
||||
{
|
||||
nameFormats.Add(nameFormat.Value);
|
||||
}
|
||||
|
||||
hireableJobs = new List<Tuple<JobPrefab, float>>();
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().ToLower() != "hireable") continue;
|
||||
|
||||
string jobName = ToolBox.GetAttributeString(subElement, "name", "");
|
||||
|
||||
JobPrefab jobPrefab = JobPrefab.List.Find(jp => jp.Name.ToLower() == jobName.ToLower());
|
||||
if (jobPrefab==null)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid job name ("+jobName+") in location type "+name);
|
||||
}
|
||||
|
||||
float jobCommonness = ToolBox.GetAttributeFloat(subElement, "commonness", 1.0f);
|
||||
totalHireableWeight += jobCommonness;
|
||||
|
||||
Tuple<JobPrefab, float> hireableJob = new Tuple<JobPrefab, float>(jobPrefab, jobCommonness);
|
||||
|
||||
hireableJobs.Add(hireableJob);
|
||||
}
|
||||
|
||||
string spritePath = ToolBox.GetAttributeString(element, "symbol", "Content/Map/beaconSymbol.png");
|
||||
symbolSprite = new Sprite(spritePath, new Vector2(0.5f, 0.5f));
|
||||
|
||||
string backgroundPath = ToolBox.GetAttributeString(element, "background", "");
|
||||
backGround = new Sprite(backgroundPath, Vector2.Zero);
|
||||
//sprite.Origin = ;
|
||||
}
|
||||
|
||||
public JobPrefab GetRandomHireable()
|
||||
{
|
||||
float randFloat = Rand.Range(0.0f, totalHireableWeight);
|
||||
|
||||
foreach (Tuple<JobPrefab, float> hireable in hireableJobs)
|
||||
{
|
||||
if (randFloat < hireable.Item2) return hireable.Item1;
|
||||
randFloat -= hireable.Item2;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static LocationType Random()
|
||||
|
||||
Reference in New Issue
Block a user