Ejemplo n.º 1
0
 private void mod(CommandSleep original, CommandSleep mod)
 {
     AlarmActivatedRef = Modable.mod(original.AlarmActivatedRef, mod.AlarmActivatedRef);
     AlarmTimeRef      = Modable.mod(original.AlarmTimeRef, mod.AlarmTimeRef);
     Duration          = Modable.mod(original.Duration, mod.Duration);
     MaxSleepFactor    = Modable.mod(original.MaxSleepFactor, mod.MaxSleepFactor);
 }
Ejemplo n.º 2
0
 public void mod(CommandSleep modable)
 {
     if (modable == null)
     {
         return;
     }
     mod(this, modable);
 }
Ejemplo n.º 3
0
    public override IModable copyDeep()
    {
        var result = new CommandSleep();

        result.AlarmActivatedRef = Modable.copyDeep(AlarmActivatedRef);
        result.AlarmTimeRef      = Modable.copyDeep(AlarmTimeRef);
        result.Duration          = Modable.copyDeep(Duration);
        result.MaxSleepFactor    = Modable.copyDeep(MaxSleepFactor);
        return(result);
    }
Ejemplo n.º 4
0
    public override void Stop()
    {
        base.Stop();
        CommandSleep c = Cmd as CommandSleep;

        if (c.StopCallback != null)
        {
            c.StopCallback();
            c.StopCallback = null;
        }
    }
Ejemplo n.º 5
0
    public override void Exit()
    {
        base.Exit();
        CommandSleep c = Cmd as CommandSleep;

        if (c.ExitCallback != null)
        {
            c.ExitCallback();
            c.ExitCallback = null;
        }
    }
Ejemplo n.º 6
0
    public override void mod(IModable modable)
    {
        CommandSleep modCommand = modable as CommandSleep;

        if (modCommand == null)
        {
            Debug.LogError("Type mismatch");
            return;
        }

        mod(modCommand);
    }
Ejemplo n.º 7
0
        public void Script_InsertCommand_InsertsCommandInCorrectPosition()
        {
            var s = ScriptManager.LoadedScripts[0];

            var c2 = s.AddCommand(new CommandSleep(2));
            var c4 = s.AddCommand(new CommandSleep(4));

            var c1 = new CommandSleep(1);
            var c3 = new CommandSleep(3);
            var c5 = new CommandSleep(5);

            s.InsertCommand(c1, 0);
            s.InsertCommandAfter(c3, c2);
            s.InsertCommand(c5, 4);

            Assert.AreEqual(c1, s.Commands.GetChild(0).value);
            Assert.AreEqual(c2, s.Commands.GetChild(1).value);
            Assert.AreEqual(c3, s.Commands.GetChild(2).value);
            Assert.AreEqual(c4, s.Commands.GetChild(3).value);
            Assert.AreEqual(c5, s.Commands.GetChild(4).value);
        }
Ejemplo n.º 8
0
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        Command result;

        JObject jo = JObject.Load(reader);

        if (!Enum.TryParse((string)jo["Type"], out Command.Type commandType))
        {
            Debug.LogError($"CommandType {jo["Type"]} not recognized in {jo}");
            return(new CommandNone());
        }

        switch (commandType)
        {
        case (Command.Type.Break):
            result = new CommandBreak();
            break;

        case (Command.Type.Call):
            result = new CommandCall();
            break;

        case (Command.Type.Conditional):
            result = new CommandConditional();
            break;

        case (Command.Type.Consume):
            result = new CommandConsume();
            break;

        case (Command.Type.Continue):
            result = new CommandContinue();
            break;

        case (Command.Type.Debug):
            result = new CommandDebug();
            break;

        case (Command.Type.Dialog):
            result = new CommandDialog();
            break;

        case (Command.Type.Dialogue):
            result = new CommandDialogue();
            break;

        case (Command.Type.Event):
            result = new CommandEvent();
            break;

        case (Command.Type.EventEnd):
            result = new CommandEventEnd();
            break;

        case (Command.Type.Flush):
            result = new CommandFlush();
            break;

        case (Command.Type.GotoLocation):
            result = new CommandGotoLocation();
            break;

        case (Command.Type.Interrupt):
            result = new CommandInterrupt();
            break;

        case (Command.Type.ItemAdd):
            result = new CommandItemAdd();
            break;

        case (Command.Type.ItemRemove):
            result = new CommandItemRemove();
            break;

        case (Command.Type.NoteAdd):
            result = new CommandNoteAdd();
            break;

        case (Command.Type.NoteRemove):
            result = new CommandNoteRemove();
            break;

        case (Command.Type.Outfit):
            result = new CommandOutfit();
            break;

        case (Command.Type.OutfitManage):
            result = new CommandOutfitManage();
            break;

        case (Command.Type.Pause):
            result = new CommandPause();
            break;

        case (Command.Type.Services):
            result = new CommandServices();
            break;

        case (Command.Type.Set):
            result = new CommandSet();
            break;

        case (Command.Type.Shop):
            result = new CommandShop();
            break;

        case (Command.Type.Sleep):
            result = new CommandSleep();
            break;

        case (Command.Type.TimePass):
            result = new CommandTimePass();
            break;

        case (Command.Type.None):
        default:
            result = new CommandNone();
            break;
        }

        serializer.Populate(jo.CreateReader(), result);

        return(result);

        /*if (reader.TokenType == JsonToken.Null)
         *  return new CText();
         *
         * if (reader.TokenType == JsonToken.StartObject)
         * {
         *  //https://stackoverflow.com/questions/35586987/json-net-custom-serialization-with-jsonconverter-how-to-get-the-default-beha
         *  existingValue = existingValue ?? serializer.ContractResolver.ResolveContract(objectType).DefaultCreator();
         *  serializer.Populate(reader, existingValue);
         *  return existingValue;
         * }
         *
         * if (reader.TokenType == JsonToken.String)
         *  return new CText((string)reader.Value);
         *
         */
        //throw new JsonSerializationException();
    }