public void OnChildTriggerEnter(TriggerForwarder child, Collider c, IMovableSnappable res) { if (res == null && child.transform.name == "PumpSnap") { string valveTag = c.tag.ToLower(); if (valveTag.EndsWith("valve")) { AttachTo(c, valveTag); } } else if (detachTimer == null && res is ResourceComponent) { if (ResourceMatchesCurrentPumpable(res as ResourceComponent)) { capturedResource = res as ResourceComponent; capturedResource.SnapCrate(this, CrateAnchor.position); if (valveType == Matter.Unspecified) { if (connectedPumpable is GasStorage && (connectedPumpable as GasStorage).Data.Container.CurrentAmount <= 0f) { this.valveType = capturedResource.Data.Container.MatterType; (connectedPumpable as GasStorage).SpecifyCompound(capturedResource.Data.Container.MatterType); this.SyncMeshesToMatterType(); } } RefreshPumpState(); } } }
public void OnStart() { m_ResourceComponent = CentorPivot.This.GetComponent <ResourceComponent>(); if (m_ResourceComponent == null) { throw new Exception("Resource component is invalid."); } m_ReadWriteVersionListFileName = Utility.Path.GetRegularPath(Path.Combine(m_ResourceComponent.ReadWritePath, ResourceRation.LocalVersionListFileName)); m_ReadWriteVersionListBackupFileName = Utility.Text.Format("{0}.{1}", m_ReadWriteVersionListFileName, ResourceRation.BackupExtension); m_DownloadComponent = CentorPivot.This.GetComponent <DownloadComponent>(); if (m_DownloadComponent == null) { throw new Exception("Download manager is invalid."); } m_DownloadComponent.DownloadStart += OnDownloadStart; m_DownloadComponent.DownloadUpdate += OnDownloadUpdate; m_DownloadComponent.DownloadSuccess += OnDownloadSuccess; m_DownloadComponent.DownloadFailure += OnDownloadFailure; }
/// <summary> /// 编辑器下加载Unity无法识别的文本文件,如.lua /// </summary> /// <param name="editorResourceComponent"></param> /// <param name="path"></param> /// <returns></returns> public static string LoadTextAsset(this ResourceComponent editorResourceComponent, string assetName) { string path = Application.dataPath.Replace("Assets", "") + assetName; StreamReader sr = new StreamReader(path, Encoding.UTF8); return(sr.ReadToEnd()); }
public void OnChildTriggerEnter(TriggerForwarder child, Collider c, IMovableSnappable res) { ResourceComponent resComp = res.transform.GetComponent <ResourceComponent>(); if (resComp != null) { if (resComp.Data.Container.MatterType.Is3DPrinterFeedstock()) { if (child == leftInputTrigger && LeftInput == null) { LeftInput = resComp; res.SnapCrate(this, child.transform.position, globalRotation: child.transform.rotation); } else if (child == rightInputTrigger && RightInput == null) { RightInput = resComp; res.SnapCrate(this, child.transform.position, globalRotation: child.transform.rotation); } } else { GuiBridge.Instance.ShowNews(NewsSource.InvalidSnap); } } }
public string GetType(ResourceComponent com) { if (resourceComponent == null) { return(fairygui.CommonName.GObject); } if (resourceComponent.isIngore) { return(resourceComponent.extendClassName); } if (com.package == resourceComponent.package) { return(resourceComponent.classNameExtend); } else { if (Setting.Options.codeUseOtherPkgType) { return(resourceComponent.classNameFull); } else { return(resourceComponent.extendClassName); } } }
public void DetachCrate(IMovableSnappable detaching) { var res = detaching.transform.GetComponent <ResourceComponent>(); if (res == capturedOre) { capturedOre = null; res.transform.SetParent(null); if (capturedPowder == null) { FlexData.CurrentOre = Matter.Unspecified; } } else if (res == capturedPowder) { capturedPowder = null; if (capturedOre == null) { FlexData.CurrentOre = Matter.Unspecified; } } unsnapTimer = StartCoroutine(UnsnapTimer()); }
void OnTriggerEnter(Collider other) { var iceDrill = other.GetComponent <IceDrill>(); if (iceDrill != null && Data.Extractable.MatterType == Matter.Water && unsnapTimer == null) { iceDrill.SnapCrate(this, this.transform.TransformPoint(Vector3.up * VerticalDrillOffset)); snappedDrill = iceDrill; } else { var res = other.GetComponent <ResourceComponent>(); if (res != null && unsnapTimer == null) { if (res.Data.Container.MatterType == Matter.Unspecified) { res.Data.Container.MatterType = this.Data.Extractable.MatterType; res.RefreshLabel(); } if (res.Data.Container.MatterType == this.Data.Extractable.MatterType) { res.SnapCrate(this, this.cratePosition); snappedCrate = res; } } } }
public void Dispose() { m_ResourceManager = null; m_DataProviderHelper = null; m_LoadAssetCallbacks = null; m_LoadBinaryCallbacks = null; }
// Update is called once per frame void Update() { EntityManager entityManager = World.Active.EntityManager; //Little hacky, since we expect element of index 0 to be our player entity NativeArray <Entity> entities = entityManager.GetAllEntities(); if (entities.Length == 0) { return; } Entity entity = entities[0]; if (!entityManager.HasComponent <ResourceComponent>(entity)) { return; } ResourceComponent resources = entityManager.GetComponentData <ResourceComponent>(entity); tx_gold.text = "" + resources.gold; tx_wood.text = "" + resources.wood; tx_steel.text = "" + resources.steel; }
protected override void OnHarvestComplete(float harvestAmountUnits) { if (outputs[0] != null) { outputs[0].Data.Container.Push(harvestAmountUnits); } else if (outputs[1] != null) { outputs[1].Data.Container.Push(harvestAmountUnits); } else { ContainerSize size; if (GreenhouseScale == 1) { size = ContainerSize.Quarter; } else { size = ContainerSize.Full; } ResourceComponent res = BounceLander.CreateCratelike(Matter.Produce, harvestAmountUnits, defaultSnap.position, null, size).GetComponent <ResourceComponent>(); res.SnapCrate(this, defaultSnap.position); outputs[0] = res; } }
/// <summary> /// 创建数据提供者。 /// </summary> /// <typeparam name="T">数据提供者的持有者的类型。</typeparam> /// <param name="owner">数据提供者的持有者。</param> /// <param name="dataProviderHelper">数据提供者辅助器。</param> /// <returns></returns> internal static IDataProvider <T> Create <T>(T owner, IDataProviderHelper <T> dataProviderHelper) { if (owner == null) { throw new Exception("Owner is invalid."); } ResourceComponent resourceManager = CentorPivot.This.GetComponent <ResourceComponent>(); if (resourceManager == null) { throw new Exception("Resource manager is invalid."); } if (dataProviderHelper == null) { throw new Exception("Data provider helper is invalid."); } DataProvider <T> dataProvider = new DataProvider <T>(owner); dataProvider.SetResourceManager(resourceManager); dataProvider.SetDataProviderHelper(dataProviderHelper); return(dataProvider); }
// Use this for initialization void Start() { _eventComponent = GameEntry.GetComponent <EventComponent>(); _baseComponent = GameEntry.GetComponent <BaseComponent>(); _resourceComponent = GameEntry.GetComponent <ResourceComponent>(); _sceneComponent = GameEntry.GetComponent <SceneComponent>(); if (!_baseComponent) { Debug.LogError("Base component is invalid."); return; } if (!_sceneComponent) { Debug.LogError("Scene Component 没有找到!"); return; } _eventComponent.Subscribe(ReferencePool.Acquire <LoadSceneSuccessEventArgs>().Id, _loadSceneComplete); if (!_baseComponent.EditorResourceMode) { if (!检查资源版本) { _resourceComponent.InitResources(); return; } _checkVersionAndUpdateAssetbundle(); } else { _load(); } }
public void OnChildTriggerEnter(TriggerForwarder child, Collider c, IMovableSnappable movesnap) { var res = c.GetComponent <ResourceComponent>(); if (res != null) { bool isOre = res.Data.Container.MatterType.IsRawMaterial(); bool isPowder = res.Data.Container.MatterType.IsFurnaceOutput(); if (isOre && capturedOre == null && child == oreSnap) { //if powder is empty or ore matches powder //and //we can make this into powder //and //not currently smelting anything or matches current smelt if ((capturedPowder == null || matches(res.Data.Container.MatterType, capturedPowder.Data.Container.MatterType)) && (res.Data.Container.MatterType.MatchingPowder() != Matter.Unspecified) && (FlexData.CurrentOre == Matter.Unspecified || res.Data.Container.MatterType == FlexData.CurrentOre)) { res.SnapCrate(this, child.transform.position); res.transform.SetParent(platform); capturedOre = res; FlexData.CurrentOre = res.Data.Container.MatterType; } else { GuiBridge.Instance.ShowNews(NewsSource.InvalidSnap); return; } } else if (isPowder && capturedPowder == null && child == powderSnap) { //if ore is empty or powder matches ore //and //we can make this powder //and //not currently smelting anything or matching ore is what we're smelting if (capturedOre == null || (capturedOre.Data.Container.MatterType == Matter.Unspecified || matches(capturedOre.Data.Container.MatterType, res.Data.Container.MatterType)) && (res.Data.Container.MatterType.MatchingOre().MatchingPowder() != Matter.Unspecified) && (FlexData.CurrentOre == Matter.Unspecified || res.Data.Container.MatterType.MatchingOre() == FlexData.CurrentOre)) { res.SnapCrate(this, child.transform.position); capturedPowder = res; FlexData.CurrentOre = res.Data.Container.MatterType.MatchingOre(); } else { GuiBridge.Instance.ShowNews(NewsSource.InvalidSnap); return; } } else { GuiBridge.Instance.ShowNews(NewsSource.InvalidSnap); return; } } }
public Entity AddResource(string newName) { var component = new ResourceComponent(); component.name = newName; return(AddResource(component)); }
private void OnCheckVersionComplete() { //等待0.5秒 TimeActionComponent.This.GetTimeAction().SetDelayTime(0.5f).StartRun( (TimeAction timeAction) => { //{size=0} 正在获取补丁信息… L0_Text.This.m_Text_Mseg .SetGTextByCode("Text_Mseg_003"); L0_Text.This.m_Text_Mseg .SetVar("size", SettingComponent.This.VersionInfo.IRV.ToString()).FlushVars(); Log.Info("Latest game version is '{0}', local game version is '{1}', UpdatePrefixUri is '{2}'.", SettingComponent.This.VersionInfo.IV, SettingComponent.This.VersionInfo.IRV, CentorPivot.This.GetComponent <ResourceComponent>().UpdatePrefixUri); }, (TimeAction timeAction) => { //TODU 强制更新 if (SettingComponent.This.VersionInfo.FU) { return; } //TODU 强制更新 if (Utility.Text.Split(SettingComponent.This.InternalGameVersion, ".", 0) != Utility.Text.Split(SettingComponent.This.VersionInfo.IV, ".", 0)) { return; } //当有版本更新检查,且和当前版本 不一致, //则在检查更新完毕且资源更新成功后更新UI Version ResourceComponent resourceComponent = CentorPivot.This.GetComponent <ResourceComponent>(); resourceComponent.UpdatePrefixUri = SettingComponent.This.UrlInfo().GetUrl(SettingComponent.This.VersionInfo.UU); switch (resourceComponent.ResourceMode) { case ResourceMode.Editor: //编辑器模式下默认进入 OnChange <ProcedurePreload>(); break; case ResourceMode.Updatable: //检查并更新版本更新列表信息 CheckAndVersionList(); break; case ResourceMode.Unspecified: break; default: break; } } ); }
public bool Release(ResourceComponent res, out MarketRow row) { ResourceRow <Market> fromParent = null; bool released = _Release(res, out fromParent); row = fromParent as MarketRow; return(released); }
private static Task <object> AwaitInternalLoadAsset <T>(this ResourceComponent self, string assetName) { s_LoadAssetTcs = new TaskCompletionSource <object>(); self.LoadAsset(assetName, typeof(T), s_LoadAssetCallbacks); return(s_LoadAssetTcs.Task); }
public void Capture(ICrateSnapper dad, ResourceComponent res) { if (CanSnap(res)) { res.SnapCrate(dad, this.allocateCrate(res)); parent.AddToGlobalList(res); } }
/// <summary> /// 初始化数据提供者的新实例。 /// </summary> /// <param name="owner">数据提供者的持有者。</param> public DataProvider(T owner) { m_Owner = owner; m_LoadAssetCallbacks = new LoadAssetCallbacks(LoadAssetSuccessCallback, LoadAssetOrBinaryFailureCallback, LoadAssetUpdateCallback, LoadAssetDependencyAssetCallback); m_LoadBinaryCallbacks = new LoadBinaryCallbacks(LoadBinarySuccessCallback, LoadAssetOrBinaryFailureCallback); m_ResourceManager = null; m_DataProviderHelper = null; }
public bool Release(ResourceComponent res, out WarehouseRow row) { ResourceRow <Warehouse> fromParent = null; bool released = _Release(res, out fromParent); row = fromParent as WarehouseRow; return(released); }
public void OnStart() { m_ResourceComponent = CentorPivot.This.GetComponent <ResourceComponent>(); if (m_ResourceComponent == null) { throw new Exception("Resource component is invalid."); } }
/// <summary> /// 封装的加载资源方法 /// </summary> /// <param name="assetName"></param> /// <param name="priority"></param> /// <param name="loadAssetSuccessCallbacks"></param> /// <param name="loadAssetFailureCallbacks"></param> /// <param name="userData"></param> public static void LoadAsset(this ResourceComponent resource, string assetName, int priority, Action <string, object, float, object> loadAssetSuccessCallbacks, Action <string, string, string, object> loadAssetFailureCallbacks, object userData = null) { resource.LoadAsset(assetName, priority, new LoadAssetCallbacks( (assetName0, asset0, duration0, userData0) => { loadAssetSuccessCallbacks.Invoke(assetName0, asset0, duration0, userData0); }, (assetName0, status0, errorMessage0, userData0) => { loadAssetFailureCallbacks.Invoke(assetName0, status0.ToString(), errorMessage0, userData0); } ), userData); }
private void CreateDefaultPersons(ResourceComponent resourceComponent) { for (var i = 0; i < 10; i++) { resourceComponent.Persons.Add(new PersonModel { Power = 10, Supplementation = 50 }); } }
/// <summary> /// 设置资源管理器。 /// </summary> /// <param name="resourceManager">资源管理器。</param> public void SetResourceManager(ResourceComponent resourceManager) { if (resourceManager == null) { throw new Exception("Resource manager is invalid."); } m_ResourceManager = resourceManager; }
void OnTriggerEnter(Collider other) { ResourceComponent comp = other.GetComponent <ResourceComponent>(); if (comp != null && this.LinkedHabitat != null) { this.LinkedHabitat.ImportResource(comp); } }
private void Start() { m_ResourceComponent = GameEntry.GetComponent <ResourceComponent>(); if (m_ResourceComponent == null) { Log.Fatal("Resource component is invalid."); return; } }
public void OnChildTriggerEnter(TriggerForwarder child, Collider c, IMovableSnappable mov) { ResourceComponent res = mov as ResourceComponent; if (unsnapTimer == null && Bays.ContainsKey(child) && Bays[child] == null && res != null) { res.SnapCrate(this, child.transform.position, globalRotation: child.transform.rotation); } }
/// <summary> /// 设置对象池管理器。 /// </summary> public void SetObjectPool() { m_ResourceComponent = CentorPivot.This.GetComponent <ResourceComponent>(); if (m_ResourceComponent == null) { throw new Exception("Resource component is invalid."); } //更新模式下 才有对象池,编辑器模式下不适应对象池 if (m_ResourceComponent.ResourceMode == ResourceMode.Updatable) { ObjectPoolComponent objectPool = CentorPivot.This.GetComponent <ObjectPoolComponent>(); if (objectPool == null) { throw new Exception("Object pool manager is invalid."); } ObjectGroup[] objectGroups = objectPool.ObjectGroup; foreach (ObjectGroup item in objectGroups) { switch (item.AssetBundleCategory) { case AssetBundleCategory.Asset: m_AssetPools[item.AssetCategory] = objectPool.CreateMultiSpawnObjectPool <AssetObject>(Utility.Text.Format("Asset Pool-{0}", item.AssetCategory.ToString())); m_AssetPools[item.AssetCategory].AutoReleaseInterval = item.AutoReleaseInterval; m_AssetPools[item.AssetCategory].Capacity = item.Capacity; m_AssetPools[item.AssetCategory].ExpireTime = item.ExpireTime; m_AssetPools[item.AssetCategory].Priority = item.Priority; break; case AssetBundleCategory.Resource: if (m_ResourcePool != null) { throw new Exception("资源包池请勿添加多个"); } m_ResourcePool = objectPool.CreateMultiSpawnObjectPool <ResourceObject>("Resource Pool"); m_ResourcePool.AutoReleaseInterval = item.AutoReleaseInterval; m_ResourcePool.Capacity = item.Capacity; m_ResourcePool.ExpireTime = item.ExpireTime; m_ResourcePool.Priority = item.Priority; break; default: break; } } } }
public void OnAwake() { m_SoundGroups = new Dictionary <string, SoundGroup>(StringComparer.Ordinal); m_SoundsBeingLoaded = new List <int>(); m_SoundsToReleaseOnLoad = new HashSet <int>(); m_LoadAssetCallbacks = new LoadAssetCallbacks(LoadAssetSuccessCallback, LoadAssetFailureCallback, LoadAssetUpdateCallback, LoadAssetDependencyAssetCallback); m_ResourceManager = null; m_SoundHelper = null; m_Serial = 0; }
public void ZeroOutManifestResource(ushort manifestId, ushort languageId) { object[] keys = new object[] { (ushort)0x18, manifestId, languageId }; ResourceComponent component = this.RetrieveResource(keys); if ((component != null) && (component is ResourceData)) { ((ResourceData)component).ZeroData(); } }
public Entity ReplaceResource(string newName) { ResourceComponent component; if (hasResource) { WillRemoveComponent(ComponentIds.Resource); component = resource; } else { component = new ResourceComponent(); } component.name = newName; return ReplaceComponent(ComponentIds.Resource, component); }
void Awake() { player = this; resourceComponent = GetComponent<ResourceComponent>(); }
public Entity AddResource(ResourceComponent component) { return AddComponent(ComponentIds.Resource, component); }
public Entity AddResource(string newName) { var component = new ResourceComponent(); component.name = newName; return AddResource(component); }