internal static void AfterSave(PlayerEntityLogic __instance) { if (__instance == null) { return; } foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks")) { if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHook mod) { mod.OnPlayerSaveAfter(__instance, out var blob); if (blob != null) { __state.MergeFrom(blob); } } } __state.FetchBlob("collections").MergeFrom(__instance.GetPrivateFieldValue <Entity>("_entity").Blob.FetchBlob("collections")); __state.SetBool("dontStare", __instance.GetPrivateFieldValue <bool>("NPCsDontStare")); __state.SetLong("theftCount", __instance.GetPrivateFieldValue <long>("_theftCount")); __state.SetLong("theftResetDay", __instance.GetPrivateFieldValue <long>("_theftResetDay")); __state.SetBool("hasSoldToMerchant", __instance.GetPrivateFieldValue <bool>("HasSoldToMerchant")); __state.SetBool("autoPickupItems", __instance.GetPrivateFieldValue <bool>("_autoPickupItems")); ServerContext.EntityBlobDatabase.Set(__instance.Uid(), __instance.DisplayName(), EntityStorageKey.OtherPlayerData, __state); Blob.Deallocate(ref __state); }
public override bool TryUndock(PlayerEntityLogic player, EntityUniverseFacade facade, int quantity) { if (IsEmpty() || DockedItem.DockingEntity != player.PlayerEntity.Id) { return(false); } var flag = base.TryUndock(player, facade, quantity); return(flag); }
internal static void AfterLoad(PlayerEntityLogic __instance) { if (__instance == null) { return; } foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks")) { if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHook mod) { var blob = BlobAllocator.Blob(true); blob.AssignFrom(__instance.PlayerEntity.Blob); mod.OnPlayerLoadAfter(blob); Blob.Deallocate(ref blob); } } }
internal static void BeforeSave(PlayerEntityLogic __instance) { __state = BlobAllocator.Blob(true); if (__instance == null) { return; } foreach (var modInstance in GameContext.ModdingController.GetPrivateFieldValue <IEnumerable>("_modHooks")) { if (modInstance.GetPrivateFieldValue <object>("_instance") is IFoxModHook mod) { mod.OnPlayerSaveBefore(__instance, out var blob); if (blob != null) { __state.MergeFrom(blob); } } } }
public void Invoke(PlayerEntityLogic logic, Entity entity, Blob config, Timestep timestep, EntityUniverseFacade facade) { string message = config.GetString("message"); Color color = new Color() { PackedValue = (uint)config.GetLong("color") }; float scale = (float)config.GetDouble("scale"); BmFontAlign align = (BmFontAlign)config.GetLong("align"); EntityId id = config.GetLong("id"); Entity ent = default(Entity); if (facade.TryGetEntity(id, out ent) && ent.TileStateEntityLogic != null) { BetterSignTileStateEntityLogic entLogic = ent.TileStateEntityLogic as BetterSignTileStateEntityLogic; entLogic.ChangeSign(message, color, scale, align); } }
/// <summary> /// This method replaced the original CheckPlantGrowthStage /// This method is public to avoid Protected memory access to the arguments (needs to be same access level as original) /// </summary> /// <param name="entity"></param> /// <param name="facade"></param> public void CheckPlantGrowthStage(Entity entity, EntityUniverseFacade facade) { PlayerEntityLogic playerEntityLogic = entity.PlayerEntityLogic; Tile tile = default(Tile); PlantConfiguration config = default(PlantConfiguration); Vector3I cursor = default(Vector3I); Vector3I adjacent = default(Vector3I); Vector3I core = default(Vector3I); if (playerEntityLogic != null && playerEntityLogic.LookingAtTile(out cursor, out adjacent) && ((ItemFacade)facade).FindReadCompoundTileCore(cursor, TileAccessFlags.None, out core, out tile) && GameContext.PlantDatabase.TryGetByTile(tile, out config)) { Season season = SeasonHelper.FromInt(facade.DayNightCycle().GetSeason()); bool livesInThisSeason = config.LivesInSeason(season); Totem totem; List <Totem> totems; bool plantedInGreenhouse = (PlantLogic.GetValidTotemsOfType(PlantLogic.GreenhouseTotemCode, out totems) && PlantLogic.IsInTotemsRegion(totems, cursor, out totem)); Notification notif; if (config.IsWitheredTile(tile)) { notif = ((!livesInThisSeason && !plantedInGreenhouse) ? GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.witheredSeason", entity.Step, NotificationParams.CreateFromTranslation(season.GetCode()), false) : GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.withered", entity.Step, NotificationParams.EmptyParams, false)); } else if (config.IsWiltedTile(tile)) { notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.wilted", entity.Step, NotificationParams.EmptyParams, false); } else if (!livesInThisSeason && !plantedInGreenhouse) { notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth.season", entity.Step, NotificationParams.CreateFromTranslation(season.GetCode()), false); } else { float percentage = config.GetGrowthPercentage(tile, config); string description = (!(percentage < 0.1f)) ? ((!(percentage < 1f)) ? "hintText.checkPlantGrowth.fruited" : "hintText.checkPlantGrowth.growing") : "hintText.checkPlantGrowth.seed"; notif = GameContext.NotificationDatabase.CreateNotificationFromCode("staxel.notifications.checkPlantGrowth", entity.Step, NotificationParams.CreateFromTranslation(description), false); } playerEntityLogic.ShowNotification(notif); } entity.Logic.ActionFacade.NoNextAction(); }
public void OnPlayerSaveAfter(PlayerEntityLogic logic, out Blob saveBlob) { saveBlob = null; }