public bool ValidateWithToasts(GameHUD hud) { if (Elements.Count > MaxEntityCount) { hud.ShowToast("SCCMLD::VWT_1", L10N.T(L10NImpl.STR_LVLED_ERR_TOOMANYENTS), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f); return(false); } if (string.IsNullOrWhiteSpace(Name)) { hud.ShowToast("SCCMLD::VWT_2", L10N.T(L10NImpl.STR_LVLED_ERR_NONAME), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f); return(false); } var hasPlayer = Elements .Where(e => e.StubType == SCCMLevelElement.SCCMStubType.Cannon) .Where(e => e.Cannon_CannonType != CannonStub.CannonStubType.Relay) .Where(e => e.Cannon_CannonType != CannonStub.CannonStubType.Shield) .Any(e => e.Cannon_CannonFrac == CannonStub.CannonStubFraction.P1); var hasEnemy = Elements .Where(e => e.StubType == SCCMLevelElement.SCCMStubType.Cannon) .Where(e => e.Cannon_CannonType != CannonStub.CannonStubType.Relay) .Where(e => e.Cannon_CannonType != CannonStub.CannonStubType.Shield) .Any(e => e.Cannon_CannonFrac == CannonStub.CannonStubFraction.A2 || e.Cannon_CannonFrac == CannonStub.CannonStubFraction.A3 || e.Cannon_CannonFrac == CannonStub.CannonStubFraction.A4); if (!hasPlayer) { hud.ShowToast("SCCMLD::VWT_3", L10N.T(L10NImpl.STR_LVLED_ERR_NOPLAYER), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f); return(false); } if (!hasEnemy) { hud.ShowToast("SCCMLD::VWT_4", L10N.T(L10NImpl.STR_LVLED_ERR_NOENEMY), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f); return(false); } return(true); }
public LevelBlueprint CompileToBlueprint(GameHUD hud) { var bp = new LevelBlueprint(); bp.UniqueID = Guid.Parse($"b16b00b5-0001-4001-0000-{OnlineID:000000000000}"); bp.WrapMode = (byte)Geometry; bp.LevelWidth = Width * 64; bp.LevelHeight = Height * 64; bp.LevelViewX = CalculateViewCenter().X; bp.LevelViewY = CalculateViewCenter().Y; bp.Name = "0-" + OnlineID; bp.FullName = Name; bp.KIType = GetKIType(); bp.CustomMusic = Music; byte cannonID = 0; foreach (var e in Elements) { e.InsertIntoBlueprint(bp, ref cannonID); } try { bp.ValidOrThrow(); BlueprintPreprocessor.ProcessLevel(bp); return(bp); } catch (Exception e) { MonoSAMGame.CurrentInst.DispatchBeginInvoke(() => { hud.ShowToast("SCCMLD::CTB_1", L10N.T(L10NImpl.STR_LVLED_ERR_COMPILERERR), 64, FlatColors.Flamingo, FlatColors.Foreground, 3f); SAMLog.Error("SCMMLD_CTBERR", "LevelBlueprint compiled to invalid", $"Exception: {e}\n\n\nData: {SerializeToString()}"); }); return(null); } }