本文整理汇总了C#中Part.SendEvent方法的典型用法代码示例。如果您正苦于以下问题:C# Part.SendEvent方法的具体用法?C# Part.SendEvent怎么用?C# Part.SendEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Part
的用法示例。
在下文中一共展示了Part.SendEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RaiseResourceListChanged
public void RaiseResourceListChanged(Part part)
{
part.SendEvent ("OnResourceListChanged", null, 0);
}
示例2: RaiseResourceMaxChanged
public void RaiseResourceMaxChanged(Part part, PartResource resource, double amount)
{
var data = new BaseEventData (BaseEventData.Sender.USER);
data.Set<PartResource> ("resource", resource);
data.Set<double> ("amount", amount);
part.SendEvent ("OnResourceMaxChanged", data, 0);
}
示例3: SetState
public void SetState(Part thatPart, bool newstate, GameObject objectLocal)
{
if (inverted)
newstate = !newstate;
switch (type) {
case ActuatorType.PartComponent:
// Note to other people who want to use this:
// If you want to control a JSIPartComponentToggle, this is how you do it!
var eventData = new BaseEventData (BaseEventData.Sender.USER);
eventData.Set ("moduleID", moduleID);
eventData.Set ("state", newstate);
eventData.Set ("objectLocal", objectLocal);
thatPart.SendEvent ("JSIComponentToggle", eventData);
break;
case ActuatorType.PartComponentGroup:
// Note to other people who want to use this:
// If you want to control a JSIPartComponentToggle, this is how you do it!
var eventgroupData = new BaseEventData (BaseEventData.Sender.USER);
eventgroupData.Set ("groupID", moduleID);
eventgroupData.Set ("state", newstate);
eventgroupData.Set ("objectLocal", objectLocal);
thatPart.SendEvent ("JSIGroupToggle", eventgroupData);
break;
case ActuatorType.PartModule:
controlledModule.enabled = newstate;
controlledModule.isEnabled = newstate;
break;
case ActuatorType.TransformTexture:
Renderer mat = targetTransform.GetComponent<Renderer> ();
mat.material.SetTexture (textureLayer, newstate ? GameDatabase.Instance.GetTexture (trueString, false) : GameDatabase.Instance.GetTexture (falseString, false));
break;
case ActuatorType.TransformShader:
Renderer shm = targetTransform.GetComponent<Renderer> ();
shm.material.shader = Shader.Find (newstate ? trueString : falseString);
break;
case ActuatorType.StraightParameter:
if (newstate) {
SetParameter (nameOfParameter, thatPart, originalParameterValue + addToParameterWhenEnabled);
} else {
SetParameter (nameOfParameter, thatPart, originalParameterValue);
}
break;
case ActuatorType.CrewCapacity:
var eventccData = new BaseEventData (BaseEventData.Sender.USER);
eventccData.Set ("state", newstate);
eventccData.Set ("objectLocal", objectLocal);
thatPart.SendEvent ("JSISetCrewCapacity", eventccData);
break;
case ActuatorType.Resource:
// We do not manipulate resource records out of the editor because fsckit.
if (HighLogic.LoadedSceneIsEditor) {
if (!newstate) {
if (resourcePointer == null) {
resourcePointer = thatPart.Resources [resourceName];
}
// We can, hopefully, avoid deleting the tank that this particular actuator did not create.
if (resourcePointer != null && resourcePointer.maxAmount == maxAmount) {
thatPart.Resources.Remove (resourcePointer);
//UnityEngine.Object.Destroy (resourcePointer);
resourcePointer = null;
}
}
if (newstate && resourcePointer == null && thatPart.Resources [resourceName] == null) {
var node = new ConfigNode ("RESOURCE");
node.AddValue ("name", resourceName);
node.AddValue ("amount", maxAmount);
node.AddValue ("maxAmount", maxAmount);
resourcePointer = thatPart.AddResource (node);
resourcePointer.flowState = true;
}
}
break;
case ActuatorType.AttachmentNode:
if (HighLogic.LoadedSceneIsEditor && savedNodePosition != faraway) {
var foundNode = thatPart.FindAttachNode (nodeName);
if (foundNode.attachedPart == null) {
foundNode.position = newstate ? faraway : savedNodePosition;
}
}
break;
}
if (HighLogic.LoadedSceneIsEditor) {
// We need to also notify the editor that we changed the part so that Engineers' Toolbox works.
GameEvents.onEditorShipModified.Fire(EditorLogic.fetch.ship);
}
}