public HeightmapArray CreateDiamondSquareNoiseArray(IntVector2 requestedSize, int workingArraySize) { var fullSize = CalculateFullSize(requestedSize, workingArraySize); ExtendedArray extendedArray = new ExtendedArray(fullSize.X, fullSize.Y); InitializeArray(extendedArray); for (int x = 0; x < requestedSize.X - 1; x += workingArraySize) { for (int y = 0; y < requestedSize.Y - 1; y += workingArraySize) { var wrapper = new SmallWindowExtendedArrayWrapper(extendedArray, new IntVector2(x, y), workingArraySize + 1); iterationIndex = 1; for (int sideLength = wrapper.SideLength() - 1; sideLength >= 2; sideLength /= 2) { iterationIndex++; DiamondStep(wrapper, sideLength); SquareStep(wrapper, sideLength); } } } var outArray = extendedArray.GetSubArray(requestedSize); NormalizeArrayWithExtremesChecking(outArray); return(new HeightmapArray(outArray)); }
private void InitializeArray(ExtendedArray extendedArray) { int endIndex = extendedArray.SideLength() - 1; float constantStartValue = 0; extendedArray.SetValue(0, 0, constantStartValue); extendedArray.SetValue(0, endIndex, constantStartValue); extendedArray.SetValue(endIndex, 0, constantStartValue); extendedArray.SetValue(endIndex, endIndex, constantStartValue); }
public HeightmapArray AddDetail(HeightmapArray inputArray) { ExtendedArray extendedArray = new ExtendedArray(inputArray.Width, inputArray.Height); InitializeArray(extendedArray); iterationIndex = 1; for (int sideLength = extendedArray.SideLength() - 1; sideLength >= 2; sideLength /= 2) { iterationIndex++; DiamondStep(extendedArray, sideLength); SquareStep(extendedArray, sideLength); } var outArray = extendedArray.getOriginalSizedArray(); //NormalizeArray(outArray); return(new HeightmapArray(outArray)); }
public virtual void ExecuteActions(Dictionary <ExtendedArray <ushort>, CraftingSim> states = null) { CurrentCP = MaxCP; CurrentProgress = 0; CurrentQuality = 0; CraftingBuffs.Clear(); InnerQuietBuff = null; WasteNotBuff = null; VenerationBuff = null; GreatStridesBuff = null; InnovationBuff = null; MuscleMemoryBuff = null; ManipulationBuff = null; ObserveBuff = null; NameOfTheElementsBuff = null; NameOfTheElementsUsed = false; Step = 0; if (CurrentRecipe == null) { return; } //if (states == null) // states = G.CraftingStates; CurrentDurability = CurrentRecipe.Durability; if (CraftingActionsLength == 0) { //FinishedStep(this, 0); FinishedExecution(this); return; } ExtendedArray <ushort> actions = null; if (states != null) { actions = GetCraftingActions().Select(x => x.Id).ToArray(); if (states.ContainsKey(actions)) { states[actions].CopyTo(this, true); FinishedExecution(this); return; } } for (int i = 0; i < CraftingActionsLength; i++) { CraftingAction action = CraftingActions[i]; if (CurrentDurability <= 0 || action.AsFirstActionOnly && i > 0 || CurrentProgress >= CurrentRecipe.MaxProgress || action.GetCPCost(this) > CurrentCP || action.CheckInner(this) != CraftingActionResult.Success) { RemoveRedundantActions(); if (states != null) { actions = GetCraftingActions().Select(x => x.Id).ToArray(); CraftingSim sim = Clone(); CopyTo(sim, true); states[actions] = sim; } FinishedExecution(this); return; } action.IncreaseProgress(this); action.IncreaseQuality(this); CurrentDurability -= action.GetDurabilityCost(this); if (CurrentDurability > CurrentRecipe.Durability) { CurrentDurability = CurrentRecipe.Durability; } CurrentCP -= action.GetCPCost(this); foreach (var buff in CraftingBuffs) { buff.Step(this); } for (int j = 0; j < CraftingBuffs.Count; j++) { var buff = CraftingBuffs[j]; if (buff.NeedsRemove) { buff.Remove(this); j--; } } Step++; if (action.AddsBuff) { action.AddBuff(this); } FinishedStep(this, i); } if (states != null) { actions = GetCraftingActions().Select(x => x.Id).ToArray(); CraftingSim sim = Clone(); CopyTo(sim, true); states[actions] = sim; } FinishedExecution(this); }
public SmallWindowExtendedArrayWrapper(ExtendedArray internalArray, IntVector2 offset, int sideLength) { _internalArray = internalArray; _offset = offset; _sideLength = sideLength; }
public RotationInfo(params CraftingAction[] actions) { Rotation = actions.Select(x => x.Id).ToArray(); }