Thermal artifact, mid-quest message popups, sortmode from immediate to deferred, saving bugfixes

This commit is contained in:
Regalis
2015-11-19 19:21:48 +02:00
parent 9b08201972
commit 35f05376b0
21 changed files with 155 additions and 56 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -4,10 +4,25 @@
name="Skyholder Artifact"
pickdistance="150">
<Sprite texture="artifact.png" depth="0.8"/>
<Sprite texture="artifact.png" depth="0.8" sourcerect="0,0,38,60"/>
<Body width="36" height="60" density="5"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
</Item>
<Item
name="Thermal Artifact"
pickdistance="150">
<Sprite texture="artifact.png" depth="0.8" sourcerect="74,0,44,61"/>
<Body radius="20" height="20" density="5"/>
<Holdable slots="BothHands" holdpos="30,-15" handle1="0,10" handle2="0,-10">
<StatusEffect type="OnActive">
<Fire/>
</StatusEffect>
</Holdable>
</Item>
</Items>

View File

@@ -11,6 +11,17 @@
itemname="Skyholder Artifact">
</SalvageQuest>
<SalvageQuest
name="Salvaging an artifact"
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
commonness="10"
reward="2000"
radarlabel="Infrasonic signal"
failuremessage="Retrieving the artifact failed"
successmessage="The artifact has been succesfully retrieved"
itemname="Thermal Artifact">
</SalvageQuest>
<MonsterQuest
name="Killing a Moloch"
description="A particularly aggressive Moloch has been terrorizing vessels traveling between [location1] and [location2]. A reward of 1000 credits has been promised to those who kill the creature."

View File

@@ -33,6 +33,8 @@ namespace Barotrauma
private Explosion explosion;
public readonly bool Fire;
private Sound sound;
public TargetType Targets
@@ -143,6 +145,9 @@ namespace Barotrauma
case "explosion":
explosion = new Explosion(subElement);
break;
case "fire":
Fire = true;
break;
case "requireditem":
case "requireditems":
RelatedItem newRequiredItem = RelatedItem.Load(subElement);
@@ -208,6 +213,7 @@ namespace Barotrauma
protected virtual void Apply(float deltaTime, Entity entity, List<IPropertyObject> targets)
{
if (explosion != null) explosion.Explode(entity.SimPosition);
if (Fire) new FireSource(ConvertUnits.ToDisplayUnits(entity.SimPosition));
if (sound != null) sound.Play(1.0f, 1000.0f, ConvertUnits.ToDisplayUnits(entity.SimPosition));

View File

@@ -73,7 +73,9 @@ namespace Barotrauma
catch (Exception e)
{
DebugConsole.ThrowError("Coroutine "+Coroutines[i]+" threw an exception: "+e.Message);
#if DEBUG
DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message);
#endif
Coroutines.RemoveAt(i);
}

View File

@@ -308,8 +308,7 @@ namespace Barotrauma
DebugConsole.ThrowError("Illegal symbols in filename (../)");
return;
}
Submarine.SaveCurrent(fileName +".sub");
NewMessage("map saved", Color.Green);
if (Submarine.SaveCurrent(fileName +".sub")) NewMessage("map saved", Color.Green);
break;
case "loadmap":
case "loadsub":

View File

