Spawnpoints for different jobs, spawning crew members with job-specific items, fixed issues with non-matching entity IDs between client and server, Unity-like coroutine system (connecting to server doesn't freeze the game anymore), map drawing improvements

This commit is contained in:
Regalis
2015-07-09 01:40:27 +03:00
parent d56f7f3f77
commit 2254585dac
35 changed files with 831 additions and 312 deletions
+32 -5
View File
@@ -268,6 +268,12 @@ namespace Subsurface
{
}
public Character(CharacterInfo characterInfo, WayPoint spawnPoint, bool isNetworkPlayer = false)
: this(characterInfo.File, spawnPoint.SimPosition, characterInfo, isNetworkPlayer)
{
}
public Character(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false)
: this(characterInfo.File, position, characterInfo, isNetworkPlayer)
{
@@ -351,7 +357,6 @@ namespace Subsurface
}
}
AnimController.FindHull();
//if (info.ID >= 0)
@@ -362,6 +367,24 @@ namespace Subsurface
CharacterList.Add(this);
}
public void GiveJobItems()
{
if (Info == null || Info.Job == null) return;
foreach (string itemName in Info.Job.SpawnItemNames)
{
ItemPrefab itemPrefab = ItemPrefab.list.Find(ip => ip.Name == itemName) as ItemPrefab;
if (itemPrefab == null)
{
DebugConsole.ThrowError("Tried to spawn ''" + Name + "'' with the item ''" + itemName + "''. Matching item prefab not found.");
continue;
}
Item item = new Item(itemPrefab, Position);
inventory.TryPutItem(item, item.AllowedSlots, false);
}
}
public void Control(float deltaTime, Camera cam, bool forcePick = false)
{
if (isDead) return;
@@ -612,15 +635,17 @@ namespace Subsurface
spriteBatch.DrawString(GUI.font, Info.Name, namePos, Color.White);
}
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition);
pos.Y = -pos.Y;
spriteBatch.DrawString(GUI.font, ID.ToString(), pos, Color.White);
if (this == Character.controlled) return;
Vector2 healthBarPos = new Vector2(Position.X - 50, -Position.Y - 50.0f);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X-2, (int)healthBarPos.Y-2, 100+4, 15+4), Color.Black, false);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f*(health/maxHealth)), 15), Color.Red, true);
Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.limbs[0].SimPosition);
pos.Y = -pos.Y;
spriteBatch.DrawString(GUI.font, ID.ToString(), pos, Color.White);
//GUI.DrawLine(spriteBatch, ConvertUnits.ToDisplayUnits(animController.limbs[0].SimPosition.X, animController.limbs[0].SimPosition.Y),
// ConvertUnits.ToDisplayUnits(animController.limbs[0].SimPosition.X, animController.limbs[0].SimPosition.Y) +
// ConvertUnits.ToDisplayUnits(animController.targetMovement.X, animController.targetMovement.Y), Color.Green);
@@ -1036,7 +1061,9 @@ namespace Subsurface
if (controlled == this) controlled = null;
if (Game1.Client!=null && Game1.Client.Character == this) Game1.Client.Character = null;
if (Game1.Client!=null && Game1.Client.Character == this) Game1.Client.Character = null;
if (inventory != null) inventory.Remove();
if (aiTarget != null)
aiTarget.Remove();
+8 -6
View File
@@ -19,6 +19,8 @@ namespace Subsurface
public int Salary;
public bool StartItemsGiven;
//public string GenderString()
//{
// return gender.ToString();
@@ -96,11 +98,10 @@ namespace Subsurface
string genderStr = ToolBox.GetAttributeString(element, "gender", "male").ToLower();
Gender = (genderStr == "male") ? Gender.Male : Gender.Female;
File = ToolBox.GetAttributeString(element, "file", "");
Salary = ToolBox.GetAttributeInt(element, "salary", 1000);
HeadSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1);
File = ToolBox.GetAttributeString(element, "file", "");
Salary = ToolBox.GetAttributeInt(element, "salary", 1000);
HeadSpriteId = ToolBox.GetAttributeInt(element, "headspriteid", 1);
StartItemsGiven = ToolBox.GetAttributeBool(element, "startitemsgiven", false);
foreach (XElement subElement in element.Elements())
{
@@ -120,7 +121,8 @@ namespace Subsurface
new XAttribute("file", File),
new XAttribute("gender", Gender == Gender.Male ? "male" : "female"),
new XAttribute("salary", Salary),
new XAttribute("headspriteid", HeadSpriteId));
new XAttribute("headspriteid", HeadSpriteId),
new XAttribute("startitemsgiven", StartItemsGiven));
Job.Save(charElement);
+10
View File
@@ -24,6 +24,16 @@ namespace Subsurface
get { return prefab.Description; }
}
public JobPrefab Prefab
{
get { return prefab; }
}
public List<string> SpawnItemNames
{
get { return prefab.ItemNames; }
}
public Job(JobPrefab jobPrefab)
{
+1 -1
View File
@@ -68,7 +68,7 @@ namespace Subsurface
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString())
switch (subElement.Name.ToString().ToLower())
{
case "item":
string itemName = ToolBox.GetAttributeString(subElement, "name", "");