Ported over all the opening directors and improved the director code a bit more. Also implemented content instances for Grid/Uld.

This commit is contained in:
Filip Maj
2017-07-09 18:38:01 -04:00
parent 24c46c0480
commit 69f7fb5e47
18 changed files with 205 additions and 94 deletions

View File

@@ -1,6 +1,7 @@

using FFXIVClassic.Common;
using FFXIVClassic_Map_Server.actors.area;
using FFXIVClassic_Map_Server.actors.group;
using FFXIVClassic_Map_Server.Actors;
using FFXIVClassic_Map_Server.lua;
using FFXIVClassic_Map_Server.packets.send.actor;
@@ -16,6 +17,7 @@ namespace FFXIVClassic_Map_Server.actors.director
private uint directorId;
private string directorScriptPath;
private List<Actor> members = new List<Actor>();
protected ContentGroup contentGroup;
private bool isCreated = false;
private bool isDeleted = false;
private bool isDeleting = false;
@@ -23,7 +25,7 @@ namespace FFXIVClassic_Map_Server.actors.director
private Script directorScript;
private Coroutine currentCoroutine;
public Director(uint id, Area zone, string directorPath, params object[] args)
public Director(uint id, Area zone, string directorPath, bool hasContentGroup, params object[] args)
: base((6 << 28 | zone.actorId << 19 | (uint)id))
{
directorId = id;
@@ -33,6 +35,9 @@ namespace FFXIVClassic_Map_Server.actors.director
LoadLuaScript();
if (hasContentGroup)
contentGroup = Server.GetWorldManager().CreateContentGroup(this, GetMembers());
eventConditions = new EventList();
eventConditions.noticeEventConditions = new List<EventList.NoticeEventCondition>();
eventConditions.noticeEventConditions.Add(new EventList.NoticeEventCondition("noticeEvent", 0xE,0x0));
@@ -108,6 +113,9 @@ namespace FFXIVClassic_Map_Server.actors.director
if (isCreated && spawnImmediate)
{
if (contentGroup != null)
contentGroup.Start();
foreach (Player p in GetPlayerMembers())
{
p.QueuePackets(GetSpawnPackets());
@@ -116,15 +124,26 @@ namespace FFXIVClassic_Map_Server.actors.director
}
if (this is GuildleveDirector)
{
((GuildleveDirector)this).LoadGuildleve();
}
StartCoroutine("main", this);
}
public void StartContentGroup()
{
if (contentGroup != null)
contentGroup.Start();
}
public void EndDirector()
{
isDeleting = true;
if (contentGroup != null)
contentGroup.DeleteGroup();
if (this is GuildleveDirector)
((GuildleveDirector)this).EndGuildleveDirector();
@@ -139,13 +158,20 @@ namespace FFXIVClassic_Map_Server.actors.director
public void AddMember(Actor actor)
{
if (!members.Contains(actor))
{
members.Add(actor);
if (contentGroup != null)
contentGroup.AddMember(actor);
}
}
public void RemoveMember(Actor actor)
{
if (members.Contains(actor))
members.Remove(actor);
if (contentGroup != null)
contentGroup.RemoveMember(actor.actorId);
if (GetPlayerMembers().Count == 0 && !isDeleting)
EndDirector();
}
@@ -175,6 +201,16 @@ namespace FFXIVClassic_Map_Server.actors.director
return isDeleted;
}
public bool HasContentGroup()
{
return contentGroup != null;
}
public ContentGroup GetContentGroup()
{
return contentGroup;
}
public void GenerateActorName(int actorNumber)
{
//Format Class Name
@@ -262,5 +298,24 @@ namespace FFXIVClassic_Map_Server.actors.director
return null;
}
public void OnEventStart(Player player, object[] args)
{
object[] args2 = new object[args.Length + (player == null ? 1 : 2)];
Array.Copy(args, 0, args2, (player == null ? 1 : 2), args.Length);
if (player != null)
{
args2[0] = player;
args2[1] = this;
}
else
args2[0] = this;
Coroutine coroutine = directorScript.CreateCoroutine(directorScript.Globals["onEventStarted"]).Coroutine;
DynValue value = coroutine.Resume(args2);
LuaEngine.GetInstance().ResolveResume(player, coroutine, value);
}
}
}

View File

@@ -18,7 +18,6 @@ namespace FFXIVClassic_Map_Server.actors.director
public uint guildleveId;
public Player guildleveOwner;
public byte selectedDifficulty;
public ContentGroup contentGroup;
public GuildleveData guildleveData;
public GuildleveWork guildleveWork = new GuildleveWork();
@@ -27,7 +26,7 @@ namespace FFXIVClassic_Map_Server.actors.director
public uint completionTime = 0;
public GuildleveDirector(uint id, Area zone, string directorPath, uint guildleveId, byte selectedDifficulty, Player guildleveOwner, params object[] args)
: base(id, zone, directorPath, args)
: base(id, zone, directorPath, true, args)
{
this.guildleveId = guildleveId;
this.selectedDifficulty = selectedDifficulty;
@@ -53,7 +52,7 @@ namespace FFXIVClassic_Map_Server.actors.director
public void LoadGuildleve()
{
contentGroup = Server.GetWorldManager().CreateGLContentGroup(this, GetMembers());
}
public void StartGuildleve()
@@ -123,7 +122,7 @@ namespace FFXIVClassic_Map_Server.actors.director
if (wasCompleted)
{
Npc aetheryteNode = zone.SpawnActor(1200040, String.Format("{0}:warpExit", guildleveOwner.actorName), guildleveOwner.positionX, guildleveOwner.positionY, guildleveOwner.positionZ);
contentGroup.AddMember(aetheryteNode);
AddMember(aetheryteNode);
foreach (Actor a in GetPlayerMembers())
{
@@ -149,8 +148,7 @@ namespace FFXIVClassic_Map_Server.actors.director
//Delete ContentGroup, change music back
public void EndGuildleveDirector()
{
contentGroup.DeleteGroup();
{
foreach (Actor p in GetPlayerMembers())
{
Player player = (Player)p;