/// <summary> /// Updates the "Stack Preview" panel for the specified <see cref="EntityCategory"/>. /// </summary> /// <param name="category"> /// An <see cref="EntityCategory"/> value indicating the entity stack to preview.</param> /// <exception cref="InvalidEnumArgumentException"> /// <paramref name="category"/> is <see cref="EntityCategory.Upgrade"/> or an invalid <see /// cref="EntityCategory"/> value.</exception> /// <remarks> /// <b>UpdatePreview</b> shows overlaid images for all entities if <paramref /// name="category"/> equals <b>Effect</b> or <b>Terrain</b>, and only the image for the /// topmost entity if <paramref name="category"/> equals <b>Unit</b>.</remarks> private void UpdatePreview(EntityCategory category) { switch (category) { case EntityCategory.Terrain: // show entire stack for terrains TerrainPreview.Show(this._terrains); break; case EntityCategory.Unit: // show only topmost entity for units int index = this._units.Count - 1; if (index < 0) { EntityPreview.Clear(); } else { EntityPreview.Show(this._units[index]); } break; case EntityCategory.Effect: // show entire stack for effects EntityPreview.Show(this._effects); break; default: ThrowHelper.ThrowInvalidEnumArgumentException( "category", (int)category, typeof(EntityCategory)); break; } }
/// <summary> /// Shows a preview of the selected <see cref="EntityClass"/>.</summary> /// <remarks> /// <b>UpdatePreview</b> updates the "Image Preview" control with the current <see /// cref="PolygonGrid.Element"/> shape and the data of the first selected item in the /// "Entity" list view.</remarks> public void UpdatePreview() { // update polygon shape if necessary EntityPreview.Polygon = MasterSection.Instance.Areas.MapGrid.Element; // show image stack of selected entity, if any EntityClass entity = EntityList.SelectedItem as EntityClass; if (entity == null) { EntityPreview.Clear(); } else { EntityPreview.Show(entity.ImageStack); } }
public static GameObject CreateAndRegisterPreview(string id, KAnimFile anim, string initial_anim, ObjectLayer object_layer, int width, int height) { GameObject gameObject = CreatePlacedEntity(id, id, id, 1f, anim, initial_anim, Grid.SceneLayer.Front, width, height, TUNING.BUILDINGS.DECOR.NONE, default(EffectorValues), SimHashes.Creature, null, 293f); gameObject.UpdateComponentRequirement <KSelectable>(false); gameObject.UpdateComponentRequirement <SaveLoadRoot>(false); EntityPreview entityPreview = gameObject.AddOrGet <EntityPreview>(); entityPreview.objectLayer = object_layer; OccupyArea occupyArea = gameObject.AddOrGet <OccupyArea>(); occupyArea.objectLayers = new ObjectLayer[1] { object_layer }; occupyArea.ApplyToCells = false; gameObject.AddOrGet <Storage>(); KPrefabID component = gameObject.GetComponent <KPrefabID>(); Assets.AddPrefab(component); return(gameObject); }
protected override void OnDragTool(int cell, int distFromOrigin) { if (!((Object)visualizer == (Object)null)) { bool flag = false; EntityPreview component = visualizer.GetComponent <EntityPreview>(); if (component.Valid) { if (DebugHandler.InstantBuildMode) { source.Place(cell); } else { source.QueuePlacement(cell); } flag = true; } if (flag) { Deactivate(); } } }
private static bool ValidTest(int cell, object data) { EntityPreview entityPreview = (EntityPreview)data; return(!Grid.Solid[cell] && (entityPreview.objectLayer == ObjectLayer.NumLayers || (UnityEngine.Object)Grid.Objects[cell, (int)entityPreview.objectLayer] == (UnityEngine.Object)entityPreview.gameObject || (UnityEngine.Object)Grid.Objects[cell, (int)entityPreview.objectLayer] == (UnityEngine.Object)null)); }