@@ -10,9 +10,11 @@ namespace Barotrauma
{
class MonsterQuest : Quest
{
string monsterFile;
private string monsterFile;
Character monster;
private int state;
private Character monster;
public override Vector2 RadarPosition
{
@@ -31,6 +33,18 @@ namespace Barotrauma
monster = new AICharacter(monsterFile, ConvertUnits.ToSimUnits(position+level.Position));
}
public override void Update(float deltaTime)
{
switch (state)
{
case 0:
if (!monster.IsDead) return;
ShowMessage(state);
state = 1;
break;
}
}
public override void End()
{

View File

@@ -25,6 +25,9 @@ namespace Barotrauma
protected string radarLabel;
protected List<string> headers;
protected List<string> messages;
private int reward;
public string Name
@@ -69,6 +72,15 @@ namespace Barotrauma
failureMessage = ToolBox.GetAttributeString(element, "failuremessage", "");
radarLabel = ToolBox.GetAttributeString(element, "radarlabel", "");
messages = new List<string>();
headers = new List<string>();
foreach (XElement subElement in element.Elements())
{
if (subElement.Name.ToString().ToLower() != "message") continue;
headers.Add(ToolBox.GetAttributeString(subElement, "header", ""));
messages.Add(ToolBox.GetAttributeString(subElement, "text", ""));
}
}
public static Quest LoadRandom(Location[] locations, Random rand)
@@ -142,8 +154,17 @@ namespace Barotrauma
return null;
}
public virtual void Start(Level level)
public virtual void Start(Level level) { }
public virtual void Update(float deltaTime) { }
public void ShowMessage(int index)
{
if (index >= headers.Count && index >= messages.Count) return;
new GUIMessageBox(
index < headers.Count ? headers[index] : "",
index < messages.Count ? messages[index] : "");
}
/// <summary>

View File

@@ -14,6 +14,8 @@ namespace Barotrauma
private Item item;
private int state;
public override Vector2 RadarPosition
{
get
@@ -69,6 +71,23 @@ namespace Barotrauma
//item.MoveWithLevel = true;
}
public override void Update(float deltaTime)
{
switch (state)
{
case 0:
if (item.CurrentHull == null) return;
ShowMessage(state);
state = 1;
break;
case 1:
if (!Level.Loaded.AtEndPosition && !Level.Loaded.AtStartPosition) return;
ShowMessage(state);
state = 2;
break;
}
}
public override void End()
{
item.Remove();

View File

@@ -38,12 +38,12 @@ namespace Barotrauma
new GUIMessageBox(quest.Name, quest.Description, 400, 400);
quest.Start(Level.Loaded);
//quest.Start(Level.Loaded);
}
public override void End(string endMessage = "")
{
quest.End();
//quest.End();
base.End(endMessage);
}

View File

@@ -14,7 +14,7 @@ namespace Barotrauma
public readonly CrewManager CrewManager;
private GUIComponent infoBox;
public static void StartTutorial()
{
Submarine.Load("Content/Map/TutorialSub.sub", "");
@@ -63,6 +63,7 @@ namespace Barotrauma
CrewManager.AddCharacter(character);
//CoroutineManager.StartCoroutine(QuitChecker());
CoroutineManager.StartCoroutine(UpdateState());
}
@@ -84,8 +85,9 @@ namespace Barotrauma
if (infoBox!=null) infoBox.Update(deltaTime);
}
private IEnumerable<object> UpdateState()
{
{
Submarine.Loaded.SetPosition(new Vector2(Submarine.Loaded.Position.X, 38500.0f));
//spawn some fish next to the player

View File

@@ -172,6 +172,7 @@ namespace Barotrauma
guiRoot.Update(deltaTime);
if (gameMode != null) gameMode.Update(deltaTime);
if (Quest != null) Quest.Update(deltaTime);
}
public void Draw(SpriteBatch spriteBatch)

View File

@@ -18,7 +18,7 @@ namespace Barotrauma
public enum ActionType
{
OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire
Always, OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire
}
class Item : MapEntity, IDamageable, IPropertyObject

View File

@@ -815,11 +815,13 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch)
{
if (renderer == null) return;
renderer.Draw(spriteBatch);
}
public void Render(GraphicsDevice graphicsDevice, Camera cam)
{
if (renderer == null) return;
renderer.Render(graphicsDevice, cam, vertices);
}

View File

@@ -76,7 +76,7 @@ namespace Barotrauma.Lights
if (!ObstructVision) return;
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative);
spriteBatch.Draw(losTexture, Vector2.Zero);
spriteBatch.End();
@@ -128,13 +128,13 @@ namespace Barotrauma.Lights
//draw the light shape
//where Alpha is 0, nothing will be written
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
light.Draw(spriteBatch);
spriteBatch.End();
}
ClearAlphaToOne(graphics, spriteBatch);
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
foreach (LightSource light in lights)
{
@@ -161,7 +161,7 @@ namespace Barotrauma.Lights
graphics.SetRenderTarget(losTexture);
graphics.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform);
Vector2 diff = lookAtPosition - ViewPos;
diff.Y = -diff.Y;
@@ -185,7 +185,7 @@ namespace Barotrauma.Lights
private void ClearAlphaToOne(GraphicsDevice graphics, SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.WriteToAlpha);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.WriteToAlpha);
spriteBatch.Draw(alphaClearTexture, new Rectangle(0, 0,graphics.Viewport.Width, graphics.Viewport.Height), Color.White);
spriteBatch.End();
}
@@ -195,7 +195,7 @@ namespace Barotrauma.Lights
if (!LightingEnabled) return;
//multiply scene with lightmap
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative);
spriteBatch.Draw(lightMap, Vector2.Zero, Color.White);
spriteBatch.End();
}

View File

