public static void Postfix(this InteractionInfo info, ref InteractionContext __result) { PlayerInteractEvent playerInteractEvent = new PlayerInteractEvent(ref __result); IEvent playerInteractIEvent = playerInteractEvent; EventManager.CallEvent(ref playerInteractIEvent); if (playerInteractEvent.IsCancelled()) { //we can not really cancel the event, but we remove all targets ;) //context.Target, context.SelectedItem, context.InteractableBlock, context.CarriedItem __result.Target = null; __result.SelectedItem = null; __result.Block = null; // InteractableBlock __result.CarriedItem = null; if (info.BlockPosition.HasValue) { __result.Player.SendCorrection(info); } //remove activity, because eco will add it WorldLayerManager.GetLayer(LayerNames.PlayerActivity)?.FuncAtWorldPos(__result.Player.Position.XZi, (pos, val) => val = Math.Max(0, val - 0.001f)); } }
public TooltipSection OilTooltip(Player player) { var layer = WorldLayerManager.GetLayer(LayerNames.Oil); var pos = player.User.Position.XZi; float value = 0.0f; layer.ForRadius(layer.WorldPosToLayerPos(pos), PumpJackObject.Radius, (x, val) => value += val); return(new TooltipSection(Localizer.Do("Oil Amount"), new LocString(Text.Num(value)))); }
public override bool Active(object obj, User user = null) { var playerActivity = WorldLayerManager.GetLayer(LayerNames.PlayerActivity); if (playerActivity.EntryWorldPos(user.Position.XZi) < 0.2) { return(true); } return(false); }
public void OnCraftingComplete() { var newSpeed = 0.0f; WorldLayerManager.GetLayer(LayerNames.Oil).ApplyRadius(this.Position.XZi, Radius, (x, val) => { var newVal = val - ((1 - (Vector2.Distance(x, this.Position.XZ) / Radius)) * 0.05f); newSpeed += newVal; return(newVal); }); }
void CollideWithTerrain(Player player, Vector3i position) { if (player != this.Controller) { return; } lock (this) { if (this.groundHits == null) { this.groundHits = new ThreadSafeHashSet <Vector3i>(); } } WorldLayer playerActivity = WorldLayerManager.GetLayer(LayerNames.PlayerActivity); // destroy plants and spawn dirt within a radius under the hit position int radius = 1; for (int x = -radius; x <= radius; x++) { for (int z = -radius; z <= radius; z++) { var offsetpos = position + new Vector3i(x, -1, z); if (!this.groundHits.Add(offsetpos)) { continue; } var abovepos = offsetpos + Vector3i.Up; var aboveblock = World.GetBlock(abovepos); var hitblock = World.GetBlock(offsetpos); if (!aboveblock.Is <Solid>()) { // turn soil into dirt if (hitblock.GetType() == typeof(GrassBlock) || hitblock.GetType() == typeof(ForestSoilBlock)) { player.SpawnBlockEffect(offsetpos, typeof(DirtBlock), BlockEffect.Delete); World.SetBlock <DirtBlock>(offsetpos); BiomePusher.AddFrozenColumn(offsetpos.XZ); } // kill any above plants if (aboveblock is PlantBlock) { // make sure there is a plant here, sometimes world/ecosim are out of sync var plant = EcoSim.PlantSim.GetPlant(abovepos); if (plant != null) { player.SpawnBlockEffect(abovepos, aboveblock.GetType(), BlockEffect.Delete); EcoSim.PlantSim.DestroyPlant(plant, DeathType.Deforestation); } else { World.DeleteBlock(abovepos); } } if (hitblock.Is <Solid>() && World.GetBlock(abovepos).Is <Empty>() && RandomUtil.Value < this.Species.ChanceToSpawnDebris) { Block placedBlock = World.SetBlock(typeof(TreeDebrisBlock), abovepos); player.SpawnBlockEffect(abovepos, typeof(TreeDebrisBlock), BlockEffect.Place); RoomData.QueueRoomTest(abovepos); } } } } }
public Type GetRegionalPrey(Animal animal) { return(animal.Species.FoodSources.Where(x => typeof(Animal).IsAssignableFrom(x)).Shuffle() .Where(x => WorldLayerManager.GetLayer(x.Name).EntryWorldPos(animal.Position.XZi) > 1f).FirstOrDefault()); }