Exemplo n.º 1
0
        public static void GiveAquariumTrophy1(Event e, GameLocation loc, GameTime time, string[] args)
        {
            int    id     = JsonAssets.GetBigCraftableId("Stardew Aquarium Trophy");
            Object trophy = new Object(Vector2.Zero, id);

            e.farmer.holdUpItemThenMessage(trophy, true);
            ++e.CurrentCommand;
        }
Exemplo n.º 2
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            JsonAssets = Helper.ModRegistry.GetApi <IJsonAssetsApi>("spacechase0.JsonAssets");
            JsonAssets.LoadAssets(Path.Combine(Helper.DirectoryPath, "data"));

            SpaceCore = Helper.ModRegistry.GetApi <ISpaceCoreAPI>("spacechase0.SpaceCore");
            SpaceCore.AddEventCommand("GiveAquariumTrophy1", typeof(ModEntry).GetMethod(nameof(GiveAquariumTrophy1)));
            SpaceCore.AddEventCommand("GiveAquariumTrophy2", typeof(ModEntry).GetMethod(nameof(GiveAquariumTrophy2)));
        }
Exemplo n.º 3
0
        public ImportResultDto ImportView(int zoneId, int appId, List <FileUploadDto> files, string defaultLanguage)
        {
            var callLog = Log.Call <ImportResultDto>($"{zoneId}, {appId}, {defaultLanguage}");

            try
            {
                // 0.1 Check permissions, get the app,
                var app = _cmsManagerLazy.Value.ServiceProvider.Build <ImpExpHelpers>().Init(Log).GetAppAndCheckZoneSwitchPermissions(_site.ZoneId, appId, _user, _site.ZoneId);
                _appHelpers.Init(app, Log);

                // 0.2 Verify it's json etc.
                if (files.Any(file => !Json.IsValidJson(file.Contents)))
                {
                    throw new ArgumentException("a file is not json");
                }

                // 1. create the views
                var serializer = _jsonBundleLazy.Value;
                serializer.Init(State.Get(app), Log);

                var bundles = files.Select(f => serializer.Deserialize(f.Contents)).ToList();

                if (bundles.Any(t => t == null))
                {
                    throw new NullReferenceException("At least one file returned a null-item, something is wrong");
                }

                // 1.1 Verify these are view-entities
                if (!bundles.All(v => v.Entity.Type.Is(Eav.ImportExport.Settings.TemplateContentType)))
                {
                    throw new Exception("At least one of the uploaded items is not a view configuration. " +
                                        "Expected all to be " + Eav.ImportExport.Settings.TemplateContentType);
                }

                // 2. Import the views
                // todo: construction of this should go into init
                _cmsManagerLazy.Value.Init(app.AppId, Log).Entities.Import(bundles.Select(v => v.Entity).ToList());

                // 3. Import the attachments
                var assets   = bundles.SelectMany(b => b.Assets);
                var assetMan = new JsonAssets();
                foreach (var asset in assets)
                {
                    assetMan.Create(GetRealPath(asset), asset);
                }

                // 3. possibly show messages / issues
                return(callLog("ok", new ImportResultDto(true)));
            }
            catch (Exception ex)
            {
                _envLogger.LogException(ex);
                return(callLog("error", new ImportResultDto(false, ex.Message, Message.MessageTypes.Error)));
            }
        }
Exemplo n.º 4
0
        public static void GiveAquariumTrophy2(Event e, GameLocation loc, GameTime time, string[] args)
        {
            int    id     = JsonAssets.GetBigCraftableId("Stardew Aquarium Trophy");
            Object trophy = new Object(Vector2.Zero, id);

            e.farmer.addItemByMenuIfNecessary(trophy);
            if (Game1.activeClickableMenu == null)
            {
                ++e.CurrentCommand;
            }
            ++e.CurrentCommand;
        }
Exemplo n.º 5
0
        private void TryAddAsset(BundleEntityWithAssets bundle, string webPath, string relativePath)
        {
            if (string.IsNullOrEmpty(webPath))
            {
                return;
            }
            var realPath     = _serverPaths.FullAppPath(webPath);
            var jsonAssetMan = new JsonAssets();
            var asset1       = jsonAssetMan.Get(realPath, relativePath);

            bundle.Assets.Add(asset1);
        }
Exemplo n.º 6
0
 public static void PrepareSave()
 {
     Which = JsonAssets?.GetHatId(Name) ?? -1;
 }