public void RequestImage(long id, DecorationDefinition definition, RequestImageCallback callback, Color backgroundColor) { string hashedName = getHashedName(id); CallbackToken callbackToken = default(CallbackToken); callbackToken.Id = id; callbackToken.DefinitionId = definition.Id; DecorationRenderParams decorationRenderParams = new DecorationRenderParams(); decorationRenderParams.CallbackToken = callbackToken; decorationRenderParams.Definition = definition; decorationRenderParams.BackgroundColor = backgroundColor; decorationRenderParams.ImageHash = hashedName; DecorationRenderParams renderParams = decorationRenderParams; if (RequestImage(renderParams, callback)) { loadedItemCount++; if (loadedItemCount >= 30) { Resources.UnloadUnusedAssets(); loadedItemCount = 0; } } }
static void TryCreateDecoration(DecorationDefinition definition) { int serial = Builder.FindExistingItemSerial(definition.ItemAndLocation); if (serial == 0) { serial = Builder.TryCreateItemReturnSerial(definition.ItemAndLocation); if (serial != 0) { ApplyPropertiesToNewItem(serial, definition); created++; } else { Console.WriteLine("Decorate Error: Failed to create {0}", definition); failed++; } } else { existed++; } if (serial != 0 && Builder.isAtCreationLocation(serial)) { Builder.setHomeAndHeavy(serial); } }
static void AddScriptsToItemByDefinitionClass(int ItemSerial, DecorationDefinition definition) { string result = null; switch (definition.ItemClass) { case "PublicMoongate": result = Server.addScript(ItemSerial, "moongate"); if (result == null) { int gateid = GetGateID(definition.ItemAndLocation.Location); Server.setObjVar(ItemSerial, "gateID", gateid); } break; case "RejuvinationAddonComponent": if (definition.ItemAndLocation.ItemID == 2 || definition.ItemAndLocation.ItemID == 4) { result = Server.addScript(ItemSerial, "des1_ankh_2"); } else { result = Server.addScript(ItemSerial, "des1_ankh"); } break; } if (result != null) { Console.WriteLine("Decorate Error: Failed to attach script to {0} Message: {1}", definition, result); } }
public static DecorationDefinition Instanciate(string definition) { string[] DefinitionAndClass = definition.Split(';'); if (DefinitionAndClass.Length < 1) { return(null); } string[] itemAndLocationArray = DefinitionAndClass[0].Split(stringSplitSeperators, StringSplitOptions.RemoveEmptyEntries); ItemAndLocation DecorationItemAndLocation; if (!TryParseItemAndLocation(itemAndLocationArray, out DecorationItemAndLocation)) { return(null); } DecorationDefinition decoration = new DecorationDefinition() { ItemAndLocation = DecorationItemAndLocation }; decoration.hue = (short)TryExtractIntFromArray(itemAndLocationArray, 4); decoration.name = TryExtractNameFromArray(itemAndLocationArray, 5, itemAndLocationArray.Length - 5); decoration.ItemClass = DefinitionAndClass.Length > 1 ? DefinitionAndClass[1].Trim() : null; return(decoration); }
private void InitializeControls() { if (!(objectManipulationInputController.CurrentlySelectedObject != null)) { return; } ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); ObjectManipulator componentInParent2 = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>(); if (!(componentInParent2 != null)) { return; } switch (componentInParent.Type) { case DecorationLayoutData.DefinitionType.Structure: HideRotationControls(); HideScaleControls(); break; case DecorationLayoutData.DefinitionType.Decoration: { IGameData gameData = Service.Get <IGameData>(); Dictionary <int, DecorationDefinition> dictionary = gameData.Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition def = dictionary[componentInParent.DefinitionId]; ConfigureScalingOptions(def, componentInParent2); ConfigureRotationOptions(def, componentInParent2); } break; } } }
private void EnforceMemberOnlyItems() { bool flag = Service.Get <CPDataEntityCollection>().IsLocalPlayerMember(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary != null) { List <int> list = new List <int>(DefinitionsIDsList.Count); foreach (int definitionsIDs in DefinitionsIDsList) { if (dictionary.ContainsKey(definitionsIDs)) { DecorationDefinition decorationDefinition = dictionary[definitionsIDs]; if (decorationDefinition.IsMemberOnly) { if (flag) { list.Add(definitionsIDs); } } else { list.Add(definitionsIDs); } } } DefinitionsIDsList = list; } }
private void onPooledObjectAdded(RectTransform item, int index) { if (index >= filteredDefinitions.Count) { return; } StaticGameDataDefinition staticGameDataDefinition = filteredDefinitions[index]; IglooCatalogItem component = item.GetComponent <IglooCatalogItem>(); IglooCatalogItemData iglooCatalogItemData = null; if (staticGameDataDefinition.GetType() == typeof(DecorationDefinition)) { DecorationDefinition decorationDefinition = (DecorationDefinition)staticGameDataDefinition; if (!decorationProgressionStatus.TryGetValue(decorationDefinition.Id, out var value)) { value = new ProgressionUtils.ParsedProgression <DecorationDefinition>(decorationDefinition, -1, null, levelLocked: false, progressionLocked: false, decorationDefinition.IsMemberOnly); } iglooCatalogItemData = new IglooCatalogItemData(decorationDefinition, value); component.SetItem(iglooCatalogItemData, this); try { Content.LoadAsync(component.SetImageFromTexture2D, decorationDefinition.Icon); } catch (Exception ex) { Log.LogException(this, ex); } } else if (staticGameDataDefinition.GetType() == typeof(StructureDefinition)) { StructureDefinition structureDefinition = (StructureDefinition)staticGameDataDefinition; if (!structureProgressionStatus.TryGetValue(structureDefinition.Id, out var value2)) { value2 = new ProgressionUtils.ParsedProgression <StructureDefinition>(structureDefinition, -1, null, levelLocked: false, progressionLocked: false, structureDefinition.IsMemberOnly); } iglooCatalogItemData = new IglooCatalogItemData(structureDefinition, value2); component.SetItem(iglooCatalogItemData, this); try { Content.LoadAsync(component.SetImageFromTexture2D, structureDefinition.Icon); } catch (Exception ex) { Log.LogException(this, ex); } } else { Log.LogErrorFormatted(this, "Definition was not a Decoration or a Structure!"); } }
protected override IEnumerator processRequest(RenderParams renderParam) { DecorationRenderParams param = renderParam as DecorationRenderParams; DecorationDefinition decorationDefinition = null; if (!decorationList.TryGetValue(param.Definition.Id, out decorationDefinition)) { Log.LogErrorFormatted(this, "Unable to locate decoration {0} in decoration definitions with id {1}.", param.Definition.Name, param.Definition.Id); } else { yield return(loadDecorationPrefab(param)); } }
static void ApplyPropertiesToNewItem(int serial, DecorationDefinition definition) { if (!string.IsNullOrEmpty(definition.name)) { Server.setObjVar(serial, "lookAtText", definition.name); } if (definition.hue > 0) { Server.setHue(serial, definition.hue); } AddScriptsToItemByDefinitionClass(serial, definition); }
private void ConfigureScalingOptions(DecorationDefinition def, ObjectManipulator m) { scaleSlider.onValueChanged.RemoveAllListeners(); if (def.MaxScale == def.MinScale) { HideScaleControls(); return; } ScaleSliderContainer.SetActive(value: true); scaleSlider.minValue = def.MinScale; scaleSlider.maxValue = def.MaxScale; scaleSlider.value = m.Scale; scaleSlider.onValueChanged.AddListener(OnScaleSliderChanged); }
public IglooCatalogItemData(DecorationDefinition definition, ProgressionUtils.ParsedProgression <DecorationDefinition> progressData) { ItemType = DecorationType.Decoration; ID = definition.Id; TitleToken = definition.Name; DescriptionToken = definition.Description; Cost = definition.Cost; IsMemberOnly = progressData.MemberLocked; Level = progressData.Level; ProgressionLocked = progressData.ProgressionLocked; MascotName = progressData.MascotName; LevelLocked = progressData.LevelLocked; StructureSize = -1; }
private void ScaleSelectedItem(ObjectManipulator m, float delta) { ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition decorationDefinition = dictionary[componentInParent.DefinitionId]; float num = m.Scale + delta; if (num >= decorationDefinition.MinScale && num <= decorationDefinition.MaxScale) { m.ScaleTo(num); } } }
private void RotatedSelectedItem(ObjectManipulator m, float delta) { ManipulatableObject componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent.DefinitionId)) { DecorationDefinition decorationDefinition = dictionary[componentInParent.DefinitionId]; float degrees = m.CurrentRotationDegreesAroundUp + delta; float degrees2 = RotateClamp360Degrees(degrees); if (isValidRotation(degrees2)) { m.RotateBy(delta); } } }
internal override List <KeyValuePair <DecorationDefinition, int> > GetDefinitionsToDisplay() { List <KeyValuePair <DecorationDefinition, int> > list = new List <KeyValuePair <DecorationDefinition, int> >(); if (sceneLayoutData != null) { foreach (DecorationLayoutData item2 in sceneLayoutData.GetLayoutEnumerator()) { DecorationLayoutData current = item2; if (current.Type == DecorationLayoutData.DefinitionType.Decoration && dictionaryOfDecorationDefinitions.ContainsKey(current.DefinitionId)) { DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[current.DefinitionId]; int availableDecorationCount = SceneRefs.Get <SceneManipulationService>().GetAvailableDecorationCount(decorationDefinition.Id); KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount); if (!list.Contains(item)) { list.Add(item); } } } } if (SceneRefs.IsSet <SceneManipulationService>()) { SceneManipulationService sceneManipulationService = SceneRefs.Get <SceneManipulationService>(); if (sceneManipulationService.IsObjectSelectedForAdd) { ObjectManipulator currentObjectManipulator = sceneManipulationService.ObjectManipulationInputController.CurrentObjectManipulator; if (currentObjectManipulator != null) { int definitionId = currentObjectManipulator.GetComponent <ManipulatableObject>().DefinitionId; DecorationDefinition decorationDefinition = dictionaryOfDecorationDefinitions[definitionId]; int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(decorationDefinition.Id); KeyValuePair <DecorationDefinition, int> item = new KeyValuePair <DecorationDefinition, int>(decorationDefinition, availableDecorationCount); if (!list.Contains(item)) { list.Add(item); } } } } return(list); }
static void ProcessDecorationFile(StreamReader reader) { string line; Console.WriteLine("Decorating"); while ((line = reader.ReadLine()) != null) { if (line.StartsWith("#")) { continue; } DecorationDefinition decoration = DecorationDefinition.Instanciate(line); if (decoration != null) { TryCreateDecoration(decoration); } } Console.WriteLine("Decorate: Total: {3} Existed: {0} Created {1} Failed {2}", existed, created, failed, existed + created + failed); }
private void ConfigureRotationOptions(DecorationDefinition def, ObjectManipulator m) { RotationWheel rotationWheel = RotationWheel; rotationWheel.ValueChanged = (Action <float>)Delegate.Remove(rotationWheel.ValueChanged, new Action <float>(OnRotationWheelChanged)); if (def.MaxRotation != 0 && def.MinRotation != 0) { MaxRotation = def.MaxRotation; MinRotation = def.MinRotation; RotationWheel.Value = m.CurrentRotationDegreesAroundUp * ((float)Math.PI / 180f); RotationWheel rotationWheel2 = RotationWheel; rotationWheel2.ValueChanged = (Action <float>)Delegate.Combine(rotationWheel2.ValueChanged, new Action <float>(OnRotationWheelChanged)); RotationWheelContainer.SetActive(value: true); } else { MaxRotation = 0f; MinRotation = 0f; HideRotationControls(); } }
public void OnScaleSliderChanged(float value) { if (!(objectManipulationInputController.CurrentlySelectedObject != null)) { return; } ObjectManipulator componentInParent = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ObjectManipulator>(); if (!(componentInParent != null)) { return; } ManipulatableObject componentInParent2 = objectManipulationInputController.CurrentlySelectedObject.GetComponentInParent <ManipulatableObject>(); Dictionary <int, DecorationDefinition> dictionary = Service.Get <IGameData>().Get <Dictionary <int, DecorationDefinition> >(); if (dictionary.ContainsKey(componentInParent2.DefinitionId)) { DecorationDefinition decorationDefinition = dictionary[componentInParent2.DefinitionId]; if (value >= decorationDefinition.MinScale && value <= decorationDefinition.MaxScale) { componentInParent.ScaleTo(value); } } }
private bool onDuplicateSelectedObject(IglooUIEvents.DuplicateSelectedObject evt) { SceneLayoutData activeSceneLayoutData = layoutManager.GetActiveSceneLayoutData(); if (activeSceneLayoutData.IsLayoutAtMaxItemLimit()) { Log.LogError(this, "Attempting to duplicate when max items already met"); return(false); } DecorationLayoutData data = default(DecorationLayoutData); bool flag = false; Vector3 zero = Vector3.zero; UnityEngine.Quaternion identity = UnityEngine.Quaternion.identity; Vector3 one = Vector3.one; if (!ClubPenguin.Core.SceneRefs.IsSet <ObjectManipulationInputController>()) { Log.LogError(this, "ObjectManipulationInputController not set when attempting to duplicate."); return(false); } ObjectManipulationInputController objectManipulationInputController = ClubPenguin.Core.SceneRefs.Get <ObjectManipulationInputController>(); if (objectManipulationInputController.CurrentlySelectedObject == null) { Log.LogError(this, "Currently selected object was null when attempting to duplicate."); return(false); } ManipulatableObject component = objectManipulationInputController.CurrentlySelectedObject.GetComponent <ManipulatableObject>(); zero = component.transform.position; identity = component.transform.rotation; Transform parent = component.transform.parent; component.transform.parent = null; one = component.transform.localScale; component.transform.parent = parent; data.DefinitionId = component.DefinitionId; data.Type = component.Type; if (true && ClubPenguin.Core.SceneRefs.IsSet <SceneManipulationService>()) { SceneManipulationService sceneManipulationService = ClubPenguin.Core.SceneRefs.Get <SceneManipulationService>(); if (data.Type == DecorationLayoutData.DefinitionType.Decoration) { Vector3 vector = Vector3.right; if (objectManipulationInputController.CurrentlySelectedObject.GetComponent <PartneredObject>() != null || objectManipulationInputController.CurrentlySelectedObject.GetComponent <SplittableObject>() != null) { vector = Vector3.right * 3f; } DecorationDefinition decorationDefinition = Service.Get <DecorationInventoryService>().GetDecorationDefinition(data.DefinitionId); int availableDecorationCount = sceneManipulationService.GetAvailableDecorationCount(data.DefinitionId); if (decorationDefinition != null && availableDecorationCount > 0) { sceneManipulationService.AddNewObject(decorationDefinition.Prefab, zero + vector, identity, one, data, setManipulationInputStateToDrag: false); } } else { StructureDefinition structureDefinition = Service.Get <DecorationInventoryService>().GetStructureDefinition(data.DefinitionId); int availableDecorationCount = sceneManipulationService.GetAvailableStructureCount(data.DefinitionId); if (structureDefinition != null && availableDecorationCount > 0) { sceneManipulationService.AddNewObject(structureDefinition.Prefab, zero + Vector3.right, identity, one, data, setManipulationInputStateToDrag: false); } } } return(false); }
public AddNewDecoration(DecorationDefinition definition, Vector2 finalTouchPoint) { Definition = definition; FinalTouchPoint = finalTouchPoint; }