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

@ -501,11 +501,11 @@ namespace FFXIVClassic_Map_Server.Actors
}
}
public Director CreateDirector(string path, params object[] args)
public Director CreateDirector(string path, bool hasContentGroup, params object[] args)
{
lock (directorLock)
{
Director director = new Director(directorIdCount, this, path, args);
Director director = new Director(directorIdCount, this, path, hasContentGroup, args);
currentDirectors.Add(director.actorId, director);
directorIdCount++;
return director;

View file

@ -14,7 +14,6 @@ namespace FFXIVClassic_Map_Server.actors.area
class PrivateAreaContent : PrivateArea
{
private Director currentDirector;
private ContentGroup currentContentGroup;
private bool isContentFinished = false;
public static PrivateAreaContent CreateContentArea(String scriptPath)
@ -26,8 +25,7 @@ namespace FFXIVClassic_Map_Server.actors.area
: base(parent, parent.actorId, classPath, privateAreaName, privateAreaType, 0, 0, 0)
{
currentDirector = director;
currentContentGroup = Server.GetWorldManager().CreateContentGroup(director);
LuaEngine.GetInstance().CallLuaFunction(contentStarter, this, "onCreate", false, currentContentGroup, currentDirector);
LuaEngine.GetInstance().CallLuaFunction(contentStarter, this, "onCreate", false, currentDirector);
}
public Director GetContentDirector()
@ -35,11 +33,6 @@ namespace FFXIVClassic_Map_Server.actors.area
return currentDirector;
}
public ContentGroup GetContentGroup()
{
return currentContentGroup;
}
public void ContentFinished()
{
isContentFinished = true;

View file

@ -114,11 +114,11 @@ namespace FFXIVClassic_Map_Server.actors.area
return mActorList[id];
}
public PrivateAreaContent CreateContentArea(Player starterPlayer, string areaClassPath, string contentScript, string areaName, string directorName)
public PrivateAreaContent CreateContentArea(Player starterPlayer, string areaClassPath, string contentScript, string areaName, string directorName, params object[] args)
{
lock (contentAreasLock)
{
Director director = CreateDirector(directorName);
Director director = CreateDirector(directorName, true, args);
if (director == null)
return null;

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;

View file

@ -19,6 +19,7 @@ namespace FFXIVClassic_Map_Server.actors.group
public ContentGroupWork contentGroupWork = new ContentGroupWork();
private Director director;
private List<uint> members = new List<uint>();
private bool isStarted = false;
public ContentGroup(ulong groupIndex, Director director, uint[] initialMembers) : base(groupIndex)
{
@ -38,6 +39,12 @@ namespace FFXIVClassic_Map_Server.actors.group
contentGroupWork._globalTemp.director = (ulong)director.actorId << 32;
}
public void Start()
{
isStarted = true;
SendGroupPacketsAll(members);
}
public void AddMember(Actor actor)
{
if (actor == null)
@ -46,15 +53,17 @@ namespace FFXIVClassic_Map_Server.actors.group
members.Add(actor.actorId);
if (actor is Character)
((Character)actor).SetCurrentContentGroup(this);
SendGroupPacketsAll(members);
((Character)actor).SetCurrentContentGroup(this);
if (isStarted)
SendGroupPacketsAll(members);
}
public void RemoveMember(uint memberId)
{
members.Remove(memberId);
SendGroupPacketsAll(members);
if (isStarted)
SendGroupPacketsAll(members);
CheckDestroy();
}

View file

@ -117,7 +117,7 @@ namespace FFXIVClassic_Map_Server.lua
Coroutine coroutine = mSleepingOnPlayerEvent[player.actorId];
mSleepingOnPlayerEvent.Remove(player.actorId);
DynValue value = coroutine.Resume(LuaUtils.CreateLuaParamObjectList(args));
ResolveResume(null, coroutine, value);
ResolveResume(player, coroutine, value);
}
catch (ScriptRuntimeException e)
{
@ -384,8 +384,13 @@ namespace FFXIVClassic_Map_Server.lua
player.EndEvent();
}
}
else
CallLuaFunction(player, target, "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
else
{
if (target is Director)
((Director)target).OnEventStart(player, LuaUtils.CreateLuaParamObjectList(lparams));
else
CallLuaFunction(player, target, "onEventStarted", false, LuaUtils.CreateLuaParamObjectList(lparams));
}
}
public DynValue ResolveResume(Player player, Coroutine coroutine, DynValue value)