@@ -22,7 +22,8 @@ namespace Barotrauma
class Submarine : Entity
{
public const string SavePath = "Data/SavedSubs";
public static string SavePath = "Data" + System.IO.Path.DirectorySeparatorChar + "SavedSubs";
public static List<Submarine> SavedSubmarines = new List<Submarine>();
@@ -102,8 +103,12 @@ namespace Barotrauma
public Vector2 Speed
{
get { return subBody.Speed; }
set { subBody.Speed = value; }
get { return subBody==null ? Vector2.Zero : subBody.Speed; }
set
{
if (subBody == null) return;
subBody.Speed = value;
}
}
public List<Vector2> HullVertices
@@ -433,18 +438,13 @@ namespace Barotrauma
//saving/loading ----------------------------------------------------
public void Save()
public bool Save()
{
SaveAs(filePath);
return SaveAs(filePath);
}
public void SaveAs(string filePath)
public bool SaveAs(string filePath)
{
//if (filePath=="")
//{
// DebugConsole.ThrowError("No save file selected");
// return;
//}
XDocument doc = new XDocument(new XElement("Submarine"));
doc.Root.Add(new XAttribute("name", name));
@@ -464,13 +464,13 @@ namespace Barotrauma
catch (Exception e)
{
DebugConsole.ThrowError("Saving submarine ''" + filePath + "'' failed!", e);
return false;
}
//doc.Save(filePath);
return true;
}
public static void SaveCurrent(string fileName)
public static bool SaveCurrent(string fileName)
{
if (loaded==null)
{
@@ -478,7 +478,7 @@ namespace Barotrauma
// return;
}
loaded.SaveAs(SavePath+"/"+fileName);
return loaded.SaveAs(SavePath+System.IO.Path.DirectorySeparatorChar+fileName);
}
public static void Preload()
@@ -646,7 +646,12 @@ namespace Barotrauma
loaded = this;
}
public static Submarine Load(string fileName, string folder = SavePath)
public static Submarine Load(string fileName)
{
return Load(fileName, SavePath);
}
public static Submarine Load(string fileName, string folder)
{
Unload();

View File

@@ -129,6 +129,11 @@ namespace Barotrauma
private List<Vector2> GenerateConvexHull()
{
if (!Structure.wallList.Any())
{
return new List<Vector2>() { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) };
}
List<Vector2> points = new List<Vector2>();
Vector2 leftMost = Vector2.Zero;

View File

@@ -57,12 +57,12 @@ namespace Barotrauma
public void RenderBack(SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f)
{
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.LinearWrap, null, null, waterEffect);
waterEffect.CurrentTechnique = waterEffect.Techniques["WaterShader"];
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
waterEffect.CurrentTechnique.Passes[0].Apply();
//waterEffect.CurrentTechnique.Passes[0].Apply();
wavePos.X += 0.0001f;
wavePos.Y += 0.0001f;
@@ -74,7 +74,6 @@ namespace Barotrauma
spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#endif
spriteBatch.End();
}

View File

@@ -174,7 +174,7 @@ namespace Barotrauma
graphics.SetRenderTarget(renderTarget);
graphics.Clear(new Color(11, 18, 26, 255));
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap);
Vector2 backgroundPos = cam.Position;
if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position;
@@ -203,8 +203,8 @@ namespace Barotrauma
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
SamplerState.LinearWrap, null, null, null,
BlendState.NonPremultiplied,
SamplerState.LinearWrap, DepthStencilState.Default, null, null,
cam.Transform);
BackgroundSpriteManager.Draw(spriteBatch);
@@ -237,29 +237,27 @@ namespace Barotrauma
spriteBatch.End();
GameMain.LightManager.DrawLightMap(spriteBatch, cam);
//----------------------------------------------------------------------------------------
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
graphics.SetRenderTarget(renderTargetWater);
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), new Color(0.75f, 0.8f, 0.9f, 1.0f));
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null,
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied,
null, DepthStencilState.Default, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate,
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Additive,
null, DepthStencilState.DepthRead, null, null,
null, DepthStencilState.Default, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.Additive);
spriteBatch.End();
@@ -268,19 +266,19 @@ namespace Barotrauma
//draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir
graphics.SetRenderTarget(renderTargetAir);
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate,
BlendState.AlphaBlend,
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate,
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Additive,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);

View File

@@ -10,13 +10,13 @@ namespace Barotrauma
{
public class SaveUtil
{
private const string SaveFolder = "Data/Saves/";
private static string SaveFolder = "Data"+Path.DirectorySeparatorChar+"Saves";
public delegate void ProgressDelegate(string sMessage);
public static void SaveGame(string fileName)
{
fileName = SaveFolder + fileName;
fileName = Path.Combine(SaveFolder, fileName);
string tempPath = Path.Combine(SaveFolder, "temp");

Binary file not shown.