public static void NotifyAreaRemovedPostfix(Pawn_PlayerSettings __instance, Area area) { AreaExt pawnArea = FieldInfos.areaAllowedInt.GetValue(__instance) as AreaExt; if (pawnArea != null && pawnArea.Empty) { FieldInfos.areaAllowedInt.SetValue(__instance, null); } }
public static void RegisterLoadIDReadFromXmlPostfix(LoadIDsWantedBank __instance, string targetLoadID, Type targetType, string pathRelToParent, IExposable parent) { if (targetType == typeof(Area) || targetType.IsInstanceOfType(typeof(Area))) { if (targetLoadID.StartsWith("@!")) { Dictionary <string, ILoadReferenceable> allObjectByLoadID = fieldAllObjectsByLoadID.GetValue(fieldLoadedObjectDirectory.GetValue(Scribe.loader.crossRefs)) as Dictionary <string, ILoadReferenceable>; AreaExt areaExt = AreaExtLoadHelper.OnLoadingVars(targetLoadID); if (!allObjectByLoadID.ContainsKey(targetLoadID)) { allObjectByLoadID.Add(targetLoadID, areaExt); } } } }
public static bool AreaRestrictionSetterPrefix(ref Area value) { AreaExt areaExt = value as AreaExt; if (areaExt != null) { if (!Find.Maps.Any(x => x.uniqueID == areaExt.MapID)) { value = null; } if (areaExt.InnerAreas.Count == 0) { value = null; } if (areaExt.IsOneInclusion) { value = areaExt.InnerAreas[0].Key; } } return(true); }
public static bool DoAreaSelectorPrefix(Rect rect, Pawn p, Area area) { MouseoverSounds.DoRegion(rect); rect = rect.ContractedBy(1f); GUI.DrawTexture(rect, (area == null) ? BaseContent.GreyTex : area.ColorTexture); Text.Anchor = TextAnchor.MiddleLeft; string text = AreaUtility.AreaAllowedLabel_Area(area); Rect rect2 = rect; rect2.xMin += 3f; rect2.yMin += 2f; Widgets.Label(rect2, text); bool dragging = (bool)FieldInfos.dragging.GetValue(null); Area currentArea = p.playerSettings.AreaRestriction; AreaExt currentAreaExt = p.playerSettings.AreaRestriction as AreaExt; AreaExtOperator currentAreaExtOp = currentAreaExt?.GetAreaOperator(area?.ID ?? -1) ?? AreaExtOperator.None; // null area인 경우, 현재 구역의 첫 구역이 exclusion이면 inclusion으로 선택된것처럼 출력해준다. (실제로는 아님) if (area == null) { if (currentArea == null || (currentAreaExt != null && currentAreaExt.IsWholeExclusive)) { GUI.color = Color.white; Widgets.DrawBox(rect, 2); GUI.color = Color.white; } } else { if (currentAreaExt != null) { if (currentAreaExtOp == AreaExtOperator.Inclusion) { GUI.color = Color.white; Widgets.DrawBox(rect, 2); GUI.color = Color.white; } else if (currentAreaExtOp == AreaExtOperator.Exclusion) { GUI.color = Color.red; Widgets.DrawBox(rect, 2); GUI.color = Color.white; } } else { if (currentArea == area) { Widgets.DrawBox(rect, 2); } } } bool mouseOver = Mouse.IsOver(rect); bool leftButton = Event.current.button == 0; bool rightButton = Event.current.button == 1; if (mouseOver && area != null) { area.MarkForDraw(); } if (editMode == AreaAllowedEditMode.None) { if (mouseOver && dragging) { if (leftButton) { // 구역이 null이 아니면서, 현재 선택되어있다면 Remove, 아니면 Inclusion if (area != null && (currentArea == area || currentAreaExtOp == AreaExtOperator.Inclusion)) { editMode = AreaAllowedEditMode.Remove; } else { editMode = AreaAllowedEditMode.AddInclusion; } } else if (rightButton) { // 이미 Exclusion으로 선택된것만 Remove, 아니면 Exclusion으로 덮어쓰거나 수정하지 않음 if (currentAreaExtOp == AreaExtOperator.Exclusion) { editMode = AreaAllowedEditMode.Remove; } else if (area != null) { editMode = AreaAllowedEditMode.AddExclusion; } } } } if (editMode == AreaAllowedEditMode.AddInclusion) { if (mouseOver && dragging) { if (currentArea != area) { if (area == null) { p.playerSettings.AreaRestriction = null; } else { if (currentArea == null) { p.playerSettings.AreaRestriction = area; } else { if (currentAreaExt != null) { if (!currentAreaExt.Contains(area, AreaExtOperator.Inclusion)) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Inclusion, area); } } else { p.playerSettings.AreaRestriction = new AreaExt(currentArea.Map, AreaExtOperator.Inclusion, currentArea).CloneWithOperationArea(AreaExtOperator.Inclusion, area); } } } } } else if (!dragging) { editMode = AreaAllowedEditMode.None; } } else if (editMode == AreaAllowedEditMode.AddExclusion) { if (mouseOver && dragging) { if (currentArea != area) { if (area == null) { p.playerSettings.AreaRestriction = null; } else { if (currentArea == null) { p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Exclusion, area); } else { if (currentAreaExt != null) { if (!currentAreaExt.Contains(area, AreaExtOperator.Exclusion)) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Exclusion, area); } } else { p.playerSettings.AreaRestriction = new AreaExt(currentArea.Map, AreaExtOperator.Inclusion, currentArea).CloneWithOperationArea(AreaExtOperator.Exclusion, area); } } } } } else if (!dragging) { editMode = AreaAllowedEditMode.None; } } else if (editMode == AreaAllowedEditMode.Remove) { if (mouseOver && dragging) { if (currentArea != null && area != null) { if (currentArea == area) { p.playerSettings.AreaRestriction = null; } else if (currentAreaExt != null && currentAreaExt.Contains(area)) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.None, area); } } } else if (!dragging) { editMode = AreaAllowedEditMode.None; } } Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, text); return(false); }
public static bool DoAreaSelectorPrefix(Rect rect, Pawn p, Area area) { MouseoverSounds.DoRegion(rect); rect = rect.ContractedBy(1f); GUI.DrawTexture(rect, (area == null) ? BaseContent.GreyTex : area.ColorTexture); Text.Anchor = TextAnchor.MiddleLeft; string text = AreaUtility.AreaAllowedLabel_Area(area); Rect rect2 = rect; rect2.xMin += 3f; rect2.yMin += 2f; Widgets.Label(rect2, text); bool dragging = (bool)FieldInfos.dragging.GetValue(null); Area currentArea = p.playerSettings.AreaRestriction; AreaExt currentAreaExt = p.playerSettings.AreaRestriction as AreaExt; if (area != null && currentAreaExt != null) { AreaExtOperator areaOp = currentAreaExt.GetAreaOperator(area.ID); if (areaOp == AreaExtOperator.Inclusion) { GUI.color = Color.white; Widgets.DrawBox(rect, 2); GUI.color = Color.white; } else if (areaOp == AreaExtOperator.Exclusion) { GUI.color = Color.red; Widgets.DrawBox(rect, 2); GUI.color = Color.white; } } else { if (currentArea == area) { Widgets.DrawBox(rect, 2); } } if (Mouse.IsOver(rect)) { if (area != null) { area.MarkForDraw(); } } if (dragging && Mouse.IsOver(rect)) { if (editMode == AreaAllowedEditMode.None) { if (area != null && currentAreaExt != null) { var t = currentAreaExt.GetAreaOperator(area.ID); if (t != AreaExtOperator.None) { if ((Event.current.button == 0 && t == AreaExtOperator.Inclusion) || (Event.current.button == 1 && t == AreaExtOperator.Exclusion)) { editMode = AreaAllowedEditMode.Remove; } else { editMode = Event.current.button == 0 ? AreaAllowedEditMode.AddInclusion : AreaAllowedEditMode.AddExclusion; } } else { editMode = Event.current.button == 0 ? AreaAllowedEditMode.AddInclusion : AreaAllowedEditMode.AddExclusion; } } else { if (currentArea == area) { editMode = AreaAllowedEditMode.Remove; } else { if (Event.current.button == 0) { editMode = AreaAllowedEditMode.AddInclusion; } else if (Event.current.button == 1) { editMode = AreaAllowedEditMode.AddExclusion; } } } } if (editMode == AreaAllowedEditMode.AddInclusion) { if (area == null) { p.playerSettings.AreaRestriction = null; SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } else if (currentAreaExt != null) { if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.Inclusion) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Inclusion, area); SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } else { p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Inclusion, area); SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } if (editMode == AreaAllowedEditMode.AddExclusion) { if (area == null) { p.playerSettings.AreaRestriction = null; SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } else if (currentAreaExt != null) { if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.Exclusion) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.Exclusion, area); SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } else { p.playerSettings.AreaRestriction = new AreaExt(area.Map, AreaExtOperator.Exclusion, area); SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } if (editMode == AreaAllowedEditMode.Remove) { if (currentAreaExt != null) { if (area != null) { if (currentAreaExt.GetAreaOperator(area.ID) != AreaExtOperator.None) { p.playerSettings.AreaRestriction = currentAreaExt.CloneWithOperationArea(AreaExtOperator.None, area); SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } } else { if (currentArea != null) { p.playerSettings.AreaRestriction = null; SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(null); } } } } Text.Anchor = TextAnchor.UpperLeft; TooltipHandler.TipRegion(rect, text); return(false); }