Ejemplo n.º 1
0
        /*public bool TryBeginCutscene(
         *                      CutsceneID cutsceneId,
         *                      SceneID sceneId,
         *                      Player playsFor,
         *                      bool sync,
         *                      out string result ) {
         *      if( !this.CanBeginCutscene(cutsceneId, playsFor, out Cutscene cutscene, out result) ) {
         *              result = "Cannot play cutscene " + cutsceneId + ": " + result;
         *              return false;
         *      }
         *      return this.TryBeginCutscene( cutscene, sceneId, sync, out result );
         * }*/

        ////

        private bool TryBeginCutscene(
            Cutscene cutscene,
            bool sync,
            out string result)
        {
            int    playsForWhom = cutscene.PlaysForWhom;
            Player playsFor     = Main.player[playsForWhom];

            if (this.GetCurrentCutscene_Player(playsFor) != null)
            {
                result = playsFor.name + " (" + playsForWhom + ") already playing cutscene " + cutscene.UniqueId;
                return(false);
            }

            cutscene.BeginCutscene_Internal();

            this._CutscenePerPlayer[playsForWhom] = cutscene;

            var myplayer = playsFor.GetModPlayer <CutsceneLibPlayer>();

            myplayer.TriggeredCutsceneIDs_Player.Add(cutscene.UniqueId);

            var myworld = ModContent.GetInstance <CutsceneLibWorld>();

            myworld.TriggeredCutsceneIDs_World.Add(cutscene.UniqueId);

            if (sync)
            {
                if (Main.netMode == NetmodeID.Server)
                {
                    CutsceneStartProtocol.SendToClients(cutscene: cutscene, ignoreWho: -1);
                }
                else if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    CutsceneStartProtocol.Broadcast(cutscene: cutscene);
                }
            }

            result = "Success.";
            return(true);
        }